Product category matching method and model generation method, device and electronic equipment thereof

By constructing a candidate product category set and fine-tuning the pre-trained large language model with data pairs, the generated product category matching model solves the problem of unstable output and achieves more accurate product category matching.

CN118113850BActive Publication Date: 2026-07-21HUA DATA TECH (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HUA DATA TECH (SHANGHAI) CO LTD
Filing Date
2024-03-26
Publication Date
2026-07-21

AI Technical Summary

Technical Problem

Existing pre-trained large language models have unstable outputs when matching product categories and cannot accurately match product categories.

Method used

By constructing a set of candidate product categories, prompts, and data pairs, fine-tuning samples are generated to fine-tune the pre-trained large language model, thus generating a product category matching model.

Benefits of technology

The generated product category matching model can match product categories more stably and accurately, constrain the output format, and learn the hierarchical relationship of the statistical product classification directory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118113850B_ABST
    Figure CN118113850B_ABST
Patent Text Reader

Abstract

The present disclosure provides a product category matching method and a model generation method, device and electronic equipment thereof. The generation method comprises: obtaining a candidate product category set of each to-be-matched product name, a plurality of prompt sentences of each to-be-matched product name and a plurality of data pairs; constructing a prompt text of each to-be-matched product name according to the prompt sentences, the candidate product category set and the data pairs; constructing a fine-tuning sample according to the prompt text and an answer text corresponding to the prompt text; and fine-tuning a pre-trained large language model using the fine-tuning sample to generate a product category matching model. The present disclosure enables the pre-trained large language model to better handle the specific task of product category matching after fine-tuning, and enables the generated product category matching model to output more stably when performing product category matching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of artificial intelligence, and in particular to a product category matching method and its model generation method, apparatus, and electronic device. Background Technology

[0002] Product category matching refers to the process of mapping any product name to the statistical product classification directory to obtain the product category to which that product name belongs in the statistical product classification directory. The statistical product classification directory is statistical standard data published by the National Bureau of Statistics, which includes 97 primary categories, each containing secondary to 5th level subcategories, totaling over 30,000 product types.

[0003] Current product category matching methods rely on pre-trained large language models to select the product category corresponding to the target product name from a statistical product classification directory. However, these pre-trained large language models are obtained through large-scale, general training samples. Since these general training samples cover various domains, topics, and contexts, the pre-trained large language model may exhibit unstable output when performing product category matching. For example, based on the prompt text for the target product name, the pre-trained large language model might not respond with a matching product category, but rather with text unrelated to the target product name. Therefore, fine-tuning samples are still needed to fine-tune the pre-trained large language model. Summary of the Invention

[0004] The technical problem to be solved by this disclosure is to overcome the defect of unstable output of pre-trained large language models in the prior art when performing product category matching, and to provide a product category matching method and its model generation method, device and electronic device.

[0005] This disclosure solves the above-mentioned technical problems through the following technical solution:

[0006] Firstly, a method for generating a product category matching model is provided, the method comprising:

[0007] The system obtains a set of candidate product categories for each product name to be matched, several prompt statements for each product name to be matched, and several data pairs. The set of candidate product categories is a collection of the product categories to which the product name to be matched belongs in the statistical product classification directory, as well as other product categories at the same level as that product category. The prompt statements are used to provide information about the product name to be matched to the pre-trained large language model and to guide the output of the large language model. The data pairs include the product name in the statistical product classification directory and the product category to which the product name belongs in the statistical product classification directory.

[0008] Based on the prompt statement, the candidate product category set, and the data pair, construct the prompt text for each of the product names to be matched;

[0009] A fine-tuning sample is constructed based on the prompt text and the corresponding response text; wherein, the response text is the product category of the product name to be matched in the statistical product classification directory;

[0010] The fine-tuned samples are used to fine-tune the pre-trained large language model to generate a product category matching model.

[0011] Optionally, obtaining the candidate product category set for each product name to be matched, several prompt statements for each product name to be matched, and several data pairs includes:

[0012] When the product name to be matched is in the statistical product classification directory, the first product category to which the product name to be matched belongs is found in the statistical product classification directory;

[0013] The set of candidate product categories consists of the first product category and other product categories at the same level as the first product category in the statistical product classification directory.

[0014] Optionally, obtaining the candidate product category set for each product name to be matched, several prompt statements for each product name to be matched, and several data pairs includes:

[0015] When the product name to be matched is not in the statistical product classification directory, the product characteristics of the product name to be matched are determined based on the product name to be matched.

[0016] Find the second product category that corresponds to the product characteristics in the statistical product classification catalog;

[0017] The set of candidate product categories consists of the second product category and other product categories at the same level as the second product category in the statistical product classification directory.

[0018] Secondly, a product category matching method is provided, the matching method including:

[0019] Obtain prompt text for at least two target product names; wherein, the prompt text is used to guide the product category matching model to output the product category to which the target product name belongs in the statistical product classification directory; the product category matching model is generated according to any of the above-mentioned product category matching model generation methods.

[0020] The prompt text is input into the product category matching model to obtain the corresponding response text; wherein, the response text is the product category that the product category matching model answers based on the prompt text;

[0021] Based on the response text, determine the target product category;

[0022] Optionally, determining the target product category based on the answer text includes:

[0023] Obtain a set of candidate product categories for the target product name; wherein, the set of candidate product categories is a set consisting of the product category to which the target product name belongs in the statistical product classification directory and other product categories at the same level as the target product category;

[0024] If any of the answer texts are from the candidate product category set, then the answer text that appears most frequently in the candidate product category set will be selected by voting and designated as the target product category.

[0025] If none of the answer texts are in the candidate product category set, then the cosine similarity between each answer text and the product category in the candidate product category set is calculated, and the product category corresponding to the maximum value of the cosine similarity is taken as the target product category.

[0026] Thirdly, a device for generating a product category matching model is provided, the device comprising:

[0027] The first acquisition module is used to acquire a set of candidate product categories for each product name to be matched, several prompt statements for each product name to be matched, and several data pairs; wherein, the set of candidate product categories is a set consisting of the product category to which the product name to be matched belongs in the statistical product classification directory and other product categories at the same level as the product category; the prompt statements are used to provide information about the product name to be matched to the pre-trained large language model and to guide the output of the large language model; the data pairs include the product name in the statistical product classification directory and the product category to which the product name belongs in the statistical product classification directory;

[0028] The first construction module is used to construct a prompt text for each of the product names to be matched based on the prompt statement, the candidate product category set, and the data.

[0029] The second construction module is used to construct a fine-tuning sample based on the prompt text and the corresponding response text; wherein, the response text is the product category of the product name to be matched in the statistical product classification directory;

[0030] The generation module is used to fine-tune the pre-trained large language model using the fine-tuning samples to generate a product category matching model.

[0031] Optionally, the first acquisition module includes:

[0032] The first search unit is used to find the first product category to which the product name to be matched belongs in the statistical product classification directory when the product name to be matched is in the statistical product classification directory;

[0033] The first unit is used to take the first product category and other product categories at the same level as the first product category in the statistical product classification directory as the candidate product category set.

[0034] Optionally, the first acquisition module further includes:

[0035] The judgment unit is used to determine the product characteristics of the product name to be matched based on the product name to be matched when the product name to be matched is not in the statistical product classification directory.

[0036] The second search unit is used to find the second product category to which the product characteristics belong in the statistical product classification catalog.

[0037] The second unit is used to take the second product category and other product categories at the same level as the second product category in the statistical product classification directory as the candidate product category set.

[0038] Fourthly, a product category matching device is provided, the matching device comprising:

[0039] The second acquisition module is used to acquire prompt text for at least two target product names; wherein, the prompt text is used to guide the product category matching model to output the product category to which the target product name belongs in the statistical product classification directory; the product category matching model is generated according to any of the above-mentioned product category matching model generation methods.

[0040] An input module is used to input the prompt text into a product category matching model to obtain a response text corresponding to the prompt text; wherein, the response text is the product category that the product category matching model answers based on the prompt text;

[0041] The determination module is used to determine the target product category based on the response text.

[0042] Optionally, the determining module includes:

[0043] The acquisition unit is used to acquire a set of candidate product categories for the target product name; wherein, the set of candidate product categories is a set consisting of the product category to which the target product name belongs in the statistical product classification directory and other product categories at the same level as the target product category;

[0044] The filtering unit is used to filter out the answer text that appears most frequently in the candidate product category set by voting method if any of the answer texts are in the candidate product category set, and then select the answer text that appears most frequently in the candidate product category set as the target product category.

[0045] The calculation unit is configured to calculate the cosine similarity between each of the answer texts and the product categories in the candidate product category set if none of the answer texts are in the candidate product category set, and to take the product category corresponding to the maximum value of the cosine similarity as the target product category.

[0046] Fifthly, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and for running on the processor, characterized in that, when the processor executes the computer program, it implements the method for generating a product category matching model as described in any of the preceding claims or the method for matching product categories as described in any of the preceding claims.

[0047] In a sixth aspect, a computer-readable storage medium is provided, on which a computer program is stored, characterized in that, when the computer program is executed by a processor, it implements the method for generating a product category matching model as described in any one of the preceding claims or the method for matching product categories as described in any one of the preceding claims.

[0048] Sixthly, a computer program product is provided, comprising a computer program, characterized in that, when the computer program is executed by a processor, it implements the method for generating a product category matching model as described in any of the preceding claims or the method for matching product categories as described in any of the preceding claims.

[0049] Based on common knowledge in the field, the above-mentioned preferred conditions can be combined arbitrarily to obtain various preferred embodiments of this disclosure.

[0050] The positive advancements of this disclosure lie in the fact that a pre-trained large language model is fine-tuned using fine-tuned samples constructed from the prompt text and the corresponding response text to generate a product category matching model. This fine-tuning allows the pre-trained large language model to better handle the specific task of product category matching, resulting in a more stable output when performing product category matching. Furthermore, by randomly selecting several data pairs from the statistical product classification directory and placing them in the prompt text to fine-tune the large model, not only is the output format of the generated product category matching model constrained, but the model also learns the hierarchical relationships within the statistical product classification directory based on these data pairs, thereby making the output of the generated product category matching model more accurate. Attached Figure Description

[0051] Figure 1 A flowchart illustrating a method for generating a product category matching model as provided in Embodiment 1 of this disclosure;

[0052] Figure 2 This is a schematic diagram of a partial statistical product classification catalog provided in Embodiment 1 of this disclosure;

[0053] Figure 3 A schematic diagram illustrating the generation process of the product category matching model provided in Embodiment 1 of this disclosure;

[0054] Figure 4 A flowchart illustrating a product category matching method provided in Embodiment 2 of this disclosure;

[0055] Figure 5 A flowchart of a product category matching process provided in Embodiment 2 of this disclosure;

[0056] Figure 6 A flowchart illustrating a product category matching process and a product category matching model generation process provided in Embodiment 2 of this disclosure;

[0057] Figure 7 A schematic diagram of a module for generating a product category matching model according to Embodiment 3 of this disclosure;

[0058] Figure 8 A schematic diagram of a module for generating a product category matching model provided in Embodiment 4 of this disclosure;

[0059] Figure 9 This is a schematic diagram of the structure of an electronic device shown in Embodiment 5 of this disclosure. Detailed Implementation

[0060] The present disclosure is further illustrated below by way of embodiments, but the present disclosure is not limited to the scope of the embodiments described herein.

[0061] The prefixes such as "first" and "second" used in this disclosure are merely for distinguishing different descriptive objects and do not limit the position, order, priority, quantity, or content of the described objects. The use of ordinal numbers and other prefixes used to distinguish descriptive objects in this disclosure does not constitute a limitation on the described objects. The description of the described objects is given in the claims or the context of the embodiments, and should not be construed as an unnecessary limitation. Furthermore, in the description of this embodiment, unless otherwise stated, "multiple" means two or more.

[0062] Example 1

[0063] To overcome the instability in output of pre-trained large language models in existing technologies when performing product category matching, Embodiment 1 of this disclosure provides a method for generating a product category matching model. Figure 1 A flowchart of a method for generating a product category matching model provided in Embodiment 1 of this disclosure is included. The method includes:

[0064] Step 101: Obtain the candidate product category set for each product name to be matched, several prompt statements for each product name to be matched, and several data pairs.

[0065] The candidate product category set is a collection of the product category to which the product name to be matched belongs in the statistical product classification catalog, as well as other product categories at the same level as that product category. The prompt statement provides information about the product name to be matched to the pre-trained large language model and guides the output content and / or output format of the large language model; this prompt statement is randomly selected from several manually preset prompt statements. Data pairs include product names in the statistical product classification catalog and the product categories to which those product names belong in the statistical product classification catalog. Data pairs not only constrain the output format of the pre-trained large language model during fine-tuning but also enable the pre-trained large language model to learn the hierarchical relationships of the statistical product classification catalog during fine-tuning, making the generated product category matching model output more accurate. The statistical product classification catalog is statistical standard data published by the National Bureau of Statistics, which includes 97 first-level categories, with second- to fifth-level subcategories under each first-level category, totaling more than 30,000 product types.

[0066] For example, such as Figure 2As shown, the product name to be matched is "engine." In the statistical product classification catalog, "engine" is categorized as "general equipment." Other product categories at the same level as "general equipment" include metal products, textile products, etc. Therefore, the candidate product category set for "engine" is [general equipment, metal products, textile products, etc.]. The prompt statement for "engine" is: Select the most suitable category for the product "engine" from the following candidate product category set, and only return the selected category name. This prompt statement is just an example; the prompt statement for "engine" could also be other statements used to provide information about the product name to be matched for the pre-trained large language model and to guide the output of the large language model. Data pairs are randomly sampled from the statistical product classification catalog, such as "engine: general equipment," "industrial vehicles: general equipment," and "vacuum application equipment: general equipment." The obtained data pairs can include "product name to be matched: product catalog to which the product name to be matched belongs," or other data pairs that do not include "product name to be matched: product catalog to which the product name to be matched belongs."

[0067] Step 102: Construct the prompt text for each product name to be matched based on the prompt statement, the candidate product category set, and the data.

[0068] For example, a prompt text for an engine might be: "Prompt: Select the most suitable category for the product 'engine' from the following candidate product category set. Only return the selected product category; do not return other content. The candidate product category set is: [Chemical Fibers, Rubber Products, Metal Products, General Equipment... (Other product categories omitted here)]\nMatching result example A:xxx, B:yyy, Engine:" Here, "Select the most suitable category for the product 'engine' from the following candidate product category set. Only return the selected product category; do not return other content." is the prompt statement; "A:xxx, B:yyy" are data pairs. A and B represent the names of the products to be matched in the data pair, and xxx and yyy represent the product catalogs to which the names of the products to be matched belong. Furthermore, the number of data pairs in the prompt text can be arbitrary.

[0069] Step 103: Construct a fine-tuning sample based on the prompt text and the corresponding response text; wherein, the response text is the product category of the product name to be matched in the statistical product classification directory.

[0070] For example, a fine-tuning sample for an engine might be: "Prompt: Select the most suitable category for the product engine from the following candidate product category set. Only return the selected product category; do not return other content. The candidate product category set is: [Chemical Fibers, Rubber Products, Metal Products, General Equipment... (Other product categories omitted here)]\nMatching result example A:xxx, B:yyy, Engine:. Answer: General Equipment." Here, "Engine:" is a part of the data pair, used to prompt the model to answer the category to which the engine belongs. "Prompt: Select the most suitable category for the product engine from the following candidate product category set. Only return the selected product category; do not return other content. The candidate product category set is: [Chemical Fibers, Rubber Products, Metal Products, General Equipment... (Other product categories omitted here)]\nMatching result example A:xxx, B:yyy, Engine:" is the prompt text, and "Answer: General Equipment" is the corresponding answer text. This answer text is user-annotated and determines the correct product category to which "Engine" belongs in the statistical product category directory based on the content of the prompt text.

[0071] Step 104: Fine-tune the pre-trained large language model using fine-tuning samples to generate a product category matching model.

[0072] The prompts from the fine-tuning samples are input into a pre-trained large language model. The pre-trained large language model outputs a response based on the prompts in the fine-tuning samples. A loss function is used to calculate the loss between this response and the response text in the fine-tuning samples. The parameters of the pre-trained large language model are then adjusted based on the loss function value to enable the generated product category matching model to better handle the specific task of product category matching. The loss function includes at least one of the following: mean squared error loss function, custom loss function, and cross-entropy loss function.

[0073] In this embodiment, a pre-trained large language model is fine-tuned based on the prompt text and the corresponding response text to generate a product category matching model. This fine-tuning allows the pre-trained large language model to better handle the specific task of product category matching, resulting in a more stable output when performing product category matching. Furthermore, several data pairs are randomly selected from the statistical product classification directory and placed within the prompt text to fine-tune the large model. This not only constrains the output format of the generated product category matching model but also allows the model to learn the hierarchical relationships within the statistical product classification directory based on these data pairs, thereby making the output of the generated product category matching model more accurate.

[0074] In one embodiment, obtaining the candidate product category set for each product name to be matched, several prompt statements for each product name to be matched, and several data pairs includes:

[0075] S1: When the product name to be matched is in the statistical product category directory, find the first product category to which the product name to be matched belongs in the statistical product category directory.

[0076] For example, if an engine is listed in the statistical product classification catalog, then the first product category to which the engine belongs is general equipment.

[0077] S2: The set of the first product category and other product categories at the same level as the first product category in the statistical product classification catalog is taken as the candidate product category set.

[0078] For example, in this embodiment S1, if the first product category to which the engine belongs is determined to be general equipment, then the candidate product category set for the engine is a set consisting of "general equipment" and other product categories at the same level as "general equipment" in the statistical product classification catalog.

[0079] In this embodiment, when the product name to be matched is in the statistical product category directory, its first product category is directly found, thereby determining its candidate product category set, which can reduce time costs. There is no need to parse the product name to be matched to analyze its first product category, improving the efficiency of obtaining the candidate product category set.

[0080] In one embodiment, obtaining the candidate product category set for each product name to be matched, several prompt statements for each product name to be matched, and several data pairs includes:

[0081] S1: When the product name to be matched is not in the statistical product category directory, determine the product characteristics of the product name to be matched based on the product name to be matched.

[0082] The product characteristics can be the inherent attributes or uses of the product to be matched. For example, if the statistical product classification catalog does not include "electroplating hangers," then the product characteristics of the electroplating hangers need to be determined based on the name "electroplating hanger," and these characteristics could be: metal or metal wire rope.

[0083] S2: Find the second product category that corresponds to the product characteristics in the statistical product classification catalog.

[0084] For example, in this embodiment S1, if the product characteristics of the electroplated pendant are determined to be: metal or metal wire rope, then the second product category to which the electroplated pendant belongs can be "metal products" or "metal wire rope products".

[0085] S3: The set of the second product category and other product categories at the same level as the second product category in the statistical product classification catalog is taken as the candidate product category set.

[0086] For example, since the second product category of the electroplated pendant obtained in embodiment S1 is "metal products" or "metal wire rope products", the candidate category set of the electroplated pendant can be a set of "metal products" and other product categories at the same level as "metal products" in the statistical product classification catalog, or a set of "metal wire rope products" and other product categories at the same level as "metal wire rope products" in the statistical product classification catalog.

[0087] In this embodiment, the second product category to which the product name belongs is determined based on its product characteristics, thereby determining its candidate product category set. Since there can be multiple candidate product category sets based on the product characteristics of the product name, multiple fine-tuning samples can be constructed from these multiple candidate product category sets, thus enhancing the generalization ability of the generated product category matching model.

[0088] In one embodiment, combined Figure 3 This section further explains the training process of the pre-trained large language model.

[0089] S1: Select the base model, select the fine-tuning method, and construct the fine-tuning samples.

[0090] The selection of the base language model and fine-tuning method is adaptively chosen based on the characteristics of the product category matching task and the available GPU resources. GPU resources refer to the resource usage of the graphics processing unit (GPU) in the computer system, including at least one of the following: GPU computing power, memory capacity, storage bandwidth, and parallel processing units. For example, in the product category matching task, which primarily involves matching Chinese product category names, the base model will be selected from large open-source Chinese models, such as the ChatGLM model and the Baichuan model. Both the ChatGLM and Baichuan models are large language models based on the Transformer architecture and support both Chinese and English languages. Furthermore, when GPU resources are sufficient, open-source models with a larger number of parameters can be chosen. Extensive experiments have shown that the number of parameters has a significant impact on the learning ability of open-source models. For example, an open-source model with 13 / 14 parameters often outperforms one with 6 / 7 parameters.

[0091] For fine-tuning, if GPU resources are sufficient, you can choose to fine-tune all parameters. If resources are insufficient, you can choose to fine-tune only some parameters, such as LoRa or P-tuning.

[0092] The method for constructing fine-tuned samples can be constructed according to steps 101 to 103 in Example 1.

[0093] S2: Input the base model, fine-tuning method, and fine-tuning samples into the GPU.

[0094] Because GPUs have a large number of parallel processing units and high-bandwidth memory access, they can process multiple training samples and calculate gradient updates in parallel. Therefore, inputting the base model, fine-tuning method, and fine-tuning samples into the GPU can not only optimize the performance of the base model, but also accelerate the training process.

[0095] S3: Generate a fine-tuned large language model.

[0096] The generated, finely tuned large language model is a product category matching model.

[0097] Example 2

[0098] To illustrate how the product category matching model handles the specific task of product category matching, Embodiment 2 of this disclosure provides a product category matching method. Figure 4 This is a flowchart of a product category matching method provided in Embodiment 2 of this disclosure. The matching method includes:

[0099] Step 401: Obtain prompt text for at least two target product names.

[0100] The prompt text is used to guide the product category matching model to output the product category to which the target product name belongs in the statistical product classification directory; the product category matching model is generated by the product category matching model generation method described above.

[0101] The prompt text for the target product name includes a set of candidate product categories for the target product name, a prompt statement for the target product name, and several data pairs. The set of candidate product categories is the product category to which the target product name belongs in the statistical product classification directory, along with other product categories at the same level. The prompt statement provides information about the target product name to the product category matching model and guides the model's output. Data pairs include the product name in the statistical product classification directory and the corresponding product category in that directory. These data pairs constrain the output format of the product category matching model.

[0102] Step 402: Input the prompt text into the product category matching model to obtain the corresponding response text.

[0103] The response text is the product category matching model that answers based on the prompt text.

[0104] Step 403: Determine the target product category based on the response text.

[0105] In this embodiment, inputting the prompt text of the target product name into the product category matching model can more accurately determine the product category to which the target product name belongs. Furthermore, to reduce the fault tolerance of the product category matching model, this product category matching method inputs prompt texts of multiple target texts into the product category matching model to obtain multiple response texts. The product category that best matches the target product name is then selected from the response texts to make the product category matching more accurate.

[0106] Optionally, based on the response text, the target product category can be determined, including:

[0107] S1: Get the set of candidate product categories for the target product name.

[0108] Among them, the candidate product category set is a set consisting of the product category to which the target product name belongs in the statistical product classification catalog and other product categories at the same level as the target product category;

[0109] S2: If any of the answer texts are in the candidate product category set, then the answer text that appears most frequently in the candidate product category set will be selected as the target product category through a voting method.

[0110] For example, if the target product is "electroplating racks," the first prompt text for "electroplating racks" is: "Select the most suitable category for electroplating racks from the following set of candidate product categories. Only return the selected category name; do not return other content. Prioritize the product itself. All categories are: [Chemical Fibers, Rubber Products, Metal Products, General Equipment... (remaining candidate categories omitted)]\nMatching result example: Engine: General Equipment, Industrial Vehicles: General Equipment, Electroplating Racks:"; the second prompt text for "electroplating racks" is: "Select the most suitable category for electroplating racks from the following set of candidate product categories. Only return the selected category name; do not return other content. Prioritize the product itself." The product's intended use. All categories are: [Chemical Fibers, Rubber Products, Metal Products, General Equipment... (remaining candidate categories omitted)]\nMatching Result Example: Engine: General Equipment, Industrial Vehicles: General Equipment, Electroplating Hangers: The third prompt text for "Electroplating Hangers" is: "Select the most suitable category for electroplating hangers from the following set of candidate product categories. Only return the selected category name; do not return other content. The material of the product should be considered first. All categories are: [Chemical Fibers, Rubber Products, Metal Products, General Equipment... (remaining candidate categories omitted)]\nMatching Result Example: Engine: General Equipment, Vacuum Application Equipment: General Equipment, Electroplating Hangers:". The first response text for the first prompt text is "Metal Products", the second response text for the second prompt text is "Metal Wire Rope Products", and the third response text for the third prompt text is "Metal Products". "Metal Products" is output twice and "Metal Wire Rope Products" is output once in the three response texts; therefore, the category to which electroplating hangers belong is "Metal Products".

[0111] S3: If none of the answer texts are in the candidate product category set, calculate the cosine similarity between each answer text and the product category in the candidate product category set, and take the product category corresponding to the maximum value of the cosine similarity as the target product category.

[0112] In this embodiment, when any answer text contains a product category that appears in the candidate product category set, a voting method is used to select the product category that appears most frequently in several answer texts, thus making the product category to which the target product name belongs more accurate. Furthermore, for the special case where none of the answer texts appear in the candidate product category set, a word vector matching strategy is adopted. Using the open-source word2vector model, the answer text and the candidate category set are vectorized, and cosine similarity is calculated. The product category with the highest cosine similarity is assigned to the product directory to which the target product name belongs. This provides a fallback solution for the special case where none of the answer texts appear in the candidate product category set, ensuring that the target product name matches the product directory.

[0113] In one embodiment, combined Figure 5 Further explanation of the product category matching process.

[0114] S1: Construct several prompt texts based on the target product name and the target product category set of the target product name.

[0115] To maximize the output of the product category matching model, two different methods are used to construct the prompt text. One method is to enrich the diversity of prompt statements and data pairs within the prompt text. When selecting prompt statements, random sampling can be performed from preset prompt statements. When selecting data pairs, random sampling can be performed from a statistical product catalog. For example, randomly sampling from 5 preset prompt statements yields 5 prompt statements. When sampling data pairs, a large number of data pairs can be obtained. Randomly combining prompt statements with data pairs results in a large volume of prompt text. On the other hand, during the product category matching model's inference process, the configuration of inference parameters enhances its diversity. For example, temperature is an effective parameter for controlling diversity during inference; higher temperatures effectively increase randomness. Combining these two methods effectively allows the large language model to generate as many response texts as possible.

[0116] S2: Input all prompt texts into the fine-tuned large language model to obtain several response texts.

[0117] The fine-tuned large language model is a product category matching model.

[0118] S3: Perform reasoning matching on several response texts to obtain the product catalog to which the target product name belongs.

[0119] Inference result matching involves comparing and matching several response texts to determine the product category that best matches the target product name.

[0120] Since this embodiment S2 uses a product category matching model, which has been fine-tuned, the inference results can output the required content in 90%-95% of cases; that is, the results predicted by the product category matching model will appear in the candidate category set in 90%-95% of cases. Therefore, the alignment strategy for matching inference results prioritizes direct matching to filter out results that accurately match the candidate category set. In a few cases where all results output by the product category matching model cannot be accurately matched, we adopt a word vector matching strategy. Using the open-source word2vector model, we vectorize the output results of the product category matching model and the results in the candidate category set, calculate the cosine similarity, and take the product category corresponding to the maximum cosine similarity as the fuzzy matching result, i.e., the product category to which the target product name belongs. This word vector matching strategy is mainly a fallback for a few cases. The alignment strategy refers to the matching or comparison of different text or semantic representations in natural language processing.

[0121] After aligning the target results, a voting method is used for the final result filtering, selecting the product category with the highest frequency as the final target product category for matching. Preferably, the top K results based on frequency can also be returned to improve the overall coverage of the matching results.

[0122] Furthermore, based on the information and structure of the statistical product category directory, it can be divided into 1 to 5 levels from top to bottom. Depending on the requirements, the target product name can be matched with its corresponding product category at each directory level from top to bottom. For example, in the initial product category matching process for the target product name, the first candidate category set is the set of product categories at level 1 of the statistical product category directory to which the target product name belongs. Once the target product name matches the first matching product category in the level 1 set, the product categories at the next level (i.e., level 2) that belong to the first matching product category are then used as the second candidate category set. This yields the second product category to which the target product name belongs in the second candidate category set. This process continues, allowing the target product name to be matched with its product category at each level. The specific level of product category to which the target product name is matched can be specifically set according to different task requirements.

[0123] In one embodiment, combined Figure 6 This section further explains the product category matching process and the generation process of the product category matching model.

[0124] S1: Use the prompt template to preprocess the labeled data and product category set to obtain fine-tuned samples.

[0125] The `prompt` template is pre-defined and used to construct prompt text for product names. The labeled data represents the set of product names not included in the statistical product catalog, while the product category set represents the set of product names included in the statistical product catalog. Preprocessing the labeled data using the `prompt` template yields the prompt text for the labeled data. This prompt text and its corresponding responses form a fine-tuning sample of the labeled data. Similarly, preprocessing the product category set using the `prompt` template yields the prompt text for the product category set. This prompt text and its corresponding responses form a fine-tuning sample for the product category set.

[0126] S2: Fine-tune the large model using training samples to obtain the fine-tuned large language model.

[0127] Among them, the large model is a pre-trained large language model, and the fine-tuned large language model is a product category matching model.

[0128] S3: The product names to be matched will be preprocessed using a large model inference using the prompt template.

[0129] The product name to be matched is the target product name in the above embodiment. Using the prompt template, the product name to be matched will be preprocessed by large model inference to obtain several prompt texts for the product name to be matched.

[0130] S4: Input the preprocessed results into the fine-tuned large language model to perform inference result matching in order to obtain the product matching category results.

[0131] The product category matching result is the product category that matches the name of the product to be matched. The preprocessed result is input into a fine-tuned large language model for inference result matching. From several prompt texts, several response texts can be obtained. Then, a voting method and / or a method of calculating cosine similarity are used to select the product category that best matches the name of the product to be matched. Corresponding to the aforementioned embodiment of the product category matching model generation method, this disclosure also provides an embodiment of a product category matching model generation apparatus.

[0132] Example 3

[0133] Figure 7 This is a schematic diagram of a product category matching model generation device provided in Embodiment 3 of this disclosure. The device includes:

[0134] The first acquisition module 71 is used to acquire a set of candidate product categories for each product name to be matched, several prompt statements for each product name to be matched, and several data pairs; wherein, the set of candidate product categories is a set consisting of the product category to which the product name to be matched belongs in the statistical product classification directory and other product categories at the same level as the product category; the prompt statements are used to provide information about the product name to be matched to the pre-trained large language model and to guide the output of the large language model; the data pairs include the product name in the statistical product classification directory and the product category to which the product name belongs in the statistical product classification directory;

[0135] The first construction module 72 is used to construct a prompt text for each of the product names to be matched based on the prompt statement, the candidate product category set, and the data.

[0136] The second construction module 73 is used to construct a fine-tuning sample based on the prompt text and the corresponding response text; wherein, the response text is the product category of the product name to be matched in the statistical product classification directory;

[0137] The generation module 74 is used to fine-tune the pre-trained large language model using the fine-tuning samples to generate a product category matching model.

[0138] Optionally, the first acquisition module 71 includes:

[0139] The first search unit is used to find the first product category to which the product name to be matched belongs in the statistical product classification directory when the product name to be matched is in the statistical product classification directory;

[0140] The first unit is used to take the first product category and other product categories at the same level as the first product category in the statistical product classification directory as the candidate product category set.

[0141] Optionally, the first acquisition module 72 further includes:

[0142] The judgment unit is used to determine the product characteristics of the product name to be matched based on the product name to be matched when the product name to be matched is not in the statistical product classification directory.

[0143] The second search unit is used to find the second product category to which the product characteristics belong in the statistical product classification catalog.

[0144] The second unit is used to take the second product category and other product categories at the same level as the second product category in the statistical product classification directory as the candidate product category set.

[0145] Corresponding to the previous product category matching method embodiments, this disclosure also provides embodiments of product category matching apparatus.

[0146] Example 4

[0147] Figure 8 This is a schematic diagram of a product category matching device provided in Embodiment 4 of this disclosure. The device includes:

[0148] The second acquisition module 81 is used to acquire prompt text for at least two target product names; wherein, the prompt text is used to guide the product category matching model to output the product category to which the target product name belongs in the statistical product classification directory; the product category matching model is generated according to any of the above-mentioned product category matching model generation methods.

[0149] Input module 82 is used to input the prompt text into the product category matching model to obtain the answer text corresponding to the prompt text; wherein, the answer text is the product category answered by the product category matching model based on the prompt text;

[0150] The determination module 83 is used to determine the target product category based on the answer text.

[0151] Optionally, the determining module 83 includes:

[0152] The acquisition unit is used to acquire a set of candidate product categories for the target product name; wherein, the set of candidate product categories is a set consisting of the product category to which the target product name belongs in the statistical product classification directory and other product categories at the same level as the target product category;

[0153] The filtering unit is used to filter out the answer text that appears most frequently in the candidate product category set by voting method if any of the answer texts are in the candidate product category set, and then select the answer text that appears most frequently in the candidate product category set as the target product category.

[0154] The calculation unit is configured to calculate the cosine similarity between each of the answer texts and the product categories in the candidate product category set if none of the answer texts are in the candidate product category set, and to take the product category corresponding to the maximum value of the cosine similarity as the target product category.

[0155] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this disclosure according to actual needs.

[0156] Example 5

[0157] Figure 9 This is a schematic diagram of the structure of an electronic device shown in Embodiment 5 of this disclosure. The electronic device includes a memory, a processor, and a computer program stored in the memory and used to run on the processor. When the processor executes the computer program, it implements the product category matching model generation method and the product category matching method described in any of the above embodiments. Figure 9 The electronic device 90 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.

[0158] like Figure 9 As shown, the electronic device 90 can be manifested as a general-purpose computing device, such as a server device. The components of the electronic device 90 may include, but are not limited to: at least one processor 91, at least one memory 92, and a bus 93 connecting different system components (including memory 92 and processor 91).

[0159] Bus 93 includes a data bus, an address bus, and a control bus.

[0160] The memory 92 may include volatile memory, such as random access memory (RAM) 921 and / or cache memory 922, and may further include read-only memory (ROM) 923.

[0161] The memory 92 may also include a program tool 925 (or utility) having a set (at least one) program module 924, including but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of these examples may include an implementation of a network environment.

[0162] The processor 91 executes various functional applications and data processing by running computer programs stored in the memory 92, such as the product category matching model generation method or product category matching method provided in any of the above embodiments.

[0163] Electronic device 90 can also communicate with one or more external devices 94 (e.g., keyboard, pointing device, etc.). This communication can be performed through input / output (I / O) interface 95. Furthermore, electronic device 90 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public network, such as the Internet) via network adapter 96. As shown, network adapter 96 communicates with other modules of electronic device 90 via bus 93. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with electronic device 90, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems.

[0164] It should be noted that although several units / modules or sub-units / modules of the electronic device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided and embodied by multiple units / modules.

[0165] Example 6

[0166] Embodiment 6 of this disclosure also provides a computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, it implements the product category matching model generation method or the product category matching method provided in any of the above embodiments.

[0167] The readable storage medium may be more specifically adopted, including but not limited to: portable disk, hard disk, random access memory, read-only memory, erasable programmable read-only memory, optical storage device, magnetic storage device, or any suitable combination thereof.

[0168] Example 7

[0169] Embodiment 7 of this disclosure also provides a computer program product, including a computer program, which, when executed by a processor, implements the product category matching model generation method or the product category matching method described in any of the preceding claims.

[0170] The program code for executing the computer program product of this disclosure can be written in any combination of one or more programming languages, and the program code can be executed entirely on a user device, partially on a user device, as a stand-alone software package, partially on a user device and partially on a remote device, or entirely on a remote device.

[0171] While specific embodiments of this disclosure have been described above, those skilled in the art should understand that these are merely illustrative examples, and the scope of protection of this disclosure is defined by the appended claims. Those skilled in the art can make various changes or modifications to these embodiments without departing from the principles and essence of this disclosure, but all such changes and modifications fall within the scope of protection of this disclosure.

Claims

1. A method for generating a product category matching model, characterized in that, The generation method includes: The system obtains a set of candidate product categories for each product name to be matched, several prompt statements for each product name to be matched, and several data pairs. The set of candidate product categories is a collection of the product categories to which the product name to be matched belongs in the statistical product classification directory, as well as other product categories at the same level as that product category. The prompt statements are used to provide information about the product name to be matched to the pre-trained large language model and to guide the output of the large language model. The data pairs include the product name in the statistical product classification directory and the product category to which the product name belongs in the statistical product classification directory. Based on the prompt statement, the candidate product category set, and the data pair, construct the prompt text for each of the product names to be matched; A fine-tuning sample is constructed based on the prompt text and the corresponding response text; wherein, the response text is the product category of the product name to be matched in the statistical product classification directory; The fine-tuned samples are used to fine-tune the pre-trained large language model to generate a product category matching model.

2. The generation method as described in claim 1, characterized in that, The process of obtaining the candidate product category set for each product name to be matched, several prompt statements for each product name to be matched, and several data pairs includes: When the product name to be matched is in the statistical product classification directory, the first product category to which the product name to be matched belongs is found in the statistical product classification directory; The set of candidate product categories consists of the first product category and other product categories at the same level as the first product category in the statistical product classification directory.

3. The generation method as described in claim 1, characterized in that, The process of obtaining the candidate product category set for each product name to be matched, several prompt statements for each product name to be matched, and several data pairs includes: When the product name to be matched is not in the statistical product classification directory, the product characteristics of the product name to be matched are determined based on the product name to be matched. Find the second product category that corresponds to the product characteristics in the statistical product classification catalog; The set of candidate product categories consists of the second product category and other product categories at the same level as the second product category in the statistical product classification directory.

4. A product category matching method, characterized in that, The matching method includes: Obtain prompt text for at least two target product names; wherein, the prompt text is used to guide the product category matching model to output the product category to which the target product name belongs in the statistical product classification directory; the product category matching model is generated according to the product category matching model generation method of any one of claims 1-3; The prompt text is input into the product category matching model to obtain the corresponding response text; wherein, the response text is the product category that the product category matching model answers based on the prompt text; Based on the response text, determine the target product category.

5. The matching method as described in claim 4, characterized in that, The step of determining the target product category based on the response text includes: Obtain a set of candidate product categories for the target product name; wherein, the set of candidate product categories is a set consisting of the product category to which the target product name belongs in the statistical product classification directory and other product categories at the same level as the target product category; If any of the answer texts are from the candidate product category set, then the answer text that appears most frequently in the candidate product category set will be selected by voting and designated as the target product category. If none of the answer texts are in the candidate product category set, then the cosine similarity between each answer text and the product category in the candidate product category set is calculated, and the product category corresponding to the maximum value of the cosine similarity is taken as the target product category.

6. A device for generating a product category matching model, characterized in that, The generating apparatus includes: The first acquisition module is used to acquire a set of candidate product categories for each product name to be matched, several prompt statements for each product name to be matched, and several data pairs; wherein, the set of candidate product categories is a set consisting of the product category to which the product name to be matched belongs in the statistical product classification directory and other product categories at the same level as the product category; the prompt statements are used to provide information about the product name to be matched to the pre-trained large language model and to guide the output of the large language model; the data pairs include the product name in the statistical product classification directory and the product category to which the product name belongs in the statistical product classification directory; The first construction module is used to construct a prompt text for each of the product names to be matched based on the prompt statement, the candidate product category set, and the data. The second construction module is used to construct a fine-tuning sample based on the prompt text and the corresponding response text; wherein, the response text is the product category of the product name to be matched in the statistical product classification directory; The generation module is used to fine-tune the pre-trained large language model using the fine-tuning samples to generate a product category matching model.

7. A product category matching device, characterized in that, The matching device includes: The second acquisition module is used to acquire prompt text for at least two target product names; wherein, the prompt text is used to guide the product category matching model to output the product category to which the target product name belongs in the statistical product classification directory; the product category matching model is generated according to the product category matching model generation method of any one of claims 1-3; An input module is used to input the prompt text into a product category matching model to obtain a response text corresponding to the prompt text; wherein, the response text is the product category that the product category matching model answers based on the prompt text; The determination module is used to determine the target product category based on the response text.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and for running on the processor, characterized in that, When the processor executes the computer program, it implements the method for generating the product category matching model according to any one of claims 1 to 3 or the method for matching product categories according to any one of claims 4 to 5.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the method for generating the product category matching model according to any one of claims 1 to 3 or the method for matching product categories according to any one of claims 4 to 5.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the method for generating the product category matching model as described in any one of claims 1 to 3 or the method for matching product categories as described in any one of claims 4 to 5.