Training Method and Device for Item Retrieval Model
By splitting the item description text into fragments and training the model with query requests, the problem of high difficulty in learning the item retrieval model in the e-commerce platform is solved, and the accuracy and recall effect of item retrieval are improved.
Patent Information
- Application Number
- CN202410703966.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2044-05-31
AI Technical Summary
In the e-commerce scenario, the existing item retrieval model has a high learning difficulty due to the large and disordered length of the item title text, and the accuracy of recalling items is insufficient.
By splitting the item description text into multiple description fragments, generating training samples in combination with query requests, and model training is performed with the description fragment as the desired output, adjusting model parameters to reduce learning difficulty and improve recall accuracy.
Reduces the text length and disorder of the item description text, improves the accuracy of the item retrieval model, and ensures that the recalled items are more in line with user preferences.
Smart Images

Figure CN118585704B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, specifically to the field of e-commerce technology, and particularly to a method and device for training an item retrieval model, an item retrieval method and device, a computer-readable medium, an electronic device, and a computer program product. Background Art
[0002] In the e-commerce scenario, the core challenge of the retrieval task is how to quickly and accurately recall specific items from a vast number of candidate items. In the generative item retrieval method, the item retrieval model generates an item Title (title) according to the query request to recall the item, realizing end-to-end retrieval. However, since the Titles of items on e-commerce platforms are generally a stack of keywords, with large text lengths and being disordered, it causes difficulties for the item retrieval model to learn during the training process, and the accuracy of the recalled items is insufficient. Summary of the Invention
[0003] The embodiments of the present application propose a method and device for training an item retrieval model, an item retrieval method and device, a computer-readable medium, an electronic device, and a computer program product.
[0004] In a first aspect, the embodiments of the present application provide a method for training an item retrieval model, including: generating a training sample by combining multiple item description segments and a query request in an original training sample, where the multiple item description segments are generated according to the item description text corresponding to the query request in the original training sample; performing model training with the query request as the input and the multiple item description segments as the expected output to obtain the item retrieval model.
[0005] In some examples, before the above-mentioned generating a training sample by combining multiple item description segments and a query request in the original training sample, the method further includes: splitting the item description text to obtain multiple item description words; obtaining multiple item description segments according to the multiple item description words.
[0006] In some examples, the above-mentioned obtaining multiple item description segments according to the multiple item description words includes: for each original training sample in the original training sample set, sorting the multiple item description words corresponding to the item description text in the original training sample by using a preset sorting method; dividing the sorted multiple item description words into multiple item description segments.
[0007] In some examples, the above-mentioned model training with a query request as the input and multiple item description segments as the expected output includes: for each item description segment among the multiple item description segments, perform the following operations: use the query request as the input of the model to obtain an output text; calculate a first loss between the output text and this item description segment; combine the multiple first losses corresponding to the multiple item description segments, and adjust the parameters of the item retrieval model.
[0008] In some examples, the above-mentioned obtaining an item retrieval model by training a model with a query request as the input and multiple item description segments as the expected output includes: training a model with a query request as the input and multiple item description segments as the expected output to obtain a trained model; updating the parameters of the trained model through an adjustment sample representing the item preference information of the user to obtain an item retrieval model.
[0009] In some examples, the above-mentioned adjustment sample includes a segment adjustment sample representing the item preference information of the user at the item description segment level and a text adjustment sample representing the item preference information of the user at the item description text level, and the above-mentioned updating the parameters of the trained model through the adjustment sample representing the item preference information of the user includes: updating the parameters of the trained model through the segment adjustment sample and the text adjustment sample.
[0010] In some examples, the above-mentioned segment adjustment sample includes a query request, a first item description segment as a positive sample, and a second item description segment as a negative sample, and the above-mentioned updating the parameters of the trained model through the segment adjustment sample includes: using the query request in the segment adjustment sample as the input of the trained model and the currently updated model respectively, determining the cumulative probability of the currently trained model generating the first item description segment and the cumulative probability of generating the second item description segment, and determining the cumulative probability of the currently updated model generating the first item description segment and the cumulative probability of generating the second item description segment; determining a second loss according to the multiple cumulative probabilities; updating the parameters of the trained model according to the second loss.
[0011] In some examples, the above-mentioned text adjustment sample includes a query request, a first description text as a positive sample, and a second description text as a negative sample, and the above-mentioned updating the parameters of the trained model through the text adjustment sample includes: using the query request in the text adjustment sample as the input of the trained model, and using the first description text ranked ahead and the second description text ranked behind as the expected output of the trained model to update the parameters of the trained model.
[0012] Second aspect, an embodiment of the present application provides an item retrieval method, including: generating, by a pre-trained item retrieval model, multiple item description segments according to a query request, where the item retrieval model is trained by any implementation manner of the first aspect above; recalling a target item from an item set according to the multiple item description segments.
[0013] In some examples, the above-mentioned generating, by a pre-trained item retrieval model, multiple item description segments according to a query request includes: determining items included in the item set; inputting the query request and the item description text corresponding to the item into the item retrieval model to generate multiple item description segments.
[0014] Third aspect, an embodiment of the present application provides a training device for an item retrieval model, including: a first generation unit configured to generate a training sample by combining multiple item description segments and a query request in an original training sample, where the multiple item description segments are generated according to the item description text corresponding to the query request in the original training sample; a training unit configured to perform model training with the query request as the input and the multiple item description segments as the expected output to obtain an item retrieval model.
[0015] In some examples, the above-mentioned device further includes: a splitting unit configured to split the item description text to obtain multiple item description words; an obtaining unit configured to obtain multiple item description segments according to the multiple item description words.
[0016] In some examples, the above-mentioned obtaining unit is further configured to: for each original training sample in the original training sample set, sort the multiple item description words corresponding to the item description text in the original training sample by a preset sorting method; divide the sorted multiple item description words into multiple item description segments.
[0017] In some examples, the above-mentioned training unit is further configured to: for each item description segment in the multiple item description segments, perform the following operations: take the query request as the input of the model to obtain an output text; calculate a first loss between the output text and the item description segment; adjust the parameters of the item retrieval model by combining the multiple first losses corresponding to the multiple item description segments.
[0018] In some examples, the above-mentioned training unit is further configured to: perform model training with the query request as the input and the multiple item description segments as the expected output to obtain a trained model; update the parameters of the trained model through an adjustment sample representing the item preference information of the user to obtain an item retrieval model.
[0019] In some examples, the above adjustment samples include segment adjustment samples that represent the item preference information of the user at the level of item description segments and text adjustment samples that represent the item preference information of the user at the level of item description text, and the above training unit is further configured to: update the parameters of the trained model through the segment adjustment samples and the text adjustment samples.
[0020] In some examples, the above segment adjustment samples include a query request, a first item description segment as a positive sample, and a second item description segment as a negative sample, and the above training unit is further configured to: use the query requests in the segment adjustment samples as the inputs of the trained model and the currently updated model respectively, determine the cumulative probability of the trained model generating the first item description segment and the cumulative probability of generating the second item description segment, and determine the cumulative probability of the currently updated model generating the first item description segment and the cumulative probability of generating the second item description segment; determine a second loss according to the multiple cumulative probabilities; and update the parameters of the trained model according to the second loss.
[0021] In some examples, the above text adjustment samples include a query request, a first description text as a positive sample, and a second description text as a negative sample, and the above training unit is further configured to: use the query request in the text adjustment sample as the input of the trained model, and use the first description text ranked ahead and the second description text ranked behind as the expected outputs of the trained model to update the parameters of the trained model.
[0022] In a fourth aspect, an embodiment of the present application provides an item retrieval device, including: a second generation unit configured to generate multiple item description segments according to a query request through a pre-trained item retrieval model, where the category determination model is trained through any implementation manner of the above third aspect; a retrieval unit configured to recall a target item from an item set according to the multiple item description segments.
[0023] In some examples, the above second generation unit is further configured to: determine the items included in the item set; input the query request and the item description text corresponding to the item into the item retrieval model to generate multiple item description segments.
[0024] In a fifth aspect, an embodiment of the present application provides a computer-readable medium, on which a computer program is stored, where when the program is executed by a processor, the method described in any implementation manner of the first aspect and the second aspect is implemented.
[0025] In a sixth aspect, an embodiment of the present application provides an electronic device, including: one or more processors; a storage device on which one or more programs are stored, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner of the first aspect and the second aspect.
[0026] In a seventh aspect, an embodiment of the present application provides a computer program product, including: a computer program which, when executed by a processor, implements the method described in any implementation manner of the first aspect or the second aspect.
[0027] In the method and apparatus for training an item retrieval model provided in the embodiments of the present application, training samples are generated by combining multiple item description segments and query requests in the original training samples, where the multiple item description segments are generated according to the item description text corresponding to the query request in the original training samples; the model is trained with the query request as the input and the multiple item description segments as the expected output to obtain an item retrieval model. Thus, based on the item description segments, the text length and disorder degree of the item description text are reduced, the learning difficulty of the item retrieval model is reduced, which helps to improve the accuracy of the item retrieval model; the retrieval task of the generative item retrieval model is redefined, so that the item retrieval model no longer generates item description text based on the query request, but generates item description segments based on the query request, improving the accuracy of the items recalled by the item retrieval model. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Other features, objects, and advantages of the present application will become more apparent by reading the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0029] Figure 1 is an exemplary system architecture diagram to which an embodiment of the present application can be applied;
[0030] Figure 2 is a flowchart of an embodiment of the method for training an item retrieval model according to the present application;
[0031] Figure 3 is a schematic diagram of an application scenario of the method for training an item retrieval model according to this embodiment;
[0032] Figure 4 is a flowchart of another embodiment of the method for training an item retrieval model according to the present application;
[0033] Figure 5 is a flowchart of an embodiment of the item retrieval method according to the present application;
[0034] Figure 6 is a structural diagram of an embodiment of the apparatus for training an item retrieval model according to the present application;
[0035] Figure 7 is a structural diagram of an embodiment of the item retrieval apparatus according to the present application;
[0036] Figure 8It is a schematic structural diagram of a computer system suitable for implementing the embodiments of the present application. Detailed implementation manners
[0037] The present application will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only used to explain the related invention, rather than limiting the invention. Additionally, it should be noted that for the sake of description, only the parts related to the relevant invention are shown in the drawings.
[0038] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. The present application will be described in detail below with reference to the drawings and embodiments.
[0039] It should be noted that in the technical solutions of the present disclosure, in terms of the collection, gathering, updating, analysis, processing, use, transmission, storage, etc. of the user's personal information, they all comply with the provisions of relevant laws and regulations, are used for legal purposes, and do not violate public order and good customs. Necessary measures are taken for the user's personal information to prevent illegal access to the user's personal information data, and to safeguard the user's personal information security, network security, and national security.
[0040] Figure 1 An exemplary architecture 100 of a training method and device for an item retrieval model and an item retrieval method and device to which the present application can be applied is shown.
[0041] As Figure 1 shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The terminal devices 101, 102, 103 are communicatively connected to form a topology network, and the network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.
[0042] The terminal devices 101, 102, 103 can interact with the server 105 through the network 104 to receive or send data, etc. The terminal devices 101, 102, 103 can be hardware devices or software that support network connections for data interaction and data processing. When the terminal devices 101, 102, 103 are hardware, they can be various electronic devices that support network connections, information acquisition, interaction, display, processing, etc. functions, including but not limited to smartphones, in-vehicle computers, tablet computers, e-book readers, laptop portable computers, and desktop computers, etc. When the terminal devices 101, 102, 103 are software, they can be installed in the above-listed electronic devices. It can be implemented as, for example, multiple software or software modules for providing distributed services, or can also be implemented as a single software or software module. No specific limitation is made here.
[0043] Server 105 may be a server that provides various services. For example, it is a background processing server that generates training samples based on the original training samples provided by the terminal devices 101, 102, and 103, and trains an item retrieval model with the training samples. For another example, it is a background processing server that receives query requests from the terminal devices 101, 102, and 103 and recalls target items through a pre-trained item retrieval model. As an example, server 105 may be a cloud server.
[0044] It should be noted that the server may be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster composed of multiple servers or as a single server. When the server is software, it can be implemented as multiple software or software modules (such as software or software modules for providing distributed services), or as a single software or software module. Specific limitations are not made here.
[0045] It should also be noted that the training method of the item retrieval model and the item retrieval method provided by the embodiments of the present application can be executed by the server, or by the terminal device, or by the server and the terminal device in cooperation with each other. Correspondingly, each part (such as each unit) included in the training device of the item retrieval model and the item retrieval device can be all set in the server, or all set in the terminal device, or separately set in the server and the terminal device.
[0046] It should be understood that Figure 1 the numbers of the terminal devices, the network, and the server in
[0047] Continuing to refer to Figure 2 , a flowchart 200 of an embodiment of the training method of the item retrieval model is shown. Flowchart 200 includes the following steps:
[0048] Step 201, generate a training sample by combining multiple item description segments and a query request in the original training sample.
[0049] In this embodiment, the execution subject of the training method of the item retrieval model (such as Figure 1The terminal device or server in the example may obtain the original training sample remotely or locally through a wired network connection or a wireless network connection, and generate the training sample by combining the multiple item description segments and the query request in the original training sample. The multiple item description segments are generated according to the item description text corresponding to the query request in the original training sample.
[0050] The original training samples include query requests and item description texts. The item description texts are used to represent the description texts of the items that are expected to be recalled based on the query requests, such as the item titles in the item display pages of e-commerce platforms. Item titles are short texts that attract user attention and describe items.
[0051] It can be understood that the training process of the item retrieval model generally requires a large number of training samples, that is, a training sample set; thus, a large number of original training samples, that is, an original training sample set, are required in this embodiment.
[0052] For each original training sample in the original training sample set, the following operations are performed: multiple item description segments are generated based on the item description text in the original training sample; multiple item description segments are combined with the query request in the original training sample to obtain a training sample. Multiple training samples are combined to obtain a training sample set.
[0053] As an example, the execution subject may divide the item description text according to a preset text length range to obtain multiple item description segments. The length of the text in each item description segment is within the preset text length range. The preset text length range may be specifically set according to actual conditions to reduce the text length of the item description segment and allow the division process to have a certain degree of flexibility to ensure that the text in the item description segment exists in units of words.
[0054] As another example, the above-mentioned execution entity can perform natural language understanding on the item description text to determine multiple description dimensions of the item in the item description text; divide multiple words in the item description text into their respective description dimensions, and obtain multiple item description fragments corresponding to the multiple description dimensions.
[0055] In some implementations of this embodiment, before executing the above step 201, the above execution subject may further perform the following operations:
[0056] The first step is to split the item description text to obtain multiple item description words.
[0057] Taking the item description text as the item title of an item obtained in an e-commerce platform as an example, it is generally composed of a stack of item keywords. The above-mentioned execution entity can split the item description text and use the obtained multiple keywords as multiple item description words.
[0058] In the second step, multiple item description segments are obtained according to multiple item descriptors.
[0059] As an example, the above-mentioned execution entity can divide multiple item descriptors so that each item description segment obtained by the division includes a preset number of item descriptors.
[0060] As another example, the above-mentioned execution entity can divide multiple item descriptors based on the semantic relevance between the multiple item descriptors, so that the item descriptors included in each item description segment obtained by the division are semantically relevant.
[0061] In this implementation, by first determining multiple item descriptors in the item description text and then dividing the multiple item descriptors to obtain multiple item description segments, the text length and disorder degree of the item description segments are further reduced.
[0062] In some implementations of this embodiment, the above-mentioned execution entity can execute the second step in the following manner:
[0063] First, for each original training sample in the original training sample set, a preset sorting method is used to sort the multiple item descriptors corresponding to the item description text in the original training sample.
[0064] For example, the multiple item descriptors can be sorted according to the order of the letters of the item descriptors in the alphabet; for another example, the multiple item descriptors can be sorted according to the importance degree of the item descriptors.
[0065] Then, the sorted multiple item descriptors are divided into multiple item description segments.
[0066] In this implementation, the above-mentioned execution entity can sequentially connect the sorted multiple item descriptors to obtain a sorted description text; the sorted description text is divided to obtain multiple item description segments.
[0067] As an example, the above-mentioned execution entity can divide the sorted description text according to a preset text length range to obtain multiple item description segments.
[0068] In the original task Q2T (Query to Title) of the item retrieval model to generate the item title of an item according to a query request, due to the disorder of the item title, it is difficult for the model to learn and the hallucination is serious; moreover, the text length of the item title is relatively large, which increases the difficulty for the item retrieval model to generate a long text of the item title based on a short text of the query request.
[0069] In this implementation manner, the sorted item title Tittle is divided into multiple item description segments span. Here, the spans can overlap and can be naturally segmented, and then the Q2multi - spans task is constructed.
[0070] Among them, the original training samples of the Q2t task: <Query, title>
[0071] The training samples of the Q2multi - spans task: <Query, span1>, <Query, span2>, <Query, span3>.
[0072] In this implementation manner, based on the method of first sorting multiple item description words and then dividing the sorted multiple item description words, multiple item description segments are obtained, so that the description words in the multiple item description segments of all training samples in the training sample set have a consistent order, further reducing the disorder degree of the item description segments.
[0073] Step 202: Use the query request as the input and multiple item description segments as the expected output to train the model, and obtain an item retrieval model.
[0074] In this embodiment, the above - mentioned execution subject can use the query request as the input and multiple item description segments as the expected output to train the model, and obtain an item retrieval model.
[0075] As an example, the above - mentioned execution subject can iteratively execute the following training operations until a preset end condition is reached to obtain an item retrieval model: First, determine one or a batch of untrained training samples from the training sample set; then, input the query request in the training sample into the current model to obtain a predicted output; then, determine the loss between the predicted output and the multiple item description segments in the training sample, where the loss is used to represent the text similarity; finally, use the stochastic gradient descent algorithm to update the parameters of the current model according to the loss.
[0076] Among them, the preset end condition is, for example, that the training loss tends to converge, the number of training times exceeds a preset number threshold, or the training time exceeds a preset time threshold.
[0077] In some implementation manners of this embodiment, the above - mentioned execution subject can execute the above - mentioned step 202 in the following manner:
[0078] First, for each item description segment in the multiple item description segments, perform the following operations: First, use the query request as the input of the model to obtain an output text; then, calculate the first loss between the output text and this item description segment.
[0079] Among them, the first loss is, for example, cosine loss, KL - divergence loss, cross - entropy loss, etc.
[0080] In one implementation, the above-mentioned execution entity can calculate the first loss through the following formula:
[0081]
[0082] Among them, L sft represents the first loss, l represents the length of the item description segment, and p θ represents the item retrieval model, q represents the query request, and p θ (j|q, I<j) generally represents the conditional probability distribution under the given query request q and I<j. Among them, I<j represents all the single words of the elements before position j in the item description segment.
[0083] In this implementation, for multiple item description segments in the same training sample, the above-mentioned process of determining the first loss can be executed in parallel.
[0084] Then, combining the multiple first losses corresponding to the multiple item description segments, adjust the parameters of the item retrieval model.
[0085] As an example, the above-mentioned execution entity can sum up the multiple first losses corresponding to the multiple item description segments in the same training sample to obtain the total loss; adjust the parameters of the item retrieval model according to the total loss.
[0086] In this implementation, by combining the multiple first losses corresponding to the multiple item description segments and adjusting the parameters of the item retrieval model, while ensuring the accuracy of the item retrieval model, the model can perform diversity learning to output corresponding multiple item description segments according to the query request.
[0087] In some implementations of this embodiment, the above-mentioned execution entity can execute the above step 202 in the following manner:
[0088] The first step is to perform model training with the query request as the input and multiple item description segments as the expected output to obtain the trained model.
[0089] In this implementation, the above-mentioned execution entity can train the trained model by using the model training method described above.
[0090] For example, first, for each item description segment in the multiple item description segments, perform the following operations: use the query request as the input of the model to obtain the output text; calculate the first loss between the output text and this item description segment.
[0091] Then, combining the multiple first losses corresponding to the multiple item description segments, adjust the parameters of the initial item retrieval model to obtain the trained model.
[0092] In the second step, the parameters of the trained model are updated with the adjustment samples that represent the user's item preference information to obtain an item retrieval model.
[0093] For example, the adjustment samples include a query request and labels that represent the user's preference scores for multiple items obtained based on the query request; in a supervised training manner, the parameters of the trained model are updated with multiple adjustment samples to obtain an item retrieval model.
[0094] For another example, the adjustment samples include a query request, positive sample description text (after the user issues a query request, the user performs selection operations such as clicking on the item corresponding to the positive sample description text), and negative sample text (after the user issues a query request, the user does not perform selection operations such as clicking on the item corresponding to the negative sample description text).
[0095] In this implementation, based on the supervised training of the model, the parameters of the trained model are further updated with the adjustment samples that represent the user's item preference information, so that the item description fragments generated by the item retrieval model are more in line with the preference needs of humans.
[0096] In some implementations of this embodiment, the adjustment samples include fragment adjustment samples that represent the user's item preference information at the item description fragment level and text adjustment samples that represent the user's item preference information at the item description text level.
[0097] For example, in the fragment adjustment samples, there are a query request and multiple item description fragments with an order, and the order of the multiple item description fragments represents the user's item preference information at the item description fragment level.
[0098] In the text adjustment samples, there are a query request and multiple item description texts with an order, and the order of the multiple item description texts represents the user's item preference information at the item description text level. To avoid the disorder of the item description texts, the above-mentioned execution entity can adopt the method of determining the sorted description texts in the above embodiment to obtain the sorted description texts corresponding to each of the multiple item description texts in the text adjustment samples, so as to update the parameters of the trained model with the text adjustment samples including multiple sorted description texts.
[0099] In this implementation, the above-mentioned execution entity can execute the second step in the following manner: update the parameters of the trained model with the fragment adjustment samples and the text adjustment samples.
[0100] As an example, the above-mentioned execution entity can combine the fragment adjustment samples and the text adjustment samples to obtain an adjustment sample set; then, a machine learning algorithm is used to update the parameters of the trained model with the adjustment sample set.
[0101] As another example, the above-mentioned execution entity first updates the parameters of the trained model through the segment adjustment samples in the segment adjustment sample set; then updates the parameters of the trained model updated through the segment adjustment samples through the text adjustment samples in the text adjustment sample set.
[0102] In this implementation, combining the segment adjustment samples and the text adjustment samples enables the item recommendation model to fully learn the item preference information of users at different levels, improving the adaptability between the item retrieval model and users.
[0103] In some implementations of this embodiment, the segment adjustment samples include query requests, the first item description segment chosen spans y as the positive sample w and the second item description segment rejected spans y as the negative sample. l .
[0104] In this implementation, the above-mentioned execution entity can update the parameters of the trained model in the following manner:
[0105] First, using the query requests in the segment adjustment samples as the inputs of the trained model and the currently updated model respectively, determine the cumulative probability of the trained model generating the first item description segment and the cumulative probability of generating the second item description segment, and determine the cumulative probability of the currently updated model generating the first item description segment and the cumulative probability of generating the second item description segment.
[0106] Then, determine the second loss according to multiple cumulative probabilities.
[0107] As an example, the above-mentioned execution entity can determine the second loss according to the following formula:
[0108]
[0109] where L DPO (π θ ; π ref ) represents the second loss, π θ (y w |x), π θ (y l |x) respectively represent the cumulative probability of the trained model generating the first item description segment y w and the cumulative probability of generating the second item description segment y l , π ref (y w |x), π ref (y l |x) respectively represent the cumulative probability of the currently updated model generating the first item description segment y w and the cumulative probability of generating the second item description segment y lCumulative probability.
[0110] At the beginning, the trained model and the currently updated model are the same model, both being the trained model. As the training process of the trained model progresses with the snippet-adjusted samples, the currently updated model continuously updates its parameter weights, and the gap from the trained model becomes larger.
[0111] Finally, update the parameters of the trained model according to the second loss.
[0112] As an example, the above-mentioned execution entity can determine the update gradient according to the second loss, and use the stochastic gradient descent method to update the parameters of the trained model according to the update gradient.
[0113] It can be understood that in this implementation manner, the process of updating the parameters of the trained model based on the snippet-adjusted samples can be iteratively executed, so that the trained model can fully learn the user's item preference information.
[0114] In this implementation manner, a specific implementation manner for updating the parameters of the trained model based on the snippet-adjusted samples is provided, enabling the trained model to fully learn the user's item preference information at the item description snippet level.
[0115] In some implementation manners of this embodiment, the text-adjusted samples include a query request, a first description text as a positive sample, and a second description text as a negative sample.
[0116] In this implementation manner, the above-mentioned execution entity can update the parameters of the trained model in the following manner:
[0117] Use the query request in the text-adjusted sample as the input of the trained model, and use the first description text ranked in the front and the second description text ranked in the back as the expected output of the trained model to update the parameters of the trained model.
[0118] As an example, the above-mentioned execution entity can adopt a machine learning algorithm, use the query request in the text-adjusted sample as the input of the trained model, and use the first description text ranked in the front and the second description text ranked in the back as the expected output of the trained model to update the parameters of the trained model.
[0119] In this implementation manner, a specific implementation manner for updating the parameters of the trained model based on the text-adjusted samples is provided, enabling the trained model to fully learn the user's item preference information at the item description text level.
[0120] Continue to refer to Figure 3 , Figure 3 is a schematic diagram 300 of the application scenario of the training method of the item retrieval model according to this embodiment. In Figure 3In the application scenario, first, the server obtains the original training sample 301, which includes a query request 3011 and an item description text 3012. Then, multiple item description segments 3013 are generated based on the item description text 3012 in the original training sample 301. Then, a training sample 302 is generated by combining the multiple item description segments 3013 and the query request 3011 in the original training sample; finally, the item retrieval model 303 is obtained by training the model with the query request 3011 as the input and the multiple item description segments 3013 as the expected output.
[0121] The method provided by the above embodiment of the present application generates a training sample by combining multiple item description segments and the query request in the original training sample, where the multiple item description segments are generated based on the item description text corresponding to the query request in the original training sample; the item retrieval model is obtained by training the model with the query request as the input and the multiple item description segments as the expected output, thereby reducing the text length and disorder degree of the item description text based on the item description segments, reducing the learning difficulty of the item retrieval model, and helping to improve the accuracy of the item retrieval model; the retrieval task of the generative item retrieval model is redefined, so that the item retrieval model no longer generates the item description text based on the query request, but generates the item description segments based on the query request, improving the accuracy of the items recalled by the item retrieval model.
[0122] Continue to refer to Figure 4 , which shows a schematic flow 400 of another embodiment of the training method of the item retrieval model according to the present application, including the following steps:
[0123] Step 401, for each original training sample in the original training sample set, split the item description text in the original training sample to obtain multiple item description words.
[0124] Step 402, for each original training sample in the original training sample set, sort the multiple item description words corresponding to the item description text in the original training sample by using a preset sorting method.
[0125] Step 403, divide the sorted multiple item description words into multiple item description segments.
[0126] Step 404, combine the multiple item description segments and the query request in the original training sample to generate a training sample.
[0127] Step 405, for each item description segment in the multiple item description segments, perform the following operations: use the query request as the input of the model to obtain an output text; calculate the first loss between the output text and the item description segment.
[0128] Step 406: Combine multiple first losses corresponding to multiple item description segments for model training to obtain a trained model.
[0129] Step 407: Use the query requests in the segment adjustment samples as inputs to the trained model and the currently updated model respectively, determine the cumulative probabilities of the trained model generating the first item description segment and the second item description segment, and determine the cumulative probabilities of the currently updated model generating the first item description segment and the second item description segment.
[0130] Among them, the segment adjustment sample includes a query request, a first item description segment as a positive sample, and a second item description segment as a negative sample.
[0131] Step 408: Determine the second loss according to multiple cumulative probabilities.
[0132] Step 409: Update the parameters of the trained model according to the second loss.
[0133] Step 410: Use the query requests in the text adjustment samples as inputs to the trained model, and use the first description text ranked first and the second description text ranked second as the expected outputs of the trained model, and continue to update the parameters of the trained model to obtain an item retrieval model.
[0134] Among them, the text adjustment sample includes a query request, a first description text as a positive sample, and a second description text as a negative sample.
[0135] It can be seen from this embodiment that compared with Figure 2 the corresponding embodiment, the process 400 of the training method of the item retrieval model in this embodiment specifically describes the generation process of item description segments, the supervised learning process of the model, and the preference information learning process of the model, further improving the accuracy of the item retrieval model.
[0136] Continue to refer to Figure 5 , which shows the process 500 of an embodiment of the item retrieval method, including the following steps:
[0137] Step 501: Generate multiple item description segments according to the query request through a pre-trained item retrieval model.
[0138] In this embodiment, the execution subject of the item retrieval method (such as Figure 1 the terminal device or server in ) can generate multiple item description segments according to the query request through a pre-trained item retrieval model. Among them, the category determination model is trained by any implementation method in the above embodiments 200 and 400.
[0139] Step 502: Recall the target item from the item set according to multiple item description fragments.
[0140] In this embodiment, the above-mentioned execution entity can recall the target item from the item set according to multiple item description fragments.
[0141] As an example, the above-mentioned execution entity can splice the item description texts of the items in the item set corresponding to the e-commerce platform to construct an index. For each item description text in the index, determine whether it includes at least one of the multiple item description fragments, so as to recall the target item from the item set.
[0142] The above-mentioned execution entity can also sort the candidate items corresponding to the item description texts including at least one item description fragment according to the number and importance of the item description fragments generated by the item retrieval model in the item description texts of the items in the item set, and use the multiple candidate items ranked at the front as the target items.
[0143] In the method provided by the above-mentioned embodiment of the present application, the item retrieval model no longer generates the item description text based on the query request, but generates the item description fragments based on the query request, which improves the accuracy of the items recalled by the item retrieval model.
[0144] In some implementation manners of this embodiment, the above-mentioned execution entity can execute the above-mentioned step 501 in the following manner:
[0145] First, determine the items included in the item set; then, input the query request and the item description text corresponding to the item into the item retrieval model to generate multiple item description fragments.
[0146] As an example, in the process of generating multiple item description fragments according to the query request by the item retrieval model, the item description text of the items in the item set is used as a constraint condition to avoid including the item description fragments of items not included in the item set in the multiple item description fragments generated by the item retrieval model.
[0147] Specifically, in the process of generating multiple item description fragments according to the query request by the item retrieval model, pruning is performed in advance on the item description fragments of items not in the item set. Here, the constrained beam-search method is used. When generating the next token, its prefix word will be retrieved in the index. If it is not in the index, then this branch will terminate generation, reducing the generation scope and improving the inference speed.
[0148] Continue to refer to Figure 6, as an implementation of the methods shown in the above figures, the present application provides an embodiment of a training device for an item retrieval model. This device embodiment corresponds to Figure 2 the method embodiment shown, and this device can be specifically applied to various electronic devices.
[0149] As shown in Figure 6 , the training device 600 for the item retrieval model includes: a first generation unit 601 configured to generate a training sample by combining multiple item description segments and a query request in an original training sample, where the multiple item description segments are generated according to the item description text corresponding to the query request in the original training sample; a training unit 602 configured to perform model training with the query request as the input and the multiple item description segments as the expected output to obtain the item retrieval model.
[0150] In some implementation manners of this embodiment, the above device further includes: a splitting unit (not shown in the figure) configured to split the item description text to obtain multiple item description words; an obtaining unit (not shown in the figure) configured to obtain multiple item description segments according to the multiple item description words.
[0151] In some implementation manners of this embodiment, the above obtaining unit is further configured to: for each original training sample in the original training sample set, sort the multiple item description words corresponding to the item description text in this original training sample by using a preset sorting method; divide the sorted multiple item description words into multiple item description segments.
[0152] In some implementation manners of this embodiment, the above training unit 602 is further configured to: for each item description segment in the multiple item description segments, perform the following operations: use the query request as the input of the model to obtain an output text; calculate a first loss between the output text and this item description segment; combine the multiple first losses corresponding to the multiple item description segments to adjust the parameters of the item retrieval model.
[0153] In some implementation manners of this embodiment, the above training unit 602 is further configured to: perform model training with the query request as the input and the multiple item description segments as the expected output to obtain a trained model; update the parameters of the trained model through an adjustment sample representing the item preference information of the user to obtain the item retrieval model.
[0154] In some implementation manners of this embodiment, the above adjustment sample includes a segment adjustment sample representing the item preference information of the user at the item description segment level and a text adjustment sample representing the item preference information of the user at the item description text level, and the above training unit 602 is further configured to: update the parameters of the trained model through the segment adjustment sample and the text adjustment sample.
[0155] In some implementation manners of this embodiment, the above fragment adjustment sample includes a query request, a first item description fragment as a positive sample, and a second item description fragment as a negative sample, and the above training unit 602 is further configured to: use the query requests in the fragment adjustment sample as the inputs of the trained model and the currently updated model respectively, determine the cumulative probability of the trained model generating the first item description fragment and the cumulative probability of generating the second item description fragment, and determine the cumulative probability of the currently updated model generating the first item description fragment and the cumulative probability of generating the second item description fragment; determine a second loss according to multiple cumulative probabilities; and update the parameters of the trained model according to the second loss.
[0156] In some implementation manners of this embodiment, the above text adjustment sample includes a query request, a first description text as a positive sample, and a second description text as a negative sample, and the above training unit 602 is further configured to: use the query request in the text adjustment sample as the input of the trained model, and use the first description text ranked in the front and the second description text ranked in the back as the expected outputs of the trained model to update the parameters of the trained model.
[0157] In this embodiment, the first generation unit in the training device of the item retrieval model combines multiple item description fragments and the query request in the original training sample to generate a training sample, where the multiple item description fragments are generated according to the item description text corresponding to the query request in the original training sample; the training unit uses the query request as the input and the multiple item description fragments as the expected outputs for model training to obtain an item retrieval model, thereby reducing the text length and disorder degree of the item description text based on the item description fragments, reducing the learning difficulty of the item retrieval model, and helping to improve the accuracy of the item retrieval model; and redefines the retrieval task of the generative item retrieval model, so that the item retrieval model no longer generates an item description text based on the query request, but generates an item description fragment based on the query request, improving the accuracy of the items recalled by the item retrieval model.
[0158] Continue to refer to Figure 7 As an implementation of the methods shown in the above figures, this application provides an embodiment of an item retrieval device. This device embodiment corresponds to Figure 2 the method embodiment shown, and this device can be specifically applied to various electronic devices.
[0159] As Figure 7As shown, the item retrieval device 700 includes: a second generation unit 701 configured to generate a plurality of item description segments according to a query request through a pre-trained item retrieval model, where the category determination model is trained by any implementation manner in the above-mentioned embodiment 600; a retrieval unit 702 configured to recall a target item from an item set according to the plurality of item description segments
[0160] In some implementation manners of this embodiment, the above-mentioned second generation unit 701 is further configured to: determine the items included in the item set; input the query request and the item description text corresponding to the item into the item retrieval model to generate a plurality of item description segments.
[0161] In the device provided in the above embodiment of the present application, the item retrieval model no longer generates an item description text based on the query request, but generates an item description segment based on the query request, improving the accuracy of the items recalled by the item retrieval model.
[0162] Next, refer to Figure 8 , which shows a schematic structural diagram of a computer system 800 suitable for use in implementing the devices (such as Figure 1 the devices 101, 102, 103, 105 shown) of the embodiments of the present application. Figure 8 The devices shown are only examples and should not impose any limitations on the functions and usage scopes of the embodiments of the present application.
[0163] As Figure 8 shown, the computer system 800 includes a processor (such as a CPU, central processing unit) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage section 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The processor 801, the ROM 802, and the RAM 803 are connected to each other through a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0164] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. as well as a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is mounted on the drive 810 as needed so that a computer program read therefrom is installed into the storage section 808 as needed.
[0165] Specifically, according to an embodiment of the present application, the processes described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product including a computer program carried on a computer-readable medium, the computer program including program code for performing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 809, and / or installed from the removable medium 811. When the computer program is executed by the processor 801, the above-described functions defined in the method of the present application are performed.
[0166] It should be noted that the computer-readable medium of the present application can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of a computer-readable storage medium can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. In the present application, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, and this computer-readable medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0167] Computer program code for performing the operations of the present application can be written in one or more programming languages or combinations thereof. The programming languages include object-oriented programming languages - such as Java, Smalltalk, C++, and also include conventional procedural programming languages - such as the "C" language or similar programming languages. The program code can be executed entirely on the client computer, partially on the client computer, executed as an independent software package, partially on the client computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the client computer through any type of network - including a local area network (LAN) or a wide area network (WAN) - or, it can be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).
[0168] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of devices, methods, and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a part of code that contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as combinations of blocks in the block diagram and / or flowchart, may be implemented by a dedicated hardware-based system that performs the specified functions or operations, or may be implemented by a combination of dedicated hardware and computer instructions.
[0169] The units involved in the embodiments described in the present application can be implemented in software or in hardware. The described units can also be provided in a processor. For example, it can be described as: a processor including a first generation unit and a training unit. Another example can be described as: a processor including a second generation unit and a retrieval unit. Among them, the names of these units do not constitute a limitation on the units themselves in some cases. For example, the first generation unit can also be described as "a unit that combines multiple item description segments and a query request in an original training sample to generate a training sample, where the multiple item description segments are generated according to the item description text corresponding to the query request in the original training sample".
[0170] On the other hand, the present application also provides a computer-readable medium, which may be included in the device described in the above embodiments; or may exist separately without being assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by the device, the computer device is caused to: combine multiple item description segments and a query request in an original training sample to generate a training sample, where the multiple item description segments are generated according to the item description text corresponding to the query request in the original training sample; perform model training with the query request as the input and the multiple item description segments as the expected output to obtain an item retrieval model. It also causes the computer device to: generate multiple item description segments according to the query request through the pre-trained item retrieval model; recall target items from the item set according to the multiple item description segments.
[0171] The above description is only a preferred embodiment of the present application and an explanation of the applied technical principles. Those skilled in the art should understand that the scope of the invention involved in the present application is not limited to the technical solutions formed by the specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above inventive concept. For example, the technical solutions formed by mutually replacing the above features with the technical features (but not limited to) disclosed in the present application that have similar functions.
Claims
1. A method for training an item retrieval model, comprising: Splitting the item description text in the original training sample to obtain multiple item description words; Sorting the multiple item description words in a preset sorting manner; Dividing the sorted multiple item description words into multiple item description segments; Combining the multiple item description segments and the query request in the original training sample to generate a training sample; Training a model with the query request as the input and the multiple item description segments as the expected output to obtain an item retrieval model, including: Training a model with the query request as the input and the multiple item description segments as the expected output to obtain a trained model; Updating the parameters of the trained model through a segment adjustment sample representing the item preference information of the user at the item description segment level and a text adjustment sample representing the item preference information of the user at the item description text level to obtain the item retrieval model.
2. The method according to claim 1, wherein The training the model with the query request as the input and the multiple item description segments as the expected output includes: For each item description segment in the multiple item description segments, perform the following operations: taking the query request as the input of the model to obtain an output text; calculating a first loss between the output text and this item description segment; Combining the multiple first losses corresponding to the multiple item description segments to adjust the parameters of the item retrieval model.
3. The method according to claim 1, wherein, The segment adjustment sample includes a query request, a first item description segment as a positive sample, and a second item description segment as a negative sample, and Updating the parameters of the trained model through the segment adjustment sample includes: Taking the query request in the segment adjustment sample as the input of the trained model and the currently updated model respectively, determining the cumulative probability of the trained model generating the first item description segment and the cumulative probability of generating the second item description segment, and determining the cumulative probability of the currently updated model generating the first item description segment and the cumulative probability of generating the second item description segment; Determining a second loss according to the multiple cumulative probabilities; Updating the parameters of the trained model according to the second loss.
4. The method according to claim 1, wherein The text adjustment sample includes a query request, a first description text as a positive sample, and a second description text as a negative sample, and Updating the parameters of the trained model through the text adjustment sample includes: Taking the query request in the text adjustment sample as the input of the trained model, and taking the first description text sorted in the front and the second description text sorted in the back as the expected output of the trained model to update the parameters of the trained model.
5. An item retrieval method, including Using a pre-trained item retrieval model, multiple item description segments are generated according to a query request, where The item retrieval model is trained by the method according to any one of claims 1-4; Recalling target items from the item set according to the multiple item description segments.
6. The method according to claim 5, wherein, The generating, by the pre-trained item retrieval model, multiple item description segments according to a query request includes: Determining the items included in the item set; Input the query request and the item description text corresponding to the item into the item retrieval model to generate the multiple item description segments.
7. A training device for an item retrieval model, comprising: A splitting unit configured to split the item description text in the original training sample to obtain multiple item description words; An obtaining unit configured to sort the multiple item description words in a preset sorting manner; and divide the sorted multiple item description words into multiple item description segments; A first generating unit configured to generate a training sample by combining the multiple item description segments and the query request in the original training sample, wherein the multiple item description segments are generated according to the item description text corresponding to the query request in the original training sample; A training unit configured to perform model training with the query request as the input and the multiple item description segments as the expected output to obtain an item retrieval model, including: performing model training with the query request as the input and the multiple item description segments as the expected output to obtain a trained model; and updating the parameters of the trained model through a segment adjustment sample representing the item preference information of the user at the item description segment level and a text adjustment sample representing the item preference information of the user at the item description text level to obtain the item retrieval model.
8. An item retrieval device, comprising A second generation unit, configured to generate a plurality of item description segments according to a query request through a pre-trained item retrieval model, wherein, The item retrieval model is trained by the method according to any one of claims 1-4; A retrieval unit configured to recall a target item from an item set according to the multiple item description segments.
9. A computer-readable medium having a computer program stored thereon, wherein, The program, when executed by a processor, implements the method according to any one of claims 1-6.
10. An electronic device, comprising: One or more processors; A storage device having stored thereon one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1-6.
11. A computer program product, comprising: A computer program, which, when executed by a processor, implements the method according to any one of claims 1-6.