Model training method and device, retrieval method and device, electronic equipment and storage medium

By adjusting the network parameters through a cross-difference training strategy in the dual-tower model, the problem of poor retrieval accuracy of the dual-tower model in e-commerce scenarios was solved, achieving more efficient retrieval accuracy and discrimination performance.

CN120930704APending Publication Date: 2025-11-11BEIJING WODONG TIANJUN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511074790.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-31
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

In e-commerce scenarios, the retrieval accuracy is poor in retrieval tasks based on the dual-tower model.

Method used

The user tower model and product tower model in the dual-tower model are used to encode the query information of sample users and the description information of sample products, respectively. The similarity between the encoded vectors is calculated to determine the loss value. The network parameters are adjusted through a cross-difference training strategy to build a bidirectional contrastive loss optimization model.

Benefits of technology

It improves the accuracy of retrieval tasks, avoids the problem of inconsistency between the output vector spaces of the user tower and the product tower, and enhances the discrimination performance of the retrieval system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120930704A_ABST
    Figure CN120930704A_ABST
Patent Text Reader

Abstract

The invention provides a model training method which is applied to the technical field of artificial intelligence. The method comprises the following steps: respectively encoding query information of a sample user and description information of a sample product by using a user tower model in a double-tower model to obtain a first sample user encoding vector for the sample user and a first sample product encoding vector for the sample product; coding the query information and the description information by using a product tower model in the double-tower model to obtain a second sample user coding vector for the sample user and a second sample product coding vector for the sample product; according to the similarity between the first sample user coding vector and the second sample product coding vector and the similarity between the second sample user coding vector and the first sample product coding vector, network parameters of the double-tower model are adjusted, and the trained double-tower model is obtained. The invention further provides a retrieval method and device, electronic equipment and a storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of artificial intelligence technology, and more specifically, to a model training method, retrieval method, apparatus, electronic device, storage medium, and program product. Background Technology

[0002] In e-commerce scenarios, the goal of retrieval is to quickly retrieve relevant products from a massive pool of candidate products. Research into related technologies reveals that a dual-tower paradigm—a dual-tower model combined with a quantitative index / graph index—can be used for retrieval tasks. This approach first maps query terms and product information to the same semantic space using massive amounts of user click data. Then, it uses inner product or cosine similarity calculations to match relevant products. When providing online services, a quantitative index (IVF-PQ, RQ, etc.) or a graph index (HNSW) is built for the products to achieve rapid retrieval. However, the retrieval accuracy using the dual-tower model remains relatively poor. Summary of the Invention

[0003] In view of this, the present disclosure provides a model training method, a retrieval method, an apparatus, an electronic device, a storage medium, and a program product.

[0004] One aspect of this disclosure provides a model training method, comprising:

[0005] The query information of the sample users and the description information of the sample products are encoded using the user tower model in the dual-tower model, respectively, to obtain the first sample user encoding vector for the above sample users and the first sample product encoding vector for the above sample products.

[0006] Using the product tower model in the above dual-tower model, the query information of the above sample users and the description information of the above sample products are encoded respectively to obtain the second sample user encoding vector for the above sample users and the second sample product encoding vector for the above sample products.

[0007] The first loss value is determined based on the similarity between the first sample user encoding vector and the second sample product encoding vector.

[0008] The second loss value is determined based on the similarity between the second sample user encoding vector and the first sample product encoding vector; and

[0009] Based on the first loss value and the second loss value mentioned above, the network parameters of the dual-tower model are adjusted to obtain the trained dual-tower model.

[0010] According to embodiments of this disclosure, the sample products include positive and negative samples for the query information, the first sample product encoding vector includes a first positive sample vector and a first negative sample vector, and the second sample product encoding vector includes a second positive sample vector and a second negative sample vector.

[0011] Based on the similarity between the first sample user encoding vector and the second sample product encoding vector, the first loss value is determined as follows:

[0012] The similarity of the first positive sample is determined based on the similarity between the first sample user encoding vector and the second positive sample vector.

[0013] The similarity of the first negative sample is determined based on the similarity between the first sample user encoding vector and the second negative sample vector.

[0014] The first loss value is determined based on the first similarity difference between the first sample similarity and the first negative sample similarity.

[0015] Based on the similarity between the second sample user encoding vector and the first sample product encoding vector, the second loss value is determined as follows:

[0016] The similarity of the second positive sample is determined based on the similarity between the second sample user encoding vector and the first positive sample vector.

[0017] The similarity of the second negative sample is determined based on the similarity between the second sample user encoding vector and the first negative sample vector.

[0018] The second loss value is determined based on the difference between the second similarity of the second sample and the second similarity of the second negative sample.

[0019] According to embodiments of this disclosure, the negative samples mentioned above include multiple samples; the method also includes:

[0020] For each negative sample among multiple negative samples, determine the first similarity sub-difference between the aforementioned first sample similarity and the aforementioned first negative sample similarity;

[0021] The first similarity sub-differences of multiple negative samples are fused to obtain the aforementioned first similarity difference;

[0022] For each negative sample among multiple negative samples, determine the second similarity sub-difference between the aforementioned second positive sample similarity and the aforementioned second negative sample similarity;

[0023] The second similarity sub-differences of multiple negative samples are fused to obtain the aforementioned second similarity difference.

[0024] According to embodiments of this disclosure, the aforementioned positive samples include a plurality of samples;

[0025] Based on the first similarity difference between the first sample similarity and the first negative sample similarity, the first loss value is determined to include:

[0026] Multiple first similarity differences are fused to obtain the first fused similarity difference;

[0027] The first loss value is determined based on the first fusion similarity difference mentioned above.

[0028] Based on the second similarity difference between the second sample similarity and the second negative sample similarity, the second loss value is determined as follows:

[0029] Multiple second similarity differences are fused to obtain a second fused similarity difference;

[0030] The second loss value is determined based on the difference in the second fusion similarity.

[0031] Another aspect of this disclosure provides a retrieval method, including:

[0032] In response to a product search request, retrieve the target query information contained in the aforementioned product search request;

[0033] The target query information is input into the user tower model in the dual-tower model, and the target query information encoding vector for the target query information is output. The dual-tower model is trained using the training method described above.

[0034] Based on the target query information encoding vector mentioned above, the preset product index is retrieved to obtain the product retrieval results. The product index is obtained by preprocessing the description information of multiple candidate products in the product pool using a dual-tower model.

[0035] According to embodiments of this disclosure, the above product index is determined using the following operations:

[0036] The user tower model in the above dual-tower model is used to encode the description information of the above candidate products to obtain the first candidate product encoding vector for the above candidate products.

[0037] The product pyramid model in the aforementioned dual-pyramid model is used to encode the description information of the candidate products, resulting in a second candidate product encoding vector for each candidate product; and

[0038] The product index is generated based on the first candidate product coding vector and the second candidate product coding vector.

[0039] According to embodiments of this disclosure, when the product index is a quantized index, generating the product index based on the first candidate product encoding vector and the second candidate product encoding vector includes:

[0040] Based on the first candidate product coding vector, multiple candidate products are clustered to obtain at least one cluster, wherein the cluster includes at least one candidate product.

[0041] For each of the at least one clusters mentioned above, the candidate products in the clusters are subjected to product quantization based on the second candidate product encoding vector of the candidate products in the clusters, to obtain the quantization result for the clusters.

[0042] The product index is generated based on at least one cluster and the quantification results of each of the above-mentioned clusters.

[0043] According to embodiments of this disclosure, when the product index is a graph index, generating the product index based on the first candidate product encoding vector and the second candidate product encoding vector includes:

[0044] The graph structure is initialized based on the graph structure parameters and preset candidate products, wherein the graph structure includes at least one graph node;

[0045] For each of the candidate products mentioned above, perform the following operations sequentially, and use the graph structure obtained when the insertion of the candidate products is completed as the index of the product:

[0046] Based on the first candidate product encoding vector of the above candidate products and the second candidate product encoding vector of the graph node in the current graph structure, determine the insertion position of the above candidate products and the neighbor nodes of the above candidate products;

[0047] Based on the insertion position of the candidate products, insert the candidate products as insertion nodes into the graph structure, and connect the insertion nodes to the neighboring nodes.

[0048] Another aspect of this disclosure provides a model training apparatus, comprising:

[0049] The first encoding module is used to encode the query information of the sample users and the description information of the sample products using the user tower model in the dual-tower model, respectively, to obtain the first sample user encoding vector for the above sample users and the first sample product encoding vector for the above sample products.

[0050] The second encoding module is used to encode the query information of the sample users and the description information of the sample products using the product tower model in the above dual-tower model, respectively, to obtain the second sample user encoding vector for the sample users and the second sample product encoding vector for the sample products.

[0051] The first determining module is used to determine a first loss value based on the similarity between the first sample user encoding vector and the second sample product encoding vector.

[0052] The second determining module is used to determine a second loss value based on the similarity between the second sample user encoding vector and the first sample product encoding vector; and

[0053] The parameter adjustment module is used to adjust the network parameters of the dual-tower model according to the first loss value and the second loss value to obtain the trained dual-tower model.

[0054] Another aspect of this disclosure provides a retrieval device, comprising:

[0055] The acquisition module is used to respond to product search requests and acquire the target query information contained in the product search requests.

[0056] The third encoding module is used to input the target query information into the user tower model in the dual-tower model and output the target query information encoding vector for the target query information. The dual-tower model is trained using the training device described above.

[0057] The query module is used to retrieve the preset product index based on the above target query information encoding vector to obtain the product search results. The above product index is obtained by preprocessing the description information of multiple candidate products in the product pool using a dual-tower model.

[0058] Another aspect of this disclosure provides an electronic device comprising:

[0059] One or more processors;

[0060] Memory, used to store one or more programs.

[0061] When the above one or more programs are executed by the above one or more processors, the above one or more processors implement the above method.

[0062] Another aspect of this disclosure provides a computer-readable storage medium storing computer-executable instructions, which, when executed, are used to implement the method described above.

[0063] Another aspect of this disclosure provides a computer program product including computer-executable instructions that, when executed, implement the method described above.

[0064] According to embodiments of this disclosure, the query information of sample users and the description information of sample products are encoded into a first sample user encoding vector and a first sample product encoding vector, respectively, using a user tower model. Simultaneously, the query information of sample users and the description information of sample products are encoded into a second sample user encoding vector and a second sample product encoding vector, respectively, using a product tower model. Then, by calculating the differences between the first and second sample user encoding vectors and the differences between the second and first sample product encoding vectors, a dual-tower model with bidirectional contrastive loss joint optimization is constructed. This cross-difference training strategy enables the user tower model and the product tower model to learn complementary feature representations while maintaining independent parameters, avoiding inconsistencies in the vector spaces of the outputs of the user tower and the product tower. Therefore, it at least partially overcomes the problem of poor retrieval accuracy, thereby achieving the technical effect of improving retrieval accuracy when performing retrieval tasks using the dual-tower model. Attached Figure Description

[0065] The above and other objects, features and advantages of this disclosure will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:

[0066] Figure 1 This illustration schematically shows an exemplary system architecture to which model training methods and training apparatus can be applied according to embodiments of the present disclosure;

[0067] Figure 2 A flowchart illustrating a model training method according to an embodiment of the present disclosure is shown schematically.

[0068] Figure 3 A schematic diagram illustrating the principle of a model training method according to an embodiment of the present disclosure is shown.

[0069] Figure 4 A schematic diagram illustrating the determination of the total loss value according to an embodiment of the present disclosure is shown.

[0070] Figure 5 A flowchart illustrating a retrieval method according to an embodiment of the present disclosure is shown schematically.

[0071] Figure 6 A schematic diagram illustrating the determination of a product index according to an embodiment of this disclosure is shown.

[0072] Figure 7 A block diagram of a model training apparatus according to an embodiment of the present disclosure is shown schematically;

[0073] Figure 8A block diagram schematically illustrates a retrieval device according to embodiments of the present disclosure; and

[0074] Figure 9 A block diagram of an electronic device suitable for implementing the methods described above, according to embodiments of the present disclosure, is illustrated schematically. Detailed Implementation

[0075] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.

[0076] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0077] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.

[0078] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).

[0079] In the embodiments disclosed herein, the collection, updating, analysis, processing, use, transmission, provision, disclosure, and storage of data (e.g., including but not limited to user personal information) comply with relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. In particular, necessary measures have been taken to prevent unauthorized access to user personal information data and to safeguard user personal information security and network security.

[0080] In the embodiments disclosed herein, user authorization or consent is obtained before acquiring or collecting user personal information.

[0081] Embodiments of this disclosure provide a model training method, comprising: encoding the query information of sample users and the description information of sample products using the user tower model in a dual-tower model, respectively, to obtain a first sample user encoding vector for sample users and a first sample product encoding vector for sample products; encoding the query information of sample users and the description information of sample products using the product tower model in the dual-tower model, respectively, to obtain a second sample user encoding vector for sample users and a second sample product encoding vector for sample products; determining a first loss value based on the similarity between the first sample user encoding vector and the second sample product encoding vector; determining a second loss value based on the similarity between the second sample user encoding vector and the first sample product encoding vector; and adjusting the network parameters of the dual-tower model based on the first loss value and the second loss value to obtain a trained dual-tower model. By employing a cross-difference training strategy, the user tower model and the product tower model learn complementary feature representations while maintaining independent parameters, avoiding inconsistencies in the vector spaces of the outputs of the user tower and the product tower. Therefore, this method at least partially overcomes the problem of poor retrieval accuracy, thereby achieving the technical effect of improving retrieval accuracy when performing retrieval tasks using a dual-tower model.

[0082] Figure 1 An exemplary system architecture 100, according to embodiments of the present disclosure, to which model training methods and training apparatus can be applied, is illustrated schematically. It should be noted that... Figure 1 The examples shown are merely examples of system architectures that can be applied to the embodiments of this disclosure, in order to help those skilled in the art understand the technical content of this disclosure, but do not mean that the embodiments of this disclosure cannot be used in other devices, systems, environments or scenarios.

[0083] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.

[0084] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, and / or social media platform software, etc. (for example only).

[0085] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0086] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (this is just an example). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.

[0087] It should be noted that the model training method provided in this embodiment can generally be executed by server 105. Correspondingly, the model training apparatus provided in this embodiment can generally be located in server 105. The model training method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Correspondingly, the model training apparatus provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Alternatively, the model training method provided in this embodiment can also be executed by the first terminal device 101, the second terminal device 102, or the third terminal device 103, or by other terminal devices different from the first terminal device 101, the second terminal device 102, or the third terminal device 103. Accordingly, the model training device provided in this embodiment may also be located in the first terminal device 101, the second terminal device 102 or the third terminal device 103, or in other terminal devices different from the first terminal device 101, the second terminal device 102 or the third terminal device 103.

[0088] For example, the query information of sample users and the description information of sample products can be originally stored in any one of the first terminal device 101, the second terminal device 102, or the third terminal device 103 (e.g., the first terminal device 101, but not limited thereto), or stored on an external storage device and can be imported into the first terminal device 101. Then, the first terminal device 101 can execute the model training method provided in the embodiments of this disclosure locally, or send the query information of sample users and the description information of sample products to other terminal devices, servers, or server clusters, and have the other terminal devices, servers, or server clusters that receive the query information of sample users and the description information of sample products execute the model training method provided in the embodiments of this disclosure.

[0089] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0090] Figure 2 A flowchart illustrating a model training method according to an embodiment of the present disclosure is shown schematically.

[0091] like Figure 2 As shown, the method includes operations S210~S250.

[0092] In operation S210, the user tower model in the dual-tower model is used to encode the query information of the sample users and the description information of the sample products respectively, so as to obtain the first sample user encoding vector for the sample users and the first sample product encoding vector for the sample products.

[0093] In operation S220, the product tower model in the dual-tower model is used to encode the query information of sample users and the description information of sample products respectively, so as to obtain the second sample user encoding vector for sample users and the second sample product encoding vector for sample products.

[0094] According to embodiments of this disclosure, the query information of the sample users is training samples used to train the dual-tower model.

[0095] In some embodiments, the query information of the sample users may include query terms entered by the sample users. Query terms may be keywords or phrases directly entered by the user.

[0096] In some embodiments, the query information of sample users may also include other implicit data, such as user characteristic information, search time, device type, and geographical location. User characteristic information includes information that characterizes user traits, such as user age and gender. It should be noted that this user characteristic information complies with relevant laws and regulations, is used for legitimate purposes, and does not violate public order and good morals. In particular, necessary measures have been taken regarding user characteristic information to prevent unauthorized access to user personal information data and to maintain user personal information security and network security.

[0097] According to embodiments of this disclosure, the sample products are products retrieved based on query information. Sample products may include positive samples and negative samples, where positive samples are those that match the query information and negative samples are those that do not match the query information.

[0098] According to embodiments of this disclosure, the description information of the sample product includes at least one of the following: title information, source information, value information, and type information.

[0099] The title information may include the sample product name or a brief identifier, such as smartphone A.

[0100] Source information can include the origin or acquisition channel of the product, such as manufacturer information, store information, etc.

[0101] Value information can include the quantifiable value of a product, such as its price.

[0102] Type information can include the product's category, such as electronic devices, clothing, or more specific subcategories (such as brand, model, etc.).

[0103] According to embodiments of this disclosure, the dual-tower model includes a user tower model and a product tower model. Both the user tower model and the product tower model have an input layer, an encoding layer, and an output layer. For example, the user tower model includes a first input layer, a first encoding layer, and a first output layer, while the product tower model may include a second input layer, a second encoding layer, and a second output layer.

[0104] The input layer maps input data into vectors of fixed dimensions; the encoding layer, using a natural language processing model structure, encodes the vectors of fixed dimensions; and the output layer reduces the dimensionality of the vectors output by the encoding layer.

[0105] Encoding fixed-dimensional vectors can include processes such as transforming and fusing fixed-dimensional vectors; dimensionality reduction can include processes such as transforming the vectors output by the encoding layer into fixed-dimensional vectors and normalizing them.

[0106] In some embodiments, encoding the query information of sample users and the description information of sample products using the user tower model in the dual-tower model may include: inputting the query information and description information into the first input layer of the user tower model, thereby mapping the query information into a fixed-dimensional query information input sequence vector and the description information into a fixed-dimensional description information input sequence vector; then inputting the two input sequence vectors into the first encoding layer, thereby encoding the two input sequence vectors respectively using the natural language processing model structure of the first encoding layer; then inputting the vector output by the first encoding layer into the first output layer, thereby performing dimensionality reduction processing on the vector output by the first encoding layer using the first output layer, and finally outputting the first sample user encoding vector for the sample users and the first sample product encoding vector for the sample products.

[0107] In some embodiments, encoding the query information of sample users and the description information of sample products using the user tower model in the dual-tower model may include: inputting the query information into the first input layer of the user tower model, thereby mapping the query information into a fixed-dimensional query information input sequence vector; inputting the description information into the second input layer of the product tower model, thereby mapping the description information into a fixed-dimensional description information input sequence vector; then, inputting both input sequence vectors into the first encoding layer, thereby encoding the two input sequence vectors respectively using the natural language processing model structure of the first encoding layer; then inputting the vector output by the first encoding layer into the first output layer, thereby performing dimensionality reduction processing on the vector output by the first encoding layer, and finally outputting the first sample user encoding vector for the sample users and the first sample product encoding vector for the sample products.

[0108] In some embodiments, encoding the query information of sample users and the description information of sample products using the product tower model in the dual-tower model may include: inputting the query information and description information into the second input layer of the product tower model, thereby mapping the query information into a fixed-dimensional query information input sequence vector and the description information into a fixed-dimensional description information input sequence vector; then inputting the two input sequence vectors into the second encoding layer, thereby encoding the two input sequence vectors respectively using the natural language processing model structure of the second encoding layer; then inputting the vector output by the second encoding layer into the second output layer, thereby performing dimensionality reduction processing on the vector output by the second encoding layer, and finally outputting a second sample user encoding vector for sample users and a second sample product encoding vector for sample products.

[0109] In some embodiments, encoding the query information of sample users and the description information of sample products using the product tower model in the dual-tower model may include: inputting the query information into the first input layer of the user tower model, thereby mapping the query information into a fixed-dimensional query information input sequence vector; inputting the description information into the second input layer of the product tower model, thereby mapping the description information into a fixed-dimensional description information input sequence vector; then, inputting both input sequence vectors into a second encoding layer, thereby encoding the two input sequence vectors using the natural language processing model structure of the second encoding layer; then inputting the vector output by the second encoding layer into a second output layer, thereby performing dimensionality reduction processing on the vector output by the second encoding layer, and finally outputting a second sample user encoding vector for sample users and a second sample product encoding vector for sample products.

[0110] According to embodiments of this disclosure, the user tower model and product tower model can adopt a bidirectional encoding representation language model structure, or any other natural language processing model structure, and this application does not limit them.

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

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

[0113] It should be noted that the query information mentioned above when training the dual-tower model in this application embodiment can be provided by the user and authorized for use, or obtained from public datasets, or obtained in other ways that comply with relevant laws and regulations.

[0114] The description information of the sample products used in training the dual-tower model in this application embodiment can be provided by the e-commerce platform and authorized for use, or obtained from public datasets, or obtained in other ways that comply with relevant laws and regulations.

[0115] In operation S230, a first loss value is determined based on the similarity between the first sample user encoding vector and the second sample product encoding vector.

[0116] In operation S240, a second loss value is determined based on the similarity between the second sample user encoding vector and the first sample product encoding vector.

[0117] In operation S250, the network parameters of the dual-tower model are adjusted according to the first loss value and the second loss value to obtain the trained dual-tower model.

[0118] Based on the similarity between the first sample user coding vector and the second sample product coding vector, the same loss function can be used to calculate the similarity between the second sample user coding vector and the first sample product coding vector.

[0119] The similarity between the first sample user encoding vector and the second sample product encoding vector can be expressed as cosine similarity. Similarly, the similarity between the second sample user encoding vector and the first sample product encoding vector can also be expressed as cosine similarity.

[0120] In one embodiment, adjusting the network parameters of the dual-tower model based on the similarity between the first sample user encoding vector and the second sample product encoding vector, and the similarity between the second sample user encoding vector and the first sample product encoding vector, to obtain a trained dual-tower model may include: determining a first loss value based on a loss function, the first sample user encoding vector, and the second sample product encoding vector; determining a second loss value based on a loss function, the second sample user encoding vector, and the first sample product encoding vector; adjusting the model parameters of the dual-tower model based on the first loss value and the second loss value; and obtaining the trained dual-tower model through multiple iterations of optimization.

[0121] In each iteration of optimization, the number of positive samples can be one or more, and the number of negative samples can be one or more; this application does not impose any restrictions on this.

[0122] In one embodiment, model training can employ the gradient backpropagation algorithm, with the Adam optimizer as the optimizer, a learning rate of 5e-5, a batch size of 256 data points, and 1 million iterations. The encoding layer has four layers, with a maximum input vector dimension of 100 and an output dimension of 128.

[0123] Figure 3 A schematic diagram illustrating the principle of a model training method according to an embodiment of the present disclosure is shown.

[0124] like Figure 3As shown, the model training method in this embodiment includes: inputting the query information 311 and the attribute information 312 of the sample user into the first input layer 321 of the user tower model for encoding, and outputting the sample user input sequence vector 322; simultaneously, inputting the description information 313 of the sample product into the second input layer 331 of the product tower model of the dual tower model for encoding, and outputting the sample product input sequence vector 332. Then, inputting the sample user input sequence vector 322 and the sample product input sequence vector 332 into the first encoding layer 323 for encoding, and outputting the first sample user encoding vector 341 and the first sample product encoding vector 342 for the sample user input sequence vector 322 through the first output layer 324. Simultaneously, inputting the sample user input sequence vector 322 and the sample product input sequence vector 332 into the second encoding layer 333 for encoding, and outputting the second sample user encoding vector 343 and the second sample product encoding vector 344 for the sample user input sequence vector 322 through the second output layer 334. Then, the first loss value 351 is determined based on the first sample user encoding vector 341 and the second sample product encoding vector 344. The second loss value 352 is determined based on the second sample user encoding vector 343 and the first sample product encoding vector 342. Then, the total loss value 361 is determined based on the first loss value 351 and the second loss value 352. The network parameters of the dual-tower model are adjusted based on the total loss value 361, and iterative training is performed to obtain the trained dual-tower model.

[0125] The amount of query information and sample product description information used when training the dual-tower model can be increased or decreased depending on the scenario, and this application does not impose any restrictions on this.

[0126] According to embodiments of this disclosure, a technique is employed to encode the query information of sample users and the description information of sample products into a first sample user encoding vector and a first sample product encoding vector, respectively, using a user tower model. Simultaneously, a product tower model is used to encode the query information of sample users and the description information of sample products into a second sample user encoding vector and a second sample product encoding vector, respectively. Then, by calculating the differences between the first sample user encoding vector and the second sample product encoding vector, and the differences between the second sample user encoding vector and the first sample product encoding vector, a bidirectional contrastive loss joint optimization dual-tower model is constructed. This cross-difference training strategy enables the user tower model and the product tower model to learn complementary feature representations while maintaining independent parameters, avoiding inconsistencies in the vector spaces of the user tower and product tower outputs. Therefore, it at least partially overcomes the problem of poor retrieval accuracy due to inconsistencies in the vector spaces of the user tower and product tower outputs, thereby achieving the technical effect of improving retrieval accuracy when performing retrieval tasks through the dual-tower model.

[0127] According to embodiments of this disclosure, the sample product may include positive and negative samples for query information, the first sample product encoding vector may include a first positive sample vector and a first negative sample vector, and the second sample product encoding vector may include a second positive sample vector and a second negative sample vector.

[0128] Figure 4 A schematic diagram illustrating the determination of the total loss value according to an embodiment of the present disclosure is shown.

[0129] like Figure 4 As shown, the method for determining the total loss value in this embodiment includes: obtaining a first negative sample similarity 431 based on the similarity between the second negative sample vector 422 in the first sample user coding vector 410 and the second sample product coding vector 420; obtaining a first positive sample similarity 432 based on the similarity between the second positive sample vector 421 in the first sample user coding vector 410 and the second sample product coding vector 420; and then determining a first loss value 440 based on the first negative sample similarity 431 and the first positive sample similarity 432.

[0130] Simultaneously, based on the similarity between the second sample user encoding vector 450 and the first negative sample vector 461 in the first sample product encoding vector 460, a second negative sample similarity 471 is obtained; based on the similarity between the second sample user encoding vector 450 and the first positive sample vector 462 in the first sample product encoding vector 460, a second positive sample similarity 472 is obtained; then, based on the second negative sample similarity 471 and the second positive sample similarity 472, a second loss value 480 is determined.

[0131] Then, the total loss value of 490 is determined based on the first loss value of 440 and the second loss value of 480.

[0132] It is understandable that the similarity between the first sample user encoding vector and the second positive sample should be greater than the similarity between the first sample user encoding vector and the second negative sample. Therefore, the first sample user encoding vector can be used as an anchor point, and softmax-loss can be used to measure the overall relative relationship. The following details the specific process of determining the first loss value using softmax-loss.

[0133] In some embodiments, determining the first loss value based on the similarity between the first sample user encoding vector and the second sample product encoding vector may include: determining the first loss value using the following formula (1). .

[0134] (1);

[0135] Where Q represents the user encoding vector of the first sample; I represents the product encoding vector of the second sample. This represents the second negative sample vector. This represents the second positive sample vector. , These represent positive and negative samples, respectively. This represents the similarity between the first sample user encoding vector and the second negative sample vector, i.e., the first negative sample similarity. This represents the similarity between the first sample user encoding vector and the second positive sample vector, i.e., the first positive sample similarity. It is a temperature coefficient that will change the distribution of similarity.

[0136] In determining the first loss value, firstly, the first positive sample similarity is determined based on the similarity between the first sample user encoding vector and the second positive sample vector. The similarity of the first negative sample is determined based on the similarity between the first sample user encoding vector and the second negative sample vector. Then, based on the similarity of the first positive sample... Similarity with the first negative sample First similarity difference Determine the first loss value.

[0137] It should be noted that when there are multiple negative samples, determining the first similarity difference requires fusing the similarity between each of the multiple negative samples and the user encoding vector of the first sample. Therefore, the above method may also include: for each of the multiple negative samples, determining the first similarity sub-difference between the first sample similarity and the first negative sample similarity of the negative sample; fusing the first similarity sub-differences of each of the multiple negative samples to obtain the first similarity difference.

[0138] In determining the first similarity difference Then, the first similarity difference is calculated using Softmax (Formula (1)). Converting to a probability distribution, the probability of a positive sample is... Then the negative log-likelihood of the positive sample probability. The first loss value is obtained, and minimizing the loss is equivalent to maximizing the probability of positive samples.

[0139] According to embodiments of this disclosure, when there are multiple positive samples, determining the first loss value based on the first similarity difference between the first sample similarity and the first negative sample similarity may further include: fusing multiple first similarity differences to obtain a first fused similarity difference; and determining the first loss value based on the first fused similarity difference.

[0140] For example, fusing multiple first similarity differences to obtain the first fused similarity difference includes: after determining the negative log-likelihood of the probability of each positive sample, fusing (summing) the negative log-likelihood of the probability of each positive sample to obtain the first loss value.

[0141] By explicitly comparing the distance difference between positive and negative samples and user representations, the model can be effectively driven to learn the ability to distinguish between relevant and irrelevant content representations, thereby enhancing the discriminative performance of the recommendation system.

[0142] The similarity between the first sample user encoding vector and the second positive sample should be greater than the similarity between the first sample user encoding vector and the second negative sample, and the similarity between the second sample user encoding vector and the first positive sample should be greater than the similarity between the second sample user encoding vector and the first negative sample. Therefore, the second sample user encoding vector can also be used as an anchor point, and softmax-loss can be used to measure the overall relative relationship. The specific process of determining the second loss value using softmax-loss is similar to the specific process of determining the second loss value using softmax-loss described above.

[0143] In some embodiments, determining the second loss value based on the similarity between the second sample user encoding vector and the first sample product encoding vector may include: determining the second loss value using the following formula (2). .

[0144] (2);

[0145] Among them, Q I I represents the second sample user encoding vector; Q This represents the coding vector of the second sample product. Represents the first negative sample vector. Represents the first positive sample vector. This represents the similarity between the second sample user encoding vector and the first negative sample vector, i.e., the second negative sample similarity. This represents the similarity between the second sample user encoding vector and the first positive sample vector, i.e., the second positive sample similarity. It is a temperature coefficient that will change the distribution of similarity.

[0146] Similarly, in determining the second loss value, firstly, the similarity of the second positive sample is determined based on the similarity between the second sample user encoding vector and the first positive sample vector. The similarity of the second negative sample is determined based on the similarity between the second sample user encoding vector and the first negative sample vector. Then, based on the similarity of the second positive sample... Similarity to the second negative sample Second similarity difference Determine the second loss value.

[0147] It should be noted that when there are multiple negative samples, determining the second similarity difference requires fusing the similarity between each of the multiple negative samples and the second sample user encoding vector. Therefore, the above method may also include: for each of the multiple negative samples, determining the second similarity sub-difference between the second sample similarity and the second negative sample similarity of the negative sample; fusing the second similarity sub-differences of each of the multiple negative samples to obtain the second similarity difference.

[0148] In determining the second similarity difference Then, the second similarity difference is calculated using Softmax (Formula (2)). Converting to a probability distribution, the probability of a positive sample is... Then the negative log-likelihood of the positive sample probability. The result is the second loss value. Minimizing the loss is equivalent to maximizing the probability of positive samples.

[0149] According to embodiments of this disclosure, when there are multiple positive samples, determining the second loss value based on the second similarity difference between the second sample similarity and the second negative sample similarity may further include: fusing multiple second similarity differences to obtain a second fused similarity difference; and determining the second loss value based on the second fused similarity difference.

[0150] For example, fusing multiple second similarity differences to obtain the second fused similarity difference includes: after determining the negative log-likelihood of the probability of each positive sample, fusing (summing) the negative log-likelihood of the probability of each positive sample to obtain the second loss value.

[0151] After determining the first loss value and the second loss value, the total loss L can be determined by the following formula (3).

[0152] (3).

[0153] Here, w represents a hyperparameter used to control the importance of the first loss value. The default initial value of w can be 0.5.

[0154] According to embodiments of this disclosure, the network parameters of the user tower and product tower are modified by changing the distribution of input data through data interaction modes. Two sets of representations can be obtained from a single input, which is simple and efficient. Compared with the structure of a shared dual-tower, it increases the degree of freedom and achieves adaptive data distribution coupling and decoupling, especially in scenarios where the input distributions of the two towers differ greatly, such as the user side containing behavioral streams and the product side containing images. It is simpler than the pseudo-interaction model and does not require additional statistical / construction of external data.

[0155] Based on the model training method for performing retrieval tasks in the above embodiments, this application provides a retrieval method. The retrieval method provided in this application embodiment is described below.

[0156] Figure 5 A flowchart illustrating a retrieval method according to an embodiment of the present disclosure is shown schematically.

[0157] like Figure 5 As shown, the method includes operations S510~S530.

[0158] When operating S510, in response to a product retrieval request, the target query information contained in the product retrieval request is obtained.

[0159] In operation S520, the target query information is input into the user tower model in the dual-tower model, and the target query information encoding vector is output for the target query information. The dual-tower model is trained using the training method described above.

[0160] When operating S530, the preset product index is retrieved based on the target query information encoding vector to obtain the product retrieval results. The product index is obtained by preprocessing the description information of multiple candidate products in the product pool using a dual-tower model.

[0161] The product pool can include all products on the platform to be searched.

[0162] The target query information is similar to the query information of the sample users mentioned above, and the description information of the candidate products is the same as the description information of the sample products mentioned above, so it will not be repeated here.

[0163] It should be noted that before going live, the description information of multiple candidate products in the product pool is pre-processed to obtain a product index. Therefore, only the product index needs to be deployed online; there is no need to deploy a product tower model service or store it. It is a vector set, so it does not increase deployment costs or communication overhead.

[0164] According to embodiments of this disclosure, by employing a technical solution that, upon receiving a product retrieval request, first extracts the target query information from the request and encodes it into a target query vector using a user tower model; then, by performing similarity matching between the query vector and a pre-built product index, quickly returns the most relevant product retrieval results, the following effects can be achieved: Utilizing a dual-tower model optimized through contrastive learning ensures that the query vector and product vector are highly distinguishable within the same semantic space; millisecond-level retrieval response is achieved through a pre-built product index; and the bidirectional semantic information of user query intent and product characteristics is fully preserved, significantly improving the accuracy and user experience in scenarios such as e-commerce search and content recommendation.

[0165] The process of determining the product index is described in detail below.

[0166] According to embodiments of this disclosure, the product index is determined by the following operations: encoding the description information of candidate products using the user tower model in the dual-tower model to obtain a first candidate product encoding vector for the candidate products; encoding the description information of candidate products using the product tower model in the dual-tower model to obtain a second candidate product encoding vector for the candidate products; and generating a product index based on the first candidate product encoding vector and the second candidate product encoding vector.

[0167] According to embodiments of this disclosure, candidate products are dual-encoded from both the user's and product's perspectives using a dual-tower model, generating a first candidate product encoding vector and a second candidate product encoding vector, thereby constructing a product index that integrates multi-dimensional features. This approach retains user preference features (capturing potential interests through a user tower model) while integrating inherent product attribute features (extracting objective characteristics through a product tower model). The resulting composite index more comprehensively expresses product semantics, significantly improving the accuracy and coverage of personalized recommendations while maintaining efficient vector retrieval capabilities.

[0168] Currently, commonly used index structures fall into two main categories: IVF-PQ (Inverted File with Product Quantization) quantization indexes and HNSW (Hierarchical Navigable Small World) graph index structures. The following section uses IVF-PQ quantization indexes and HNSW-based graph index structures as examples to explain in detail how to generate a product index based on the first and second candidate product encoding vectors.

[0169] Figure 6 A schematic diagram illustrating the determination of a product index according to an embodiment of the present disclosure is shown.

[0170] It should be noted that when the product index is an IVF-PQ quantized index, the product index can include a primary index and a secondary index. The primary index can be a list of cluster centers, and the secondary index can be the code table for each cluster.

[0171] like Figure 6As shown, this embodiment includes: inputting candidate products 610 into a user tower model 620 and outputting a first candidate product encoding vector set 621; inputting candidate products 610 into a product tower model 630 and outputting a second candidate product encoding vector set 631. The first candidate product encoding vector set 621 may include the first candidate product encoding vectors of each of the multiple candidate products 610, and the second candidate product encoding vector set 631 may include the second candidate product encoding vectors of each of the multiple candidate products 610. Then, based on the first candidate product encoding vector set 621, the multiple candidate products 610 are clustered to obtain a clustering result 640, wherein the clustering result 640 includes at least one cluster, and each cluster includes at least one candidate product. Then, for each cluster in the at least one cluster, based on the second candidate product encoding vector set 631 and the second candidate product encoding vectors of the candidate products in the cluster, the candidate products in the cluster are subjected to product quantization processing to obtain a sub-code table for the cluster, and then the quantization result 650 is determined based on the sub-code table of each of the at least one cluster. Then, a product index 660 is constructed based on the clustering result 640 and the quantization result 650. The product index 660 may include a primary index and a secondary index. The primary index may be a list of cluster centers in the clustering result 640, and the secondary index may be a sub-code table corresponding to each cluster center in the quantization result 650, with each cluster center...

[0172] In some embodiments, the clustering process of multiple candidate products 610 based on the first candidate product encoding vector set 621 can employ the K-Means clustering algorithm, and may include the following steps:

[0173] Initialization: Select K vectors randomly or through an optimization algorithm (such as K-Means) as initial cluster centers, where K is the preset number of cluster centers (i.e. the number of "buckets" or "cells").

[0174] Assignment: Iterate through each first candidate product encoding vector in the set 621, and calculate its distance to all K current cluster centers (usually using Euclidean distance or inner product similarity). Assign each first candidate product encoding vector to the cell represented by the cluster center that is closest to it (or has the highest similarity).

[0175] Update: For each cluster unit, calculate the mean of all item vectors assigned to this unit and update the mean vector as the new cluster center.

[0176] Iteration: Repeat the above allocation and update steps until the stopping condition is met.

[0177] The stopping conditions are usually set as follows: the total distance moved by the cluster center points is less than a certain threshold; or the preset maximum number of iterations is reached; or the rate of change in sample allocation within the cluster unit is lower than a threshold.

[0178] Forming an inverted index: After clustering, the final K cluster centers constitute the coarse cluster center set C = {c1, c2, ..., cK}. Simultaneously, a record is created of which cluster center each first candidate product code vector is assigned to, forming an inverted index structure. That is, for each cluster center, a list (called the inverted list) is maintained, storing the product identifiers in the product pool for all first candidate product code vectors assigned to that unit.

[0179] In some embodiments, based on the second candidate product encoding vector set 631 and the second candidate product encoding vectors of candidate products in the cluster, product quantization is performed on the candidate products in the cluster. PQ quantization can be used, and may include the following steps:

[0180] Vector association: Using the above reverse sequence list, the second candidate product code vector in the set of second candidate product code vectors generated by the product tower model is associated with its corresponding coarse clustering unit according to its product identifier.

[0181] PQ quantization: Within each coarse clustering unit, product quantization (PQ) is performed independently on the subset of vectors stored therein: each high-dimensional vector in the unit is divided into M low-dimensional sub-vectors; for each sub-vector space, a quantization code table (sub-codebook) is independently learned using the data in that unit; using the learned M sub-codebooks, all vectors in that unit are quantized and encoded to generate the corresponding sub-code table (composed of M sub-codes).

[0182] According to embodiments of this disclosure, when the product index is a graph index, the product index includes graph nodes at different levels.

[0183] According to embodiments of this disclosure, generating a product index based on a first candidate product encoding vector and a second candidate product encoding vector may include: initializing a graph structure based on graph structure parameters and preset candidate products, wherein the graph structure includes at least one graph node; performing the following operations sequentially on each of the multiple candidate products, and using the graph structure obtained when the multiple candidate products are inserted as the product index: determining the insertion position of the candidate product and the neighboring nodes of the candidate product based on the first candidate product encoding vector of the candidate product and the second candidate product encoding vector of the graph node in the current graph structure; inserting the candidate product as an insertion node into the graph structure based on the insertion position of the candidate product, and connecting the insertion node with the neighboring nodes.

[0184] Graph structure parameters can include the number of levels, the upper limit of the number of connections per node, and the similarity calculation method, which are used to control the complexity and search efficiency of the graph.

[0185] Preset candidate products can be products among the candidate products and can be specified by a user.

[0186] Determining the insertion position and neighboring nodes of a candidate product based on its first candidate product encoding vector and the second candidate product encoding vector of a graph node in the current graph structure can include: finding the most suitable insertion position and adjacent nodes (neighboring nodes) based on the similarity (Euclidean distance, cosine similarity, etc.) between the first candidate product encoding vector and the second candidate product encoding vector of a graph node in the current graph structure.

[0187] Based on the insertion position of the candidate product, inserting the candidate product as an insertion node into the graph structure and connecting the insertion node with neighboring nodes can include: adding the current candidate product as an insertion node to the graph structure according to the determined insertion position, and establishing connections (forming edges) with the previously found neighboring nodes, thereby integrating it into the hierarchical structure of the entire graph.

[0188] In one example, the method for inserting candidate products may specifically include:

[0189] For each candidate product, starting from the highest layer (the sparsest layer), search for its insertion position layer by layer downwards until the lowest layer (the densest layer).

[0190] Perform the following operations at each level:

[0191] Determine the insertion position: Calculate the similarity between the first candidate product encoding vector of the current candidate product and the second candidate product encoding vector of the current layer graph node, and find the most similar nodes as the entry points.

[0192] Greedy neighbor search: Based on the nearest neighbor search strategy, find the nearest nodes in the current layer as neighbor nodes.

[0193] Connect neighboring nodes: Insert the current candidate product as a new node into the layer and establish connections (edges) with the searched neighboring nodes, while limiting the maximum number of neighbors for each node in the layer.

[0194] After all candidate products have been inserted, the resulting multi-layered HNSW graph structure is the product index.

[0195] After completing the product index construction, delete the first candidate product code vector set and keep only the second candidate product code vector set, without increasing the additional storage space.

[0196] According to embodiments of this disclosure, a highly efficient and general-purpose model-index consistency retrieval framework is proposed. It achieves alignment of the dual-tower space through data interaction without adding extra data, resolving inconsistencies on the model side and improving performance. Simultaneously, it constructs an index using product vectors output from the user tower model and product tower model, aligning the retrieval and training processes and reducing losses caused by inconsistencies. This solution possesses high efficiency, generality, and adaptability; that is, it does not increase the data query burden, does not increase service deployment costs, and quickly adapts to various index structures.

[0197] Figure 7 A block diagram of a model training apparatus according to an embodiment of the present disclosure is shown schematically.

[0198] like Figure 7 As shown, the model training device 700 of this embodiment includes a first encoding module 710, a second encoding module 720, a first determination module 730, a second determination module 740, and a parameter adjustment module 750.

[0199] The first encoding module 710 is used to encode the query information of the sample user and the description information of the sample product using the user tower model in the dual-tower model, respectively, to obtain the first sample user encoding vector for the sample user and the first sample product encoding vector for the sample product.

[0200] The second encoding module 720 is used to encode the query information of sample users and the description information of sample products using the product tower model in the dual-tower model, respectively, to obtain the second sample user encoding vector for sample users and the second sample product encoding vector for sample products.

[0201] The first determining module 730 is used to determine a first loss value based on the similarity between the first sample user encoding vector and the second sample product encoding vector.

[0202] The second determining module 740 is used to determine a second loss value based on the similarity between the second sample user encoding vector and the first sample product encoding vector.

[0203] The parameter adjustment module 750 is used to adjust the network parameters of the dual-tower model according to the first loss value and the second loss value to obtain the trained dual-tower model.

[0204] According to embodiments of this disclosure, the sample product includes positive samples and negative samples for query information, the first sample product encoding vector includes a first positive sample vector and a first negative sample vector, and the second sample product encoding vector includes a second positive sample vector and a second negative sample vector.

[0205] According to embodiments of this disclosure, the first determining module includes: a first determining unit, a second determining unit, and a third determining unit.

[0206] The first determining unit is used to determine the similarity of the first positive sample based on the similarity between the first sample user coding vector and the second positive sample vector.

[0207] The second determining unit is used to determine the similarity of the first negative sample based on the similarity between the first sample user encoding vector and the second negative sample vector.

[0208] The third determining unit is used to determine the first loss value based on the first similarity difference between the first sample similarity and the first negative sample similarity.

[0209] According to embodiments of this disclosure, the second determining module includes: a fourth determining unit, a fifth determining unit, and a sixth determining unit.

[0210] The fourth determining unit is used to determine the similarity of the second positive sample based on the similarity between the second sample user coding vector and the first positive sample vector.

[0211] The fifth determining unit is used to determine the similarity of the second negative sample based on the similarity between the second sample user coding vector and the first negative sample vector.

[0212] The sixth determining unit is used to determine the second loss value based on the second similarity difference between the second sample similarity and the second negative sample similarity.

[0213] According to embodiments of this disclosure, negative samples include a plurality of samples.

[0214] According to embodiments of this disclosure, the first determining module further includes a seventh determining unit and a first fusion unit.

[0215] The seventh determining unit is used to determine, for each of the multiple negative samples, a first similarity sub-difference between the first sample similarity and the first negative sample similarity of the negative sample.

[0216] The first fusion unit is used to fuse the first similarity sub-differences of multiple negative samples to obtain the first similarity difference.

[0217] According to embodiments of this disclosure, the second determining module further includes: an eighth determining unit and a second fusion unit.

[0218] The eighth determining unit is used to determine the second similarity sub-difference between the second positive sample similarity and the second negative sample similarity of the negative sample for each of the multiple negative samples.

[0219] The second fusion unit is used to fuse the second similarity sub-differences of multiple negative samples to obtain the second similarity difference.

[0220] According to embodiments of this disclosure, positive samples include a plurality of samples.

[0221] According to embodiments of this disclosure, the third determining unit includes: a first fusion subunit and a first determining subunit.

[0222] The first fusion subunit is used to fuse multiple first similarity differences to obtain a first fused similarity difference.

[0223] The first determining subunit is used to determine the first loss value based on the first fusion similarity difference.

[0224] According to embodiments of this disclosure, the sixth determining unit includes: a second fusion subunit and a second determining subunit.

[0225] The second fusion subunit is used to fuse multiple second similarity differences to obtain a second fused similarity difference.

[0226] The second determining subunit is used to determine the second loss value based on the second fusion similarity difference.

[0227] According to embodiments of this disclosure, the descriptive information includes at least one of the following: title information, source information, value information, and type information;

[0228] The query information includes the query terms, or the query information includes the query terms and user characteristic information of the sample users.

[0229] Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure, or at least part of the functions of any one or more of them, can be implemented in one module. Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be implemented by dividing them into multiple modules. Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be at least partially implemented as hardware circuitry, such as a Field-Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a System-on-Chip, a System-on-a-Substrate, a System-on-Package, an Application-Specific Integrated Circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be at least partially implemented as computer program modules, which, when run, can perform corresponding functions.

[0230] For example, any plurality of the first encoding module 710, the second encoding module 720, the first determining module 730, the second determining module 740, and the parameter adjustment module 750 can be combined into one module / unit / subunit, or any one of these modules / units / subunits can be split into multiple modules / units / subunits. Alternatively, at least part of the functionality of one or more of these modules / units / subunits can be combined with at least part of the functionality of other modules / units / subunits and implemented in one module / unit / subunit. According to embodiments of this disclosure, at least one of the first encoding module 710, the second encoding module 720, the first determining module 730, the second determining module 740, and the parameter adjustment module 750 can be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging the circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, at least one of the first encoding module 710, the second encoding module 720, the first determining module 730, the second determining module 740, and the parameter adjustment module 750 can be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is run.

[0231] It should be noted that the model training device part in the embodiments of this disclosure corresponds to the model training method part in the embodiments of this disclosure. The specific description of the model training device part is referred to in the model training method part, and will not be repeated here.

[0232] Figure 8 A block diagram of a retrieval apparatus according to an embodiment of the present disclosure is shown schematically.

[0233] like Figure 8 As shown, the retrieval device 800 of this embodiment includes an acquisition module 810, a third encoding module 820, and a query module 830.

[0234] The acquisition module 810 is used to respond to a product search request and acquire the target query information contained in the product search request.

[0235] The third encoding module 820 is used to input the target query information into the user tower model in the dual-tower model and output the target query information encoding vector for the target query information. The dual-tower model is trained using a training device.

[0236] The query module 830 is used to retrieve the preset product index based on the target query information encoding vector to obtain the product retrieval results. The product index is obtained by preprocessing the description information of multiple candidate products in the product pool using a dual-tower model.

[0237] According to embodiments of this disclosure, the product index is determined using the following modules: a fourth encoding module, a fifth encoding module, and a generation module.

[0238] The fourth encoding module is used to encode the description information of the candidate products using the user tower model in the dual-tower model, so as to obtain the first candidate product encoding vector for the candidate products.

[0239] The fifth encoding module is used to encode the description information of candidate products using the commodity tower model in the dual-tower model, so as to obtain the second candidate product encoding vector for the candidate products.

[0240] The generation module is used to generate a product index based on the first candidate product encoding vector and the second candidate product encoding vector.

[0241] According to embodiments of this disclosure, the generation module includes: a clustering submodule, a product quantization submodule, and a generation submodule.

[0242] The clustering submodule is used to cluster multiple candidate products based on the first candidate product encoding vector to obtain at least one cluster, wherein the cluster includes at least one candidate product.

[0243] The product quantization submodule is used to perform product quantization on the candidate products in the clusters based on the second candidate product encoding vector of the candidate products in the clusters for each cluster in at least one cluster, so as to obtain the quantization result for the clusters.

[0244] The generation submodule is used to generate a product index based on at least one cluster and the quantization results of at least one cluster.

[0245] According to embodiments of this disclosure, the generation module further includes: an initialization submodule and a third determination submodule.

[0246] The initialization submodule is used to initialize the graph structure according to the graph structure parameters and preset candidate products, wherein the graph structure includes at least one graph node;

[0247] The execution submodule is used to sequentially execute the ninth determination unit and the insertion unit for each of the multiple candidate products, and use the graph structure obtained when the multiple candidate products are inserted as the product index.

[0248] The ninth determining unit is used to determine the insertion position of the candidate product and the neighboring nodes of the candidate product based on the first candidate product encoding vector of the candidate product and the second candidate product encoding vector of the graph node in the current graph structure.

[0249] The insertion unit is used to insert the candidate product as an insertion node into the graph structure according to the insertion position of the candidate product, and connect the insertion node with the neighboring nodes.

[0250] Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure, or at least part of the functions of any one or more of them, can be implemented in one module. Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be implemented by dividing them into multiple modules. Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be at least partially implemented as hardware circuitry, such as a Field-Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a System-on-Chip, a System-on-a-Substrate, a System-on-Package, an Application-Specific Integrated Circuit (ASIC), or implemented in hardware or firmware by any other reasonable means of integrating or packaging circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be at least partially implemented as computer program modules, which, when run, can perform corresponding functions.

[0251] For example, any plurality of the acquisition module 810, the third encoding module 820, and the query module 830 can be combined into one module / unit / subunit, or any one of these modules / units / subunits can be split into multiple modules / units / subunits. Alternatively, at least part of the functionality of one or more of these modules / units / subunits can be combined with at least part of the functionality of other modules / units / subunits and implemented in one module / unit / subunit. According to embodiments of this disclosure, at least one of the acquisition module 810, the third encoding module 820, and the query module 830 can be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or any other reasonable means of integrating or packaging the circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, at least one of the acquisition module 810, the third encoding module 820, and the query module 830 may be implemented at least partially as a computer program module, which can perform corresponding functions when the computer program module is run.

[0252] It should be noted that the retrieval device part in the embodiments of this disclosure corresponds to the retrieval method part in the embodiments of this disclosure. The specific description of the retrieval device part is referred to in the retrieval method part, and will not be repeated here.

[0253] Figure 9 A block diagram of an electronic device suitable for implementing the methods described above, according to embodiments of the present disclosure, is illustrated schematically. Figure 9 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0254] like Figure 9 As shown, an electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage portion 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

[0255] RAM 903 stores various programs and data required for the operation of electronic device 900. Processor 901, ROM 902, and RAM 903 are interconnected via bus 904. Processor 901 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 902 and / or RAM 903. It should be noted that the programs may also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.

[0256] According to embodiments of this disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to a bus 904. The electronic device 900 may also include one or more of the following components connected to the input / output (I / O) interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the input / output (I / O) interface 905 as needed. A removable medium 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 910 as needed so that computer programs read from it can be installed into the storage section 908 as needed.

[0257] According to embodiments of this disclosure, the method flow according to embodiments of this disclosure can be implemented as a computer software program. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable storage medium, the computer program containing program code for performing the methods shown in the flowchart. In such embodiments, the computer program can be downloaded and installed from a network via communication section 909, and / or installed from removable medium 911. When the computer program is executed by processor 901, it performs the functions defined in the system of embodiments of this disclosure. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0258] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of this disclosure.

[0259] According to embodiments of this disclosure, the computer-readable storage medium can be a non-volatile computer-readable storage medium. Examples include, but are not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0260] For example, according to embodiments of this disclosure, a computer-readable storage medium may include the ROM 902 and / or RAM 903 described above and / or one or more memories other than ROM 902 and RAM 903.

[0261] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods provided in the embodiments of this disclosure. When the computer program product is run on an electronic device, the program code is used to enable the electronic device to implement the methods provided in the embodiments of this disclosure.

[0262] When the computer program is executed by the processor 901, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0263] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 909, and / or installed from a removable medium 911. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.

[0264] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, languages ​​such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on a user's computing device, partially on a user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0265] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions. Those skilled in the art will understand that the features described in the various embodiments of the present disclosure can be combined and / or combined in various ways, even if such combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments of this disclosure may be combined and / or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.

[0266] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.

Claims

1. A model training method, comprising: The query information of the sample user and the description information of the sample product are encoded using the user tower model in the dual-tower model, respectively, to obtain the first sample user encoding vector for the sample user and the first sample product encoding vector for the sample product. The product tower model in the dual-tower model is used to encode the query information of the sample user and the description information of the sample product respectively, to obtain the second sample user encoding vector for the sample user and the second sample product encoding vector for the sample product. The first loss value is determined based on the similarity between the first sample user encoding vector and the second sample product encoding vector; The second loss value is determined based on the similarity between the second sample user encoding vector and the first sample product encoding vector; as well as Based on the first loss value and the second loss value, the network parameters of the dual-tower model are adjusted to obtain the trained dual-tower model.

2. The method according to claim 1, wherein, The sample products include positive and negative samples for the query information. The first sample product encoding vector includes a first positive sample vector and a first negative sample vector. The second sample product encoding vector includes a second positive sample vector and a second negative sample vector. The first loss value is determined based on the similarity between the first sample user encoding vector and the second sample product encoding vector, including: The first positive sample similarity is determined based on the similarity between the first sample user encoding vector and the second positive sample vector; The similarity of the first negative sample is determined based on the similarity between the first sample user encoding vector and the second negative sample vector. The first loss value is determined based on the first similarity difference between the first sample similarity and the first negative sample similarity. The second loss value is determined based on the similarity between the second sample user encoding vector and the first sample product encoding vector, including: The similarity of the second positive sample is determined based on the similarity between the second sample user encoding vector and the first positive sample vector. The similarity of the second negative sample is determined based on the similarity between the second sample user encoding vector and the first negative sample vector. The second loss value is determined based on the second similarity difference between the second sample similarity and the second negative sample similarity.

3. The method according to claim 2, wherein, The negative samples include multiple samples; the method further includes: For each negative sample among multiple negative samples, determine a first similarity sub-difference between the first sample similarity and the first negative sample similarity of the negative sample; The first similarity sub-differences of multiple negative samples are fused to obtain the first similarity difference; For each negative sample among a plurality of negative samples, a second similarity sub-difference is determined between the second positive sample similarity and the second negative sample similarity of the negative sample; The second similarity sub-differences of multiple negative samples are fused to obtain the second similarity difference.

4. The method according to claim 2 or 3, wherein, The positive samples include multiple samples; The first loss value is determined based on the first similarity difference between the first sample similarity and the first negative sample similarity, including: Multiple first similarity differences are fused to obtain the first fused similarity difference; The first loss value is determined based on the first fusion similarity difference; The second loss value is determined based on the second similarity difference between the second sample similarity and the second negative sample similarity, including: Multiple second similarity differences are fused to obtain a second fused similarity difference; The second loss value is determined based on the second fusion similarity difference.

5. A retrieval method, comprising: In response to a product search request, obtain the target query information contained in the product search request; The target query information is input into the user tower model in the dual-tower model, and the target query information encoding vector for the target query information is output. The dual-tower model is trained using the training method of any one of claims 1 to 4. The product index is retrieved based on the target query information encoding vector to obtain the product retrieval results. The product index is obtained by preprocessing the description information of multiple candidate products in the product pool using a dual-tower model.

6. The method according to claim 5, wherein, The product index is determined using the following operation: The description information of the candidate product is encoded using the user tower model in the dual-tower model to obtain the first candidate product encoding vector for the candidate product; The description information of the candidate products is encoded using the product tower model in the dual-tower model to obtain a second candidate product encoding vector for the candidate products; as well as The product index is generated based on the first candidate product coding vector and the second candidate product coding vector.

7. The method according to claim 6, wherein, When the product index is a quantized index, generating the product index based on the first candidate product encoding vector and the second candidate product encoding vector includes: Based on the first candidate product encoding vector, the multiple candidate products are clustered to obtain at least one cluster, wherein the cluster includes at least one candidate product; For each of the at least one clusters, the candidate products in the cluster are subjected to product quantization based on the second candidate product encoding vector of the candidate products in the cluster, to obtain the quantization result for the cluster. The product index is generated based on the at least one cluster and the quantization results of each of the at least one cluster.

8. The method according to claim 6, wherein, When the product index is a graph index, generating the product index based on the first candidate product encoding vector and the second candidate product encoding vector includes: The graph structure is initialized based on the graph structure parameters and preset candidate products, wherein the graph structure includes at least one graph node; For each of the multiple candidate products, the following operations are performed sequentially, and the graph structure obtained when the multiple candidate products are inserted is used as the product index: Based on the first candidate product encoding vector of the candidate product and the second candidate product encoding vector of the graph node in the current graph structure, determine the insertion position of the candidate product and the neighboring nodes of the candidate product; Based on the insertion position of the candidate product, the candidate product is inserted into the graph structure as an insertion node, and the insertion node is connected to the neighboring node.

9. A model training device, comprising: The first encoding module is used to encode the query information of the sample user and the description information of the sample product using the user tower model in the dual-tower model, respectively, to obtain the first sample user encoding vector for the sample user and the first sample product encoding vector for the sample product. The second encoding module is used to encode the query information of the sample user and the description information of the sample product using the product tower model in the dual-tower model, respectively, to obtain a second sample user encoding vector for the sample user and a second sample product encoding vector for the sample product. The first determining module is used to determine a first loss value based on the similarity between the first sample user encoding vector and the second sample product encoding vector; The second determining module is used to determine a second loss value based on the similarity between the second sample user encoding vector and the first sample product encoding vector; as well as The parameter adjustment module is used to adjust the network parameters of the dual-tower model according to the first loss value and the second loss value to obtain the trained dual-tower model.

10. A retrieval device, comprising: The acquisition module is used to acquire the target query information contained in the product search request in response to the product search request; The third encoding module is used to input the target query information into the user tower model in the dual-tower model and output the target query information encoding vector for the target query information, wherein the dual-tower model is trained using the training device described in claim 8; The query module is used to retrieve a preset product index based on the target query information encoding vector to obtain product retrieval results. The product index is obtained by preprocessing the description information of multiple candidate products in the product pool using a dual-tower model.

11. An electronic device, comprising: One or more processors; Memory, used to store one or more programs. Wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the method of any one of claims 1 to 8.

12. A computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the method of any one of claims 1 to 8.

13. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 8.