Article retrieval method, model training method, electronic device, and storage medium
By constructing a codebook to compress item feature vectors into identifier sequences and adding them to the retrieval model vocabulary, the problem of inaccurate retrieval results in e-commerce scenarios is solved, enabling faster and more accurate item retrieval and improving user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 阿里巴巴(中国)网络技术有限公司
- Filing Date
- 2026-02-24
- Publication Date
- 2026-06-05
AI Technical Summary
Existing item retrieval methods do not yield accurate results in e-commerce scenarios.
Construct a pre-trained codebook, compress the feature vectors of different items into a sequence of item identifiers, and add these identifiers to the vocabulary of the retrieval model. This enables the retrieval model to recognize and use these identifiers, and to quickly and accurately output the matching sequence of item identifiers based on the learned knowledge.
By compressing item features into a sequence of identifiers, the computational load for matching and sorting is reduced, improving retrieval speed and accuracy, and providing a faster and more accurate user experience.
Smart Images

Figure CN122152903A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method for retrieving items, a model training method, an electronic device, and a storage medium. Background Technology
[0002] In item retrieval and recommendation scenarios, such as e-commerce, when a user enters item query information to search for related items, the system needs to retrieve relevant items from a large number of items based on the item query information.
[0003] Such searches often employ generative retrieval (GR) methods. In generative retrieval, the retrieval model transforms the input item query information into a sequence of item identifiers. Then, it matches the items corresponding to this sequence of item identifiers as the search results.
[0004] However, the accuracy of current search results is not high. Summary of the Invention
[0005] This application provides a method for retrieving items, a model training method, an electronic device, and a storage medium to improve the accuracy of retrieval results.
[0006] In a first aspect, embodiments of this application provide a method for retrieving items, the method comprising: Received the target item query information; The target item query information is input into the trained retrieval model to obtain a sequence of target item identifiers corresponding to the target item query information; wherein, the vocabulary of the retrieval module retrieval model includes each item identifier contained in the codebook, and the codebook is trained to compress the item feature vectors of different items into a sequence of item identifiers; Identify the item corresponding to the target item identifier sequence and output the item.
[0007] Secondly, embodiments of this application provide a model training method, the method comprising: Obtain the first training sample of the retrieval model to be trained. The first training sample includes the description information of the first sample item and the item identifier reference sequence of the first sample item. The item identifier reference sequence of the first sample item is determined based on a trained codebook. The codebook is trained to compress the item feature vectors of different items into an item identifier sequence. The description information of the first sample item is input into the retrieval model to be trained to obtain the item identifier prediction sequence of the first sample item. The first loss function value is determined based on the predicted sequence of item identifiers and the reference sequence of item identifiers of the first sample item; The parameters of the retrieval model to be trained are adjusted based on the first loss function value; Obtain a second training sample for the retrieval model to be trained. The second training sample includes query information of the second sample item and a reference sequence of item identifiers of the second sample item. The reference sequence of item identifiers of the second sample item is determined based on the codebook. The query information of the second sample item is input into the retrieval model to be trained to obtain the item identifier prediction sequence of the second sample item; The second loss function value is determined based on the predicted sequence of item identifiers and the reference sequence of item identifiers for the second sample item; The parameters of the retrieval model trained in the first stage are adjusted based on the value of the second loss function to obtain the trained retrieval model.
[0008] Thirdly, embodiments of this application provide an item retrieval device, the device comprising: The receiving module is used to receive query information for the target item; The item retrieval module is used to input the target item query information into a trained retrieval model to obtain a sequence of target item identifiers corresponding to the target item query information; wherein, the vocabulary of the retrieval model of the retrieval module includes each item identifier contained in the codebook, and the codebook is trained to compress the item feature vectors of different items into a sequence of item identifiers; the module determines the item corresponding to the target item identifier sequence and outputs the item.
[0009] Fourthly, embodiments of this application provide an item retrieval device, the device comprising: The first-stage training module is used to acquire the first training samples of the retrieval model to be trained. The first training samples include the description information of the first sample item and the item identifier reference sequence of the first sample item. The item identifier reference sequence of the first sample item is determined based on a trained codebook, which is trained to compress the item feature vectors of different items into an item identifier sequence. The description information of the first sample item is input into the retrieval model to be trained to obtain the item identifier prediction sequence of the first sample item. Based on the item identifier prediction sequence and the item identifier reference sequence of the first sample item, a first loss function value is determined. The parameters of the retrieval model to be trained are adjusted based on the first loss function value. The second-stage training module is used to obtain a second training sample for the retrieval model to be trained. The second training sample includes query information of the second sample item and a reference sequence of item identifiers for the second sample item. The reference sequence of item identifiers for the second sample item is determined based on the codebook. The query information of the second sample item is input into the retrieval model to be trained to obtain a predicted sequence of item identifiers for the second sample item. A second loss function value is determined based on the predicted sequence of item identifiers for the second sample item and the reference sequence of item identifiers. The parameters of the retrieval model after the first stage of training are adjusted based on the second loss function value to obtain the trained retrieval model.
[0010] Fifthly, embodiments of this application provide an electronic device, including: a memory, a processor, and a communication interface; wherein, the memory stores executable code, and when the executable code is executed by the processor, the processor performs the item retrieval method as described in the first aspect.
[0011] In a sixth aspect, embodiments of this application provide an electronic device, including: a memory, a processor, and a communication interface; wherein, the memory stores executable code, and when the executable code is executed by the processor, the processor executes the model training method as described in the second aspect.
[0012] In a seventh aspect, embodiments of this application provide a non-transitory machine-readable storage medium storing executable code, which, when executed by a processor of an electronic device, enables the processor to at least implement the item retrieval method as described in the first aspect.
[0013] Eighthly, embodiments of this application provide a non-transitory machine-readable storage medium storing executable code, which, when executed by a processor of an electronic device, enables the processor to at least implement the model training method as described in the second aspect.
[0014] Ninthly, embodiments of this application provide a computer program product, the computer program product including a computer program, which, when executed by a processor, is capable of implementing the item retrieval method as described in the first aspect.
[0015] In a tenth aspect, embodiments of this application provide a computer program product, the computer program product including a computer program, which, when executed by a processor, can implement the model training method as described in the second aspect.
[0016] In the item retrieval scheme provided in this application embodiment, a pre-trained codebook is constructed. This codebook is used to compress the item feature vectors of different items into a sequence of item identifiers. Subsequently, the item identifiers contained in the codebook are added to the vocabulary of the retrieval model, enabling the retrieval model to recognize and use these identifiers when processing queries. When the system receives item query information, the retrieval model, based on its learned knowledge, quickly and accurately outputs a sequence of item identifiers matching the query information, and then returns the corresponding item accordingly. Furthermore, since the item features are compressed into smaller identifier sequences, compared to directly processing high-dimensional feature vectors, the computational load of subsequent matching and sorting is reduced, improving retrieval speed. In addition, the codebook, during training, has learned to map semantically similar items to similar item identifiers. Integrating these identifiers into the vocabulary of the retrieval model allows the retrieval model to understand the relationship between these structured item identifier sequences and items, thereby improving retrieval accuracy and speed, and responding to user queries faster and more accurately. This contributes to providing a smoother and more reliable user experience. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 A schematic diagram of the hardware execution environment for a model optimization method provided in an embodiment of this application; Figure 2 This is an application diagram of a cloud computing environment provided in an embodiment of this application; Figure 3 A flowchart illustrating an article retrieval method provided in this application embodiment; Figure 4 A flowchart illustrating a model training method provided in this application embodiment; Figure 5 A flowchart illustrating another model training method provided in this application embodiment; Figure 6 A schematic diagram illustrating the training principle of an identifier conversion model provided in an embodiment of this application; Figure 7 A schematic diagram of the structure of an article retrieval device provided in an embodiment of this application; Figure 8 This is a schematic diagram of the structure of an electronic device provided in this embodiment. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. In addition, the timing of the steps in the following method embodiments is only an example and not a strict limitation.
[0020] It should be noted that, in the cases involving user information in the embodiments of this application, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse. In addition, the various models involved in this application (including but not limited to large language models or other models) comply with relevant laws and standards.
[0021] First, the terms or concepts involved in the embodiments of this application will be explained: Retrieval models refer to models trained based on deep learning and artificial intelligence technologies, such as language models (LM), image recognition models, or multimodal models (MM) based on artificial intelligence. They have great generalization and intelligence capabilities, thus enabling them to perform a variety of tasks, such as language understanding, generation, and image recognition.
[0022] Generative retrieval is a retrieval paradigm that directly maps user query information into semantic identifiers (IDs) through a retrieval model. These semantic IDs are not randomly generated but are sequences of semantically meaningful tokens generated based on the user query information; they can also be called identifier sequences. Generative retrieval does not rely on traditional retrieval methods based on similarity calculations.
[0023] Residual Quantization (RQ) is a hierarchical quantization method that approximates the original embedding layer by layer through a multi-level codebook, with each layer processing the residual of the previous layer.
[0024] Codebook: A set of learnable discrete vectors used to embed and compress feature vectors into a discrete sequence of identifiers.
[0025] Contrastive learning is an unsupervised learning method that aims to learn data representations by maximizing the similarity between relevant samples and minimizing the similarity between irrelevant samples.
[0026] In item retrieval and recommendation scenarios, when a user enters item query information to search for related items, the system needs to retrieve relevant items from a large number of items based on the query information. Taking an e-commerce scenario as an example, suppose a user enters "men's pure cotton short-sleeved shirt" in the search box, the system will perform a search based on this and display the matched items in the item display area below the search box.
[0027] In this type of retrieval process, generative retrieval methods are typically used. The retrieval model transforms the input item query information into a sequence of item identifiers. Then, the items corresponding to this item identifier sequence are output as the retrieval results. However, the accuracy of the retrieval results is not high.
[0028] Based on the above, this application provides an item retrieval method. A pre-trained codebook is pre-built to compress the feature vectors of different items into a sequence of item identifiers. Subsequently, the item identifiers contained in the codebook are added to the vocabulary of the retrieval model, enabling the retrieval model to recognize and use these identifiers when processing queries. When the system receives item query information, the retrieval model, based on its learned knowledge, quickly and accurately outputs a sequence of item identifiers matching the query information, and then returns the corresponding item. Furthermore, since the item features are compressed into smaller identifier sequences, compared to directly processing high-dimensional feature vectors, the computational load for subsequent matching and sorting is reduced, improving retrieval speed. In addition, the codebook, during training, has learned to map semantically similar items to similar item identifiers. Integrating these identifiers into the vocabulary of the retrieval model allows the retrieval model to understand the relationship between these structured item identifier sequences and items, thereby improving retrieval accuracy and speed, and responding to user queries faster and more accurately. This contributes to providing a smoother and more reliable user experience.
[0029] The model optimization scheme provided in the embodiments of this application will be described below.
[0030] Figure 1 A schematic diagram of the hardware execution environment for a model optimization method provided in this application embodiment is shown below. Figure 1 As shown, the hardware execution environment for this model optimization method can consist of a client device 101 and a server device 102, with the client device 101 and server device 102 communicating with each other. The server device 102 can be a cloud server from a cloud service provider. The client device 101 can be a laptop, tablet, PC, robot, etc.
[0031] In an optional embodiment, the execution process of the above-described item retrieval method may be as follows: Client device 101 receives input target item query information. Further, client device 101 may receive target item query information input by the user in an item query interface. For example, if an e-commerce application (APP) is running on client device 101, the user can input target item query information in the search box of the item query interface and trigger a query. Client device 101 sends the target item query information to server device 102. Server device 102 inputs the target item query information into a trained retrieval model to obtain a sequence of target item identifiers corresponding to the target item query information. The vocabulary of the retrieval model includes item identifiers contained in a codebook, which is trained to compress the item feature vectors of different items into a sequence of item identifiers. Server device 102 determines the item corresponding to the target item identifier sequence and feeds back the determined item to client device 101. Further, client device 101 may display the determined item in the item query interface, or jump from the item query interface to the search results display interface to display the determined item.
[0032] The retrieval model can be set in the server device 102 or in other devices that are communicatively connected to the server device 102. Based on this, the server device 102 can obtain the corresponding item identifier sequence through the retrieval model when responding to item query information.
[0033] In practical applications, the aforementioned server-side device 102 can be a cloud server maintained by a cloud service provider—referred to as a computing node. In cases such as... Figure 2 The cloud computing environment shown may include several distributed deployments. Figure 2 The diagram illustrates compute nodes (201-1, 201-2, ...), each possessing processing resources such as computing and storage. In a cloud computing environment, multiple compute nodes can be organized to provide a specific service; conversely, a single compute node can provide one or more services. Figure 2 The diagram illustrates services A, B, C, and D. In a cloud computing environment, these services can be provided via external service interfaces, which client device 101 calls to use the corresponding services. Service interfaces can take the form of Software Development Kits (SDKs) or Application Programming Interfaces (APIs).
[0034] The services described above are deployed using various virtualization technologies supported by cloud computing environments, such as virtual machine-based and container-based virtualization technologies. Taking container-based virtualization technology as an example, several containers corresponding to a service can be assembled into a container group (pod). For example... Figure 2 The illustrated service B can be configured with one or more pods, and each pod can include a proxy and one or more containers. The one or more containers in the pod are used to handle requests related to one or more corresponding functions of the service, and the proxy in the pod is used to control network functions related to the service, such as routing and load balancing.
[0035] During operation, executing a request from client device 101 may require invoking one or more services in the cloud computing environment, and executing one or more functions of one service may require invoking one or more functions of another service. For example... Figure 2 As shown, after receiving a request from client device 101, service A can call service B. Service B can request service D to perform one or more functions. In this embodiment of the application, cloud services for model optimization can be deployed in one or more computing nodes.
[0036] The execution process of the item retrieval method provided in this application embodiment is described in detail below with reference to the accompanying drawings. Optionally, the item retrieval method can be executed by devices such as servers and computers, for example, by computing nodes in the aforementioned cloud computing environment.
[0037] Figure 3 A flowchart of an article retrieval method provided in this application embodiment is shown below. Figure 3 As shown, the method includes the following steps: 301. Received the target item query information.
[0038] 302. Input the target item query information into the trained retrieval model to obtain the target item identifier sequence corresponding to the target item query information; wherein, the vocabulary of the retrieval model includes the item identifiers contained in the codebook, and the codebook is trained to compress the item feature vectors of different items into the item identifier sequence.
[0039] 303. Determine the item corresponding to the target item identifier sequence and output the item.
[0040] In this embodiment, the codebook is trained in advance. The codebook is used to compress the feature vectors of different items into a sequence of item identifiers; that is, the feature vectors of items can be compressed into the corresponding sequences of item identifiers through the codebook.
[0041] Among them, the item feature vector refers to the semantic representation in vector form obtained after extracting features from item description information or item query information.
[0042] Item description information is used to indicate the attributes of an item, and is typically described in natural language. Furthermore, item description information may include at least one of the following: title name, category name, brand name, color, size, material, and target user. Item description information can be represented as a sequence of terms based on its attribute information: ,in, This represents the total number of lexical units for an item. For example, if the item description is "red long-sleeved men's shirt", the corresponding lexical sequence would be {red, long-sleeved, men, shirt}.
[0043] Item search information refers to descriptive information used to retrieve a specific item, typically expressed in natural language. Similar to item descriptions, item search information includes item attribute information. Furthermore, item search information may include at least one of the following: category name, brand name, color, size, material, and target users. For example, a target item search could be a sentence like "Please help me find shoes for my child to wear in spring," or a phrase like "fleece-lined jeans for autumn and winter."
[0044] The codebook contains different identifier vectors, which can be called item identifiers, or the indices of the identifier vectors can be called item identifiers. An item identifier sequence refers to a sequence of item identifiers arranged in a predetermined order. For example, an item identifier sequence can be represented as follows: ,in, It is the length of the item identifier sequence, that is, the number of identifiers in the item identifier sequence, and each identifier This can also be called a token. It is evident that the item identifier sequence is a discrete sequence of a predetermined length. Therefore, the process of converting it into an item identifier sequence can also be called a compression process. Furthermore, the codebook can have a multi-layered structure, with each codebook layer containing a predetermined number of item identifiers. The item identifier sequence is the item identifiers corresponding to each item in the order of the layers. Typically, each codebook layer corresponds to one item identifier sequence. For example, suppose the codebook has four codebook layers, a, b, c, and d. Then the length of the item identifier sequence generated from the codebook is 4. Assume the generated item identifier sequence is of the form: [<a-1>, <b-0>, <c-6>, <d-2>], where <a-1> is the first item identifier in the item identifier sequence, representing the vector with index 1 in codebook layer a.
[0045] The codebook is used to convert item feature vectors into corresponding item identifier sequences. Identical items produce identical item identifier sequences, and more similar items should produce more similar item identifier sequences. This allows for rapid retrieval of matching items from a large dataset based on the item identifier sequences. Therefore, the codebook is pre-trained, adjusting the identifier vectors it contains. A trained codebook can better compress item feature vectors into corresponding item identifier sequences.
[0046] In this embodiment, the retrieval model can be a model built using a deep learning architecture (Transformer) based on an attention mechanism. The retrieval model includes a vocabulary, which typically contains natural language words. However, the retrieval model cannot understand the item identifiers contained in the codebook. Therefore, the item identifiers from the codebook can be added to the vocabulary of the retrieval model to enable it to understand the item identifiers. Furthermore, the training process of the retrieval model is based on a pre-trained codebook. For example, item feature vectors and corresponding item identifier sequences are obtained from the pre-trained codebook, and the retrieval model is trained using the correspondence between item feature vectors and item identifier sequences.
[0047] In practical applications, after receiving the target item query information, the target item query information is input into the trained retrieval model to obtain the target item identifier sequence corresponding to the target item query information.
[0048] The target item query information can be entered by the user or sent by other devices. This application does not limit the method of receiving the target item query information.
[0049] Next, identify the item that corresponds to the target item identifier sequence and output the item.
[0050] In this context, the item corresponding to the target item identifier sequence refers to the item that matches the target item query information, i.e., the item that conforms to the target item query information. For example, if the target item query information is "red and white striped woolen hat", then all matching red and white striped woolen hats will be considered as the corresponding items.
[0051] Additionally, if no item matches the target item query information, a notification can be output stating that no matching item was found.
[0052] Furthermore, when the number of matching items found is less than the preset number (i.e., there are few matching items), the item identifier sequence corresponding to the target item query information can be partially removed (e.g., the last item identifier) before searching. The resulting items are then used as the items corresponding to the target item identifier sequence and output. For example, suppose the item identifier sequence corresponding to the target item query information is "1,2,3,4". When matching items based on "1,2,3,4", 3 items are matched, which is less than the current preset number of 8. The last item identifier in the target item identifier sequence can be ignored before matching, meaning that items that satisfy the first 3 item identifiers "1,2,3" are used as the items corresponding to the target item identifier sequence and output.
[0053] The quantity of the item may be multiple. If there are multiple items, they can be sorted and output. Furthermore, the sorting of multiple items can be done randomly or according to a preset rule. The following examples illustrate two methods of sorting according to preset rules. One possible implementation is to sort the multiple items based on their respective query hit counts, from highest to lowest. Another possible implementation is to sort based on the target item identifier sequence corresponding to each item. If there are identical target item identifier sequences, the items corresponding to the same target item identifier sequence can be randomly sorted.
[0054] In summary, the scheme provided in the embodiments of this application pre-constructs a pre-trained codebook, which is used to compress the feature vectors of different items into a sequence of item identifiers. Subsequently, the item identifiers contained in the codebook are stored and added to the vocabulary of the retrieval model, enabling the retrieval model to recognize and process these identifiers during the inference phase. When the system receives a query for a target item, the retrieval model, based on its learned semantic and compression relationship knowledge, can quickly and accurately generate a sequence of target item identifiers matching the query information, and then output the corresponding item accordingly. Furthermore, since the item features are compressed into a smaller sequence of identifiers, compared to directly processing high-dimensional feature vectors, the computational load for subsequent matching and sorting is reduced, improving retrieval speed. In addition, the codebook, during training, has learned to map semantically similar items to similar item identifiers. By integrating these identifiers into the vocabulary of the retrieval model, the retrieval model can understand the relationship between these structured item identifier sequences and items, thereby improving retrieval accuracy and speed, and responding to user queries faster and more accurately. This contributes to providing a smoother and more reliable user experience. It can quickly process item query requests and output items with high accuracy, improving the user experience.
[0055] In some scenarios, the retrieval models mentioned above are trained. The following details the execution process of a retrieval model training method provided in this embodiment. Optionally, the model training method provided in this embodiment can be combined with... Figure 3 The illustrated embodiments can be executed in combination, or they can be executed independently. If combined with... Figure 3 When the illustrated embodiments are executed in combination, they can be performed before steps 301-303. If executed separately, they can be performed by devices such as servers or computers.
[0056] In one possible implementation, a reference sequence of item identifiers corresponding to item query information can be obtained from a pre-trained codebook. The retrieval model to be trained is then trained using the item query information and its corresponding reference sequence of item identifiers, so that the retrieval model learns the correspondence between the item query information and the item identifier sequence, thus obtaining a trained retrieval model.
[0057] In another possible implementation, the retrieval model can be trained in two stages. The first stage aims to familiarize the retrieval model with the correspondence between item descriptions and item identifier sequences in the codebook. The second stage, similar to the first possible implementation, uses the already trained codebook to obtain item query information and its corresponding item identifier reference sequences to train the retrieval model. The following example... Figure 4 The illustrated embodiments will be described in detail.
[0058] Figure 4 A flowchart of a model training method provided in an embodiment of this application is shown below. Figure 4 As shown, the method includes the following steps: 401. Obtain the first training sample of the retrieval model to be trained. The first training sample includes the description information of the first sample item and the item identifier reference sequence of the first sample item. The item identifier reference sequence of the first sample item is determined based on the trained codebook. The codebook is trained to compress the item feature vectors of different items into the item identifier sequence.
[0059] 402. Input the description information of the first sample item into the retrieval model to be trained to obtain the predicted sequence of item identifiers for the first sample item.
[0060] 403. Determine the first loss function value based on the predicted sequence of item identifiers and the reference sequence of item identifiers for the first sample item.
[0061] 404. Adjust the parameters of the retrieval model to be trained based on the value of the first loss function.
[0062] 405. Obtain the second training sample of the retrieval model to be trained. The second training sample includes the query information of the second sample item and the item identifier reference sequence of the second sample item. The item identifier reference sequence of the second sample item is determined based on the codebook.
[0063] 406. Input the query information of the second sample item into the retrieval model to be trained to obtain the predicted sequence of item identifiers for the second sample item.
[0064] 407. Determine the value of the second loss function based on the predicted sequence of item identifiers and the reference sequence of item identifiers for the second sample items.
[0065] 408. Adjust the parameters of the retrieval model trained in the first stage according to the value of the second loss function to obtain the trained retrieval model.
[0066] In practical applications, a two-stage training approach can be used to train the retrieval model. The process of each stage of training is described below.
[0067] In the first stage of training, the first training sample is obtained. The first training sample includes the description information of the first sample item and a reference sequence of item identifiers for the first sample item. Based on the already trained codebook, the description information of the first sample item can be compressed into the reference sequence of item identifiers for the first sample item. This codebook is similar to the codebook described in the previous embodiments and will not be repeated here. The reference sequence of item identifiers for the first sample item obtained through the codebook can be considered as the labeled data during the training process, thus enabling the training of the retrieval model to be trained based on the first training sample.
[0068] During training, the description information of the first sample item is input into the retrieval model to obtain the predicted sequence of item identifiers for the first sample item.
[0069] Optionally, the vocabulary of the retrieval model includes the item identifiers contained in the codebook.
[0070] The training objective of the first stage is to ensure that the predicted item identifier sequence of the first sample item, obtained by converting the description information of the first sample item into a reference item identifier sequence obtained by converting the codebook, is consistent with the predicted item identifier sequence of the first sample item. Therefore, the first loss function value can be determined based on the predicted item identifier sequence and the reference item identifier sequence. The parameters of the retrieval model to be trained are then adjusted based on the first loss function value to complete the first stage of training.
[0071] Furthermore, the first-stage training process can adopt a batch training approach, that is, the retrieval model is trained in multiple batches using the first training samples.
[0072] In one possible embodiment, the first loss function may be a supervised fine-tuning (SFT) loss function.
[0073] Furthermore, the value of the first loss function can be determined using the following formula (1): Formula (1) in, It is the first loss function, and it is the negative log-likelihood loss function in supervised fine-tuning; It is the first item in the item identifier reference sequence. Item identifier; It is the first item in the predicted sequence of identifiers. The item identifiers are the contents generated before the t-th item identifier; T is the length of the item identifier reference sequence, that is, the total number of item identifiers in the item identifier reference sequence; This is the description information of the first sample item; This indicates that the retrieval model predicts the order of items in the first sample sequence based on the description information of the first sample item and the prefix being the item identifier. In the case of the item identifier, the item identifier prediction sequence is the first... The item identifier and the item identifier reference sequence. The probability that two items have the same identifier.
[0074] In the second stage of training, a second training sample is first acquired. This second training sample includes query information for the second sample item and a reference sequence of item identifiers for the second sample item. Based on the already trained codebook, the query information for the second sample item can be compressed into a reference sequence of item identifiers for the second sample item. This codebook is similar to the codebook described in the previous embodiment and will not be repeated here. The reference sequence of item identifiers for the second sample item obtained through the codebook can be considered as labeled data during the training process, thus enabling the training of the retrieval model to be trained based on the second training sample.
[0075] During training, the query information of the second sample item is input into the retrieval model to obtain the predicted sequence of item identifiers for the second sample item.
[0076] The training objective of the second stage is to ensure that the predicted sequence of item identifiers for the second sample item, obtained by the retrieval model from the query information of the second sample item, matches the reference sequence of item identifiers for the second sample item obtained from the codebook. Therefore, the value of the second loss function can be determined based on the predicted and reference sequences of the item identifiers for the second sample item. The parameters of the retrieval model after the first stage of training are then adjusted based on the second loss function value to complete the second stage of training and obtain the trained retrieval model.
[0077] Furthermore, the second-stage training process can adopt a batch training approach, that is, the retrieval model can be trained in multiple batches using the second training samples.
[0078] In one possible embodiment, the second loss function may be a supervised fine-tuning loss function.
[0079] Furthermore, the value of the second loss function can be determined using the following formula (2): Formula (2) in, It is the second loss function, which is the negative log-likelihood loss function in supervised fine-tuning; It is the first item in the item identifier reference sequence. Item identifier; It is the first item in the predicted sequence of identifiers. The item identifiers are the contents generated before the t-th item identifier; T is the length of the item identifier reference sequence, that is, the total number of item identifiers in the item identifier reference sequence; This is the query information for the second sample item; This indicates that the retrieval model predicts the order of items in the sequence where the input is the query information of the second sample item and the prefix is the item identifier. In the case of the item identifier, the item identifier prediction sequence is the first... The item identifier and the item identifier reference sequence. The probability that two items have the same identifier.
[0080] Furthermore, the first sample item and the second sample item can be completely identical, partially identical, or completely different; this application does not impose any restrictions on this. It is evident that if the first sample item and the second sample item are identical, then their corresponding item identifier reference sequences are the same.
[0081] In this embodiment, since the item identifiers contained in the codebook are unknown to the retrieval model to be trained, direct end-to-end training makes it difficult to establish an effective mapping between query intent and item identifiers. Therefore, a two-stage progressive training approach is adopted: In the first stage, item description information is used as input to train the retrieval model to generate corresponding item identifier sequences. Under rich semantic supervision, the retrieval model initially establishes a stable correspondence between each item identifier and item semantics. In the second stage, item query information is used as input to continue training the retrieval model to generate corresponding item identifier sequences. Since the model has already learned the semantic meaning of the identifiers in the first stage, this stage can more efficiently align the user's query intent with the item identifiers, achieving a transfer from semantic understanding to intent matching. This allows the retrieval model to establish a connection between query intent and each item identifier. Through this phased training approach, the retrieval model not only avoids the training instability problem caused by the lack of semantic visibility of identifiers, but also achieves semantic reshaping at the lexical level. That is, it endows originally meaningless identifiers with interpretable and generalizable semantic representations within the retrieval model, thereby improving the accuracy and robustness of retrieval.
[0082] In some scenarios, the codebook mentioned above is obtained from a trained identifier conversion model. The following specific embodiment describes the process of training the identifier conversion model. Optionally, the training method of the retrieval model provided in this embodiment can be integrated with... Figure 3 and / or Figure 4 The illustrated embodiments can be executed in combination, or they can be executed independently. If combined with... Figure 3 If the illustrated embodiment is executed in conjunction with other methods, it can be performed before steps 301-303. If combined with… Figure 4 When the illustrated embodiments are executed in combination, they can be performed before steps 401-408. If executed separately, they can be performed by devices such as servers or computers.
[0083] Figure 5 A flowchart of another model training method provided in the embodiments of this application is shown below. Figure 5 As shown, the method includes the following steps: 501. Obtain the third training sample of the identifier conversion model to be trained. The third training sample includes the item description information of the third sample item.
[0084] 502. Obtain the initial item feature vector corresponding to the item description information of the third sample item through the feature extraction module in the identifier conversion model.
[0085] 503. Input the initial item feature vector of the third sample item into the residual quantization module of the codebook to be trained in the identifier conversion model to obtain the item identifier sequence of the third sample item. The item identifier sequence of the third sample item corresponds to multiple codebook layers in the codebook.
[0086] 504. Input the item identifier sequence of the third sample item into the feature decoding module in the identifier conversion model to obtain the reconstructed item feature vector of the third sample item.
[0087] 505. Determine the residual quantization loss function value based on the reconstructed item feature vector, the initial item feature vector, and the item identifier sequence of the third sample item.
[0088] 506. Adjust the parameters of the identifier conversion model based on the residual quantization loss function value.
[0089] In this embodiment, the third sample item may be completely identical, partially identical, or completely different from the first or second sample item mentioned in the above embodiments; this application does not limit this. In practical applications, the first, second, and third sample items may all be identical.
[0090] In this embodiment, the identifier conversion model includes a codebook. During the training of the identifier conversion model, the codebook is also being trained. That is, when the identifier conversion model is trained, the codebook is also trained.
[0091] In training the identifier conversion model, a third training sample, including item description information of a third sample item, is first obtained. The identifier conversion model is then trained using this third training sample.
[0092] The identifier conversion model consists of a feature extraction module, a residual quantization module, and a feature decoding module connected sequentially. The feature extraction module extracts features from the input item description or query information to obtain the corresponding initial item feature vector. This module is connected to the residual quantization module. The residual quantization calculation in the residual quantization module is based on a codebook; therefore, the residual quantization module contains a codebook, and the identifier vectors in the codebook are continuously optimized during training. The initial item feature vector obtained from the feature extraction module is input to the residual quantization module to obtain the corresponding item identifier sequence. The item identifier sequence is then input to the feature decoding module to obtain the corresponding reconstructed item feature vector.
[0093] When training the identifier conversion model using the third training sample, the item description information of the third sample item is input into the identifier conversion model. Therefore, based on the structure of the identifier conversion model described above, the processing steps in the identifier conversion model are as follows: The initial item feature vector corresponding to the item description information of the third sample item is obtained through the feature extraction module. The initial item feature vector of the third sample item is input into the residual quantization module to obtain the item identifier sequence of the third sample item. The item identifier sequence of the third sample item is input into the feature decoding module in the identifier conversion model to obtain the reconstructed item feature vector of the third sample item.
[0094] In one possible embodiment, the feature extraction module includes an embedding module and an encoding module. Accordingly, in step 502, the embedding module obtains a first item feature vector corresponding to the item description information of the third sample item. The first item feature vector is input into the encoding module to obtain a second item feature vector corresponding to the third sample item, and this second item feature vector is used as the initial item feature vector corresponding to the item description information of the third sample item.
[0095] Furthermore, the encoding module and the residual quantization module can be a residual quantization-based variational autoencoder (RQ-VAE).
[0096] In practical applications, a two-stage training paradigm is often adopted, where the embedding module is trained first, followed by the RQ-VAE part. However, the bias generated in the embedding module cannot be corrected in the second stage of training, resulting in error accumulation and ultimately leading to a decline in the retrieval performance of the retrieval model.
[0097] In some embodiments, the residual quantization loss function value is determined based on the reconstruction loss function value and the codebook commitment loss function value. Specifically, the reconstruction loss function value is determined based on the reconstructed item feature vector of the third sample item and the initial item feature vector. The codebook commitment loss function value is determined based on the item identifier sequence of the third sample item.
[0098] For example, Figure 6 This is a schematic diagram illustrating the training principle of an identifier conversion model provided in an embodiment of this application. Figure 6 In this process, the product description information (Product Into) of the third sample item is input into the embedding module (EmbeddingModel), and then into the encoding module (DNN Encoder) to obtain the initial item feature vector of the third sample item. . Figure 6 The codebook contains Each codebook layer, among which... The codebook layers are designated as the first codebook layer (codebook layer 0), the second codebook layer (codebook layer 1), ..., the Lth codebook layer (codebook layer L-1). Each codebook layer contains K identifier vectors. It is the first In the codebook layer, the first A single identifier vector. (For) By including Residual quantization is performed on the codebooks of each codebook layer, where... It also represents the length of the item identifier sequence. The residual quantization process can be represented by the following formula (3): Formula (3) in, From the first The index of the identifier vector selected in each codebook layer It is the first A set of identifier vectors in each codebook layer; It is the first In the codebook layer, the first One identifier vector; It is the first The residuals generated by the layer; It is the first The residuals generated by the layer; The Euclidean norm is used to measure the distance between vectors. Indicates that the determination makes smallest That is, in each codebook layer, the identifier vector with the smallest distance to the residual of the previous layer is selected. In the initial step, let... = After residual quantization, the identifier vector index sequence is obtained. and identifier vector sequence The sequence of identifier vector indices is typically used as the sequence of item identifiers. Alternatively, the sequence of identifier vectors can also be used as the sequence of item identifiers.
[0099] Next, the identifier vector sequence The input is fed into the feature decoding module (DNN Decoder) to obtain the reconstructed item feature vector of the third sample item. .
[0100] Furthermore, the reconstruction loss function value can be determined using the following formula (4). : Formula (4) Furthermore, the codebook commitment loss function value can be determined using the following formula (5). : Formula (5) in, This indicates that the gradient operation has been stopped. It is a hyperparameter used to balance the intensity relationship between the optimization of the embedding module and the encoding module.
[0101] In this embodiment, the identifier conversion model is trained as a whole using a third training sample, i.e., the embedding module and the RQ-VAE part are trained together. The residual quantization loss function value is determined based on the reconstructed item feature vector, the initial item feature vector, and the item identifier sequence from the third sample item. The parameters of the identifier conversion model are adjusted based on the residual quantization loss function value. The training objective is to ensure that the reconstructed item feature vector is consistent with the initial item feature vector, and to minimize the loss of the item identifier sequence obtained from the codebook. The constraint of reconstruction error prompts the model to more accurately retain the key semantic information of the items, improving the quality of feature reconstruction. Furthermore, explicit optimization of the quantization loss guides the identifiers in the codebook to represent item features more efficiently and compactly, enhancing the expressive power and generalization of discrete identifiers. The discrete identifier sequence provides a more reliable foundation for subsequent retrieval models, improving retrieval accuracy.
[0102] In some embodiments, the identifier conversion model can also be trained using a contrastive learning approach. The process of training the identifier conversion model using a contrastive learning approach is described in detail below.
[0103] The query feature vector corresponding to the query information of the third sample item is obtained through the feature extraction module in the identifier conversion model.
[0104] Based on the query feature vector of the third sample item, the initial item feature vector, and the initial item feature vector of the fourth sample item, the contrastive learning loss function value is determined. The fourth sample item is a sample item in the training sample set whose difference from the third sample item meets the set conditions. The initial item feature vector of the fourth sample item is obtained based on the feature extraction module. The initial item feature vector of the fourth sample item is used as the negative sample corresponding to the query feature vector of the third sample item, and the initial item feature vector of the third sample item is used as the positive sample corresponding to the query feature vector of the third sample item.
[0105] Accordingly, step 506 is implemented by adjusting the parameters of the identifier conversion model based on the residual quantization loss function value and the contrastive learning loss function value.
[0106] In contrastive learning, positive and negative samples are required to learn based on similarity. When training the identifier conversion model, the positive and negative sample items corresponding to the third sample item are needed for comparative learning. The aforementioned third training sample also includes the item query information for the third sample item. The corresponding positive and negative sample items (fourth sample items) of the third sample item are then obtained. Training is performed based on the similarity between the initial item feature vector of the third sample item and the initial item feature vectors of the positive and negative sample items.
[0107] Following on from the examples above, please continue reading. Figure 6 The item query information of the third sample item is input into the embedding model to obtain the query feature vector. .
[0108] Optionally, the fourth sample item can be another item from the same batch as the third sample item. Further, the fourth sample item can be obtained from the third training sample, excluding the third sample item and similar sample items.
[0109] Furthermore, during the comparative learning training process, similar sample items of the third sample item can be obtained as positive samples, and sample items of different classes of the third sample item can be obtained as negative samples, thereby enabling the model to perform comparative learning.
[0110] Accordingly, the contrastive learning loss function value is determined as follows: based on the query feature vector of the third sample item, the initial item feature vector, the initial item feature vectors of multiple similar sample items, and the initial item feature vector of the fourth sample item, the contrastive learning loss function value is determined, and the initial item feature vectors of multiple similar sample items are used as positive samples of the query feature vector of the third sample item.
[0111] Furthermore, multiple similar sample items can be obtained from a third training sample.
[0112] In one possible embodiment, the contrastive learning loss function value can be the Information Noise Contrastive Estimation (InfoNCE) loss function value.
[0113] Furthermore, the contrastive learning loss function value can be calculated using the following formula (6): Formula (6) in, It is the value of the contrastive learning loss function; It is the temperature coefficient; It is the item query vector of the third sample item; This represents the initial item feature vector of the positive sample item corresponding to the third sample item. It is the initial item feature vector corresponding to the negative sample item (fourth sample item) of the third sample item; s(⋅) represents the similarity score, for example, cosine similarity can be used.
[0114] In one possible embodiment, the contrastive learning loss function value can also be calculated based on the item query vector of the third sample item and the reconstructed item feature vectors of the positive and negative sample items of the third sample item. This contrastive learning loss function value can be an InfoNCE loss function value.
[0115] Furthermore, in formula (6), the corresponding This represents the reconstructed item feature vector of the positive sample item corresponding to the third sample item. It is the reconstructed item feature vector corresponding to the negative sample item (fourth sample item) of the third sample item.
[0116] In this embodiment, by using the initial item feature vector and / or reconstructed item feature vector as positive and negative samples for comparative learning of the item query vector, the distance between the query vector and the truly relevant item features can be effectively reduced, while the distance between it and irrelevant item features can be increased. This enhances the robustness of the alignment between item query information and item description information, enabling the model to more accurately capture the semantic essence of items during implicit query understanding and improving the model's generalization ability.
[0117] In some embodiments, items of the same type often need to be converted into similar item identifier sequences. This requires training an identifier conversion model to convert items of the same type into similar initial item feature vectors. Therefore, in this embodiment, the identifier conversion model is also trained using semantic loss between similar items. The process of training the identifier conversion model using semantic loss between similar items is described in detail below.
[0118] Identify the cluster of similar items for the third sample item.
[0119] The feature extraction module obtains the initial item feature vectors of multiple similar sample items in the same product cluster.
[0120] The semantic loss function value is determined based on the initial item feature vectors of multiple similar sample items and the reference item feature vector of the third sample item.
[0121] Accordingly, in step 506, the parameters of the identifier conversion model are adjusted based on the semantic loss function value, the residual quantization loss function value, and the contrastive learning loss function value.
[0122] Furthermore, multiple similar sample items can be all sample items in the obtained cluster of similar items, or only a portion of the sample items in the obtained cluster of similar items. For example, m sample items can be obtained through random sampling, and the semantic features of the m sample items can be extracted to obtain the initial item feature vector of similar sample items. Obtain the mean of the initial item feature vectors of similar sample items. This process can be expressed as the following formula (7): Formula (7) The semantic loss function value is used to train the consistency between the initial item feature vectors of the third sample item and its class sample items.
[0123] Furthermore, the semantic loss function value can be calculated using the mean squared error (MSE) loss function. Semantic loss function value It can be expressed as the following formula (8): Formula (8) in, It is the initial item feature vector of the third sample item; It is the mean of the initial item feature vectors of the same type of sample items of the third sample item.
[0124] Following on from the examples above, please continue reading. Figure 6 The item description information of similar sample items is input into the embedding model, and then into the DNN encoder to obtain the initial item feature vectors of similar sample items of the third sample item. From these, m initial item feature vectors of similar sample items are obtained, and the mean of the initial item feature vectors of similar sample items of the third sample item is calculated. .based on and get .
[0125] This embodiment constrains semantic consistency among similar sample items, preventing similar items from being mapped to item identifiers with different semantics, and ensuring that similar items are mapped to semantically similar or consistent item identifier sequences. This effectively reduces category confusion caused by representational ambiguity, thereby improving the model's accuracy and robustness in retrieval and recommendation tasks.
[0126] In some embodiments, before training the identifier conversion model described above, it is necessary to initialize the codebook in the identifier conversion model, that is, to assign initial values to the codebook.
[0127] Following on from the examples above, please continue reading. Figure 6The codebook contains a first codebook layer (Codebook1), a second codebook layer (Codebook2), ..., an Lth codebook layer (Codebook L). Each codebook layer contains K identifier vectors. The codebook initialization process involves assigning initial values to the K identifier vectors contained in each codebook layer.
[0128] In the codebook initialization process of the identifier conversion model, initialization can be performed using preset initialization values or random initialization values. Alternatively, the codebook can be initialized using clustering. The process of initializing the codebook using clustering is described below: During clustering, multiple item descriptions can be obtained from the training sample set. Initial item feature vectors for multiple sample items are obtained through a feature extraction module. These initial item feature vectors are then clustered to obtain multiple initial clusters. The number of clusters corresponds to the number of item identifiers in each codebook layer; that is, each cluster corresponds to one identifier vector in the first codebook layer. Next, based on the initial item feature vectors contained in each of the initial clusters, the cluster center feature vectors of the initial clusters are determined to initialize the item identifiers in the first codebook layer. In other words, the cluster center feature vector of each cluster is determined as the initial value of the identifier vector in the first codebook layer. This completes the initialization of the first codebook layer. The iterative process continues based on the difference, layer by layer, until the last codebook layer is initialized. The iterative execution process is as follows: determine the difference between the initial item feature vectors of multiple sample items and the cluster center feature vectors of the clusters to which each sample item belongs in the i-th codebook layer; where i ≥ 1. Clustering is performed on the differences to obtain multiple updated clusters. Based on the initial item feature vectors contained in each of the updated clusters, the cluster center feature vectors of the updated clusters are determined to initialize the item identifiers contained in the (i+1)th codebook layer. The clustering process during initialization is similar to the process of obtaining the item identifier sequence described above, and is also an iterative process based on residuals.
[0129] Clustering effectively reduces the number of iterations during model training, enabling faster model convergence and improving training efficiency and robustness.
[0130] Figure 7 This is a schematic diagram of the structure of a model optimization device provided in an embodiment of this application, as shown below. Figure 7 As shown, the device includes: Receiving module 11 is used to receive the target item query information; The retrieval module 12 is used to input the target item query information into the trained retrieval model to obtain the target item identifier sequence corresponding to the target item query information; wherein, the vocabulary of the retrieval model includes the item identifiers contained in the codebook, and the codebook is trained to compress the item feature vectors of different items into the item identifier sequence; the item corresponding to the target item identifier sequence is determined and the item is output.
[0131] In one possible embodiment, the device further includes: The first-stage training module of the retrieval model is used to obtain the first training samples of the retrieval model to be trained. The first training samples include the description information of the first sample item and the reference sequence of the item identifier of the first sample item. The reference sequence of the item identifier of the first sample item is determined based on the codebook. The description information of the first sample item is input into the retrieval model to be trained to obtain the predicted sequence of the item identifier of the first sample item. The first loss function value is determined based on the predicted sequence of the item identifier of the first sample item and the reference sequence of the item identifier. The parameters of the retrieval model to be trained are adjusted based on the first loss function value.
[0132] In one possible embodiment, the device further includes: The second-stage training module of the retrieval model is used to obtain the second training samples of the retrieval model to be trained. The second training samples include query information of the second sample items and reference sequences of item identifiers of the second sample items. The reference sequences of item identifiers of the second sample items are determined based on the codebook. The query information of the second sample items is input into the retrieval model to be trained to obtain the predicted sequence of item identifiers of the second sample items. The second loss function value is determined based on the predicted sequence of item identifiers of the second sample items and the reference sequence of item identifiers. The parameters of the retrieval model after the first stage of training are adjusted based on the second loss function value to obtain the trained retrieval model.
[0133] In one possible embodiment, the device further includes: The identifier conversion training module is used to obtain the third training sample of the identifier conversion model to be trained. The third training sample includes the item description information of the third sample item. The feature extraction module in the identifier conversion model obtains the initial item feature vector corresponding to the item description information of the third sample item. The initial item feature vector of the third sample item is input into the residual quantization module of the identifier conversion model, which contains the codebook to be trained, to obtain the item identifier sequence of the third sample item. The item identifier sequence of the third sample item corresponds to multiple codebook layers in the codebook. The item identifier sequence of the third sample item is input into the feature decoding module of the identifier conversion model to obtain the reconstructed item feature vector of the third sample item. Based on the reconstructed item feature vector, the initial item feature vector, and the item identifier sequence of the third sample item, the residual quantization loss function value is determined. Based on the residual quantization loss function value, the parameters of the identifier conversion model are adjusted.
[0134] In one possible embodiment, the identifier conversion training module is specifically used to: determine the reconstruction loss function value based on the reconstructed item feature vector of the third sample item and the initial item feature vector; determine the codebook commitment loss function value based on the item identifier sequence of the third sample item; and determine the residual quantization loss function value based on the reconstruction loss function value and the codebook commitment loss function value.
[0135] In one possible embodiment, the third training sample further includes query information of the third sample item; the identifier conversion training module is specifically used to: obtain the query feature vector corresponding to the query information of the third sample item through the feature extraction module in the identifier conversion model; determine the contrastive learning loss function value based on the query feature vector of the third sample item, the initial item feature vector, and the initial item feature vector of the fourth sample item, wherein the fourth sample item is a sample item in the training sample set whose difference from the third sample item meets the set conditions, the initial item feature vector of the fourth sample item is obtained based on the feature extraction module, the initial item feature vector of the fourth sample item is used as the negative sample corresponding to the query feature vector of the third sample item, and the initial item feature vector of the third sample item is used as the positive sample corresponding to the query feature vector of the third sample item; and adjust the parameters of the identifier conversion model based on the residual quantization loss function value and the contrastive learning loss function value.
[0136] In one possible embodiment, the identifier conversion training module is specifically used to: determine the same category of items for the third sample item; obtain initial item feature vectors of multiple similar sample items in the same category of items through the feature extraction module; determine the semantic loss function value based on the initial item feature vectors of multiple similar sample items and the reference item feature vector of the third sample item; and adjust the parameters of the identifier conversion model based on the semantic loss function value, the residual quantization loss function value, and the contrastive learning loss function value.
[0137] In one possible embodiment, the identifier conversion training module is specifically used to: determine the contrastive learning loss function value based on the query feature vector of the third sample item, the initial item feature vector, the initial item feature vectors of multiple similar sample items, and the initial item feature vector of the fourth sample item, and use the initial item feature vectors of multiple similar sample items as positive samples of the query feature vector of the third sample item.
[0138] In one possible embodiment, the identifier conversion training module is further configured to: obtain initial item feature vectors of multiple sample items in the training sample set through the feature extraction module; perform clustering processing on the initial item feature vectors of multiple sample items to obtain initial multiple clusters, the number of multiple clusters corresponding to the number of item identifiers contained in each codebook layer in the codebook; determine the cluster center feature vectors of the initial multiple clusters based on the initial item feature vectors contained in each of the initial multiple clusters to initialize the item identifiers contained in the first codebook layer of the codebook; iteratively execute the following process until the last codebook layer is initialized: determine the difference between the initial item feature vectors of multiple sample items and the cluster center feature vectors of the clusters to which the multiple sample items belong in the i-th codebook layer; where i≥1; perform clustering processing on the difference to obtain updated multiple clusters; determine the updated cluster center feature vectors of the updated multiple clusters based on the initial item feature vectors contained in each of the updated multiple clusters to initialize the item identifiers contained in the (i+1)-th codebook layer of the codebook.
[0139] In one possible embodiment, the feature extraction module includes an embedding module and an encoding module. The identifier conversion training module is specifically used to: obtain a first item feature vector corresponding to the item description information of the third sample item through the embedding module; input the first item feature vector into the encoding module to obtain a second item feature vector corresponding to the third sample item; and use the second item feature vector as the initial item feature vector corresponding to the item description information of the third sample item.
[0140] Figure 7 The apparatus shown can perform the steps in the model optimization method in the foregoing embodiments. For detailed execution process and technical effects, please refer to the description in the foregoing embodiments, which will not be repeated here.
[0141] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, such as... Figure 8 As shown, in practice, this electronic device includes a memory 21 and a processor 22.
[0142] Memory 21 is used to store computer programs and can be configured to store various other data to support operation on the electronic device. Examples of this data include instructions for any application or method used to operate on the electronic device, data structures, contact data, phone book data, messages, pictures, videos, etc.
[0143] The processor 22, coupled to the memory 21, is used to execute the computer program in the memory 21 to implement the method provided in the foregoing embodiments.
[0144] Furthermore, such as Figure 8 As shown, the electronic device also includes other components such as a communication component 23, a display 24, a power supply component 25, and an audio component 26. Figure 8 The diagram only shows some components and does not mean that the electronic device includes only these components. Figure 8 The components shown are as follows. The electronic device in this embodiment can be a terminal device such as a desktop computer, laptop computer, smartphone, or IoT device, or a server device such as a conventional server, cloud server, or server array.
[0145] The aforementioned memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random-Access Memory (SRAM), Electrically Erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0146] The aforementioned communication component is configured to facilitate wired or wireless communication between the device containing the communication component and other devices. The device containing the communication component can access wireless networks based on communication standards, such as 2G, 3G, 4G / LTE, 5G, or combinations thereof. In one exemplary embodiment, the communication component receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel.
[0147] The aforementioned display includes a screen, which may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a Touch Panel, the screen can be implemented as a touchscreen to receive input signals from the user. The Touch Panel includes one or more touch sensors to sense touches, swipes, and gestures on the Touch Panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation.
[0148] The aforementioned power supply components provide power to various components within the device in which they reside. These power supply components may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to the device in which they reside.
[0149] The aforementioned audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC) configured to receive external audio signals when the device containing the audio component is in an operating mode, such as call mode, recording mode, or voice recognition mode. The received audio signals can be further stored in memory or transmitted via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.
[0150] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to implement the steps in the above-described method embodiments. The computer-readable storage medium includes volatile or non-volatile components, or a combination thereof, and can be removable or non-removable. Examples of computer-readable storage media include, but are not limited to, phase-change random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random-access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), flash memory or other memory technologies, CD-ROM, digital video disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium.
[0151] Accordingly, this application also provides a computer program product, which includes a computer program or instructions that, when executed by a processor, cause the processor to implement the steps in the above method embodiments. It should be understood that each step or combination of steps in the above method flow can be implemented by the computer program or instructions. Furthermore, these computer programs or instructions can be applied to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device, enabling the processor of the general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to function as an apparatus for implementing the corresponding functions in the above method embodiments.
[0152] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for retrieving items, characterized in that, The method includes: Received the target item query information; The target item query information is input into a trained retrieval model to obtain a sequence of target item identifiers corresponding to the target item query information; wherein, the vocabulary of the retrieval model includes each item identifier contained in the codebook, and the codebook is trained to compress the item feature vectors of different items into a sequence of item identifiers; Identify the item corresponding to the target item identifier sequence and output the item.
2. The method according to claim 1, characterized in that, The method further includes the following first training phase of the retrieval model: Obtain the first training sample of the retrieval model to be trained. The first training sample includes the description information of the first sample item and the item identifier reference sequence of the first sample item. The item identifier reference sequence of the first sample item is determined based on the codebook. The description information of the first sample item is input into the retrieval model to be trained to obtain the item identifier prediction sequence of the first sample item. The first loss function value is determined based on the predicted sequence of item identifiers and the reference sequence of item identifiers of the first sample item; The parameters of the retrieval model to be trained are adjusted based on the first loss function value.
3. The method according to claim 2, characterized in that, The method further includes the following second training phase for the retrieval model: Obtain a second training sample for the retrieval model to be trained. The second training sample includes query information of the second sample item and a reference sequence of item identifiers of the second sample item. The reference sequence of item identifiers of the second sample item is determined based on the codebook. The query information of the second sample item is input into the retrieval model to be trained to obtain the item identifier prediction sequence of the second sample item; The second loss function value is determined based on the predicted sequence of item identifiers and the reference sequence of item identifiers for the second sample item; The parameters of the retrieval model trained in the first stage are adjusted according to the second loss function value to obtain the trained retrieval model.
4. The method according to claim 1, characterized in that, The method further includes: Obtain the third training sample of the identifier conversion model to be trained, wherein the third training sample includes the item description information of the third sample item; The initial item feature vector corresponding to the item description information of the third sample item is obtained through the feature extraction module in the identifier conversion model. The initial item feature vector of the third sample item is input into the residual quantization module of the identifier conversion model, which contains the codebook to be trained, to obtain the item identifier sequence of the third sample item, which corresponds to multiple codebook layers in the codebook. The item identifier sequence of the third sample item is input into the feature decoding module in the identifier conversion model to obtain the reconstructed item feature vector of the third sample item; The residual quantization loss function value is determined based on the reconstructed item feature vector, the initial item feature vector, and the item identifier sequence of the third sample item; The parameters of the identifier conversion model are adjusted based on the residual quantization loss function value.
5. The method according to claim 4, characterized in that, The step of determining the residual quantization loss function value based on the reconstructed item feature vector, the initial item feature vector, and the item identifier sequence of the third sample item includes: The reconstruction loss function value is determined based on the reconstructed item feature vector of the third sample item and the initial item feature vector; The codebook commitment loss function value is determined based on the item identifier sequence of the third sample item; The residual quantization loss function value is determined based on the reconstruction loss function value and the codebook commitment loss function value.
6. The method according to claim 4 or 5, characterized in that, The third training sample also includes query information for the third sample item; the method further includes: The feature extraction module in the identifier conversion model obtains the query feature vector corresponding to the query information of the third sample item; based on the query feature vector of the third sample item, the initial item feature vector, and the initial item feature vector of the fourth sample item, the contrastive learning loss function value is determined. The fourth sample item is a sample item in the training sample set whose difference from the third sample item meets the set conditions. The initial item feature vector of the fourth sample item is obtained based on the feature extraction module. The initial item feature vector of the fourth sample item serves as the negative sample corresponding to the query feature vector of the third sample item, and the initial item feature vector of the third sample item serves as the positive sample corresponding to the query feature vector of the third sample item. The step of adjusting the parameters of the identifier conversion model based on the residual quantization loss function value includes: The parameters of the identifier conversion model are adjusted based on the residual quantization loss function value and the contrastive learning loss function value.
7. The method according to claim 6, characterized in that, The method further includes: Identify the similar item clusters of the third sample item; The feature extraction module obtains the initial item feature vectors of multiple similar sample items in the same product cluster; The semantic loss function value is determined based on the initial item feature vectors of the multiple similar sample items and the reference item feature vector of the third sample item; The step of basing the loss function value on the residual quantization loss function value and the contrastive learning loss function value includes: The parameters of the identifier conversion model are adjusted based on the semantic loss function value, the residual quantization loss function value, and the contrastive learning loss function value.
8. The method according to claim 7, characterized in that, The step of determining the contrastive learning loss function value based on the query feature vector of the third sample item, the initial item feature vector, and the initial item feature vector of the fourth sample item includes: Based on the query feature vector of the third sample item, the initial item feature vector, the initial item feature vectors of the multiple similar sample items, and the initial item feature vector of the fourth sample item, the contrastive learning loss function value is determined, and the initial item feature vectors of the multiple similar sample items are used as positive samples of the query feature vector of the third sample item.
9. The method according to any one of claims 4, 5, 7, and 8, characterized in that, The method also includes the following initialization process for the codebook to be trained: The feature extraction module obtains the initial item feature vectors of multiple sample items in the training sample set; Clustering is performed on the initial item feature vectors of the multiple sample items to obtain multiple initial clusters. The number of the multiple clusters corresponds to the number of item identifiers contained in each codebook layer in the codebook. Based on the initial item feature vectors contained in each of the initial multiple clusters, the cluster center feature vectors of the initial multiple clusters are determined to initialize the item identifiers contained in the first codebook layer of the codebook. The following process is executed iteratively until the last codebook layer is initialized: Determine the difference between the initial item feature vector of the plurality of sample items and the cluster center feature vector of the cluster to which each of the plurality of sample items belongs at the i-th codebook layer; where i≥1; The differences are then clustered to obtain updated clusters. Based on the initial item feature vectors contained in each of the updated multiple clusters, the cluster center feature vectors of the updated multiple clusters are determined to initialize the item identifiers contained in the (i+1)th codebook layer of the codebook.
10. The method according to claim 4, characterized in that, The feature extraction module includes an embedding module and an encoding module; The step of obtaining the initial item feature vector corresponding to the item description information of the third sample item through the feature extraction module in the identifier conversion model includes: The first item feature vector corresponding to the item description information of the third sample item is obtained through the embedding module; The first item feature vector is input into the encoding module to obtain the second item feature vector corresponding to the third sample item, and the second item feature vector is used as the initial item feature vector corresponding to the item description information of the third sample item.
11. A model training method, characterized in that, include: Obtain the first training sample of the retrieval model to be trained. The first training sample includes the description information of the first sample item and the item identifier reference sequence of the first sample item. The item identifier reference sequence of the first sample item is determined based on a trained codebook. The codebook is trained to compress the item feature vectors of different items into an item identifier sequence. The description information of the first sample item is input into the retrieval model to be trained to obtain the item identifier prediction sequence of the first sample item. The first loss function value is determined based on the predicted sequence of item identifiers and the reference sequence of item identifiers of the first sample item; The parameters of the retrieval model to be trained are adjusted based on the first loss function value; Obtain a second training sample for the retrieval model to be trained. The second training sample includes query information of the second sample item and a reference sequence of item identifiers of the second sample item. The reference sequence of item identifiers of the second sample item is determined based on the codebook. The query information of the second sample item is input into the retrieval model to be trained to obtain the item identifier prediction sequence of the second sample item; The second loss function value is determined based on the predicted sequence of item identifiers and the reference sequence of item identifiers for the second sample item; The parameters of the retrieval model trained in the first stage are adjusted based on the value of the second loss function to obtain the trained retrieval model.
12. The method according to claim 11, characterized in that, The method further includes: Obtain the third training sample of the identifier conversion model to be trained, wherein the third training sample includes query information of the third sample item and item description information of the third sample item; The feature extraction module in the identifier conversion model obtains the query feature vector corresponding to the query information of the third sample item and the initial item feature vector corresponding to the item description information of the third sample item. The initial item feature vector of the third sample item is input into the residual quantization module of the identifier conversion model, which contains the codebook to be trained, to obtain the item identifier sequence of the third sample item, which corresponds to multiple codebook layers in the codebook. The item identifier sequence of the third sample item is input into the feature decoding module in the identifier conversion model to obtain the reconstructed item feature vector of the third sample item; The residual quantization loss function value is determined based on the reconstructed item feature vector, the initial item feature vector, and the item identifier sequence of the third sample item; Based on the query feature vector of the third sample item, the initial item feature vector, and the initial item feature vector of the fourth sample item, the contrastive learning loss function value is determined. The fourth sample item is a sample item in the training sample set whose difference from the third sample item meets the set conditions. The initial item feature vector of the fourth sample item is obtained based on the feature extraction module. The initial item feature vector of the fourth sample item serves as the negative sample corresponding to the query feature vector of the third sample item, and the initial item feature vector of the third sample item serves as the positive sample corresponding to the query feature vector of the third sample item. The parameters of the identifier conversion model are adjusted based on the residual quantization loss function value and the contrastive learning loss function value.
13. An electronic device, characterized in that, include: The device includes a memory, a processor, and a communication interface; wherein the memory stores executable code, which, when executed by the processor, causes the processor to perform the method as described in any one of claims 1 to 12.
14. A non-transitory machine-readable storage medium, characterized in that, The non-transitory machine-readable storage medium stores executable code that, when executed by a processor of an electronic device, causes the processor to perform the method as described in any one of claims 1 to 12.
15. A computer program product, characterized in that, include: A computer program, when executed by a processor of an electronic device, causes the processor to perform the method as described in any one of claims 1 to 12.