Model training method and device for executing retrieval task and retrieval method and device

By conducting specific model training on the double tower model, the problem of inconsistency in the characterization space of the double tower model output search terms and candidate products is solved, and the accuracy of the search task is improved.

CN119441578APending Publication Date: 2025-02-14BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310956014.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-31
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

When performing the search task, the output search terms and the representation of candidate products have problems with vector space inconsistent, resulting in poor search accuracy.

Method used

By inputting the sample search information and description information of candidate objects into the first and second tower models in the double tower model for encoding, a positive and negative samples are generated, the loss function is determined based on the similarity, and the double tower model is used for encoding. Perform training to alleviate the problem of spatial inconsistency in characterization.

Benefits of technology

The search accuracy when performing the search task through the double tower model is improved, and the similarity and distinction between the characterization of search terms and candidate products is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119441578A_ABST
    Figure CN119441578A_ABST
Patent Text Reader

Abstract

The invention provides a model training method for executing a retrieval task and a retrieval method and device, and relates to the technical field of the Internet, and the model training method for executing the retrieval task comprises the following steps: obtaining the representation of sample retrieval information and the representation of each candidate object by adopting two tower models of a double-tower model, the candidate objects comprise positive samples and negative samples; and determining a first loss function according to the similarity between the characterization of the positive sample and the characterization of the negative sample and the characterization of the sample retrieval information so as to carry out model training on the double-tower model. The problem of spatial inconsistency between the retrieval information and the representation of the candidate object is avoided, and the retrieval accuracy of the double-tower model when the double-tower model is used for the retrieval task is improved. When the retrieval task is executed through the double-tower model, the multiple pieces of historical retrieval information and the multiple candidate objects are jointly clustered, so that the representation of the cluster center of each cluster is influenced through the historical retrieval information, and the accuracy of the retrieval result is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet technology, and in particular to a model training method, a retrieval method and a device for performing retrieval tasks. Background Art

[0002] With the rapid development of the Internet and artificial intelligence technology, online shopping has been widely accepted by the public for its advantages such as staying at home, being convenient and fast, and having a wide variety of goods. On this basis, the competition among various e-commerce platforms is not only reflected in the collection of many products, but also in providing users with better online search and product recommendation services, so as to select highly matching products for users. In the e-commerce scenario, the core challenge of the search task is how to quickly and accurately recall specific collection products from a large number of candidate products. Summary of the invention

[0003] The present application aims to solve one of the technical problems in the related art at least to some extent.

[0004] The present application proposes a model training method, a retrieval method and a device for performing retrieval tasks, so as to solve the technical problem of poor retrieval accuracy when performing retrieval tasks through a dual-tower model in the related art.

[0005] The first aspect of the present application proposes a model training method for performing a retrieval task, comprising: inputting sample retrieval information into the first tower model in the twin-tower model for encoding to obtain a representation of the sample retrieval information; inputting description information of multiple candidate objects into the second tower model in the twin-tower model for encoding to obtain a representation of each of the candidate objects, wherein the multiple candidate objects include positive samples that match the sample retrieval information, and negative samples that do not match the sample retrieval information; determining a first loss function based on the similarity between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information; and performing model training on the twin-tower model based on the first loss function. Thus, it is possible to implement the training of the twin-tower model for performing retrieval tasks, fully alleviate the spatial inconsistency problem between the two representations output by the twin-tower model, and thereby improve the retrieval accuracy when performing retrieval tasks through the twin-tower model.

[0006] The second aspect of the present application proposes a retrieval method, including: obtaining multiple historical retrieval information and obtaining description information of multiple candidate objects; using the first tower model in the trained double-tower model to encode each of the historical retrieval information to obtain the representation of each of the historical retrieval information, and using the second tower model in the double-tower model to encode the description information of each of the candidate objects to obtain the representation of each of the candidate objects; generating a representation set based on the representations of the multiple historical retrieval information and the representations of the multiple candidate objects, and clustering the multiple historical retrieval information and the multiple candidate objects based on the representations in the representation set to obtain multiple clusters; when the client provides a target search term, determining a target cluster that matches the target search term from the multiple clusters; generating a retrieval result based on the candidate objects contained in the target cluster and pushing it to the client. Thus, the retrieval accuracy when performing a retrieval task through the double-tower model is improved.

[0007] The third aspect embodiment of the present application proposes a model training device for performing a retrieval task, comprising: a first processing module, used to input sample retrieval information into the first tower model in a dual-tower model for encoding to obtain a representation of the sample retrieval information; a second processing module, used to input description information of multiple candidate objects into the second tower model in the dual-tower model for encoding to obtain a representation of each of the candidate objects, wherein the multiple candidate objects include positive samples that match the sample retrieval information, and negative samples that do not match the sample retrieval information; a determination module, used to determine a first loss function based on the similarity between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information; a training module, used to perform model training on the dual-tower model based on the first loss function.

[0008] The fourth aspect of the present application proposes a retrieval device, including: an acquisition module, used to acquire multiple historical retrieval information, and to acquire description information of multiple candidate objects; an encoding module, used to use the first tower model in the trained dual-tower model to encode each of the historical retrieval information to obtain a representation of each of the historical retrieval information, and to use the second tower model in the dual-tower model to encode the description information of each of the candidate objects to obtain a representation of each of the candidate objects; a clustering module, used to generate a representation set based on the representations of the multiple historical retrieval information and the representations of the multiple candidate objects, and cluster the multiple historical retrieval information and the multiple candidate objects based on the representations in the representation set to obtain multiple clusters; a first determination module, used to determine a target cluster matching the target search term from the multiple clusters when the client provides a target search term; a generation module, used to generate a retrieval result based on the candidate objects contained in the target cluster and push it to the client.

[0009] The fifth aspect embodiment of the present application proposes an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the model training method for performing retrieval tasks as proposed in the first aspect embodiment of the present application, or execute the retrieval method as proposed in the second aspect embodiment of the present application.

[0010] The sixth aspect embodiment of the present application proposes a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the model training method for performing retrieval tasks as proposed in the first aspect embodiment of the present application, or to execute the retrieval method as proposed in the second aspect embodiment of the present application.

[0011] The seventh aspect embodiment of the present application proposes a computer program product, including a computer program, which, when executed by a processor, implements the model training method for performing retrieval tasks as proposed in the first aspect embodiment of the present application, or executes the retrieval method as proposed in the second aspect embodiment of the present application.

[0012] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0014] Figure 1A flowchart of a model training method for performing a retrieval task provided in Example 1 of the present application;

[0015] Figure 2 A flowchart of a model training method for performing a retrieval task provided in Embodiment 2 of the present application;

[0016] Figure 3 A flowchart of a model training method for performing a retrieval task provided in Example 3 of the present application;

[0017] Figure 4 A flowchart of the search method provided in Example 4 of the present application;

[0018] Figure 5 Another schematic diagram of the search method provided in the fourth embodiment of the present application;

[0019] Figure 6 A schematic diagram of the structure of a model training device for performing a retrieval task provided in Embodiment 5 of the present application;

[0020] Figure 7 A schematic diagram of the structure of a search device provided in Embodiment 6 of the present application;

[0021] Figure 8 A block diagram of an exemplary electronic device suitable for implementing the embodiments of the present application is shown. DETAILED DESCRIPTION

[0022] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0023] It should be noted that the acquisition, storage and application of user personal information involved in the technical solution of this application are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0024] Related technologies usually use the user tower and product tower of the dual-tower model to separately encode the user's search terms and candidate product information, obtain the representation of the search terms and the representation of the candidate products, and then recall the products through the vector index service based on the representation of the search terms and the representation of the candidate products. However, there is a lack of deep interaction between the user tower and the product tower of the dual-tower model, which leads to the problem that the representation of the search terms output by the user tower of the dual-tower model and the representation of the candidate products output by the product tower are inconsistent in vector space (i.e., they are in different spaces). The representation of the search terms and the representation of the candidate products have low similarity and poor differentiation, which leads to poor retrieval accuracy when performing retrieval tasks through the dual-tower model.

[0025] In response to the above-mentioned problems, the present application proposes a model training method, a retrieval method, a device, an electronic device, a storage medium and a computer program product for performing retrieval tasks.

[0026] The model training method for performing the retrieval task includes: inputting the sample retrieval information into the first tower model in the dual-tower model for encoding to obtain the representation of the sample retrieval information; inputting the description information of multiple candidate objects into the second tower model in the dual-tower model for encoding to obtain the representation of each candidate object, wherein the multiple candidate objects include positive samples that match the sample retrieval information and negative samples that do not match the sample retrieval information; determining the first loss function according to the similarity between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information; and training the dual-tower model based on the first loss function. Thus, the training of the dual-tower model for performing the retrieval task can be realized, and the spatial inconsistency problem between the two representations output by the dual-tower model can be fully alleviated, thereby improving the retrieval accuracy when performing the retrieval task through the dual-tower model.

[0027] The following describes, with reference to the accompanying drawings, a model training method, a retrieval method, an apparatus, an electronic device, a storage medium, and a computer program product for performing a retrieval task according to an embodiment of the present application.

[0028] First, the model training method for performing retrieval tasks provided in an embodiment of the present application is described.

[0029] It should be noted that the model training method for performing retrieval tasks provided in the embodiment of the present application is performed by a model training device for performing retrieval tasks. The model training device for performing retrieval tasks will be referred to as the model training device below. The model training device can be an electronic device, or it can be configured in an electronic device, so as to implement the training of the twin-tower model for performing retrieval tasks by executing the model training method for performing retrieval tasks provided in the embodiment of the present application, and fully alleviate the spatial inconsistency problem between the two representations output by the twin-tower model, thereby improving the retrieval accuracy when performing retrieval tasks through the twin-tower model.

[0030] Among them, the electronic device can be a personal computer (PC for short), a cloud device, a mobile device, a server, etc. The mobile device can be, for example, a mobile phone, a tablet computer, a personal digital assistant, a wearable device, a car-mounted device, or any other hardware device, and this application does not impose any restrictions on this.

[0031] Figure 1 This is a flow chart of a model training method for performing a retrieval task provided in the first embodiment of the present application. Figure 1As shown, the model training method for performing a retrieval task may include the following steps 101-104.

[0032] Step 101: input sample retrieval information into the first tower model in the double tower model for encoding to obtain a representation of the sample retrieval information.

[0033] Among them, the sample retrieval information is the training sample used to train the dual-tower model.

[0034] In one embodiment, the sample search information may include a search term input by a user.

[0035] In one embodiment, the sample search information may include the search term input by the user and user characteristic information, wherein the user characteristic information is information representing the characteristics of the user, such as the user's age, gender, and frequently purchased products.

[0036] It should be noted that the above-mentioned sample retrieval information when training the dual-tower model in the embodiment of the present application can be provided by the user and authorized for use, or obtained from a public data set, or obtained through other methods that comply with relevant laws and regulations. This application does not impose any restrictions on this.

[0037] Among them, one of the tower models of the double-tower model is called the first tower model, that is, the user tower model.

[0038] In one embodiment, the first tower model may include an input layer, an encoding layer, and an output layer.

[0039] Among them, the input layer is used to map the input into a vector of fixed dimension; the encoding layer adopts the natural language processing model structure to encode the vector of fixed dimension; the output layer is used to reduce the dimension of the vector output by the encoding layer.

[0040] Among them, encoding the fixed-dimensional vector may include converting and fusing the fixed-dimensional vector; dimensionality reduction processing may include converting the vector output by the encoding layer into a fixed-dimensional vector, normalizing, and other processing.

[0041] Correspondingly, the sample retrieval information can be input into the input layer of the first tower model, so that the input layer is used to map the sample retrieval information into a vector of fixed dimension, and then the fixed-dimensional vector is input into the encoding layer, so that the natural language processing model structure of the encoding layer is used to encode the fixed-dimensional vector, and then the vector output by the encoding layer is input into the output layer, so that the output layer is used to perform dimensionality reduction processing on the vector output by the encoding layer.

[0042] Among them, the first tower model can adopt the Bert model (Bidirectional Encoder Representations from Transformers, a bidirectional encoding representation language model) structure, or any other natural language processing model structure, which is not limited in this application.

[0043] In one embodiment, the dimension of the vector output by the encoding layer of the first tower model may be 768, and the dimension of the vector output by the output layer may be 128.

[0044] Step 102, inputting description information of multiple candidate objects into the second tower model in the dual-tower model for encoding to obtain representations of each candidate object, wherein the multiple candidate objects include positive samples that match the sample retrieval information and negative samples that do not match the sample retrieval information.

[0045] In one embodiment, the description information of the candidate object may include at least one of the product title, the store to which it belongs, the price, and the brand of the candidate object.

[0046] It should be noted that the description information of the above-mentioned candidate objects when training the dual-tower model in the embodiment of the present application can be provided by the e-commerce platform and authorized for use, or obtained from a public data set, or obtained through other methods that comply with relevant laws and regulations. This application does not impose any restrictions on this.

[0047] Among them, the other tower model in the double tower model except the first tower model is called the second tower model, that is, the product tower model.

[0048] In one embodiment, the second tower model may include an input layer, an encoding layer, and an output layer.

[0049] Among them, the input layer is used to map the input into a vector of fixed dimension; the encoding layer adopts the natural language processing model structure to encode the vector of fixed dimension; the output layer is used to reduce the dimension of the vector output by the encoding layer.

[0050] Among them, encoding the fixed-dimensional vector may include converting and fusing the fixed-dimensional vector; dimensionality reduction processing may include converting the vector output by the encoding layer into a fixed-dimensional vector, normalizing, and other processing.

[0051] Correspondingly, for each candidate object, the description information of the candidate object can be input into the input layer of the second tower model, so that the input layer is used to map the description information of the candidate object into a vector of fixed dimension, and then the fixed-dimensional vector is input into the encoding layer, so that the natural language processing model structure of the encoding layer is used to encode the fixed-dimensional vector, and then the vector output by the encoding layer is input into the output layer, so that the output layer is used to perform dimensionality reduction processing on the vector output by the encoding layer.

[0052] Among them, the second tower model can adopt the Bert model structure, or any other natural language processing model structure, and this application does not impose any restrictions on this.

[0053] In one embodiment, the dimension of the vector output by the encoding layer of the second tower model may be 768, and the dimension of the vector output by the output layer may be 128.

[0054] Step 103: Determine a first loss function according to the similarity between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information.

[0055] The similarities between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information include the similarity between the representation of the positive sample and the representation of the negative sample, and the similarity between the representation of the positive sample and the representation of the sample retrieval information.

[0056] Step 104: Perform model training on the twin-tower model based on the first loss function.

[0057] In one embodiment, the model parameters of the dual-tower model can be adjusted according to the first loss function, and the trained dual-tower model can be obtained through multiple iterative optimizations.

[0058] In each iterative optimization process, the number of positive samples can be one or more, and the number of negative samples can be one or more, and this application does not impose any limitation on this.

[0059] In one embodiment, the model training may adopt a gradient back propagation algorithm, the optimizer is an Adam optimizer, the learning rate is 5e-5, the data volume of each optimization batch is 256, and the iterative optimization is 1 million times. The number of layers of the coding layer is 4, the maximum dimension of the vector input of the coding layer is 100, and the dimension of the output is 128.

[0060] In an embodiment of the present application, when training the twin-tower model, the positive sample is used as an anchor point, and a first loss function is determined according to the similarity between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information, and then based on the first loss function, the twin-tower model is trained. Therefore, when training the twin-tower model, not only the relationship between the positive sample and the sample retrieval information (heterogeneous relationship) is considered, but also the relationship between the positive sample and the negative sample (homogeneous relationship) is fully considered. Combining the heterogeneous and homogeneous relationships to train the twin-tower model can fully alleviate the spatial inconsistency problem of the two representations output by the twin-tower model, thereby improving the retrieval accuracy when performing retrieval tasks through the twin-tower model.

[0061] In addition, the amount of sample retrieval information and description information of candidate objects used in model training of the dual-tower model can be increased or decreased according to different scenarios, and this application does not impose any restrictions on this.

[0062] In addition, since only the loss function used is improved during the training process of the dual-tower model, the trained dual-tower model can be directly deployed in the online service system without modifying the online service system, so the deployment cost of the dual-tower model is low.

[0063] In summary, the model training method for performing retrieval tasks provided in the embodiment of the present application inputs sample retrieval information into the first tower model in the twin-tower model for encoding to obtain a representation of the sample retrieval information, and inputs description information of multiple candidate objects into the second tower model in the twin-tower model for encoding to obtain a representation of each candidate object, wherein the multiple candidate objects include positive samples that match the sample retrieval information, and negative samples that do not match the sample retrieval information, and the first loss function is determined according to the similarity between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information, and the twin-tower model is trained based on the first loss function. Thus, the training of the twin-tower model for performing retrieval tasks can be achieved, and the spatial inconsistency problem between the two representations output by the twin-tower model can be fully alleviated, thereby improving the retrieval accuracy when performing retrieval tasks through the twin-tower model.

[0064] Combine the following Figure 2 , in the model training method for performing the retrieval task in the embodiment of the present application, the process of determining the first loss function according to the similarity between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information is further explained.

[0065] Figure 2 This is a flow chart of the model training method for performing a retrieval task provided in the second embodiment of the present application. Figure 2 As shown, the model training method for performing a retrieval task may include the following steps 201-206.

[0066] Step 201: input sample retrieval information into the first tower model in the double tower model for encoding to obtain a representation of the sample retrieval information.

[0067] Step 202, input the description information of multiple candidate objects into the second tower model in the dual-tower model for encoding to obtain the representation of each candidate object, wherein the multiple candidate objects include positive samples that match the sample retrieval information and negative samples that do not match the sample retrieval information, and there are multiple negative samples.

[0068] Step 203: Fusing the similarity between the representation of the positive sample and the representation of each negative sample to obtain the fused similarity of the positive sample.

[0069] In one embodiment, for a positive sample, the similarities between the representation of the positive sample and the representations of each negative sample may be summed to obtain the fusion similarity of the positive sample.

[0070] In one embodiment, for a positive sample, the similarity between the representation of the positive sample and the representation of each negative sample can be fused in the form shown in the following formula (1) to obtain the fused similarity of the positive sample.

[0071]

[0072] Among them, S i represents the fusion similarity of the i-th positive sample; s(I i,p ,I j,n ) represents the similarity between the representation of the i-th positive sample and the representation of the j-th negative sample; τ1 represents the temperature coefficient, which is used to scale the value; {negative} represents the set of negative samples. The number of positive samples can be one or more, and the value of i can be an integer from 1 to N, where N is an integer greater than or equal to 1. The number of negative samples is multiple, and the value of j can be an integer from 1 to M, where M is an integer greater than 1.

[0073] It should be noted that the above-mentioned method of fusing the similarity between the representation of the positive sample and the representation of each negative sample is only an exemplary description. In practical applications, those skilled in the art may adopt other fusion methods to realize the fusion of the similarity between the representation of the positive sample and the representation of each negative sample, and this application does not impose any restrictions on this.

[0074] Step 204: Determine a first similarity component corresponding to the positive sample according to the similarity between the representation of the sample retrieval information and the representation of the positive sample.

[0075] In one embodiment, the first similarity component corresponding to the positive sample may be determined in the manner shown in the following formula (2).

[0076]

[0077] Among them, S i ' represents the first similarity component of the i-th positive sample; s(Q,I i,p ) represents the similarity between the representation of the sample retrieval information and the representation of the i-th positive sample.

[0078] Step 205 : determining a first loss function according to a proportional relationship between the first similarity component corresponding to the positive sample and the fusion similarity of the positive sample.

[0079] In one embodiment, there may be multiple positive samples, that is, N is an integer greater than 1. Accordingly, step 205 may be implemented in the following manner: for any positive sample, a first ratio corresponding to the positive sample is determined based on the ratio of the first similarity component corresponding to the positive sample to the fused similarity of the positive sample; and the first ratios corresponding to the positive samples are fused to obtain a first loss function.

[0080] In one embodiment, the first ratio corresponding to any positive sample can be determined according to the ratio of the first similarity component corresponding to the positive sample to the fusion similarity of the positive sample in the manner shown in the following formula (3).

[0081]

[0082] Among them, l i Represents the first ratio corresponding to the i-th positive sample.

[0083] In one embodiment, the first ratios corresponding to the positive samples may be summed to obtain a first loss function. Accordingly, the first loss function L1 may be in the form shown in the following formula (4):

[0084]

[0085] Among them, {positive} represents the positive sample set.

[0086] By determining the first loss function in the above manner, it is possible to use the positive sample as an anchor point, use softmax (normalized exponential function)-loss (loss) to measure the overall relative relationship, and further distinguish the distance between the positive sample, the negative sample and the sample retrieval information.

[0087] Step 206: Perform model training on the twin-tower model based on the first loss function.

[0088] Among them, the specific implementation process and principle of steps 201, 202, and 206 can refer to the description of other embodiments and will not be repeated here.

[0089] Thus, the training of the twin-tower model for performing retrieval tasks can be realized, and when the twin-tower model is trained, the similarity between the representation of the positive sample and the representation of each negative sample is fused to obtain the fused similarity of the positive sample, and the first similarity component corresponding to the positive sample is determined according to the similarity between the representation of the sample retrieval information and the representation of the positive sample. The first loss function is determined according to the proportional relationship between the first similarity component corresponding to the positive sample and the fused similarity of the positive sample, and then based on the first loss function, the twin-tower model is trained. Therefore, when the twin-tower model is trained, not only the relationship between the positive sample and the sample retrieval information (heterogeneous relationship) is considered, but also the relationship between the positive sample and the negative sample (homogeneous relationship) is fully considered. By combining the heterogeneous and homogeneous relationships, the distances among the sample retrieval information, the positive sample, and the negative sample are further distinguished. Training the twin-tower model can fully alleviate the spatial inconsistency problem of the two representations output by the twin-tower model, thereby improving the retrieval accuracy when performing retrieval tasks through the twin-tower model.

[0090] From the above analysis, we can know that when training the dual-tower model for retrieval tasks, we can consider the relationship between positive samples and sample retrieval information and the relationship between positive samples and negative samples to alleviate the spatial inconsistency problem of the two representations output by the dual-tower model. In a possible implementation form, we can also train the dual-tower model by combining the relationship between sample retrieval information and positive samples and negative samples. Figure 3 , the model training method for performing retrieval tasks in the embodiments of the present application is further explained.

[0091] Figure 3 This is a flow chart of the model training method for performing a retrieval task provided in Example 3 of the present application. Figure 3 As shown, the model training method for performing a retrieval task may include the following steps 301-306.

[0092] Step 301: input sample retrieval information into the first tower model in the double tower model for encoding to obtain a representation of the sample retrieval information.

[0093] Step 302: Input description information of multiple candidate objects into the second tower model in the dual-tower model for encoding to obtain representations of each candidate object, wherein the multiple candidate objects include positive samples that match the sample retrieval information and negative samples that do not match the sample retrieval information.

[0094] Step 303: Determine a first loss function according to the similarity between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information.

[0095] The specific implementation process and principle of steps 301-303 may refer to the description of other embodiments and will not be repeated here.

[0096] Step 304 : Determine a second loss function according to the similarity between the representation of the sample retrieval information and the representation of the negative sample and the representation of the positive sample.

[0097] The similarities between the representation of the sample retrieval information and the representation of the negative sample and the representation of the positive sample include the similarity between the representation of the sample retrieval information and the representation of the negative sample, and the similarity between the representation of the sample retrieval information and the representation of the positive sample.

[0098] It can be understood that the similarity between the sample retrieval information and the positive sample should be greater than the similarity between the sample retrieval information and the negative sample. Therefore, the sample retrieval information can be used as an anchor point and softmax-loss can be used to measure the overall relative relationship.

[0099] In one embodiment, there may be multiple negative samples, and step 304 may be implemented by the following methods shown in steps 304a-304c.

[0100] Step 304a, merging the similarity between the representation of the sample retrieval information and the representation of each negative sample to obtain the total similarity of multiple negative samples.

[0101] In one embodiment, the similarity between the representation of the sample retrieval information and the representation of each negative sample may be summed to obtain the total similarity of the multiple negative samples.

[0102] In one embodiment, the form shown in the following formula (5) can be used to fuse the similarity between the representation of the sample retrieval information and the representation of each negative sample to obtain the total similarity of multiple negative samples.

[0103]

[0104] Among them, S represents the total similarity of multiple negative samples; s(Q,I j,n ) represents the similarity between the representation of the sample retrieval information and the representation of the jth negative sample; τ2 represents the temperature coefficient, which is used to scale the value. Wherein, the number of negative samples is multiple, and correspondingly, the value of j can be an integer from 1 to M, where M is an integer greater than 1.

[0105] It should be noted that the above-mentioned method of fusing the similarity between the representation of sample retrieval information and the representation of each negative sample is only an exemplary description. In practical applications, those skilled in the art may adopt other fusion methods to realize the fusion of the similarity between the representation of sample retrieval information and the representation of each negative sample, and this application does not impose any restrictions on this.

[0106] Step 304b: Determine a second similarity component corresponding to the positive sample according to the similarity between the representation of the sample retrieval information and the representation of the positive sample.

[0107] In one embodiment, the second similarity component corresponding to the positive sample may be determined in the manner shown in formula (6).

[0108]

[0109] Among them, S i ” represents the second similarity component of the i-th positive sample; s(Q,I i,p ) represents the similarity between the representation of the sample retrieval information and the representation of the i-th positive sample.

[0110] Step 304c: determine a second loss function according to a proportional relationship between a second similarity component corresponding to the positive sample and a total similarity of the plurality of negative samples.

[0111] In one embodiment, there may be multiple positive samples, and accordingly, step 304c may be implemented in the following manner: for any positive sample, the second ratio corresponding to the positive sample is determined according to the ratio of the second similarity component corresponding to the positive sample to the total similarity; the second ratios corresponding to the positive samples are merged to obtain a second loss function.

[0112] In one embodiment, the second ratio corresponding to any positive sample can be determined according to the ratio of the second similarity component corresponding to the positive sample to the total similarity in the manner shown in the following formula (7).

[0113]

[0114] Among them, l i ' represents the second ratio corresponding to the i-th positive sample.

[0115] In one embodiment, the second ratios corresponding to the positive samples may be summed to obtain a second loss function. Accordingly, the second loss function L2 may be in the form shown in the following formula (8):

[0116]

[0117] There are multiple positive samples, and accordingly, the value of i can be an integer from 1 to N, where N is an integer greater than 1.

[0118] By determining the second loss function in the above manner, it is possible to use sample retrieval information as an anchor point and use softmax-loss to measure the overall relative relationship.

[0119] Step 305: weight the first loss function and the second loss function according to the hyperparameter to obtain a target loss function.

[0120] In one embodiment, step 305 may be implemented by the following method (9):

[0121] L=L2+wL1 (9)

[0122] Wherein, L represents the objective function; w represents a hyperparameter used to control the importance of the first loss function. The default initial value of w may be 0.5.

[0123] Step 306, adjusting the model parameters and hyperparameters of the twin-tower model according to the target loss function.

[0124] Thus, the training of the twin-tower model for performing retrieval tasks can be realized, and when the twin-tower model is trained, the first loss function is determined according to the similarity between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information, and the second loss function is determined according to the similarity between the representation of the sample retrieval information and the representation of the negative sample and the representation of the positive sample, respectively. According to the hyperparameter, the first loss function and the second loss function are weighted to obtain the target loss function, and then according to the target loss function, the model parameters and hyperparameters of the twin-tower model are adjusted. Therefore, when the twin-tower model is trained, not only the relationship between the sample retrieval information and the positive sample and the relationship between the positive sample and the sample retrieval information (heterogeneous relationship) are considered, but also the relationship between the positive sample and the negative sample (homogeneous relationship) is fully considered. Combining the heterogeneous and homogeneous relationships, the distances among the sample retrieval information, the positive sample and the negative sample are further distinguished. Training the twin-tower model can fully alleviate the spatial inconsistency problem of the two representations output by the twin-tower model, thereby improving the retrieval accuracy when performing retrieval tasks through the twin-tower model.

[0125] Based on the model training method for performing the retrieval task in the above embodiment, a retrieval method is provided in the embodiment of the present application. The retrieval method provided in the embodiment of the present application is described below.

[0126] It should be noted that the retrieval method provided in the embodiment of the present application is executed by a retrieval device. The retrieval device can be an electronic device or can be configured in an electronic device to improve the retrieval accuracy when performing a retrieval task through a dual-tower model by executing the retrieval method provided in the embodiment of the present application.

[0127] Among them, the electronic device can be a personal computer (PC for short), a cloud device, a mobile device, a server, etc. The mobile device can be, for example, a mobile phone, a tablet computer, a personal digital assistant, a wearable device, a car-mounted device, or any other hardware device, and this application does not impose any restrictions on this.

[0128] Figure 4 This is a flow chart of the search method provided in Example 4 of this application. Figure 4 As shown, the retrieval method may include the following steps 401-405.

[0129] Step 401, obtaining multiple pieces of historical search information and obtaining description information of multiple candidate objects.

[0130] In one embodiment, the historical search information may include historical search terms input by the user.

[0131] In one embodiment, the historical search information may include historical search terms input by the user and user feature information.

[0132] In one embodiment, a portion of historical search terms can be randomly sampled from the historical search records of multiple users according to the distribution, and the characteristic information of the user corresponding to each historical search term can be obtained, and each historical search term and the corresponding user's characteristic information can be used as a piece of historical retrieval information, thereby obtaining multiple pieces of historical retrieval information.

[0133] In one embodiment, the description information of the candidate object may include at least one of the product title, the store to which it belongs, the price, and the brand of the candidate object.

[0134] Step 402, using the first tower model in the trained dual-tower model to encode each piece of historical retrieval information to obtain a representation of each piece of historical retrieval information, and using the second tower model in the dual-tower model to encode the description information of each candidate object to obtain a representation of each candidate object.

[0135] Among them, each piece of historical search information can be input into the first tower model respectively to obtain the representation of each piece of historical search information, and the description information of each candidate object can be input into the second tower model to obtain the representation of each candidate object.

[0136] The twin-tower model is trained using the model training method in the aforementioned embodiment. For the description of the twin-tower model, reference can be made to the description of other embodiments, which will not be repeated here.

[0137] Step 403: Generate a representation set according to the representations of the multiple pieces of historical search information and the representations of the multiple candidate objects, and cluster the multiple pieces of historical search information and the multiple candidate objects according to the representations in the representation set to obtain multiple clusters.

[0138] The manner of clustering the multiple pieces of historical search information and the multiple candidate objects can be set as required and is not limited here.

[0139] Step 404: when the client provides a target search term, determine a target cluster matching the target search term from multiple clusters.

[0140] In one embodiment, the similarity between the target search term and the cluster center of each cluster may be determined, and based on the similarity between the target search term and the cluster center of each cluster, a target cluster matching the target search term may be determined from multiple clusters.

[0141] In one embodiment, the target search term may be input into the first tower model to obtain a representation of the target search term, and for each cluster, the similarity between the target search term and the cluster center of the cluster is determined based on the representation of the target search term and the representation of the cluster center of the cluster.

[0142] Step 405: Generate search results based on the candidate objects included in the target cluster and push them to the client.

[0143] The search result includes one or more target objects among the candidate objects included in the target cluster.

[0144] It can be understood that since the cluster is obtained by clustering multiple historical search information and multiple candidate objects, and the target cluster is one or more of the multiple clusters, the target cluster includes the candidate objects and the historical search information. In the embodiment of the present application, since the goal of the search task is to push one or more target objects to the client, the search results can be generated and pushed to the client based on the candidate objects included in the target cluster.

[0145] It is understandable that the retrieval method in the related art has the problem of inconsistency in the vector space between the representation of the search terms output by the user tower of the dual-tower model and the representation of the candidate products output by the product tower, which will cause the search terms and the candidate products to have strong heterogeneity, resulting in low accuracy of the search results. In addition, in the stage of recalling products through vector indexing services, each candidate product is clustered (homogeneous matching) based on its representation to obtain multiple clusters, and then the search results are obtained by matching the search terms with the cluster centers (heterogeneous matching). This method only considers the candidate product information and ignores the influence of the search information. The error of homogeneous matching will be further amplified in the heterogeneous matching stage, which further reduces the accuracy of the recall.

[0146] In the embodiment of the present application, the twin-tower model is trained using the model training method of the above embodiment, which fully alleviates the spatial inconsistency problem between the two representations output by the twin-tower model, thereby improving the retrieval accuracy when the twin-tower model is used to perform retrieval tasks. In addition, when performing retrieval tasks through the twin-tower model, a representation set is generated based on the representations of multiple historical retrieval information and the representations of multiple candidate objects, and the multiple historical retrieval information and the multiple candidate objects are clustered according to the representations in the representation set to obtain multiple clusters, thereby influencing the representation of the cluster center of each cluster through the historical retrieval information, further avoiding the spatial inconsistency problem of the representation of the retrieval information and the candidate objects, and further improving the retrieval accuracy when the twin-tower model is used to perform retrieval tasks.

[0147] In one embodiment of the present application, after step 403, it may also include: configuring index numbers of multiple candidate objects based on the first sequence number interval; configuring index numbers of multiple historical retrieval information based on the second sequence number interval; storing index numbers associated with each cluster based on the historical retrieval information and candidate objects contained in each cluster; when the target cluster is determined, determining the candidate objects contained in the target cluster based on the target index numbers associated with the target cluster that are in the first sequence number interval.

[0148] The first sequence number interval and the second sequence number interval are different sequence number intervals, that is, the index sequence numbers of the plurality of candidate objects are different from the index sequence numbers of the plurality of historical search information.

[0149] The index serial number associated with the cluster includes the index serial numbers of the historical search information and candidate objects contained in the cluster.

[0150] In an embodiment of the present application, since the target cluster contains candidate objects and historical retrieval information, and the goal of the retrieval task is to push one or more of the candidate objects contained in the target cluster to the client, the target index number in the first sequence number interval among the index numbers associated with the target cluster can be determined to determine the index of the candidate objects contained in the target cluster, and then the candidate objects contained in the target cluster are determined based on the target index number, and then the retrieval results are generated based on the candidate objects contained in the target cluster and pushed to the client.

[0151] As a result, when recalling products through the vector index service, the search results are generated and pushed to the client through the inverse quantization method.

[0152] It should be noted that in practical applications, in addition to the inverse quantization method, other methods, such as PQ (Product Quantization), OPQ (Optimized Product Quantization), tree-based methods, etc., can also be used to generate search results, which is not limited here.

[0153] refer to Figure 5 The dual-tower model includes a first tower model and a second tower model. When training the dual-tower model, the sample retrieval information can be input into the first tower model for encoding to obtain the representation of the sample retrieval information, and the description information of multiple candidate objects can be input into the second tower model for encoding to obtain the representation of each candidate object, and then according to the similarity between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information, the first loss function is determined, and the dual-tower model is trained based on the first loss function.

[0154] When performing retrieval tasks through the dual-tower model, the first tower model can be used to encode each piece of historical retrieval information to obtain a representation of each historical retrieval information, and the second tower model can be used to encode the description information of each candidate object to obtain a representation of each candidate object. The representation of each historical retrieval information and the representation of each candidate object are then used as input to the PQ module. The PQ module can perform clustering and calculate cluster centers, construct code tables, etc. based on vector distribution, and output the index vector of the target object, thereby obtaining retrieval results and providing fast retrieval services online.

[0155] In summary, the retrieval method provided in the embodiment of the present application obtains multiple historical retrieval information and descriptive information of multiple candidate objects; uses the first tower model in the trained dual-tower model to encode each piece of historical retrieval information to obtain the representation of each piece of historical retrieval information, and uses the second tower model in the dual-tower model to encode the descriptive information of each candidate object to obtain the representation of each candidate object; generates a representation set based on the representations of multiple pieces of historical retrieval information and the representations of multiple candidate objects, and clusters multiple pieces of historical retrieval information and multiple candidate objects based on the representations in the representation set to obtain multiple clusters; when the client provides a target search term, determines a target cluster that matches the target search term from multiple clusters; generates a retrieval result based on the candidate objects contained in the target cluster and pushes it to the client. Thus, the accuracy of image retrieval is improved.

[0156] Figure 6 This is a schematic diagram of the structure of a model training device for performing retrieval tasks provided in Example 5 of the present application.

[0157] like Figure 6As shown, the model training device 600 for performing a retrieval task may include: a first processing module 610 , a second processing module 620 , a determination module 630 and a training module 640 .

[0158] The first processing module 610 is used to input the sample retrieval information into the first tower model in the double tower model for encoding to obtain a representation of the sample retrieval information;

[0159] A second processing module 620 is used to input description information of multiple candidate objects into the second tower model in the dual-tower model for encoding to obtain representations of each candidate object, wherein the multiple candidate objects include positive samples that match the sample retrieval information and negative samples that do not match the sample retrieval information;

[0160] A determination module 630, configured to determine a first loss function according to the similarity between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information;

[0161] The training module 640 is used to perform model training on the dual-tower model based on the first loss function.

[0162] It should be noted that the model training device for performing retrieval tasks provided in the embodiments of the present application can execute the model training method for performing retrieval tasks in the aforementioned embodiments. The model training device for performing retrieval tasks can be an electronic device, or can be configured in an electronic device, so as to implement the training of the twin-tower model for performing retrieval tasks by executing the model training method for performing retrieval tasks provided in the embodiments of the present application, thereby fully alleviating the spatial inconsistency problem between the two representations output by the twin-tower model, thereby improving the retrieval accuracy when performing retrieval tasks through the twin-tower model.

[0163] Among them, the electronic device can be a PC, cloud device, mobile device, server, etc., and the mobile device can be, for example, a mobile phone, tablet computer, personal digital assistant, wearable device, vehicle-mounted device, or any other hardware device, and this application does not impose any restrictions on this.

[0164] In a possible implementation of the embodiment of the present application, there are multiple negative samples, and the determination module 630 includes:

[0165] A fusion unit, used to fuse the similarity between the representation of the positive sample and the representation of each negative sample to obtain the fused similarity of the positive sample;

[0166] A first determining unit, configured to determine a first similarity component corresponding to the positive sample according to a similarity between a representation of the sample retrieval information and a representation of the positive sample;

[0167] The second determining unit is used to determine the first loss function according to the proportional relationship between the first similarity component corresponding to the positive sample and the fusion similarity of the positive sample.

[0168] In a possible implementation of an embodiment of the present application, there are multiple positive samples, and the second determination unit is specifically used to: for any positive sample, determine the first ratio corresponding to the positive sample according to the ratio of the first similarity component corresponding to the positive sample and the fused similarity of the positive sample; fuse the first ratios corresponding to the positive samples to obtain a first loss function.

[0169] In a possible implementation of the embodiment of the present application, the training module 640 includes:

[0170] A third determining unit, configured to determine a second loss function according to the similarities between the representation of the sample retrieval information and the representation of the negative sample and the representation of the positive sample respectively;

[0171] A processing unit, configured to weight the first loss function and the second loss function according to the hyperparameter to obtain a target loss function;

[0172] The adjustment unit is used to adjust the model parameters and hyperparameters of the dual-tower model according to the target loss function.

[0173] In a possible implementation manner of the embodiment of the present application, there are multiple negative samples, and the third determining unit is specifically configured to:

[0174] The representation of the sample retrieval information is combined with the similarity between the representations of each negative sample to obtain the total similarity of multiple negative samples;

[0175] Determining a second similarity component corresponding to the positive sample according to the similarity between the representation of the sample retrieval information and the representation of the positive sample;

[0176] A second loss function is determined according to a proportional relationship between a second similarity component corresponding to the positive sample and a total similarity of multiple negative samples.

[0177] In a possible implementation manner of the embodiment of the present application, there are multiple positive samples, and the third determining unit is further configured to:

[0178] For any positive sample, according to the ratio of the second similarity component corresponding to the positive sample to the total similarity, determine the second ratio corresponding to the positive sample;

[0179] The second ratios corresponding to the positive samples are fused to obtain a second loss function.

[0180] In a possible implementation of the embodiment of the present application, the description information includes at least one of a product title, a store, a price, and a brand of the corresponding candidate object;

[0181] The sample search information includes the search term, or the sample search information includes the search term and user characteristic information.

[0182] In a possible implementation of the embodiment of the present application, the first tower model and the second tower model both include an input layer, a coding layer, and an output layer;

[0183] Among them, the input layer is used to map the input into a vector of fixed dimension;

[0184] The encoding layer uses the natural language processing model structure to encode vectors of fixed dimensions;

[0185] The output layer is used to reduce the dimension of the vector output by the encoding layer.

[0186] It should be noted that the explanations in the aforementioned embodiment of the model training method for performing retrieval tasks are also applicable to the model training device for performing retrieval tasks in this embodiment, and will not be repeated here.

[0187] The model training device for performing retrieval tasks in the embodiment of the present application inputs sample retrieval information into the first tower model in the twin-tower model for encoding to obtain a representation of the sample retrieval information, and inputs description information of multiple candidate objects into the second tower model in the twin-tower model for encoding to obtain a representation of each candidate object, wherein the multiple candidate objects include positive samples that match the sample retrieval information, and negative samples that do not match the sample retrieval information, and determine a first loss function based on the similarity between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information, and perform model training on the twin-tower model based on the first loss function. Thus, it is possible to implement the training of the twin-tower model for performing retrieval tasks, fully alleviate the spatial inconsistency problem between the two representations output by the twin-tower model, and thereby improve the retrieval accuracy when performing retrieval tasks through the twin-tower model.

[0188] Figure 7 This is a schematic diagram of the structure of the retrieval device provided in Example 6 of the present application.

[0189] like Figure 7 As shown, the search device 700 may include: an acquisition module 710 , an encoding module 720 , a clustering module 730 , a first determination module 740 , and a generation module 750 .

[0190] The acquisition module 710 is used to acquire multiple pieces of historical search information and to acquire description information of multiple candidate objects;

[0191] The encoding module 720 is used to encode each piece of historical search information using the first tower model in the trained dual-tower model to obtain a representation of each piece of historical search information, and to encode the description information of each candidate object using the second tower model in the dual-tower model to obtain a representation of each candidate object;

[0192] A clustering module 730, configured to generate a representation set according to the representations of the plurality of historical search information and the representations of the plurality of candidate objects, and cluster the plurality of historical search information and the plurality of candidate objects according to the representations in the representation set to obtain a plurality of clusters;

[0193] A first determination module 740 is used to determine a target cluster matching the target search term from multiple clusters when the client provides the target search term;

[0194] The generating module 750 is used to generate the search results according to the candidate objects included in the target cluster and push them to the client.

[0195] Wherein, the double tower model is obtained by training using the device described in the embodiment of the first aspect.

[0196] In a possible implementation of the embodiment of the present application, the retrieval device 700 may further include:

[0197] A configuration module, configured to configure index serial numbers of a plurality of candidate objects based on a first serial number interval, and to configure index serial numbers of a plurality of historical search information based on a second serial number interval;

[0198] A storage module, used for storing index numbers associated with each cluster according to historical search information and candidate objects contained in each cluster;

[0199] The second determination module is used to determine the candidate objects included in the target cluster according to the target index numbers in the first sequence number interval among the index numbers associated with the target cluster when the target cluster is determined.

[0200] It should be noted that the retrieval device provided in the embodiment of the present application can execute the retrieval method of the aforementioned embodiment. The retrieval device can be an electronic device or can be configured in an electronic device to improve the retrieval accuracy when performing retrieval tasks through the dual-tower model by executing the retrieval method provided in the embodiment of the present application.

[0201] Among them, the electronic device can be a PC, cloud device, mobile device, server, etc., and the mobile device can be, for example, a mobile phone, tablet computer, personal digital assistant, wearable device, vehicle-mounted device, or any other hardware device, and this application does not impose any restrictions on this.

[0202] It should be noted that the explanations in the aforementioned retrieval method embodiment are also applicable to the retrieval device of this embodiment and will not be repeated here.

[0203] The retrieval device of the embodiment of the present application obtains multiple historical retrieval information and descriptive information of multiple candidate objects; uses the first tower model in the trained double-tower model to encode each historical retrieval information to obtain the representation of each historical retrieval information, and uses the second tower model in the double-tower model to encode the descriptive information of each candidate object to obtain the representation of each candidate object; generates a representation set based on the representations of the multiple historical retrieval information and the representations of the multiple candidate objects, and clusters the multiple historical retrieval information and the multiple candidate objects based on the representations in the representation set to obtain multiple clusters; when the client provides a target search term, determines a target cluster that matches the target search term from the multiple clusters; generates a retrieval result based on the candidate objects included in the target cluster and pushes it to the client. Thus, the accuracy of image retrieval is improved.

[0204] In order to implement the above embodiments, the present application also proposes an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the model training method for performing retrieval tasks proposed in any of the aforementioned embodiments of the present application, or execute the retrieval method proposed in any of the aforementioned embodiments of the present application.

[0205] In order to implement the above embodiments, the present application also proposes a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute a model training method for performing a retrieval task as proposed in any of the foregoing embodiments of the present application, or to execute a retrieval method as proposed in any of the foregoing embodiments of the present application.

[0206] In order to implement the above-mentioned embodiments, the present application also proposes a computer program product, including a computer program, which, when executed by a processor, implements a model training method for performing a retrieval task as proposed in any of the aforementioned embodiments of the present application, or implements a retrieval method as proposed in any of the aforementioned embodiments of the present application.

[0207] Figure 8 A block diagram of an exemplary electronic device suitable for implementing the embodiments of the present application is shown. Figure 8 The electronic device 800 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0208] like Figure 8As shown, the electronic device 800 is in the form of a general purpose computing device. The components of the electronic device 800 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16).

[0209] The bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnection (PCI) bus.

[0210] The electronic device 800 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 800, including volatile and non-volatile media, removable and non-removable media.

[0211] The memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 800 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 8 not shown, usually called a "hard drive"). Although Figure 8Not shown, a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (e.g., a compact disc read only memory (CD-ROM), a digital versatile disc read only memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present application.

[0212] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in the memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described herein.

[0213] The electronic device 800 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), one or more devices that enable a user to interact with the electronic device 800, and / or any device that enables the electronic device 800 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be performed through an input / output (I / O) interface 22. Furthermore, the electronic device 800 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 800 through a bus 18. It should be understood that although Figure 8 Not shown, other hardware and / or software modules may be used in conjunction with electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0214] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the methods mentioned in the above embodiments.

[0215] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0216] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0217] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0218] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.

[0219] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0220] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0221] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0222] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. A model training method for performing a retrieval task, characterized in that: include: Inputting the sample retrieval information into the first tower model of the double tower model for encoding to obtain a representation of the sample retrieval information; Inputting description information of a plurality of candidate objects into the second tower model in the dual-tower model for encoding to obtain representations of the candidate objects, wherein the plurality of candidate objects include positive samples that match the sample retrieval information and negative samples that do not match the sample retrieval information; Determining a first loss function according to the similarities between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information respectively; Based on the first loss function, model training is performed on the dual-tower model.

2. The method according to claim 1, characterized in that There are multiple negative samples, and determining a first loss function according to the similarities between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information respectively includes: Fusing the similarity between the representation of the positive sample and the representation of each of the negative samples to obtain a fused similarity of the positive sample; Determining a first similarity component corresponding to the positive sample according to the similarity between the representation of the sample retrieval information and the representation of the positive sample; The first loss function is determined according to a proportional relationship between the first similarity component corresponding to the positive sample and the fusion similarity of the positive sample.

3. The method according to claim 2, characterized in that There are multiple positive samples, and determining the first loss function according to a proportional relationship between a first similarity component corresponding to the positive sample and a fusion similarity of the positive sample includes: For any of the positive samples, determining a first ratio corresponding to the positive sample according to a ratio of a first similarity component corresponding to the positive sample to a fusion similarity of the positive sample; The first ratios corresponding to the positive samples are fused to obtain the first loss function.

4. The method according to any one of claims 1 to 3, characterized in that: The performing model training on the dual-tower model based on the first loss function includes: Determining a second loss function according to the similarities between the representation of the sample retrieval information and the representation of the negative sample and the representation of the positive sample respectively; Weighting the first loss function and the second loss function according to the hyperparameter to obtain a target loss function; According to the objective loss function, the model parameters and the hyperparameters of the dual-tower model are adjusted.

5. The method according to claim 4, characterized in that There are multiple negative samples, and determining a second loss function based on similarities between the representation of the sample retrieval information and the representation of the negative sample and the representation of the positive sample, respectively, includes: Merging the similarity between the representation of the sample retrieval information and the representation of each of the negative samples to obtain a total similarity of the multiple negative samples; Determining a second similarity component corresponding to the positive sample according to the similarity between the representation of the sample retrieval information and the representation of the positive sample; The second loss function is determined according to a proportional relationship between the second similarity component corresponding to the positive sample and the total similarity of the multiple negative samples.

6. The method according to claim 5, characterized in that There are multiple positive samples, and determining the second loss function according to the proportional relationship between the second similarity component corresponding to the positive sample and the total similarity of the multiple negative samples includes: For any of the positive samples, determining a second ratio corresponding to the positive sample according to a ratio of a second similarity component corresponding to the positive sample to the total similarity; The second ratios corresponding to the positive samples are merged to obtain the second loss function.

7. The method according to any one of claims 1 to 3, characterized in that: The description information includes at least one of the product title, store, price and brand of the corresponding candidate object; The sample search information includes a search term, or the sample search information includes the search term and user feature information.

8. The method according to any one of claims 1 to 3, characterized in that: The first tower model and the second tower model both include an input layer, a coding layer and an output layer; Wherein, the input layer is used to map the input into a vector of fixed dimension; The encoding layer adopts a natural language processing model structure to encode the fixed-dimensional vector; The output layer is used to perform dimensionality reduction processing on the vector output by the encoding layer.

9. A search method, characterized in that: include: Obtain multiple pieces of historical search information and obtain description information of multiple candidate objects; Using the first tower model in the trained dual-tower model to encode each piece of the historical search information to obtain a representation of each piece of the historical search information, and using the second tower model in the dual-tower model to encode the description information of each candidate object to obtain a representation of each candidate object; generating a representation set according to the representations of the plurality of historical search information and the representations of the plurality of candidate objects, and clustering the plurality of historical search information and the plurality of candidate objects according to the representations in the representation set to obtain a plurality of clusters; In the case where the client provides a target search term, determining a target cluster matching the target search term from the multiple clusters; According to the candidate objects included in the target cluster, a search result is generated and pushed to the client.

10. The method according to claim 9, characterized in that After generating a representation set according to the representations of the plurality of historical search information and the representations of the plurality of candidate objects, and clustering the plurality of historical search information and the plurality of candidate objects to obtain a plurality of clusters, the method further includes: Configure index serial numbers of the plurality of candidate objects based on the first serial number interval; Configure index serial numbers of the plurality of historical search information based on the second serial number interval; According to the historical search information and candidate objects contained in each cluster, the index number associated with each cluster is stored; When the target cluster is determined, the candidate objects included in the target cluster are determined according to the target index numbers in the first number interval among the index numbers associated with the target cluster.

11. A model training device for performing a retrieval task, characterized in that: include: A first processing module, used for inputting the sample retrieval information into the first tower model in the double tower model for encoding, so as to obtain a representation of the sample retrieval information; A second processing module is used to input description information of multiple candidate objects into the second tower model in the dual-tower model for encoding to obtain representations of each of the candidate objects, wherein the multiple candidate objects include positive samples that match the sample retrieval information and negative samples that do not match the sample retrieval information; A determination module, configured to determine a first loss function according to the similarity between the representation of the positive sample and the representation of the negative sample and the representation of the sample retrieval information respectively; A training module is used to perform model training on the dual-tower model based on the first loss function.

12. A search device, characterized in that: include: An acquisition module is used to acquire multiple pieces of historical search information and to acquire description information of multiple candidate objects; an encoding module, configured to encode each piece of the historical search information using the first tower model in the trained dual-tower model to obtain a representation of each piece of the historical search information, and to encode the description information of each candidate object using the second tower model in the dual-tower model to obtain a representation of each candidate object; a clustering module, configured to generate a representation set according to the representations of the plurality of historical search information and the representations of the plurality of candidate objects, and cluster the plurality of historical search information and the plurality of candidate objects according to the representations in the representation set to obtain a plurality of clusters; A first determination module, configured to determine a target cluster matching the target search term from among the multiple clusters when a client provides the target search term; A generating module is used to generate a search result according to the candidate objects included in the target cluster and push the result to the client.

13. The device according to claim 12, characterized in that Also includes: A configuration module, configured to configure index serial numbers of the plurality of candidate objects based on a first serial number interval, and to configure index serial numbers of the plurality of historical search information based on a second serial number interval; A storage module, used for storing index numbers associated with each cluster according to historical search information and candidate objects contained in each cluster; The second determination module is configured to determine, when the target cluster is determined, the candidate objects included in the target cluster according to the target index numbers in the first sequence number interval among the index numbers associated with the target cluster.

14. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 8, or the method of claim 9 or 10.

15. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 8, or the method according to claim 9 or 10.

Citation Information

Cited By

  • Information retrieval method and device and electronic equipment

    CN121144486A