Search recommendation method, apparatus and device
By constructing concatenated vectors and semantic IDs, and combining user behavior and multimodal vectors, the problems of unreasonable item representation and multi-module cascading in existing technologies are solved, achieving more efficient and accurate search recommendations and enhancing user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA MOBILE JIUTIAN ARTIFICIAL INTELLIGENCE TECHNOLOGY (BEIJING) CO LTD
- Filing Date
- 2026-02-03
- Publication Date
- 2026-06-05
AI Technical Summary
Existing search and recommendation technologies suffer from problems such as unreasonable item representation, separation of search and recommendation optimization, and complex system structure, poor scalability, and low recommendation accuracy due to the cascading of multiple modules.
By acquiring text IDs and semantic IDs from search information, a concatenated vector is constructed. The target semantic ID is output using a search recommendation model. Combining user historical behavior and multimodal vectors, a fusion vector is constructed and residual quantization K-means clustering is performed to generate a semantic ID, thus unifying the search recommendation process across multiple scenarios and tasks.
It improves the accuracy and diversity of recommendation results, enhances user engagement, breaks down information silos, and improves system scalability and recommendation accuracy.
Smart Images

Figure CN122153152A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of artificial intelligence, and specifically relates to a search recommendation method, apparatus, and device. Background Technology
[0002] Search recommendation is an intelligent task based on matching information retrieval with user needs. Its core objective is to filter and accurately push resources from massive amounts of information or goods through various algorithmic models, helping users quickly and efficiently obtain content that meets their needs. It also helps platforms improve the exposure efficiency and conversion rate of information or goods. It is widely used in various scenarios such as search engines, e-commerce platforms, and content information platforms to achieve precise matching between user needs and resource supply.
[0003] In the field of search recommendation, item representation is a core prerequisite for achieving accurate matching and efficient recommendation. Existing technologies typically employ one-hot encoding or semantic encoding to represent items, but both have significant limitations and are difficult to adapt to the actual needs of real-world scenarios. One-hot encoding assigns a unique code to each item ID. With the large number of new items added daily in real-world applications, the vocabulary needs continuous expansion, leading to a rapid increase in vocabulary size, significantly increasing the training difficulty and computational cost of the model. Furthermore, newly added items cannot be effectively represented using existing encodings, further limiting the practicality of the solution. Semantic encoding, on the other hand, often constructs semantic vectors based on multimodal representation methods of the item's own content and then performs discretization through vector quantization. However, it only focuses on the content features of the item itself, ignoring the implicit similarity relationships between items in search recommendation scenarios, which are largely influenced by user behavior. It lacks key signals related to item collaboration and cannot effectively model item similarity based on user behavior, thus affecting the accuracy and personalization of recommendations.
[0004] Meanwhile, existing technologies typically separate search and recommendation problems for independent optimization. Multiple independent models for recall, ranking, and other functions need to be trained separately in different scenarios, achieving the overall optimization goal through multi-module cascading. This separate optimization and multi-module cascading architecture not only makes the entire search and recommendation system complex, increasing the workload of development and maintenance, but also results in poor model scalability, making it difficult to fully leverage the transfer capabilities of data across multiple scenarios and hindering cross-scenario collaborative optimization. Furthermore, multi-module cascading can easily lead to conflicting modeling goals among modules, with significant optimization dependencies between models, exhibiting a trade-off between them, further impacting the overall system performance.
[0005] In summary, current search and recommendation technologies suffer from numerous technical pain points, such as unreasonable item representation, separation of search and recommendation optimization, and defects in multi-module cascading leading to homogenization. A better search and recommendation solution is urgently needed. Summary of the Invention
[0006] This application provides a search recommendation method, apparatus, and device to improve the accuracy and diversity of recommendation results, further enhance user engagement, and break the information cocoon of the recommendation system.
[0007] Firstly, this application provides a search recommendation method, including: Get search information; Based on the search information, obtain the text identifier (ID) and semantic ID; Obtain the concatenation vector based on the text ID and the semantic ID; The concatenated vector is input into the search recommendation model to obtain the target semantic ID output by the search recommendation model. The search recommendation model is used to output the target semantic ID that matches the search information. The target item is determined based on the target semantic ID.
[0008] According to the search recommendation method provided in this application, obtaining the text ID and semantic ID based on the search information includes: obtaining the target scene, user needs, and user historical behavior based on the search information; obtaining the text ID based on the target scene and the user needs; obtaining multiple reference items based on the user historical behavior; obtaining similar items of the multiple reference items to obtain multiple similar item pairs for each reference item; obtaining the fusion vector of each reference item based on the similar item pairs of each reference item; and obtaining the semantic ID based on the fusion vector of each reference item.
[0009] According to the search recommendation method provided in this application, obtaining similar items of the plurality of reference items to obtain a plurality of similar item pairs for each reference item includes: obtaining a first similar item of each reference item in the target scene; obtaining a multimodal vector of each reference item; obtaining a second similar item of each reference item in other scenes based on the multimodal vector of each reference item; and obtaining a plurality of similar item pairs for each reference item based on the first similar item, the second similar item, and the reference item.
[0010] According to the search recommendation method provided in this application, before obtaining the first similar item of each reference item in the target scene, the method includes: constructing an interaction matrix, the interaction matrix indicating whether each user has an interaction with each item; obtaining an interaction set of each item according to the interaction matrix, the interaction set including users who have interaction with the corresponding item; obtaining the first similar item of each reference item in the target scene includes: performing the following operations for each reference item: obtaining the interaction set of the current reference item from the interaction set of each item; obtaining the first similar item of the current reference item in the target scene based on the interaction set of the current reference item and the interaction sets of other items, wherein the interaction set of other items is the interaction set of each item excluding the interaction set of the reference item.
[0011] According to the search recommendation method provided in this application, the step of obtaining the second similar items of each reference item in other scenarios based on the multimodal vector of each reference item includes: performing retrieval and recall of each reference item in other scenarios based on the multimodal vector of each reference item to obtain multiple reference similar items of each reference item; generating a first prompt word for each reference item based on the text information of the type of the item to be searched in the search message, the text information of each reference item, and the text information of the multiple reference similar items; and obtaining the second similar items of each reference item in other scenarios based on the first prompt word through a large model.
[0012] According to the search recommendation method provided in this application, obtaining the fusion vector of each reference item based on multiple similar item pairs of each reference item includes: performing the following operations for each reference item to obtain the fusion vector of each reference item: obtaining the multimodal vector of each item in multiple similar item pairs of the current reference item; inputting the multimodal vector of each item into a recommendation semantic model to obtain the fusion vector of the current reference item output by the recommendation semantic model, wherein the first training data of the recommendation semantic model includes positive samples based on similar item pairs and negative samples based on dissimilar items, and the recommendation semantic model is trained based on the training data using a contrastive loss function.
[0013] According to the search recommendation method provided in this application, obtaining the semantic ID based on the fusion vector of each reference item includes: Step 1: performing residual quantization K-means clustering on the fusion vector of each reference item to obtain multiple cluster center vectors; Step 2: using the index of the cluster center vector with the highest similarity to the fusion vector of each reference item as the semantic ID index of each reference item; Step 3: subtracting the corresponding cluster center vector from the fusion vector of each reference item to obtain the residual vector of each reference item, and determining the residual vector as the fusion vector of each reference item; repeating steps 1-3 a preset number of times to obtain multiple semantic ID indices; and obtaining the semantic ID based on the multiple semantic ID indices.
[0014] According to the search recommendation method provided in this application, obtaining the concatenation vector based on the text ID and the semantic ID includes: obtaining the text embedding vector of the text ID; determining the average value of the text embedding vector; initializing the semantic ID embedding matrix based on the average value of the text embedding vector; obtaining the semantic embedding vector of the semantic ID based on the semantic ID embedding matrix; and obtaining the concatenation vector based on the text embedding vector and the semantic embedding vector.
[0015] According to the search recommendation method provided in this application, the search recommendation model is trained in the following manner: acquiring user dialogue data and user behavior data corresponding to the user dialogue data; generating a second prompt word based on the prompt word template, the user dialogue data, and the user behavior data; acquiring a training text ID and a training semantic ID based on the second prompt word; acquiring a training concatenation vector based on the training text ID and the training semantic ID; inputting the training concatenation vector into a base model to obtain a training target semantic ID output by the model, wherein the base model includes a LoRA layer; calculating a generation loss function based on the training target semantic ID; updating the parameters of the LoRA layer based on the generation loss function to obtain a trained search recommendation model.
[0016] According to the search recommendation method provided in this application, the step of updating the parameters of the LoRA layer according to the generation loss function to obtain a trained search recommendation model includes: obtaining the training text embedding vector of the training text ID and the training semantic embedding vector of the training semantic ID; obtaining the average value of the training text embedding vector and the average value of the training semantic embedding vector respectively; obtaining a contrastive loss function based on the average value of the training text embedding vector and the average value of the training semantic embedding vector; obtaining a final loss function based on the generation loss function and the contrastive loss function; and updating the parameters of the LoRA layer according to the final loss function to obtain a trained search recommendation model.
[0017] According to the search recommendation method provided in this application, the method further includes: obtaining a first reward value, wherein the first reward value is associated with whether the training target semantic ID corresponds to a real item; obtaining a second reward value, wherein the second reward value is associated with the accuracy and diversity of the item corresponding to the training target semantic ID; and optimizing the search recommendation model through reinforcement learning based on the first reward value and the second reward value.
[0018] According to the search recommendation method provided in this application, obtaining the second reward value includes: determining the accuracy of the training target semantic ID based on the click-through rate of the item corresponding to the training target semantic ID; obtaining a first training multimodal vector of multiple training reference items included in the user behavior data; obtaining the average multimodal vector of the first training multimodal vector; obtaining a second training multimodal vector of the item corresponding to the training target semantic ID; determining the diversity of the training target semantic ID based on the average multimodal vector of the first training multimodal vector and the second training multimodal vector; and obtaining the second reward value based on the accuracy and diversity of the training target semantic ID.
[0019] Secondly, this application provides a search recommendation device, comprising: The first acquisition unit is used to acquire search information; The second acquisition unit is used to acquire the text ID and semantic ID based on the search information; The third acquisition unit is used to acquire the concatenation vector based on the text ID and the semantic ID; The output unit is used to input the concatenated vector into the search recommendation model to obtain the target semantic ID output by the search recommendation model. The search recommendation model is used to output the target semantic ID that matches the search information. A determining unit is used to determine the target item based on the target semantic ID.
[0020] Thirdly, this application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor executes the computer program to implement the search recommendation method as described in the first aspect above.
[0021] Fourthly, this application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the search recommendation method as described in the first aspect above.
[0022] Fifthly, this application also provides a computer program product, including a computer program, characterized in that, when the computer program is executed by a processor, it implements the search recommendation method as described in the first aspect above.
[0023] According to the search recommendation method, apparatus, and device provided in this application, search information is first obtained; then, a text ID and a semantic ID are obtained based on the search information; next, a concatenated vector is obtained based on the text ID and the semantic ID; then, the concatenated vector is input into a search recommendation model to obtain a target semantic ID output by the search recommendation model. The search recommendation model is used to output a target semantic ID that matches the search information; finally, the target item is determined based on the target semantic ID. This can improve the accuracy and diversity of recommendation results, further enhance user engagement, and break the information cocoon of the recommendation system. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the 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.
[0025] Figure 1 This is a flowchart illustrating a search recommendation method provided in this application.
[0026] Figure 2 This is a block diagram of the functional units of a search recommendation device provided in this application.
[0027] Figure 3 This is a schematic diagram of the structure of the electronic device provided in this application. Detailed Implementation
[0028] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions 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.
[0029] The terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0030] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0031] Current search and recommendation technologies suffer from pain points such as unreasonable item representation, task separation optimization, and defects in multi-module cascading, and urgently require better solutions.
[0032] To address the aforementioned problems, this application provides a search recommendation method, apparatus, and device. The embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0033] Please see Figure 1 The search recommendation method includes the following steps.
[0034] S101, obtain search information.
[0035] The search information includes key elements necessary for accurate search recommendations. These can include target scenario definitions, user needs, and user history. Target scenario definitions clarify the application context of the search recommendation task, such as e-commerce shopping or short video recommendation scenarios. User needs can be various expectations expressed by users in natural language regarding the target item, such as "loose and breathable summer tops," which includes descriptions of attributes and uses. User needs can also be a combination of multiple specific needs. User history records the user's past interactions with items in various scenarios, such as clicks, purchases, viewed item names, related text descriptions, and image information—multimodal information.
[0036] S102, Obtain the text ID and semantic ID based on the search information.
[0037] S103, obtain the concatenation vector based on the text ID and the semantic ID.
[0038] Specifically, a text embedding vector can be obtained based on the text ID, and a semantic embedding vector can be obtained based on the semantic ID. Then, the text embedding vector and the semantic embedding vector are concatenated to obtain the concatenated vector.
[0039] S104, Input the concatenated vector into the search recommendation model to obtain the target semantic ID output by the search recommendation model.
[0040] The search recommendation model is used to output the target semantic ID that matches the search information.
[0041] S105, determine the target item based on the target semantic ID.
[0042] As can be seen, this solution constructs text IDs and semantic IDs by integrating multimodal information and user collaboration signals, unifies the search and recommendation process across multiple scenarios and tasks, and takes into account both recommendation accuracy and diversity. This can improve the accuracy of search and recommendation, system scalability, and long-term user experience, breaking the information cocoon problem.
[0043] In one possible embodiment, obtaining the text ID and semantic ID based on the search information includes: obtaining the target scene, user needs, and user historical behavior based on the search information; obtaining the text ID based on the target scene and the user needs; obtaining multiple reference items based on the user historical behavior; obtaining similar items of the multiple reference items to obtain multiple similar item pairs for each reference item; obtaining a fusion vector for each reference item based on the similar item pairs for each reference item; and obtaining the semantic ID based on the fusion vector for each reference item.
[0044] The text ID can be obtained by parsing the target scenario definition and user needs-related text content from the search information, and then converting these natural language texts through word segmentation. Specifically, the target scenario definition and user needs can be integrated according to a unified prompt template and then represented by special characters. <s>The system clearly distinguishes between textual information and subsequent user behavior sequences. A text segmentation tool then breaks down the integrated text into words or subwords, which are then mapped to corresponding text IDs. These text IDs accurately represent the semantic information of the target scenario and user needs. The semantic IDs are determined based on the items included in the user behavior sequence.
[0045] Semantic IDs can be obtained by relying on user historical behavior. First, relevant items are extracted from user history as multiple reference items. Then, similar items are obtained for each reference item to construct multiple similar item pairs. Next, the multimodal representation vectors of similar items are fed into the recommendation semantic model to obtain a fused vector. Finally, vector quantization is performed on the fused vector to obtain the corresponding semantic ID.
[0046] As can be seen, this embodiment can solve the problems of excessively large traditional coding vocabulary, cold start of new items, and lack of coordination signals, improve the rationality and accuracy of item representation, and provide a reliable foundation for subsequent efficient search and recommendation.
[0047] In one possible embodiment, obtaining similar items of the plurality of reference items to obtain a plurality of similar item pairs for each reference item includes: obtaining a first similar item of each reference item in the target scene; obtaining a multimodal vector of each reference item; obtaining a second similar item of each reference item in other scenes based on the multimodal vector of each reference item; and obtaining a plurality of similar item pairs for each reference item based on the first similar item, the second similar item, and the reference item.
[0048] Specifically, based on multiple reference items determined from a user sequence, the collaborative signal of each reference item can be obtained. This collaborative information refers to similar items of the reference items obtained based on the user behavior sequence. These similar items include pixel items within the same scene and across different scenes. Multiple similar item pairs include pairs consisting of the reference item and similar items within the same scene, as well as pairs consisting of the reference item and similar items from other scenes.
[0049] As can be seen, in this embodiment, by acquiring the first similar item based on user behavior collaboration in the target scenario and the second similar item based on multimodal vectors in other scenarios, and then pairing them with reference items to form multiple similar item pairs, the collaborative signals contained in user behavior in the same scenario and the multimodal content features of items across scenarios can be fully integrated. This improves the comprehensiveness and accuracy of item association modeling, provides reliable support for the subsequent construction of high-quality item fusion vectors and optimization of item representation, and enhances the ability to migrate and utilize data from multiple scenarios, avoiding the problem of insufficient item association mining caused by a single scenario or a single feature dimension.
[0050] In one possible embodiment, before obtaining the first similar item of each reference item in the target scene, the method includes: constructing an interaction matrix, the interaction matrix indicating whether each user interacts with each item; obtaining an interaction set for each item based on the interaction matrix, the interaction set including users who have interacted with the corresponding item; obtaining the first similar item of each reference item in the target scene includes: performing the following operations for each reference item: obtaining the interaction set of the current reference item from the interaction set of each item; obtaining the first similar item of the current reference item in the target scene based on the interaction set of the current reference item and the interaction sets of other items, wherein the interaction set of other items is the interaction set of each item excluding the interaction set of the reference item.
[0051] The interaction matrix is used to clearly indicate whether there is an interaction between each user and each item in the target scenario. The rows of the matrix can correspond to different users and the columns can correspond to different items, or the rows can correspond to different items and the columns to different users. The element values in the matrix can be set as follows: if there is a valid interaction between the user and the item, such as clicking, purchasing, browsing, or collecting, the element value is 1; if there is no interaction between the user and the item, or only a meaningless brief contact, the element value is 0. The interaction matrix can clearly and intuitively present the relationship between users and items.
[0052] Based on the constructed interaction matrix, the interaction set corresponding to each item can be further obtained. Specifically, the interaction set is the set of all users who have the above-mentioned effective interaction behavior with the corresponding item. For example, the interaction set of item A is the set of all users who have clicked on or purchased item A. Through the interaction set, the user preference coverage of the item can be quantified, providing core data support for subsequent calculation of item similarity.
[0053] When obtaining the first similar item for each reference item in the target scene, the following operations can be performed separately for each reference item: First, accurately extract the interaction set corresponding to the current reference item from the interaction sets of all items to ensure the accuracy of the data source. Then, calculate the similarity between the interaction set of the current reference item and the interaction sets of other items. The interaction sets of other items refer to all interaction sets remaining after excluding the interaction set of the current reference item from the interaction sets of all items. The similarity calculation method can employ algorithms suitable for set similarity comparison, such as Jaccard similarity. The calculation logic of Jaccard similarity is to use the intersection of two interaction sets as the numerator and the union of two interaction sets as the denominator, quantifying the similarity between the two sets through this ratio. The similarity can then be calculated based on the following formula: Here, A and B represent the sets of all users who interact with item A and item B, respectively. Finally, based on the calculated similarity values, the items are sorted, and one or more items with the highest similarity (excluding the current reference item itself) are selected as the first similar items of that reference item in the target scenario.
[0054] This similarity calculation method based on user interaction sets can fully explore the collaborative relationships between items implied by user behavior in the target scenario, ensuring that the selection of the first similar item can match the user's actual preferences, and providing a reliable foundation for the subsequent construction of high-quality similar item pairs and the fusion of collaborative signals.
[0055] In one possible embodiment, obtaining the second similar items of each reference item in other scenarios based on the multimodal vector of each reference item includes: performing retrieval and recall of each reference item in other scenarios based on the multimodal vector of each reference item to obtain multiple reference similar items of each reference item; generating a first prompt word for each reference item based on the text information of the type of the item to be searched in the search message, the text information of each reference item, and the text information of the multiple reference similar items; and obtaining the second similar items of each reference item in other scenarios based on the first prompt word using a large model.
[0056] The multimodal vector for each reference item can be generated based on multimodal models such as Contrastive Language-Image Pre-training (CLIP). This model integrates textual and image information of the reference item. The textual information can include item name, attribute description, and functional introduction, while the image information can include actual product images and detailed display images. After extracting the text and image vectors, concatenating the two types of vectors forms a complete multimodal vector that comprehensively represents the content features of the reference item.
[0057] Based on this multimodal vector, each reference item can be retrieved and recalled in other scenarios. During the retrieval process, the similarity of the multimodal vectors can be used as a basis to select N items from other relevant scenarios outside the target scenario that best match the content features of the reference item. These N items are then used as multiple reference similar items for that reference item. For example, if the target scenario is an e-commerce shopping scenario, other scenarios may include content information scenarios, lifestyle service scenarios, short video recommendation scenarios, etc. N is a preset positive integer, such as 5, 8, etc.
[0058] Subsequently, first prompts for each reference item can be generated. This generation process can fully integrate key content from the search information. The text information about the type of item being searched can be extracted from user needs; for example, if a user searches for "loose and breathable summer tops," the text information for the type of item being searched would be "loose and breathable summer tops." Simultaneously, item names related to the user's historical behavior in the search information can be incorporated, such as the names of items the user has previously clicked or purchased. This, combined with the text information of each reference item itself (such as its name and core attributes) and the text information of multiple similar reference items (such as their names and key descriptions), allows for the construction of first prompts using a structured template.
[0059] The typical form of the first prompt can be designed as: "You are a user behavior predictor. Please combine the user's historical behavior and select the most likely choice from the candidate similar items based on the type of item to be searched and the text information of the reference items."
[0060] ## User History Behavior Item Names: <Name1>, <Name2>...<Namen> ## Text information about the type of item to be searched: <Text about the type of item to be searched> ##Reference Item Text Information: <Reference Item Text> ##Refer to similar item text information: <1> <Refer to similar item 1 text> <2> <Reference to similar items 2 text> ... <n><Refer to similar items n text>.
[0061] Please directly output the number of the most likely similar item to reference:
[0062] This structure clearly conveys key information and guides the large model to accurately perform the filtering task. Finally, the generated first prompt can be input into a general large model, such as the open-source model Qwen2-7B. The large model can comprehensively judge based on user preferences reflected in historical behavior, demand orientation of the type of item to be searched, and the content relevance between the reference item and similar reference items, and output the most likely reference similar item number. The reference similar item corresponding to this number is the second similar item of each reference item in other scenarios.
[0063] This approach allows for the full exploration of the relationships between user preferences and item content features across different scenarios, providing strong support for the subsequent construction of item representations that integrate cross-scenario collaborative signals.
[0064] In one possible embodiment, obtaining the fusion vector of each reference item based on multiple similar item pairs of each reference item includes: performing the following operations for each reference item to obtain the fusion vector of each reference item: obtaining the multimodal vector of each item in multiple similar item pairs of the current reference item; inputting the multimodal vector of each item into a recommendation semantic model to obtain the fusion vector of the current reference item output by the recommendation semantic model, wherein the first training data of the recommendation semantic model includes positive samples based on similar item pairs and negative samples based on dissimilar items, and the recommendation semantic model is trained based on the training data using a contrastive loss function.
[0065] The recommendation semantic model can be structured as a typical dual-tower architecture, containing a multi-layer fully connected neural network (MLP) capable of deep feature extraction and information fusion from the input multimodal vectors, ultimately outputting an N-dimensional fused vector corresponding to the current reference item. Training of the recommendation semantic model requires specific initial training data. Positive samples can consist of previously constructed pairs of similar items; that is, the two items in each similar item pair are considered positive sample pairs. Negative samples can be randomly selected from the training batch from other items unrelated to the current reference item or similar items. A contrastive loss function is used to guide the model's learning during training, and the formula for this contrastive loss function is shown below: in, For the multimodal vector of the reference item, For the multimodal vectors of similar items to the reference item, This is the multimodal vector of negative samples in a batch.
[0066] This loss function can shorten the vector distance between positive sample pairs while widening the vector distance between negative and positive samples, enabling the model to accurately capture the association features between similar items. Through this training method, the recommendation semantic model can fully mine the item content information contained in the multimodal vectors and the collaborative signals contained in similar item pairs, thereby outputting a high-quality fused vector that integrates multimodal features and collaborative information. This fused vector can more comprehensively and accurately represent the core features of the current reference item, providing reliable support for achieving better item discretization representations in the future.
[0067] In one possible embodiment, obtaining the semantic ID based on the fusion vector of each reference item includes: Step 1: performing residual quantization K-means clustering on the fusion vector of each reference item to obtain multiple cluster center vectors; Step 2: using the index of the cluster center vector with the highest similarity to the fusion vector of each reference item as the semantic ID index of each reference item; Step 3: subtracting the corresponding cluster center vector from the fusion vector of each reference item to obtain the residual vector of each reference item, and determining the residual vector as the fusion vector of each reference item; repeating steps 1-3 a preset number of times to obtain multiple semantic ID indices; and obtaining the semantic ID based on the multiple semantic ID indices.
[0068] Dense vector quantization can be achieved using the Residual Quantization K-means (RQ-Kmeans) vector quantization method. For the fused vectors of all reference items, a K-means clustering algorithm is used for the first round of clustering. The number of cluster centers can be flexibly adjusted according to the actual scenario requirements. All the cluster center vectors obtained after clustering constitute the first-level codebook. Subsequently, for the fused vector of each reference item, its similarity (e.g., cosine similarity) with each cluster center vector in the first-level codebook is calculated, and the index corresponding to the cluster center vector with the highest similarity is selected as the first semantic ID index of that reference item. Next, the fused vector of each reference item is subtracted from its corresponding first-level cluster center vector to obtain the residual vector of each reference item. This residual vector represents the difference between the original fused vector and the first-level cluster center vector. At this point, the residual vector can be redefined as the "fused vector" to be processed in the current round, and the process proceeds to the next iteration.
[0069] Then, the clustering, index extraction, and residual calculation steps are repeated a preset number of times according to the same logic. The preset number of times can be set according to the representation accuracy requirements, and is usually set to 3 times. Each iteration generates new cluster centers and corresponding codebooks (such as the second round codebook, the third round codebook) based on the current residual vector, and extracts new semantic ID indices (such as the second semantic ID index, the third semantic ID index). The number of cluster centers in each round can be adjusted independently to balance representation accuracy and computational efficiency. Finally, all the semantic ID indices extracted in the multiple iterations are combined in the iteration order to form the semantic ID corresponding to each reference item. This semantic ID can be represented in the following form: Where t_1, t_2, and t_3 are the semantic ID indices obtained in the first, second, and third iterations, respectively.
[0070] As can be seen, this scheme accurately and efficiently discretizes the item representation vector that integrates multi-dimensional information by combining the indexes of multiple codebooks. This avoids the vocabulary expansion problem caused by traditional one-hot encoding and allows new items to quickly generate semantic IDs through the same clustering and residual calculation process, effectively solving the cold start problem for new items. At the same time, since the fused vector itself contains multimodal and collaborative signals, the corresponding semantic ID can also fully carry the content features and associations of the item, providing a reliable discretized representation foundation for subsequent search and recommendation tasks.
[0071] In one possible embodiment, obtaining the concatenation vector based on the text ID and the semantic ID includes: obtaining the text embedding vector of the text ID; determining the average value of the text embedding vector; initializing the semantic ID embedding matrix based on the average value of the text embedding vector; obtaining the semantic embedding vector of the semantic ID based on the semantic ID embedding matrix; and obtaining the concatenation vector based on the text embedding vector and the semantic embedding vector.
[0072] The text embedding vectors can be retrieved from a pre-trained text embedding matrix, which maps discrete text IDs to continuous high-dimensional vectors. The average value of the text embedding vectors comprehensively represents the overall semantic features of the text ID sequence, providing a semantically relevant foundation for the subsequent initialization of the semantic ID embedding matrix. The semantic ID embedding matrix is initialized based on this average value, and its dimension can be consistent with the text embedding vectors. This initialization method ensures that the initial vector representation of the semantic IDs and the semantic vectors of the text IDs have a similar distribution in the same semantic space, effectively reducing the difficulty for the model to subsequently learn the text-semantic association and accelerating their semantic alignment.
[0073] Based on the initialized semantic ID embedding matrix, the semantic embedding vector corresponding to each semantic ID can be retrieved. This semantic embedding vector can transform discrete semantic IDs into continuous vector forms, realizing the vectorization of item representation. Finally, the text embedding vector corresponding to the text ID and the semantic embedding vector corresponding to the semantic ID are concatenated along the feature dimension. The concatenation method can be direct end-to-end connection, forming a concatenated vector with a dimension equal to the sum of the dimensions of the text embedding vector and the semantic embedding vector. This concatenated vector retains the textual semantic information of user needs and scenario definitions while incorporating the multimodal features and collaborative association information of items. It can provide comprehensive and unified input features for subsequent search and recommendation models, ensuring that the model can simultaneously understand textual semantics and item representation, laying the foundation for accurately matching user needs with target items.
[0074] In one possible embodiment, the search recommendation model is trained as follows: acquiring user dialogue data and corresponding user behavior data; generating a second prompt word based on the prompt word template, the user dialogue data, and the user behavior data; acquiring a training text ID and a training semantic ID based on the second prompt word; acquiring a training concatenation vector based on the training text ID and the training semantic ID; inputting the training concatenation vector into a base model to obtain a training target semantic ID output by the model, wherein the base model includes a LoRA layer; calculating a generation loss function based on the training target semantic ID; and updating the parameters of the LoRA layer based on the generation loss function to obtain the trained search recommendation model.
[0075] When acquiring the user dialogue data and corresponding user behavior data required for training, the sources of these data are flexible and diverse. They can be data related to search and recommendation tasks in multiple scenarios collected and integrated from open-source datasets, or real user interaction data accumulated within the business. If the existing data volume is insufficient or the coverage of scenarios is limited, it can also be extended and generated through data generation methods based on large models to ensure the richness and scenario diversity of training data.
[0076] The second prompt word template can be designed as a structured form that includes scenario definition, user needs (extracted from user dialogue data), and user historical behavior sequence (extracted from user behavior data), and can use special characters. <s>Clearly distinguishing between textual information and user behavior sequences allows the model to more clearly identify different types of input data. For example, a template could be presented as: ##Scene Definition: <Scene Description> ##User Requirements: <Requirement 1>, <Requirement 2>...<Requirement n> ## User historical behavior: <s><Items corresponding to Requirement 1><Items corresponding to Requirement 2>...<Items corresponding to Requirement n><\s>.
[0077] The training text ID is obtained by segmenting the text content such as scene definition and user needs in the second prompt word using a text segmenter. The training semantic ID is obtained by processing the items associated with the user behavior sequence in the second prompt word using the aforementioned method for obtaining semantic IDs. Specifically, the multimodal vector of the item and the collaborative signals of the same scene and other scenes (i.e., similar items) are first obtained. After training the recommendation semantic model to obtain the fused vector, it is generated by residual quantization K-means vector quantization. Then, a training concatenation vector is obtained based on the training text ID and training semantic ID. Specifically, the text embedding vector corresponding to the training text ID is first obtained, the average value of the text embedding vector is calculated, and then the semantic ID embedding matrix is initialized with this average value. The semantic embedding vector corresponding to the training semantic ID is retrieved from the initialized semantic ID embedding matrix. Finally, the text embedding vector and the semantic embedding vector are concatenated dimensionally to form the training concatenation vector. This vector can simultaneously carry textual semantic information and item representation information, providing comprehensive input for model training.
[0078] The training concatenation vectors are input into a pre-selected base model, which can be a large open-source language model such as Qwen2-7B. This base model contains a low-rank adapter (LoRA) layer. This architecture allows for efficient fine-tuning by training only the LoRA layer parameters while maintaining the model's original general natural language understanding capabilities, avoiding the high computational cost and overfitting risk associated with training all parameters. After receiving the training concatenation vectors, the base model performs feature extraction and semantic mapping through its internal multi-layer neural network, outputting a training target semantic ID. This training target semantic ID is used to compare with the real labels, i.e., the semantic IDs of items corresponding to user behavior data.
[0079] The generation loss function can be the autoregressive cross-entropy loss commonly used in generative models, and the specific formula is as follows: Among them, t 1 , t 2 , ..., t k For the token sequence already generated by the model, there is a corresponding text ID sequence related to user needs and scenario definitions, t k+1 For the next token to be predicted, the semantic ID of the recommended item, p( tk+1 ∣…) represents the conditional probability of the model predicting semantic IDs based on the text ID sequence.
[0080] This generative loss function measures the difference between the generated training target semantic ID and the real semantic ID, guiding the model to optimize parameters and improve the prediction accuracy of semantic IDs. Finally, based on the calculated generative loss function, the parameters of the LoRA layer in the base model are updated using the backpropagation algorithm. During the update process, most of the original parameters of the base model are frozen, and only the low-rank matrix parameters of the LoRA layer are adjusted. This ensures that the model adapts to search and recommendation tasks without losing its original general language processing capabilities. After multiple rounds of iterative training, when the generative loss function converges to a preset threshold, a well-trained search and recommendation model is obtained. This model can accurately understand the semantic information in the training concatenation vectors and efficiently output target semantic IDs that match user needs.
[0081] In one possible embodiment, updating the parameters of the LoRA layer according to the generation loss function to obtain the trained search recommendation model includes: obtaining the training text embedding vector of the training text ID and the training semantic embedding vector of the training semantic ID; obtaining the average value of the training text embedding vector and the average value of the training semantic embedding vector, respectively; obtaining a contrastive loss function based on the average value of the training text embedding vector and the average value of the training semantic embedding vector; obtaining a final loss function based on the generation loss function and the contrastive loss function; and updating the parameters of the LoRA layer according to the final loss function to obtain the trained search recommendation model.
[0082] The training text embedding vectors can be obtained using the methods described above, and the training semantic embedding vectors can be obtained using the methods described above as well; these will not be repeated here. The contrastive loss function can be expressed by the following formula: in, This represents the average training text embedding vector of the Chinese text ID for positive samples within the batch. This represents the average value of the training semantic embedding vectors for the training semantic IDs in the positive sample pairs within the batch. The average value of the training semantic embedding vectors for the semantic IDs of other random items within the batch.
[0083] The final loss function can be a weighted sum of the generation loss function and the contrastive loss function. Different weighting coefficients can be set, such as a weighting coefficient of 0.7 for the generation loss and 0.3 for the contrastive loss. The generation loss mainly ensures that the model accurately generates training target semantic IDs that match the real labels based on the training concatenation vectors, guaranteeing the accuracy of the recommendation results. The contrastive loss helps to align the semantics of the text with the semantics of the items, allowing the model to more accurately capture the relationship between textual needs and semantic IDs while maintaining its ability to understand natural language.
[0084] Finally, the parameters of the LoRA layer are updated according to the final loss function. During the update process, most of the original parameters of the base model can be frozen, and only the low-rank matrix parameters in the LoRA layer are updated through the backpropagation algorithm. This method can significantly reduce the computational cost, avoid the resource consumption caused by training all parameters, and effectively retain the original general language processing capabilities of the base model. As the training iteration progresses, when the value of the final loss function converges to a preset threshold, training can be stopped, and a trained search recommendation model is obtained. This model can accurately understand the user's search needs expressed through text and efficiently generate matching target semantic IDs, thereby realizing an end-to-end search recommendation task.
[0085] In one possible embodiment, the method further includes: obtaining a first reward value, wherein the first reward value is associated with whether the training target semantic ID corresponds to a real item; obtaining a second reward value, wherein the second reward value is associated with the accuracy and diversity of the item corresponding to the training target semantic ID; and optimizing the search recommendation model through reinforcement learning based on the first reward value and the second reward value.
[0086] The reward model evaluates and scores the results generated during training to guide model optimization. Two types of model rewards are defined: format reward and personalized reward. The specific scheme is as follows: Format reward: During the pre-training phase, the model learns to generate semantic IDs for items. A semantic ID typically consists of multiple ID indices representing a real item. Therefore, the semantic IDs generated by the model during prediction and inference may not be mapped to real items, thus requiring alignment of the format of the semantic IDs generated by the model. A first reward value of 1 is given if the generated semantic ID can be mapped to a real item, and 0 is given if it cannot. The corresponding formula is as follows: Personalized Rewards: Traditional metrics such as click-through rate (CTR), purchase rate, and playback duration can be used to measure the personalization capabilities of a model. However, these statistical metrics typically involve modeling and learning from users' historical behavior. If only this information is used to guide the model's learning, it can easily lead to homogenized recommendation results, biased towards recommending users based on a single high-metric behavior. Therefore, it is necessary to consider the diversity and novelty of recommendation results while also considering recommendation accuracy to avoid the information cocoon problem. Thus, a personalized reward is defined, and the search recommendation model is optimized through reinforcement learning using a second reward value and a first reward value.
[0087] In one possible embodiment, obtaining the second reward value includes: determining the accuracy value of the training target semantic ID based on the click-through rate of the item corresponding to the training target semantic ID; obtaining a first training multimodal vector of multiple training reference items included in the user behavior data; obtaining the average multimodal vector of the first training multimodal vector; obtaining a second training multimodal vector of the item corresponding to the training target semantic ID; determining the diversity value of the training target semantic ID based on the average multimodal vector of the first training multimodal vector and the second training multimodal vector; and obtaining the second reward value based on the accuracy and diversity of the training target semantic ID.
[0088] The second reward value can include two parts: accuracy reward and diversity reward. Accuracy reward typically uses commonly used evaluation metrics in recommendations, a typical example being click-through rate (CTR). The accuracy value can be determined based on CTR. The diversity reward is defined as the dissimilarity between the recommended item and the user behavior sequence. This can be achieved by calculating the average semantic vectors of the recommended item and the user behavior separately, then inverting their similarity to obtain the diversity value. The lower the similarity, the stronger the diversity. The second reward value combines these two rewards, balancing the accuracy and diversity of the recommendation results. The formula is: Among them, Score 准确性 To ensure accurate value selection, Score 多样性 For the value of diversity, μ is the weighting coefficient.
[0089] It is evident that defining a reward model based on this scheme can improve the accuracy of recommendations while also enhancing the diversity and novelty of the recommendation results, thus avoiding the problem of information cocoons.
[0090] The search recommendation apparatus provided in the embodiments of this application is described below. The search recommendation apparatus described below can be referred to in correspondence with the search recommendation method described above.
[0091] Please see Figure 2 The search recommendation device 200 includes: a first acquisition unit 201 for acquiring search information; a second acquisition unit 202 for acquiring a text ID and a semantic ID based on the search information; a third acquisition unit 203 for acquiring a concatenated vector based on the text ID and the semantic ID; an output unit 204 for inputting the concatenated vector into a search recommendation model to obtain a target semantic ID output by the search recommendation model, wherein the search recommendation model is used to output a target semantic ID that matches the search information; and a determination unit 205 for determining the target item based on the target semantic ID.
[0092] In one possible embodiment, in terms of obtaining the text ID and semantic ID based on the search information, the second acquisition unit 202 is specifically configured to: obtain the target scene, user needs, and user historical behavior based on the search information; obtain the text ID based on the target scene and the user needs; obtain multiple reference items based on the user historical behavior; obtain similar items of the multiple reference items to obtain multiple similar item pairs for each reference item; obtain the fusion vector of each reference item based on the similar item pairs of each reference item; and obtain the semantic ID based on the fusion vector of each reference item.
[0093] In one possible embodiment, in obtaining similar items of the plurality of reference items and obtaining a plurality of similar item pairs for each reference item, the second obtaining unit 202 is specifically configured to: obtain a first similar item of each reference item in the target scene; obtain a multimodal vector of each reference item; obtain a second similar item of each reference item in other scenes based on the multimodal vector of each reference item; and obtain a plurality of similar item pairs for each reference item based on the first similar item, the second similar item, and the reference item.
[0094] In one possible embodiment, before acquiring the first similar item of each reference item in the target scene, the second acquisition unit 202 is specifically configured to: construct an interaction matrix, the interaction matrix indicating whether each user interacts with each item; acquire the interaction set of each item according to the interaction matrix, the interaction set including users who have interacted with the corresponding item; regarding acquiring the first similar item of each reference item in the target scene, the second acquisition unit 202 is specifically configured to: perform the following operations for each reference item: acquire the interaction set of the current reference item from the interaction set of each item; acquire the first similar item of the current reference item in the target scene based on the interaction set of the current reference item and the interaction sets of other items, wherein the interaction set of other items is the interaction set of each item excluding the interaction set of the reference item.
[0095] In one possible embodiment, in obtaining second similar items of each reference item in other scenarios based on the multimodal vector of each reference item, the second obtaining unit 202 is specifically configured to: perform retrieval and recall of each reference item in other scenarios based on the multimodal vector of each reference item to obtain multiple reference similar items of each reference item; generate a first prompt word for each reference item based on the text information of the type of the item to be searched in the search message, the text information of each reference item, and the text information of the multiple reference similar items; and obtain the second similar items of each reference item in other scenarios based on the first prompt word through a large model.
[0096] In one possible embodiment, in obtaining the fusion vector of each reference item based on multiple similar item pairs of each reference item, the second acquisition unit 202 is specifically configured to: perform the following operations for each reference item to obtain the fusion vector of each reference item: acquire the multimodal vector of each item in multiple similar item pairs of the current reference item; input the multimodal vector of each item into a recommendation semantic model to obtain the fusion vector of the current reference item output by the recommendation semantic model, wherein the first training data of the recommendation semantic model includes positive samples based on similar item pairs and negative samples based on dissimilar items, and the recommendation semantic model is trained based on the training data using a contrastive loss function.
[0097] In one possible embodiment, in obtaining the semantic ID based on the fusion vector of each reference item, the second obtaining unit 202 is specifically configured to: Step 1: Perform residual quantization K-means clustering on the fusion vector of each reference item to obtain multiple cluster center vectors; Step 2: Use the index of the cluster center vector with the highest similarity corresponding to the fusion vector of each reference item as the semantic ID index of each reference item; Step 3: Subtract the corresponding cluster center vector from the fusion vector of each reference item to obtain the residual vector of each reference item, and determine the residual vector as the fusion vector of each reference item; Repeat steps 1-3 a preset number of times to obtain multiple semantic ID indices; Obtain the semantic ID based on the multiple semantic ID indices.
[0098] In one possible embodiment, the search recommendation device 200 includes a training unit, which is configured to: acquire user dialogue data and user behavior data corresponding to the user dialogue data; generate a second prompt word based on the prompt word template, the user dialogue data, and the user behavior data; acquire a training text ID and a training semantic ID based on the second prompt word; acquire a training concatenation vector based on the training text ID and the training semantic ID; input the training concatenation vector into a base model to obtain a training target semantic ID output by the model, wherein the base model includes a LoRA layer; calculate a generation loss function based on the training target semantic ID; and update the parameters of the LoRA layer based on the generation loss function to obtain a trained search recommendation model.
[0099] In one possible embodiment, in updating the parameters of the LoRA layer according to the generation loss function to obtain the trained search recommendation model, the training unit is specifically configured to: obtain the training text embedding vector of the training text ID and the training semantic embedding vector of the training semantic ID; obtain the average value of the training text embedding vector and the average value of the training semantic embedding vector, respectively; obtain a contrastive loss function based on the average value of the training text embedding vector and the average value of the training semantic embedding vector; obtain a final loss function based on the generation loss function and the contrastive loss function; and update the parameters of the LoRA layer according to the final loss function to obtain the trained search recommendation model.
[0100] In one possible embodiment, the training unit is further configured to: obtain a first reward value, wherein the first reward value is associated with whether the training target semantic ID corresponds to a real item; obtain a second reward value, wherein the second reward value is associated with the accuracy and diversity of the item corresponding to the training target semantic ID; and optimize the search recommendation model through reinforcement learning based on the first reward value and the second reward value.
[0101] In one possible embodiment, regarding obtaining the second reward value, the training unit is specifically configured to: determine the accuracy of the training target semantic ID based on the click-through rate of the item corresponding to the training target semantic ID; obtain a first training multimodal vector of multiple training reference items included in the user behavior data; obtain the average multimodal vector of the first training multimodal vector; obtain a second training multimodal vector of the item corresponding to the training target semantic ID; determine the diversity of the training target semantic ID based on the average multimodal vector of the first training multimodal vector and the second training multimodal vector; and obtain a second reward value based on the accuracy and diversity of the training target semantic ID.
[0102] Please see Figure 3 , Figure 3 A schematic diagram of the physical structure of an electronic device is provided. It may include a processor 310, a communication interface 320, a memory 330, and a communication bus 340, wherein the processor 310, communication interface 320, and memory 330 communicate with each other via the communication bus 340. The processor 310 can call a computer program in the memory 330 to execute a search recommendation method. This method includes: acquiring search information; acquiring a text identifier ID and a semantic ID based on the search information; acquiring a concatenated vector based on the text ID and the semantic ID; inputting the concatenated vector into a search recommendation model to obtain a target semantic ID output by the search recommendation model, the search recommendation model being used to output a target semantic ID matching the search information; and determining the target item based on the target semantic ID.
[0103] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0104] On the other hand, this application also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the search recommendation method provided in the above embodiments. The method includes: obtaining search information; obtaining a text identifier ID and a semantic ID based on the search information; obtaining a concatenated vector based on the text ID and the semantic ID; inputting the concatenated vector into a search recommendation model to obtain a target semantic ID output by the search recommendation model, wherein the search recommendation model is used to output a target semantic ID that matches the search information; and determining the target item based on the target semantic ID.
[0105] On the other hand, embodiments of this application also provide a processor-readable storage medium storing a computer program. The computer program is used to cause a processor to execute the search recommendation method provided in the above embodiments. The method includes: acquiring search information; acquiring a text identifier ID and a semantic ID based on the search information; acquiring a concatenated vector based on the text ID and the semantic ID; inputting the concatenated vector into a search recommendation model to obtain a target semantic ID output by the search recommendation model, wherein the search recommendation model is used to output a target semantic ID that matches the search information; and determining the target item based on the target semantic ID.
[0106] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0107] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0108] 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.< / s> < / s> < / n> < / s>
Claims
1. A search recommendation method, characterized in that, include: Get search information; Based on the search information, obtain the text identifier ID and semantic ID; Obtain the concatenation vector based on the text ID and the semantic ID; The concatenated vector is input into the search recommendation model to obtain the target semantic ID output by the search recommendation model. The search recommendation model is used to output the target semantic ID that matches the search information. The target item is determined based on the target semantic ID.
2. The method according to claim 1, characterized in that, The step of obtaining the text ID and semantic ID based on the search information includes: Based on the search information, the target scenario, user needs, and user historical behavior are obtained; Obtain the text ID based on the target scenario and the user requirements; Multiple reference items are obtained based on the user's historical behavior. Obtain similar items for the multiple reference items, resulting in multiple pairs of similar items for each reference item; The fusion vector of each reference item is obtained based on the similar item pairs of each reference item; The semantic ID is obtained based on the fusion vector of each reference item.
3. The method according to claim 2, characterized in that, The step of obtaining similar items for the multiple reference items, and obtaining multiple pairs of similar items for each reference item, includes: Obtain the first similar item for each reference item in the target scene; Obtain the multimodal vector for each reference item; Based on the multimodal vector of each reference item, obtain the second similar item of each reference item in other scenarios; Based on the first similar item, the second similar item, and the reference item, multiple pairs of similar items are obtained for each reference item.
4. The method according to claim 3, characterized in that, Before obtaining the first similar item for each reference item in the target scene, the method includes: Construct an interaction matrix that indicates whether each user interacts with each item; The interaction set for each item is obtained based on the interaction matrix, and the interaction set includes users who have interactive behaviors with the corresponding item; The step of obtaining the first similar item for each reference item in the target scene includes: Perform the following operations for each of the reference items: Obtain the interaction set of the current reference item from the interaction set of each item; Based on the interaction set of the current reference item and the interaction set of other items, obtain the first similar item of the current reference item in the target scene, where the interaction set of other items is the interaction set of each item excluding the interaction set of the reference item.
5. The method according to claim 3, characterized in that, The step of obtaining the second similar item of each reference item in other scenarios based on the multimodal vector of each reference item includes: Based on the multimodal vector of each reference item, the reference item is retrieved and recalled in other scenarios to obtain multiple similar reference items for each reference item; The first prompt word for each reference item is generated based on the text information of the type of item to be searched in the search letter, the text information of each reference item, and the text information of the multiple reference similar items; Based on the first prompt, the second similar item for each reference item in other scenarios is obtained through a large model.
6. The method according to claim 2, characterized in that, The step of obtaining the fusion vector of each reference item based on multiple similar item pairs of each reference item includes: Perform the following operations for each reference item to obtain the fusion vector for each reference item: Obtain the multimodal vector of each item in multiple similar item pairs of the current reference item; The multimodal vector of each item is input into the recommendation semantic model to obtain the fusion vector of the current reference item output by the recommendation semantic model. The first training data of the recommendation semantic model includes positive samples based on similar item pairs and negative samples based on dissimilar items. The recommendation semantic model is trained based on the contrastive loss function according to the training data.
7. The method according to any one of claims 2-6, characterized in that, The step of obtaining the semantic ID based on the fusion vector of each reference item includes: Step 1: Perform residual quantization K-means clustering on the fusion vector of each reference item to obtain multiple cluster center vectors; Step 2: Use the index of the cluster center vector with the highest similarity corresponding to the fusion vector of each reference item as the semantic ID index of each reference item; Step 3: Subtract the corresponding cluster center vector from the fusion vector of each reference item to obtain the residual vector of each reference item, and determine the residual vector as the fusion vector of each reference item; Repeat steps 1-3 as preset to obtain multiple semantic ID indexes; The semantic ID is obtained based on the multiple semantic ID indexes.
8. The method according to claim 1, characterized in that, The step of obtaining the concatenation vector based on the text ID and the semantic ID includes: Obtain the text embedding vector of the text ID; Determine the average value of the text embedding vector; Initialize the semantic ID embedding matrix based on the average value of the text embedding vectors; The semantic embedding vector of the semantic ID is obtained based on the semantic ID embedding matrix; The concatenation vector is obtained based on the text embedding vector and the semantic embedding vector.
9. The method according to claim 1, characterized in that, The search recommendation model is trained in the following manner: Acquire user dialogue data and corresponding user behavior data; A second prompt word is generated based on the prompt word template, the user dialogue data, and the user behavior data; Obtain the training text ID and training semantic ID based on the second prompt word; Obtain the training concatenation vector based on the training text ID and the training semantic ID; The training concatenation vector is input into the base model to obtain the training target semantic ID output by the model. The base model includes a LoRA layer. Calculate and generate a loss function based on the semantic ID of the training target; The parameters of the LoRA layer are updated according to the generation loss function to obtain the trained search recommendation model.
10. The method according to claim 9, characterized in that, The step of updating the parameters of the LoRA layer according to the generation loss function to obtain the trained search recommendation model includes: Obtain the training text embedding vector of the training text ID and the training semantic embedding vector of the training semantic ID; The average value of the training text embedding vector and the average value of the training semantic embedding vector are obtained respectively; The contrastive loss function is obtained based on the average value of the trained text embedding vectors and the average value of the trained semantic embedding vectors; The final loss function is obtained based on the generation loss function and the comparison loss function; The parameters of the LoRA layer are updated based on the final loss function to obtain the trained search recommendation model.
11. The method according to claim 9 or 10, characterized in that, The method further includes: Obtain a first reward value, and determine whether the first reward value is associated with a real item corresponding to the semantic ID of the training target. Obtain a second reward value, which is correlated with the accuracy and diversity of the items corresponding to the semantic ID of the training target; The search recommendation model is optimized using reinforcement learning based on the first reward value and the second reward value.
12. The method according to claim 11, characterized in that, The process of obtaining the second reward value includes: The accuracy of the training target semantic ID is determined based on the click-through rate of the items corresponding to the training target semantic ID; Obtain the first training multimodal vector of multiple training reference items included in the user behavior data; Obtain the average multimodal vector of the first trained multimodal vector; Obtain the second training multimodal vector of the item corresponding to the semantic ID of the training target; The diversity of the training target semantic ID is determined based on the average multimodal vector of the first training multimodal vector and the second training multimodal vector; A second reward value is obtained based on the accuracy and diversity of the training target semantic ID.
13. A search and recommendation device, characterized in that, include: The first acquisition unit is used to acquire search information; The second acquisition unit is used to acquire the text ID and semantic ID based on the search information; The third acquisition unit is used to acquire the concatenation vector based on the text ID and the semantic ID; The output unit is used to input the concatenated vector into the search recommendation model to obtain the target semantic ID output by the search recommendation model. The search recommendation model is used to output the target semantic ID that matches the search information. A determining unit is used to determine the target item based on the target semantic ID.
14. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the search recommendation method as described in any one of claims 1 to 12.
15. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the search recommendation method as described in any one of claims 1 to 12.
16. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the search recommendation method as described in any one of claims 1 to 12.