Model generation method, commodity search method and electronic equipment

Through the two-stage training method, negative sample pairs are constructed using comparative learning and combined with AI large-scale language model annotation, the problem of negative related sample annotation in the product search field is solved, the model training efficiency and accuracy are improved, and the cost is reduced.

CN119179892APending Publication Date: 2024-12-24ALIBABA (SHENZHEN) TECH CO LTD

Patent Information

Application Number
CN202411053074.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2024-12-24

AI Technical Summary

Technical Problem

In the field of product search, it is difficult to accurately label negative correlation sample pairs, resulting in low model training efficiency and high cost and low efficiency of manual labeling.

Method used

A two-stage training method is adopted. The first stage is to construct negative sample pairs through comparative learning, and the second stage is to use AI large-scale language models for annotation and fine-tuning training to generate a semantic correlation model.

Benefits of technology

This improves the efficiency of model training, reduces labor and time costs, and improves the generalization ability and prediction accuracy of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119179892A_ABST
    Figure CN119179892A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a model generation method, a commodity search method and electronic equipment, and the method comprises the steps: obtaining a plurality of positive sample pairs in a first training stage, taking the positive sample pairs as the input information of a basic model, constructing a plurality of negative sample pairs based on the positive sample pairs, and carrying out the comparative learning, training the basic model to obtain a pre-training model of the semantic correlation in the commodity search field; in the second training stage, multiple sample pairs are obtained, correlation scoring is conducted on the multiple sample pairs through an artificial intelligence AI large-scale language model, and after correlation labeling results of the multiple sample pairs are obtained according to the scoring result, the multiple sample pairs and the corresponding correlation labeling results are used for conducting correlation labeling on the multiple sample pairs; and training the pre-training model to obtain a semantic correlation model of a commodity search field, so as to provide a commodity search result in a commodity search scene. Through the embodiment of the invention, the model training efficiency can be improved, and the manpower and time cost can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of commodity search, and in particular to model generation, commodity search methods and electronic equipment. Background Art

[0002] In e-commerce search scenarios, the relevance of user search terms (queries) and the products (items) displayed to users directly determines the user experience and affects the user's purchasing decision. In practical applications, relevance scores are generally used to quantify the relevance between search terms and displayed products, that is, the relevance score between user search terms and product information text (including title, brand, store, etc.).

[0003] The existing text relevance scheme mainly predicts the relevance score of search terms and product texts by training language models. Therefore, the language model with this capability can also be called a semantic relevance model in the field of product search. However, in the process of training or fine-tuning such a language model, it is necessary to rely on a large amount of training sample data with labeled information. For example, the specific sample data can come from the historical search records of a large number of users, including which search terms are used, which products are displayed, which products are clicked by users, which products are purchased, etc. Based on this information, multiple sample pairs can be established, and each sample pair can include a search term and the text information corresponding to a product. Then, each sample pair can be labeled, that is, whether the search term in the sample pair is related to the product, and then the specific sample pair can be labeled as "related" or "not related", and then the language model can be trained or fine-tuned using these labeled sample data.

[0004] There are many ways to achieve labeling of sample data. For example, in one way, sample pairs can be automatically labeled based on historical search records and their context data. For example, if a user enters a search term and clicks or purchases a product, it proves that the search term is related to the product, and the higher the click-through rate or purchase conversion rate, the stronger the correlation between the two. Therefore, sample pairs can be automatically labeled based on search terms in historical search records and data such as product clicks and purchase conversions. However, this method often has a good performance in obtaining positively correlated sample pair labeling results, but is not conducive to labeling negatively correlated sample pairs. This is because whether a user clicks or purchases a product is determined by many factors, including the price, store, brand, etc. of the product. Therefore, if a user searches for a term and clicks or purchases a product, it means that the product is related to the search term. However, conversely, if a user searches for a term but does not click or purchase a product, it does not mean that the search term is not related to the product. In other words, this method of labeling sample pairs through user historical search records and their context can more accurately label multiple sample pairs that are indeed correlated. However, it is more difficult to accurately label negatively correlated sample pairs. In fact, in the process of training or fine-tuning the model, such negatively correlated sample pairs are needed as training data.

[0005] Another way to label samples is manual labeling, which can obtain more accurate labeling results and can label both positively correlated sample pairs and negatively correlated sample pairs. However, manual labeling is not only expensive, but also has low data output efficiency. It often takes months to label data for millions of sample pairs covering large-scale commodity categories in e-commerce scenarios. Summary of the invention

[0006] This application provides a model generation, product search method and electronic equipment, which can improve the efficiency of model training and reduce manpower and time costs.

[0007] This application provides the following solutions:

[0008] A model generation method, comprising:

[0009] In the first training stage, a plurality of positive sample pairs are obtained, and the positive sample pairs are used as input information of the basic model. The basic model is trained by constructing a plurality of negative sample pairs based on the plurality of positive sample pairs and performing comparative learning to obtain a pre-trained model of semantic relevance in the commodity search field; the positive sample pairs are sample pairs consisting of search terms and text description information of positively related commodities, and the negative sample pairs are sample pairs consisting of search terms and text description information of negatively related commodities;

[0010] In the second training stage, multiple sample pairs are obtained, and the multiple sample pairs are scored for relevance using an artificial intelligence (AI) large-scale language model. After obtaining relevance labeling results of the multiple sample pairs based on the scoring results, the pre-trained model is trained using the multiple sample pairs and their corresponding relevance labeling results to obtain a semantic relevance model in the field of product search, which is used to provide product search results in product search scenarios.

[0011] The method of training the basic model by constructing multiple negative sample pairs based on the multiple positive sample pairs and performing comparative learning includes:

[0012] A loss function based on contrastive learning is constructed so that in the process of correlation calculation of the basic model, multiple negative sample pairs are constructed by cross-combining multiple positive sample pairs in the same batch processing set, and the correlation calculation results of the multiple positive sample pairs and the correlation calculation results of the multiple negative sample pairs are obtained through the basic model, and the basic model is trained with the maximization of the correlation calculation results of the positive sample pairs as the optimization goal.

[0013] The method of constructing multiple negative sample pairs by cross-combining multiple positive sample pairs in the same batch processing set includes:

[0014] The search terms in the positive sample pairs and the text description information of the commodities in other positive sample pairs in the same batch processing set are respectively used to form the negative sample pairs.

[0015] Wherein, in the first training stage, a plurality of positive sample pairs are obtained, including:

[0016] According to the historical search behavior log information of multiple users, the commodities whose click-through rate and / or purchase conversion rate corresponding to the search term meet the conditions are obtained as the positively related commodities of the search term, and the text description information of the positively related commodities is obtained, so that the search term and the text description information of the positively related commodities form a positive sample pair.

[0017] Wherein, in the second training stage, a plurality of sample pairs are obtained, including:

[0018] According to the historical search behavior log information of multiple users, the text description information of multiple commodities corresponding to the search words is obtained, so as to form sample pairs with the search words and the text description information of each commodity.

[0019] Among them, the multiple sample pairs obtained in the second training stage include multiple categories, and the multiple categories include: sample pairs consisting of search words and text description information of products browsed by users and with a click-through rate higher than a threshold, sample pairs consisting of search words and text description information of products browsed by users but with a click-through rate lower than a threshold, and sample pairs consisting of search words and text description information of products that are recalled but not browsed by users.

[0020] In the process of training the pre-trained model in the second training stage, a temperature coefficient is added to the loss function constructed based on binary cross entropy to increase the discrimination of the correlation calculation results between positive and negative sample pairs.

[0021] A commodity search method, comprising:

[0022] Acquire a semantic relevance model for a commodity search domain, wherein the semantic relevance model is generated by training using the method described in any one of claims 1 to 7;

[0023] Enumerate multiple search terms that may be used in a commodity search scenario, and calculate the semantic relevance between the multiple search terms and the text description information of multiple commodities in the commodity library by using the semantic relevance model in an offline calculation manner;

[0024] According to the semantic relevance calculation result, determine and save the relevant product sets corresponding to the multiple search terms respectively;

[0025] After receiving a product search request submitted by a user, a related product set corresponding to the search term is determined from the stored information according to the search term associated with the request, so as to determine the product search result from the related product set.

[0026] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of any of the methods described above.

[0027] An electronic device, comprising:

[0028] one or more processors; and

[0029] A memory associated with the one or more processors, the memory being used to store program instructions, wherein the program instructions, when read and executed by the one or more processors, execute the steps of any of the methods described above.

[0030] A computer program product comprises a computer program / computer executable instructions, wherein the computer program / computer executable instructions implement the steps of any of the aforementioned methods when executed by a processor in an electronic device.

[0031] According to the specific embodiments provided in this application, this application discloses the following technical effects:

[0032] Through the embodiment of the present application, the semantic relevance model training in the field of commodity search can be divided into two stages. In the first training stage, multiple positive sample pairs can be obtained, and the positive sample pairs are used as the input information of the basic model. By constructing multiple negative sample pairs based on the multiple positive sample pairs and performing comparative learning, the basic model is trained to obtain a pre-trained model of semantic relevance in the field of commodity search. Afterwards, in the second training stage, multiple sample pairs can be obtained again, and the correlation of multiple sample pairs is scored by a large-scale language model of AI (artificial intelligence), and the correlation annotation results of the multiple sample pairs are obtained according to the scoring results. After that, the pre-trained model is trained using the multiple sample pairs and their corresponding correlation annotation results to obtain a semantic relevance model in the field of commodity search. In this way, since the sample pairs in the second training stage are annotated by a large model, only positive sample pairs need to be obtained in the first stage, and negative sample pairs are automatically constructed based on the principle of comparative learning, while positive sample pairs can be obtained through automated data mining (positive sample pairs can be mined more accurately based on the user's historical search behavior records). Therefore, manual annotation is not required in both training stages, which can effectively improve the efficiency of model training and reduce manpower and time costs. In addition, since a large number of negative sample pairs can be constructed based on positive sample pairs in the first training phase, a large number of sample pairs will actually participate in the first phase of training, thereby improving the generalization ability of the model. On the basis that the model has the generalization ability, the main goal of the second training phase is to improve the prediction accuracy of the model. Therefore, the number of sample pairs required to be annotated for the large model is reduced, thereby ensuring the feasibility of the solution as a whole.

[0033] Of course, any product implementing the present application does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0035] Figure 1 It is a schematic diagram of the system architecture provided by the embodiment of the present application;

[0036] Figure 2 is a flow chart of the model generation method provided in an embodiment of the present application;

[0037] Figure 3 is a flowchart of a commodity search method provided by an embodiment of the present application;

[0038] Figure 4 It is a schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0039] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0040] As described in the background technology section, in the process of training or fine-tuning the language model to obtain the ability to predict the relevance score of search terms and product texts and become a semantic relevance model in the field of product search, it is important to label the sample pairs. However, in the prior art, it is difficult to accurately label the negative sample pairs in the automatic labeling method of information such as the click-through rate of the product after the user searches using a certain search term in the historical search behavior records; the manual labeling method will have problems such as high cost and low efficiency.

[0041] In view of the above problems, in an embodiment of the present application, the relevance annotation of sample pairs can be realized by means of the ability of AI (Artificial Intelligence) large-scale language model (LLM, Large Language Model), and then used to train the basic model to make it a semantic relevance model. However, the inventors of the present application found in the process of realizing the present application that if the sample pairs are directly annotated with the LLM model for relevance and the open source basic model is trained, the following problems may exist: First, the open source basic model usually does not have professional knowledge in the field of commodity search. Even if a relatively accurate positive and negative sample annotation result is obtained through the LLM model, it is difficult to obtain an ideal training result by directly training the basic model. Secondly, if the ideal training result is to be obtained, the number of sample pairs required may be very large, and even hundreds of millions of sample pairs may be required. However, if all sample pairs of this magnitude are annotated by the LLM model, it will still be a very time-consuming process.

[0042] To this end, in an embodiment of the present application, the model training process can be divided into two stages. In the first training stage, the basic model can be pre-trained by contrastive learning. Then, in the second training stage, the pre-trained model can be fine-tuned using sample pairs annotated by the LLM model to achieve the generation of a semantically relevant model in the field of product search.

[0043] Specifically, the so-called contrastive learning is a machine learning method that aims to learn useful representations or features by comparing the similarities and differences between different samples. The basic idea of ​​contrastive learning is to make similar samples closer in the feature space and dissimilar samples farther away.

[0044] In an embodiment of the present application, when the basic model is pre-trained by contrastive learning in the first training stage, some positive sample pairs can be obtained first. For example, the click-through rate and / or purchase conversion rate corresponding to the search term can be obtained according to the historical search behavior log information of multiple users. The goods that meet the conditions are used as the positively related goods of the search term, and then the search term and the text description information of these positively related goods can be used to form a positive sample pair. In the process of training the basic model, these positive sample pairs can be used as the input of the basic model, and the basic model can be trained by constructing multiple negative sample pairs based on these positive sample pairs and performing contrastive learning to obtain a pre-trained model of semantic relevance in the field of commodity search. In other words, in the process of pre-training the basic model, a loss function can be constructed based on contrastive learning, so that in the process of calculation, multiple negative sample pairs can be automatically constructed based on multiple positive sample pairs. When calculating the correlation score, not only the correlation scores corresponding to each positive sample pair can be calculated, but also the correlation scores of each negative sample pair can be calculated. Then, based on these correlation scores, we can bring them into the loss function to optimize the model with the goal of making the correlation scores of positive sample pairs higher and the correlation scores of negative sample pairs lower.

[0045] Specifically, when constructing negative sample pairs, multiple negative sample pairs can be constructed by cross-combining multiple positive sample pairs in the same batch processing set (batch), which will be introduced in detail later. In short, through the above-mentioned contrastive learning method, since multiple negative sample pairs can be automatically constructed, on the one hand, the automatic construction of negative sample pairs can be realized, and on the other hand, a large number of sample pairs can be constructed, so that the pre-training process can be completed on the basis of a large number of sample pairs. For example, suppose that 10 million positive sample pairs are mined from historical search records. However, by cross-combining the positive sample pairs, hundreds of millions of sample pairs can actually be constructed for pre-training the basic model, so that the generalization ability of the model can be guaranteed.

[0046] Through the above pre-training process, a pre-trained model of semantic relevance in the field of product search can be obtained. It is called a pre-trained model because the model already has a certain basic ability to distinguish the semantic relevance between search terms and products. However, this ability may be relatively rudimentary. This is because the negative sample pairs constructed by cross-combining different positive sample pairs in the same batch, although negative sample pairs are indeed input in most cases, these negative sample pairs are usually sample pairs that are relatively easy to distinguish. For example, in the above example, the negative sample pairs constructed by cross-combination may include (brand A mobile phone, brand B refrigerator of a certain model). For such negative sample pairs, since the text description information between the search term and the product can be judged to be unrelated simply from the text similarity, such sample pairs are also samples that are easy to score for relevance for the model. However, in practical applications, there are often some "difficult negative samples". For example, suppose in a certain sample pair, the search term = brand A mobile phone, the product text description information = brand A mobile phone case. From a semantic point of view, the central word of the search term is mobile phone, and the central word of the product text description is mobile phone accessories. This does not meet user needs and belongs to a "negative sample pair"; however, from a textual point of view, since most of the text content of "brand A mobile phone" and "brand A mobile phone case" is the same, it is difficult to distinguish whether the two are related. Therefore, the sample pair (brand A mobile phone, brand A mobile phone case) belongs to a "difficult negative sample pair". In the negative sample pairs constructed by contrastive learning, it is relatively difficult to have such "difficult negative sample pairs". This makes it difficult for the trained model to give accurate semantic relevance calculation results when facing such "difficult negative sample pairs" because the model is not allowed to see more such "difficult negative sample pairs" during the training process. Based on this situation, the model trained by comparative learning can only be called a relatively basic "pre-trained model". However, since it has learned a lot of knowledge in the field of product search, it has more professional characteristics in the field of product search than the open source basic model.

[0047] Since the pre-trained model has a relatively low ability to discriminate difficult negative samples, after obtaining the above-mentioned pre-trained model conversion, the above-mentioned pre-trained model can also be fine-tuned, that is, entering the second stage of training. In the second training stage, first, multiple sample pairs can be obtained, and these sample pairs can also come from the historical search behavior log information of multiple users. In the second training stage, when obtaining sample pairs, it is not necessary to distinguish whether they are positive sample pairs or negative sample pairs, but the LLM model can be used to annotate these sample pairs with correlation. After the labeling is completed, the pre-trained model can be further fine-tuned using the sample pairs with labeled information. The training process can construct a loss function based on binary cross entropy, that is, the specific training goal is to make the semantic correlation calculation results of the sample pairs output by the model closer to the labeled results. In this way, the accuracy of the semantic correlation calculation of the model can be further improved.

[0048] Of course, in a preferred implementation, the multiple sample pairs obtained in the second training phase may include multiple categories, so that the collected sample pairs can cover more online scenarios. For example, the specific multiple categories may include: sample pairs consisting of search terms and text description information of products browsed by users and with a click-through rate higher than a threshold, sample pairs consisting of search terms and text description information of products browsed by users but with a click-through rate lower than a threshold, and sample pairs consisting of search terms and text description information of products that were recalled but not browsed by users.

[0049] Through this method of dividing the training into two stages, if both training stages obtain tens of millions of sample pairs, since the first training stage can also construct a large number of negative sample pairs based on the positive sample pairs, the number of sample pairs actually participating in the first stage training will reach hundreds of millions, thereby improving the generalization ability of the model. On the basis that the model has the generalization ability, the second stage focuses on improving the prediction accuracy of the model. Therefore, the number of sample pairs required is reduced. For example, in practical applications, the LLM large model only needs to score the semantic relevance of tens of millions of sample pairs, thereby ensuring the feasibility of the solution as a whole. In addition, the sample pairs in the second training stage are annotated by the LLM large model. Since only positive sample pairs need to be obtained in the first training stage, negative sample pairs are automatically constructed based on the principle of contrastive learning, while positive sample pairs can be obtained through automated data mining (as mentioned above, based on the user's historical search behavior records, positive sample pairs can be mined more accurately). Therefore, neither training stage involves manual annotation, which can effectively improve efficiency and reduce manpower and time costs.

[0050] From the perspective of system architecture, see Figure 1, the embodiment of the present application mainly involves a commodity information service system. In the process of providing the commodity search function in the system, in order to improve the accuracy of the commodity search results, the semantic relevance model can be pre-trained. The embodiment of the present application mainly improves the training method of the semantic relevance model. Specifically, the training process can be divided into two stages. In the first stage, multiple positive sample pairs are obtained, and the basic model is pre-trained by comparative learning to obtain a pre-trained model of semantic relevance in the commodity search field; then in the second stage, the correlation of multiple sample pairs is scored by using an AI large-scale language model to achieve automatic labeling of sample pairs, and then the pre-trained model is fine-tuned using the automatically labeled sample pairs to obtain a semantic relevance model in the commodity search field. The semantic relevance model trained above can be applied to commodity search scenarios. For the search terms entered by the user, the commodities whose semantic relevance meets the conditions are calculated so as to return the commodity search results to the user.

[0051] The specific implementation scheme provided in the embodiments of the present application is described in detail below.

[0052] Embodiment 1

[0053] First, the present invention provides a model generation method. Figure 2 , the method may include:

[0054] S201: In the first training stage, a plurality of positive sample pairs are obtained, and the positive sample pairs are used as input information of a basic model. The basic model is trained by constructing a plurality of negative sample pairs based on the plurality of positive sample pairs and performing comparative learning to obtain a pre-trained model of semantic relevance in the field of product search; the positive sample pairs are sample pairs consisting of search terms and text description information of positively related products, and the negative sample pairs are sample pairs consisting of search terms and text description information of negatively related products.

[0055] Among them, the first training stage is mainly to pre-train the basic model by contrastive learning. Among them, the basic model can be an open source BERT (Bidirectional Encoder Representations from Transformers, bidirectional encoder representation from Transformer) model, etc. In order to perform contrastive learning, multiple positive sample pairs can be obtained in the first stage, that is, it is necessary to know that the search term and the product are positively correlated before they can become sample pairs in the first training stage. In order to achieve this purpose, there can be multiple implementation methods. For example, in one way, the click-through rate and / or purchase conversion rate corresponding to the search term can be obtained according to the historical search behavior log information of multiple users. The goods that meet the conditions are obtained as the positively related goods of the search term, and the text description information of the positively related goods is obtained, so that the text description information of the search term and the positively related goods are composed of positive sample pairs. That is to say, as mentioned above, although it is difficult to accurately mine negative sample pairs through the user's historical search behavior log, it is usually effective to obtain positive sample pairs. Therefore, multiple positive sample pairs can be obtained through such log information.

[0056] After obtaining multiple positive sample pairs, we can formally enter the comparative learning process. In the comparative learning process, the positive sample pairs can be used as the input of the model. In the process of calculating the semantic relevance of the model, negative sample pairs can be automatically constructed, and the semantic relevance of the search term and the product text in each positive sample pair and the semantic relevance of the search term and the product text in each negative sample pair can be calculated respectively.

[0057] However, the number of positive sample pairs obtained in the first training stage may be relatively large. For example, in practical applications, there may be tens of millions of positive sample pairs. However, the scale of input information is limited when the model performs batch processing. Therefore, the sample pairs can be divided into multiple batches, and each batch is input into the model. Correspondingly, the model can also construct negative samples within a batch. For example, each batch may include 100 sample pairs, and so on. Among them, these 100 sample pairs in the same batch are all positive sample pairs. In the contrastive learning method, after the positive sample pairs in the same batch are input into the basic model, in the process of calculating the correlation score, multiple negative sample pairs can be constructed based on these 100 sample pairs, and then not only the correlation score of the positive sample pairs can be calculated, but also the correlation score of the negative sample pairs can be calculated.

[0058] Among them, the so-called cross-combination of multiple positive sample pairs means cross-combining the search terms and product text description information in multiple positive sample pairs. For example, assuming that the search terms and products in the positive sample pairs include (search term a, product A), (search term b, product B), (search term c, product C), etc., since the products corresponding to one search term and other search terms are usually unrelated, for example, a search term is "a certain brand of mobile phone", and the product in the positive sample pair is a certain model of mobile phone of the brand, and another search term is "refrigerator", and the product in the positive sample pair is a certain brand of refrigerator. Obviously, the search term "a certain brand of mobile phone" is unrelated to the product "a certain brand of refrigerator", and the search term "refrigerator" is also unrelated to the product "a certain brand of mobile phone". Therefore, by cross-combining the search terms and products in these sample pairs, multiple negative sample pairs can be automatically constructed. For example, (search term a, product B), (search term a, product C), (search term b, product A), (search term b, product C), (search term c, product A), (search term c, product B), and so on. That is to say, each search term can form a negative sample pair with the product text description in other sample pairs in the same batch. In this way, a large number of negative sample pairs can be constructed. For example, if a batch includes 100 positive sample pairs, 900 negative sample pairs can be constructed, for a total of 1,000 sample pairs. That is to say, each time a batch of positive sample pairs is input, but when calculating the correlation score, multiple negative sample pairs can be automatically constructed, and the correlation scores of each positive sample pair and each negative sample pair are calculated separately. The correlation score of each sample pair is the semantic correlation score between the search term and the product text description information in the same sample pair.

[0059] When calculating the semantic relevance score between the search term and the product text description information in each sample pair, the specific model can first obtain the digital expression of the search term and the product text description information in each sample pair, for example, express it as a vector. In this way, the vector of the search term in the same sample pair is dotted with the vector of the product text description information, and the result obtained can be used to express the semantic relevance between the two.

[0060] After obtaining the semantic relevance calculation results of each sample pair, they can be input into the loss function to calculate the loss (Loss). In specific implementation, a loss function based on contrastive learning can be pre-constructed so that in the process of correlation calculation of the basic model, multiple negative sample pairs are constructed by cross-combining multiple positive sample pairs in the same batch processing set (batch), and the correlation calculation results of the multiple positive sample pairs and the correlation calculation results of the multiple negative sample pairs are obtained through the basic model, and the basic model is trained with maximizing the correlation calculation results of the positive sample pairs as the optimization goal. For example, in one way, the loss function specifically used for contrastive learning can be expressed as:

[0061]

[0062] Among them, q is the digital expression vector of the current search term, i+ is the digital expression vector of the text description information of the positively related products corresponding to the search term; i- is the digital expression vector of the text description information of other products in the training batch, cos is the calculated cosine similarity distance, τ is the temperature coefficient used to adjust the discrimination of positive and negative samples, and exp is the natural exponential function. Through this loss function, the training goal is to make the similarity between the search term and the product text description information in the positive sample pair greater, and the similarity distance between the current search term and the text description information of other products in the batch smaller in the negative sample pair.

[0063] Through this comparative learning, the model can learn the semantic expression of search terms and product text description information in the product search scenario without manually constructing negative sample pairs. After the training is completed, a semantic relevance pre-training model in the product search field can be obtained.

[0064] S202: In the second training stage, multiple sample pairs are obtained, and the multiple sample pairs are scored for relevance using an artificial intelligence (AI) large-scale language model. After obtaining relevance labeling results of the multiple sample pairs based on the scoring results, the pre-trained model is trained using the multiple sample pairs and their corresponding relevance labeling results to obtain a semantic relevance model in the field of product search, which is used to provide product search results in a product search scenario.

[0065] After completing the pre-training of the first stage, you can enter the second training stage. In this stage, you can also first obtain multiple sample pairs. However, unlike the first stage, the sample pairs obtained in the second training stage can include positive sample pairs and negative sample pairs. When obtaining sample pairs, there is no need to distinguish whether they are positive sample pairs or negative sample pairs. After obtaining the sample pairs, the LLM model will label the correlation of each sample pair. In other words, the LLM large model can label whether the search terms and products in a certain sample pair are related. Among them, these sample pairs labeled by the LLM model may include difficult negative sample pairs. Since the LLM model itself has powerful natural language understanding and reasoning capabilities, even difficult negative samples can usually be labeled more accurately.

[0066] Specifically, in the second training phase, the text description information of multiple products corresponding to the search terms can also be obtained based on the historical search behavior log information of multiple users, so as to form sample pairs with the text description information of each product. For example, the historical search behavior log information may include the search terms that the user has used in the past, which products have been recalled, which products have been exposed, which products have been clicked, which products have been purchased, etc., and these search terms and these products can form sample pairs.

[0067] It should be noted here that, although it is not necessary to distinguish between positive and negative samples when collecting sample pairs in the second training stage, in order to make the sample pairs collected in the second training stage cover more online scenarios, when collecting sample pairs, the sample pairs can also be classified according to the user behavior corresponding to the search terms, and then a certain number of sample pairs are sampled from each category, and the LLM large model performs correlation annotation. For example, when specifically classified, multiple categories may include: sample pairs consisting of search terms and text description information of products browsed by users and with a click-through rate higher than a threshold (that is, products with high exposure and click-through rate), sample pairs consisting of search terms and text description information of products browsed by users but with a click-through rate lower than a threshold (that is, products with low exposure and click-through rate), and sample pairs consisting of search terms and text description information of products that are recalled but not browsed by users (that is, products that are recalled but not exposed). In this way, the large model can annotate sample pairs of various situations, which is conducive to mining more difficult negative samples and improving the training effect of the model.

[0068] Of course, when the LLM large model is labeling sample pairs, there may be uncertainties about whether the sample pairs are related or not. In this case, the calculation result given by the large model may be an intermediate value of about 0.5 (the result of the correlation calculation is usually a decimal between 0 and 1). In this case, it is difficult to determine whether the specific sample pairs are related. Therefore, in the specific implementation, the labeling results of the large model can also be screened, the positive and negative samples that the model is confident of are retained, and the data that the model is uncertain about is removed to further enhance the accuracy of the labeled samples. In this way, the triple data of <search term text, product text description information, large model labeling result ∈ [0,1]> can be obtained.

[0069] After obtaining the above triplet data, the pre-trained model obtained in the first training phase can be further fine-tuned. In the second phase of training, since each sample pair corresponds to the correlation score result given by the large model, the pre-trained model needs to predict whether each sample pair is related, which is a binary classification problem. Therefore, the specific loss function can be the binary cross entropy function (BCELoss). For example, the specific loss function can be:

[0070]

[0071] BCE loss = -[y true *log(y pred )+(1-y true )*(1-log(y pred )] (3)

[0072] Among them, y pred is the correlation prediction result given by the pre-trained model, y true is the correlation score result given by the LLM model (the score result can be regarded as the true value). q is the digital expression vector of the search term in a sample pair, i is the digital expression vector of the text description information of the product in the sample pair, cos is the calculated cosine similarity distance, and exp is the natural exponential function.

[0073] It should be noted here that since the cosine similarity distance (cos) is usually between 0 and 1, it cannot be well distributed in the sensitive activation range of the softmax function (normalized exponential function). Therefore, in the preferred implementation, a temperature coefficient τ can be added to the original binary cross entropy function to increase the cos distance value, thereby increasing the discrimination of the correlation calculation results between positive and negative sample pairs. The addition of the temperature coefficient τ effectively improves the model training effect.

[0074] After the second stage of training is completed, the final semantic relevance model of the commodity search field can be obtained. The semantic relevance model can be applied to the specific commodity search process, and the semantic relevance of the search terms entered by the user is calculated to meet the conditions, so as to return the commodity search results to the user. In specific implementation, there can be a variety of specific application methods. For example, in one way, after the user enters a specific search term, the semantic relevance model can be used to digitally express the search term, and the text description information of the commodity in the commodity library can also be digitally expressed, and then the correlation between the search term and the text description information of each commodity is calculated respectively, and then the search result is given. Of course, in actual applications, the above calculation process may take a certain amount of time, and after the user enters the search term, the search results usually need to be given as soon as possible to shorten the user's waiting time. Therefore, in another implementation method, it is also possible to enumerate a variety of different search terms that the user may actually use in the commodity search scenario in advance, and then use the above semantic relevance model to calculate the semantic relevance between each search term and the commodity in the commodity library in an offline manner, so that a commodity set consisting of commodities that meet the conditions of semantic relevance can be generated for each search term. In this way, when the user enters a specific search term to initiate a product search, as long as the search term has been calculated offline by the model before, the product set corresponding to the search term can be determined. Then, based on the user's personalized preference information, etc., suitable products can be screened out from the product set, and personalized sorting and other processing can be performed. After that, the product search results can be directly returned to the user, thereby shortening the user's waiting time.

[0075] In summary, through the embodiment of the present application, the semantic relevance model training in the field of commodity search can be divided into two stages. In the first training stage, multiple positive sample pairs can be obtained, and the positive sample pairs are used as the input information of the basic model. By constructing multiple negative sample pairs based on the multiple positive sample pairs and performing comparative learning, the basic model is trained to obtain a pre-trained model of semantic relevance in the field of commodity search. Afterwards, in the second training stage, multiple sample pairs can be obtained again, and the correlation of multiple sample pairs is scored by a large-scale language model of AI (artificial intelligence), and the correlation annotation results of the multiple sample pairs are obtained according to the scoring results. After that, the pre-trained model is fine-tuned using the multiple sample pairs and their corresponding correlation annotation results to obtain a semantic relevance model in the field of commodity search. In this way, since the sample pairs in the second training stage are annotated by a large model, only positive sample pairs need to be obtained in the first stage, and negative sample pairs are automatically constructed based on the principle of comparative learning, while positive sample pairs can be obtained through automated data mining (positive sample pairs can be mined more accurately based on the user's historical search behavior records). Therefore, both training stages do not require manual annotation, which can effectively improve efficiency and reduce manpower and time costs. In addition, since a large number of negative sample pairs can be constructed based on positive sample pairs in the first training phase, a large number of sample pairs will actually participate in the first phase of training, thereby improving the generalization ability of the model. On the basis that the model has the generalization ability, the main goal of the second training phase is to improve the prediction accuracy of the model. Therefore, the number of sample pairs required to be annotated for the large model is reduced, thereby ensuring the feasibility of the solution as a whole.

[0076] Embodiment 2

[0077] This second embodiment mainly provides a commodity search method. Figure 3 , the method may specifically include:

[0078] S301: Acquire a semantic relevance model for a commodity search domain, wherein the semantic relevance model is generated by training using the method described in the first embodiment.

[0079] S302: enumerate a plurality of search terms that may be used in a commodity search scenario, and calculate the semantic relevance between the plurality of search terms and the text description information of a plurality of commodities in the commodity library by using the semantic relevance model through offline calculation.

[0080] S303: According to the semantic relevance calculation result, determine and save the relevant product sets corresponding to the multiple search terms respectively.

[0081] S304: After receiving the product search request submitted by the user, determine the relevant product set corresponding to the search term from the stored information according to the search term associated with the request, so as to determine the product search result from the relevant product set.

[0082] For the contents not described in detail in the second embodiment, please refer to the records in the first embodiment and other parts of this specification, which will not be repeated here.

[0083] It should be noted that the embodiments of the present application may involve the use of user data. In actual applications, user-specific personal data can be used in the scheme described herein within the scope permitted by applicable laws and regulations, subject to the requirements of applicable laws and regulations of the country where the user is located (for example, with the user's explicit consent, effective notification to the user, etc.).

[0084] Corresponding to the aforementioned method embodiment, the embodiment of the present application further provides a model generation device, which may include:

[0085] A first training unit is used to obtain a plurality of positive sample pairs in a first training phase, and use the positive sample pairs as input information of a basic model, and train the basic model by constructing a plurality of negative sample pairs based on the plurality of positive sample pairs and performing comparative learning, so as to obtain a pre-trained model of semantic relevance in the field of commodity search; the positive sample pairs are sample pairs consisting of search terms and text description information of positively related commodities, and the negative sample pairs are sample pairs consisting of search terms and text description information of negatively related commodities;

[0086] The second training unit is used to obtain multiple sample pairs in the second training stage, score the relevance of the multiple sample pairs through an artificial intelligence (AI) large-scale language model, obtain relevance labeling results of the multiple sample pairs based on the scoring results, and then use the multiple sample pairs and their corresponding relevance labeling results to train the pre-trained model to obtain a semantic relevance model in the product search field, so as to provide product search results in the product search scenario.

[0087] The first training unit can be specifically used for:

[0088] A loss function based on contrastive learning is constructed so that in the process of correlation calculation of the basic model, multiple negative sample pairs are constructed by cross-combining multiple positive sample pairs in the same batch processing set, and the correlation calculation results of the multiple positive sample pairs and the correlation calculation results of the multiple negative sample pairs are obtained through the basic model, and the basic model is trained with the maximization of the correlation calculation results of the positive sample pairs as the optimization goal.

[0089] The search terms in the positive sample pairs and the text description information of the commodities in other positive sample pairs in the same batch processing set may be used to form the negative sample pairs.

[0090] Specifically, when the first training unit obtains multiple positive sample pairs, it can be used to:

[0091] According to the historical search behavior log information of multiple users, the commodities whose click-through rate and / or purchase conversion rate corresponding to the search term meet the conditions are obtained as the positively related commodities of the search term, and the text description information of the positively related commodities is obtained, so that the search term and the text description information of the positively related commodities form a positive sample pair.

[0092] In addition, when the second training unit obtains multiple sample pairs in the second training phase, it can be used to:

[0093] According to the historical search behavior log information of multiple users, the text description information of multiple commodities corresponding to the search words is obtained, so as to form sample pairs with the search words and the text description information of each commodity.

[0094] Among them, the multiple sample pairs obtained in the second training stage include multiple categories, and the multiple categories include: sample pairs consisting of search words and text description information of products browsed by users and with a click-through rate higher than a threshold, sample pairs consisting of search words and text description information of products browsed by users but with a click-through rate lower than a threshold, and sample pairs consisting of search words and text description information of products that are recalled but not browsed by users.

[0095] During the training of the pre-trained model in the second training phase, a temperature coefficient is added to the loss function constructed based on binary cross entropy to increase the discrimination of the correlation calculation results between the positive and negative sample pairs.

[0096] Corresponding to the second embodiment, the embodiment of the present application further provides a commodity search device, which may include:

[0097] A model acquisition unit, used to acquire a semantic relevance model of a commodity search field, wherein the semantic relevance model is generated by training using the method described in the first embodiment;

[0098] A semantic relevance calculation unit, used to enumerate multiple search terms that may be used in a commodity search scenario, and calculate the semantic relevance between the multiple search terms and the text description information of multiple commodities in the commodity library by using the semantic relevance model in an offline calculation manner;

[0099] A storage unit, configured to determine and store the related commodity sets corresponding to the plurality of search terms respectively according to the result of the semantic relevance calculation;

[0100] The search result generating unit is used to determine the relevant product set corresponding to the search term from the stored information after receiving the product search request submitted by the user, according to the search term associated with the request, so as to determine the product search result from the relevant product set.

[0101] In addition, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of any one of the methods in the aforementioned method embodiments are implemented.

[0102] And an electronic device, comprising:

[0103] one or more processors; and

[0104] A memory associated with the one or more processors, the memory being used to store program instructions, wherein the program instructions, when read and executed by the one or more processors, execute the steps of the method described in any one of the aforementioned method embodiments.

[0105] A computer program product includes a computer program / computer executable instructions, which, when executed by a processor in an electronic device, implement the steps of the method described in the aforementioned method embodiment.

[0106] in, Figure 4 The architecture of the electronic device is shown as an example, which may include a processor 410, a video display adapter 411, a disk drive 412, an input / output interface 413, a network interface 414, and a memory 420. The processor 410, the video display adapter 411, the disk drive 412, the input / output interface 413, the network interface 414, and the memory 420 may be communicatively connected via a communication bus 430.

[0107] Among them, the processor 410 can be implemented by a general-purpose CPU (Central Processing Unit, processor), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, etc., to execute relevant programs to implement the technical solution provided in this application.

[0108] The memory 420 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 420 can store an operating system 421 for controlling the operation of the electronic device 400, and a basic input and output system (BIOS) for controlling the low-level operation of the electronic device 400. In addition, a web browser 423, a data storage management system 424, and a model generation processing system 425, etc. can also be stored. The above-mentioned model generation processing system 425 can be an application program that specifically implements the operations of the aforementioned steps in the embodiment of the present application. In short, when the technical solution provided in the present application is implemented by software or firmware, the relevant program code is stored in the memory 420 and is called and executed by the processor 410.

[0109] The input / output interface 413 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0110] The network interface 414 is used to connect to a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).

[0111] The bus 430 comprises a pathway for transmitting information between the various components of the device (eg, the processor 410, the video display adapter 411, the disk drive 412, the input / output interface 413, the network interface 414, and the memory 420).

[0112] It should be noted that, although the above device only shows a processor 410, a video display adapter 411, a disk drive 412, an input / output interface 413, a network interface 414, a memory 420, a bus 430, etc., in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include components necessary for implementing the solution of the present application, and does not necessarily include all the components shown in the figure.

[0113] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.

[0114] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The system and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.

[0115] The above is a detailed introduction to the model generation, product search method and electronic device provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and its core idea of ​​the present application. At the same time, for those skilled in the art, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as limiting the present application.

Claims

1. A model generation method, characterized in that: include: In the first training stage, a plurality of positive sample pairs are obtained, and the positive sample pairs are used as input information of the basic model. The basic model is trained by constructing a plurality of negative sample pairs based on the plurality of positive sample pairs and performing comparative learning to obtain a pre-trained model of semantic relevance in the commodity search field; the positive sample pairs are sample pairs consisting of search terms and text description information of positively related commodities, and the negative sample pairs are sample pairs consisting of search terms and text description information of negatively related commodities; In the second training stage, multiple sample pairs are obtained, and the multiple sample pairs are scored for relevance using an artificial intelligence (AI) large-scale language model. After obtaining relevance labeling results of the multiple sample pairs based on the scoring results, the pre-trained model is trained using the multiple sample pairs and their corresponding relevance labeling results to obtain a semantic relevance model in the field of product search, which is used to provide product search results in product search scenarios.

2. The method according to claim 1, characterized in that The training of the basic model by constructing a plurality of negative sample pairs based on the plurality of positive sample pairs and performing comparative learning includes: A loss function based on contrastive learning is constructed so that in the process of correlation calculation of the basic model, multiple negative sample pairs are constructed by cross-combining multiple positive sample pairs in the same batch processing set, and the correlation calculation results of the multiple positive sample pairs and the correlation calculation results of the multiple negative sample pairs are obtained through the basic model, and the basic model is trained with the maximization of the correlation calculation results of the positive sample pairs as the optimization goal.

3. The method according to claim 2, characterized in that The method of constructing multiple negative sample pairs by cross-combining multiple positive sample pairs in the same batch processing set includes: The search terms in the positive sample pairs and the text description information of the commodities in other positive sample pairs in the same batch processing set are respectively used to form the negative sample pairs.

4. The method according to claim 1, characterized in that: In the first training stage, a plurality of positive sample pairs are obtained, including: According to the historical search behavior log information of multiple users, the commodities whose click-through rate and / or purchase conversion rate corresponding to the search term meet the conditions are obtained as the positively related commodities of the search term, and the text description information of the positively related commodities is obtained, so that the search term and the text description information of the positively related commodities form a positive sample pair.

5. The method according to claim 1, characterized in that In the second training stage, a plurality of sample pairs are obtained, including: According to the historical search behavior log information of multiple users, the text description information of multiple commodities corresponding to the search words is obtained, so as to form sample pairs with the search words and the text description information of each commodity.

6. The method according to claim 1, characterized in that The multiple sample pairs obtained in the second training phase include multiple categories, including: sample pairs consisting of search terms and text description information of products browsed by users and with a click-through rate higher than a threshold, sample pairs consisting of search terms and text description information of products browsed by users but with a click-through rate lower than a threshold, and sample pairs consisting of search terms and text description information of products that were recalled but not browsed by users.

7. The method according to claim 1, characterized in that During the training of the pre-trained model in the second training phase, a temperature coefficient is added to the loss function constructed based on binary cross entropy to increase the discrimination of the correlation calculation results between the positive and negative sample pairs.

8. A commodity search method, characterized in that: include: Acquire a semantic relevance model for a commodity search domain, wherein the semantic relevance model is generated by training using the method described in any one of claims 1 to 7; Enumerate multiple search terms that may be used in a commodity search scenario, and calculate the semantic relevance between the multiple search terms and the text description information of multiple commodities in the commodity library by using the semantic relevance model in an offline calculation manner; According to the semantic relevance calculation result, determine and save the relevant product sets corresponding to the multiple search terms respectively; After receiving a product search request submitted by a user, a related product set corresponding to the search term is determined from the stored information according to the search term associated with the request, so as to determine the product search result from the related product set.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 8 are implemented.

10. An electronic device, characterized in that: include: one or more processors; as well as A memory associated with the one or more processors, the memory being used to store program instructions, wherein the program instructions, when read and executed by the one or more processors, execute the steps of the method described in any one of claims 1 to 8.

11. A computer program product comprising a computer program / computer executable instructions, characterized in that: When the computer program / computer executable instructions are executed by a processor in an electronic device, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Semantic data processing method and device and semantic data searching method and device

    CN113869060A

  • Language model training method and device, language model prediction method and device and electronic equipment

    CN114386396A

  • Robust visual question and answer model training method based on comparative learning

    CN116662591A

  • Translation scoring model training method and translation selection method

    CN117521844A

  • Correlation judgment method and LLM-based correlation judgment model construction method

    CN117743950A

Cited By

  • Text retrieval image model fine tuning and image retrieval method and device

    CN120510470A