Large model recommendation method and device based on keyword retrieval, medium and equipment
By obtaining the keywords input by users and combining deep neural networks and large language models, combining graph message delivery mechanisms and Bayesian sorting algorithms, the problem that existing recommendation systems are difficult to provide accurate personalized recommendations in new user scenarios is solved, and high-quality personalized recommendations are achieved.
Patent Information
- Application Number
- CN202510256401.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-05
- Publication Date
- 2025-06-20
AI Technical Summary
Existing recommendation systems have difficulty generating accurate and personalized recommendations when dealing with new users (cold start users), especially in the absence of user history data.
By obtaining the keywords input by users, using deep neural networks and large language models, combining graph messaging mechanisms and Bayesian sorting algorithms, project recommendations are performed. This method does not rely on the user's historical data and can dynamically adapt to the user's immediate interests and the real-time characteristics of the project.
In the absence of user historical data, providing high-quality personalized recommendations to new users improves the accuracy and personalization of recommendations, and significantly improves user experience and satisfaction.
Smart Images

Figure CN120179900A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of large model recommendations based on keyword retrieval, and particularly to a large model recommendation method, device, medium, and equipment based on keyword retrieval. Background Art
[0002] With the rapid development of Internet technology, users are faced with a vast amount of information choices on digital platforms. In many fields, such as e-commerce, content sharing platforms, and online service markets, personalized recommendation systems have become key tools to help users discover and filter information. These systems provide customized item recommendations for users by analyzing their historical behaviors, preferences, and context information.
[0003] However, existing recommendation systems have encountered significant challenges in dealing with new users (cold start users). Due to the lack of historical interaction data of these users, it is difficult for the system to generate accurate and personalized recommendations. Traditional recommendation algorithms, such as content-based recommendation and collaborative filtering recommendation, rely on users' historical data or item features for prediction, but in the new user scenario, these methods often fail to provide effective recommendations. In addition, with the development of large language models (LLMs), generative recommendation technologies have begun to emerge. These technologies use pre-trained language models to generate personalized recommendation content, but they also have limitations in dealing with cold start problems. LLMs usually require a large amount of training data, and in the cold start scenario, this data is often unavailable. In addition, the recommendation results generated by LLMs may lack accuracy and interpretability because they rely on the knowledge learned by the model during the training phase rather than the latest user feedback or real-time data.
[0004] To solve the above problems, some attempts have been made in the technical field, such as using users' basic profiles or social network information to infer new users' interests, or collecting users' direct feedback through active learning strategies. Although these methods have alleviated the cold start problem to a certain extent, they still cannot fully meet the requirements of the recommendation scenario, especially in cases where it is necessary to quickly adapt to new user preferences and process large-scale data sets, resulting in the problem that the existing technology cannot provide accurate personalized recommendations for new users. Summary of the Invention
[0005] This application provides a large model recommendation method, device, medium, and equipment based on keyword retrieval to solve the problem in the existing technology that accurate personalized recommendations cannot be provided for new users.
[0006] In a first aspect, this application provides a large model recommendation method based on keyword retrieval, including:
[0007] Obtain keywords input by the user;
[0008] Retrieve a first candidate item set based on user preferences according to the keywords and a preset item database;
[0009] Input the keywords and the first candidate item set into a preset deep neural network, and output respective user embedding vectors and respective item embedding vectors;
[0010] Obtain a second candidate item set with a preliminary ranking according to the respective user embedding vectors and respective item embedding vectors;
[0011] Input the second candidate item set and the keywords into a preset large language model, and output a third candidate item set with a re-ranking;
[0012] Obtain a recommendation for the keywords according to the third candidate item set.
[0013] This application captures the user's immediate interests by directly obtaining the keywords input by the user. This method does not rely on the user's historical data, thus providing a starting point for solving the cold start problem. Then, these keywords are used to retrieve a preliminary candidate item set from the item database. This step is based on the relevance of the keywords, ensuring that even new users can obtain relevant recommendations. Then, the keywords are transformed into user and item embedding vectors through a deep neural network. These vectors can represent the characteristics of users and items in the vector space, providing a mathematical basis for personalized recommendations. Further, combining the graph message passing mechanism and the Bayesian ranking algorithm, the candidate item set is ranked. This step utilizes the user's immediate input and the real-time data of the items, enhancing the personalization and accuracy of the recommendations. Finally, the preliminarily ranked candidate item set is input into a large language model, and the natural language processing ability of the model is used for re-ranking to ensure that the recommendation results are not only based on the user's immediate input but also take into account the context information of the items. This application can provide high-quality personalized recommendations for new users in the absence of the user's historical data to solve the problem in the prior art that accurate personalized recommendations cannot be provided for new users.
[0014] As a preferred embodiment of the first aspect, the obtaining a second candidate item set with a preliminary ranking according to the respective user embedding vectors and respective item embedding vectors is specifically:
[0015] Evaluate the relevance between the keywords and the first candidate item set according to the graph message passing mechanism, the respective user embedding vectors and respective item embedding vectors;
[0016] Rank the first candidate item set according to the Bayesian ranking algorithm, the respective user embedding vectors, the respective item embedding vectors and the relevance, and obtain a second candidate item set with a preliminary ranking.
[0017] In this preferred embodiment, the present application can effectively evaluate the relevance between the keywords input by the user and the first candidate item set by combining the graph message passing mechanism and the Bayesian ranking algorithm. In this process, the graph message passing mechanism is first used to capture the complex interaction between the user embedding vector and the item embedding vector, so as to deeply understand the matching degree between the user preference and the item characteristics. Subsequently, based on these evaluation results, the Bayesian ranking algorithm considers the user embedding vector, the item embedding vector, and the relevance between them, and ranks the first candidate item set to generate a second candidate item set with a preliminary ranking. This ranking method not only improves the accuracy of the recommendation because it combines the user's real-time input and the real-time data of the item, but also enhances the personalization degree of the recommendation result because it can dynamically adapt to the unique preferences of each user, thus solving the cold start problem and significantly improving the user experience and satisfaction.
[0018] As a preferred embodiment of the first aspect, the step of ranking the first candidate item set according to the Bayesian ranking algorithm, each user embedding vector, and the relevance to obtain a second candidate item set with a preliminary ranking is specifically as follows:
[0019] Determine the feature representation of the keyword according to each user embedding vector;
[0020] Calculate the matching degrees between the keyword and each candidate item in the first candidate item set according to the feature representation of the keyword and each item embedding vector;
[0021] Obtain the comprehensive scores of each candidate item in the first candidate item set according to the Bayesian ranking algorithm and the relevance;
[0022] Rank each item in the first candidate item set according to the comprehensive scores to obtain a second candidate item set.
[0023] In this preferred embodiment, the present application determines the feature representation of keyword preferences based on the user's embedding vector, and this step can capture the user's interests and preferences; then, it calculates the matching degree between the keyword preference feature representation and the embedding vectors of each candidate item, so as to evaluate the relevance between the user and each candidate item; then, it uses the Bayesian ranking algorithm and the relevance score to calculate the comprehensive score for each candidate item, and this process takes into account the matching degree between the user and the item and the relevance of the item, ensuring the accuracy of the recommendation; finally, it ranks the candidate items according to the comprehensive score to generate the second candidate item set, and this result directly reflects the order of the items that the user is most likely to be interested in. Through the precise matching of user and item features and the calculation of the comprehensive score, the present application improves the relevance and personalization of the recommendation, effectively solving the cold start problem, that is, even in the absence of user historical data, it can provide high-quality personalized recommendations for new users.
[0024] As a preferred embodiment of the first aspect, the step of inputting the second candidate item set and the keyword into a preset large language model to output a re-ranked third candidate item set is specifically as follows:
[0025] Input the keyword and the second candidate item set into a preset large language model in the zero-shot mode, so that the large language model in the zero-shot mode outputs a re-ranked third candidate item set and a recommendation instruction;
[0026] Among them, the preset large language model in the zero-shot mode can understand and complete the task through the task description without labeled data or examples for a specific task.
[0027] In this preferred embodiment, the present application further optimizes and ranks the candidate item set by inputting the second candidate item set and the keyword into a preset large language model in the zero-shot mode and using the natural language processing and reasoning capabilities of the model. First, the large language model in the zero-shot mode can directly understand and process the keyword and item information in the form of natural language without additional training data or examples, thus reducing the complexity and cost of model training; second, the model can automatically generate a recommendation instruction according to the input keyword and item features. This step not only improves the personalization of the recommendation because it directly considers the user's immediate needs, but also enhances the interpretability of the recommendation because it can provide clear reasons for the recommendation; finally, the output third candidate item set and recommendation instruction provide more accurate and intuitive recommendation results for the user, thus significantly improving the user experience and satisfaction. The present application demonstrates an efficient, flexible and user-friendly recommendation method, which is particularly suitable for recommending new users in cold start scenarios.
[0028] As a preferred embodiment of the first aspect, the step of inputting the keyword and the second candidate item set into a pre-set large language model in zero-shot mode, so that the large language model in zero-shot mode outputs a re-ranked third candidate item set and a recommendation instruction, further includes:
[0029] Obtain each user embedding vector and each item embedding vector;
[0030] Input the user embedding vector and the item embedding vector into a large language model in few-shot mode, so that the large language model in few-shot mode outputs a re-ranked fourth candidate item set.
[0031] In this preferred embodiment, the present application enhances the personalization of recommendations by obtaining user embedding vectors and item embedding vectors and inputting them into a large language model in few-shot mode. The model can learn user preferences based on a small number of samples and output a re-ranked fourth candidate item set. This step takes into account the specific characteristics of users and the subtle differences between items. This method not only solves the cold start problem, that is, it can provide high-quality recommendations even when the user's historical data is insufficient, but also further improves the relevance and user satisfaction of the recommendations through few-shot learning, because the model can quickly adapt to the preferences of new users and provide more accurate personalized recommendations.
[0032] In a second aspect, the present application provides a large model recommendation device based on keyword retrieval. The large model recommendation device based on keyword retrieval includes an acquisition module, a retrieval module, an input-output module, a preliminary ranking module, and a re-ranking module;
[0033] The acquisition module is used to acquire keywords input by the user;
[0034] The retrieval module is used to retrieve a first candidate item set based on user preferences according to the keyword and a pre-set item database;
[0035] The input-output module is used to input the keyword and the first candidate item set into a pre-set deep neural network, and output each user embedding vector and each item embedding vector;
[0036] The preliminary ranking module is used to obtain a preliminarily ranked second candidate item set according to the user embedding vectors and the item embedding vectors;
[0037] The re-ranking module is used to input the second candidate item set and the keyword into a pre-set large language model, and output a re-ranked third candidate item set;
[0038] Obtain the recommendation of the keyword according to the third candidate item set.
[0039] The device uses five modules to divide the work and coordinate with each other, which can better provide personalized recommendations for new users. This application captures the user's immediate interests by directly obtaining the keywords input by the user. This method does not rely on the user's historical data, thus providing a starting point for solving the cold start problem. Then, these keywords are used to retrieve a preliminary set of candidate items from the item database. This step is based on the relevance of the keywords to ensure that even new users can receive relevant recommendations. Next, the keywords are transformed into user and item embedding vectors through a deep neural network. These vectors can represent the characteristics of users and items in the vector space, providing a mathematical basis for personalized recommendations. Further, combining the graph message passing mechanism and the Bayesian ranking algorithm, the set of candidate items is ranked. This step utilizes the user's immediate input and the real-time data of the items, enhancing the personalization and accuracy of the recommendations. Finally, the preliminarily ranked set of candidate items is input into a large language model, and the natural language processing ability of the model is used to re-rank them, ensuring that the recommendation results are not only based on the user's immediate input but also take into account the context information of the items. This application can provide high-quality personalized recommendations for new users in the absence of user historical data to solve the problem in the prior art that accurate personalized recommendations cannot be provided for new users.
[0040] As a preferred embodiment of the second aspect, obtaining the preliminarily ranked second set of candidate items according to the respective user embedding vectors and the respective item embedding vectors specifically includes:
[0041] Evaluating the relevance between the keywords and the first set of candidate items according to the graph message passing mechanism, the respective user embedding vectors, and the respective item embedding vectors;
[0042] Ranking the first set of candidate items according to the Bayesian ranking algorithm, the respective user embedding vectors, the respective item embedding vectors, and the relevance to obtain the preliminarily ranked second set of candidate items.
[0043] In this preferred embodiment, the present application can effectively evaluate the relevance between the keywords input by the user and the first candidate item set by combining the graph message passing mechanism and the Bayesian ranking algorithm. In this process, the graph message passing mechanism is first used to capture the complex interaction between the user embedding vector and the item embedding vector, so as to deeply understand the matching degree between the user preference and the item characteristics. Subsequently, based on these evaluation results, the Bayesian ranking algorithm considers the user embedding vector, the item embedding vector, and the relevance between them, and ranks the first candidate item set to generate a second candidate item set with a preliminary ranking. This ranking method not only improves the accuracy of the recommendation because it combines the user's real-time input and the real-time data of the item, but also enhances the personalization degree of the recommendation result because it can dynamically adapt to the unique preferences of each user, thus solving the cold start problem and significantly improving the user experience and satisfaction.
[0044] As a preferred embodiment of the second aspect, the step of ranking the first candidate item set according to the Bayesian ranking algorithm, each user embedding vector, and the relevance to obtain a second candidate item set with a preliminary ranking is specifically as follows:
[0045] Determine the feature representation of the keyword according to each user embedding vector;
[0046] Calculate the matching degrees between the keyword and each candidate item in the first candidate item set according to the feature representation of the keyword and each item embedding vector;
[0047] Obtain the comprehensive scores of each candidate item in the first candidate item set according to the Bayesian ranking algorithm and the relevance;
[0048] Rank each item in the first candidate item set according to the comprehensive scores to obtain a second candidate item set.
[0049] In this preferred embodiment, the present application determines the feature representation of keyword preferences based on the user's embedding vector. This step can capture the user's interests and preferences. Then, the matching degree between the keyword preference feature representation and the embedding vectors of each candidate item is calculated to evaluate the relevance between the user and each candidate item. Next, using the Bayesian ranking algorithm and the relevance score, a comprehensive score is calculated for each candidate item. This process takes into account the matching degree between the user and the item and the relevance of the item, ensuring the accuracy of the recommendation. Finally, the candidate items are sorted according to the comprehensive score to generate a second set of candidate items. This result directly reflects the order of the items that the user is most likely to be interested in. Through the precise matching of user and item features and the calculation of the comprehensive score, the present application improves the relevance and personalization of the recommendation, effectively solving the cold start problem, that is, even in the absence of user historical data, high-quality personalized recommendations can be provided for new users.
[0050] In a third aspect, the present application provides a computer-readable storage medium. The computer-readable storage medium includes a stored computer program. When the computer program runs, it controls the device where the computer-readable storage medium is located to execute the method for large model recommendation based on keyword retrieval as described above. Its beneficial effects are the same as those of the method for large model recommendation based on keyword retrieval provided in the first aspect of the present application.
[0051] In a fourth aspect, the present application provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements any one of the methods for large model recommendation based on keyword retrieval as described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 : A flowchart of an embodiment of the method for large model recommendation based on keyword retrieval provided by the present application;
[0053] Figure 2 : A flowchart of an embodiment of the large model recommendation process enhanced by keyword retrieval provided by the present application;
[0054] Figure 3 : A schematic structural diagram of an embodiment of the device for large model recommendation based on keyword retrieval provided by the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0055] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without making creative efforts belong to the scope of protection of the present application.
[0056] Embodiment 1
[0057] Please refer to Figure 1 , which is the large model recommendation method based on keyword retrieval provided by the embodiments of the present application.
[0058] In this embodiment, the process of the large model recommendation method based on keyword retrieval in the present application is described in detail through steps S01 - S06.
[0059] S01: Obtain the keywords input by the user.
[0060] S02: According to the keywords and the preset item database, retrieve the first candidate item set based on user preferences.
[0061] As a preferred embodiment of Embodiment 1, the retrieving the first candidate item set based on user preferences according to the keywords and the preset item database is specifically:
[0062] Extract meaningful noun phrases from the collected comments to form a keyword set representing users and items, and use these word sets as queries for cold - start users to obtain potential candidate items, and the potential candidate items are used as the first candidate item set.
[0063] S03: Input the keywords and the first candidate item set into a preset deep neural network, and output each user embedding vector and each item embedding vector.
[0064] As a preferred embodiment of Embodiment 1, the inputting the keywords and the first candidate item set into a preset deep neural network to output each user embedding vector and each item embedding vector is specifically:
[0065] The present application generates embedding vectors of users and candidate items from keyword representations. For the keyword - based content recommendation designed in the present application, the portraits of all users (including cold - start users) are presented in the form of keyword sequences. Among them, the keyword sequence of a given user u is: where T represents the number of keywords of the user, and d is the dimension size of the keyword vectorized by the BERT model. Therefore, the above - mentioned recommendation problem can be abstracted as where f is a learning function for estimating the scores of user and candidate item pairs. Its interaction vector can be estimated by the inner product of p u and q r as follows:
[0066]
[0067] where u represents a user in the recommendation system, r represents a candidate item in the recommendation system, p u is the latent vector representation of user u, and q r is the latent vector representation of item r. Then, the representations of user and candidate item portraits are learned through an attention-based set pooling strategy, which is G(E u ), and it is defined as follows:
[0068]
[0069] where σ represents the softmax layer, is a trainable parameter. G(E u ) is the dot product attention mechanism, where the key and value correspond to the same representation, and the query is only a trainable parameter. Therefore, G(E u ) represents the weighted average of the feature encoding sequence. Among them, the learned entity features should be able to fully represent the user portrait.
[0070] To further optimize the proposed method, this application uses Bayesian personalized ranking for prediction, where r p is the candidate item liked by user u, so the optimization of the model is as follows.
[0071]
[0072] where, represents the relationship between user u and items r p and r n , σ is the sigmoid function; λ Θ is the model regularization parameter. For the inference process, similar to the model training process, both stages involve encoding the keyword set.
[0073] S04: Obtain a second set of candidate items with preliminary ranking according to the respective user embedding vectors and respective item embedding vectors.
[0074] As a preferred embodiment of Embodiment 1, the obtaining of the second set of candidate items with preliminary ranking according to the respective user embedding vectors and respective item embedding vectors is specifically:
[0075] Using content-based recommendation solutions cannot provide satisfactory embeddings for collaborative filtering prediction. Its main drawback is that the embedding function fails to encode the important collaborative signals hidden in the "keyword-candidate item" and "keyword-user" interactions. Drawing on the structured information of LightGCN, this application proposes a model based on a triple graph structure (user-keyword-candidate item). Two types of edges are established in the training data: (user-keyword) and (keyword-candidate item). When a user views the comments of a certain candidate item using a keyword, if the keyword is included in the comments, a connection is established at the edge of the graph, and the following node information is generated through information transmission between nodes.
[0076] q r = AGG(q w , w∈k r );
[0077] where w is the keyword used by the user during the query, k r is the set of comments of the candidate item, q w is the neighboring node information, and AGG is a function that aggregates information from neighboring nodes, which also applies to q w .
[0078] Since the number of graph nodes may be extremely large (even reaching millions), this application proposes an unsupervised learning model to achieve information processing. Based on a simple weighted sum information aggregator (AGG), which is similar to the representation method of LightGCN, the selection of parameter weights can be achieved without training. For candidate item nodes, the generation of messages is updated by multiplying the information of keyword nodes by the weights of the edges and then summing all the messages, as follows:
[0079]
[0080] where e w represents the embedding feature of the keyword node, while represents the connection between the keyword node w and the candidate item node r. Specifically, the edge between the keyword and the candidate item can represent the importance of the keyword to the candidate item, denoted as
[0081] Furthermore, this application also introduces a TF-IRF solution, similar to the TF-IDF algorithm, to measure the importance of keywords to candidate items. The edge weight between the candidate item and the keyword w is denoted as s w r, and its definition is as follows:
[0082]
[0083] where Denote the number of times keyword w appears in the keyword set of candidate item r, q w is the total number of times this word appears in the entire training data, f w Denote the number of candidate items containing the word w. Therefore, the scoring matrix S for all candidate items can be defined in the following matrix form:
[0084]
[0085] where denotes the connection matrix between cold-start users and their selected keywords. Then, the top k candidate items that may be recommended are selected through the following formula.
[0086] C k = argmax(S);
[0087] The above method does not require training and only needs to construct a graph to achieve the final prediction. If the keywords selected by cold-start users do not exist in the training data, this application replaces them with the semantically closest keywords. For this purpose, this application uses a pre-trained BERT model to vectorize all keywords and ensures that semantically similar keywords are adjacent to each other. Among them, the closest keywords are searched through the nearest neighbor model.
[0088] Furthermore, the graph message passing mechanism of this application aims to allow nodes to exchange information and update their own feature representations based on the message passing mechanism in the graph neural network, where each node generates a message according to the information of its neighbor nodes, and then aggregates these messages and updates its own state, including the message generation, message aggregation, and node update processes.
[0089] The Bayesian ranking algorithm of this application aims to perform ranking by calculating the conditional probability of each item based on Bayes' theorem. This algorithm assumes that features are independent of each other and uses the prior probability and conditional probability to calculate the posterior probability, thereby ranking the items.
[0090] S05: Input the second candidate item set and the keywords into a preset large language model, and output a re-ranked third candidate item set.
[0091] As a preferred embodiment of Embodiment 1, the inputting the second candidate item set and the keywords into a preset large language model and outputting a re-ranked third candidate item set is specifically:
[0092] Input the second candidate item set and the keywords into the preset large language model by designing a prompt template, and the designed prompt template is as follows.
[0093] Prompt template T:
[0094] Suppose you are a recommendation system in the e-commerce field. The recommendation mode is: H;
[0095] Input: Please recommend 10 items that are most suitable for me from the candidate set based on the user information and candidate item keywords I provided. I will purchase the above items.
[0096] Output: It must include the IDs of 10 items in the candidate item set, rather than keywords. The format is a string: item_id_1,item_id_2,...
[0097] This application uses a large language model to re-rank candidate items for each user and combines natural language instructions. By leveraging its reasoning and generation capabilities, user information and candidate item information are incorporated into the instructions, enabling the LLM to understand user preferences. Similar to retrieval models, user and item information is represented by keywords. This application adds statements to the prompt template to trigger the recommendation function of the LLM and describe the task instructions to the model.
[0098] This application proposes a general item recommendation prompt framework based on keywords, including: (1) user keywords; (2) the second candidate item set; (3) the item keyword set. This prompt framework is defined as [H z and [H f , representing the zero-shot and few-shot modes respectively.
[0099] Furthermore, it also includes:
[0100] (1) Zero-shot paradigm
[0101] This application provides meaningful keywords that can best describe the user's interests, as well as keywords related to the items. These keywords are sorted according to their importance to the user and the items. By leveraging pre-trained knowledge, the large model can capture the user's interests and the characteristics of the candidate items. Among them, this application can first adopt the Zero-shot zero-sample technology to give zero-sample prompts to the large model, that is, instead of giving specific example prompts to the large model, only give an overview requirement prompt. Therefore, the zero-sample prompt mode [H z can be represented as follows.
[0102] Mode: Zero-shot paradigm [H z ;
[0103] These are the keywords I often mention when selecting candidate items: {user keywords}.
[0104] The candidate item set is enclosed in square brackets and the item IDs are separated by commas (format: [item_id_1,item_id_2,...]): {candidate item set};
[0105] The keywords related to the candidate items are in the following format: item_id_1 (keyword 1, keyword 2,...) belongs to {item key words sets}.
[0106] Since large language models are trained based on a large amount of rich information and datasets, zero-shot prompting requires meaningful keywords to process information and provide high-quality re-ranking results. When given user-related keywords, the large model can understand and predict the user's interests. Similarly, the large model can also understand the characteristics of the items and recommend the most relevant candidate items to the user based on the provided keywords.
[0107] (2) Few-shot prompting paradigm
[0108] Similar to human reasoning ability, the large model can better understand human intentions and the required answers through a few good examples. Therefore, few-shot learning often performs better than zero-shot. The following is an example of re-ranking prompts.
[0109] Pattern: Few-shot prompt [H f ;
[0110] The following are some example references.
[0111] # Repeat for i ∈ {1,..., k}:
[0112] Example i:
[0113] These are the keywords that users often mention when selecting items: {user keywords}.
[0114] The candidate item set is enclosed in square brackets and the item IDs are separated by commas (format: [item_id_1, item_id_2,...]): {candidate item set};
[0115] The keywords related to the candidate items are in the following format: item_id_1 (keyword 1, keyword 2,...) belongs to {item keywords sets}.
[0116] The items should be recommended to the user for ranking as follows: {item_id_1, item_id_2,...};
[0117] Few-shot prompt [H f contains [H zTake the examples and information in [[ ]] and fill them into the template. In the prompts of this application, the keyword candidates are arranged in order to preserve the order of the retrieval model, which is based on the TF-IRF score. The examples are from users in the training set. For each example, the candidates are selected based on the number of overlaps with the selected user keywords. For the candidate set of each user, the final sorted list is obtained by sorting the scores of the candidate items.
[0118] S06: Obtain the recommendation of the keyword according to the third candidate item set.
[0119] The cold user startup project of this application is as Figure 2 As shown, the framework of the method proposed in this application includes two main stages: candidate retrieval and candidate re-ranking based on large language models. In the first stage, this application uses a keyword-driven retrieval model to identify potential candidates, which not only effectively solves the limitations of large language models in processing large amounts of text but also reduces the risk of generating misleading information. In the second stage, this application uses various prompting strategies of large language models (including zero-shot and few-shot methods) to re-rank the candidates and directly embeds multiple examples into the prompts to improve the model performance. Through actual comparative experiments, it is shown that the method proposed in this application can significantly improve the recommendation quality, especially in the re-ranking stage, the large language model combined with context instructions greatly enhances the effect of cold-start user recommendations.
[0120] This application captures the user's immediate interests by directly obtaining the keywords input by the user. This method does not rely on the user's historical data, thus providing a starting point for solving the cold-start problem. Then, these keywords are used to retrieve a preliminary set of candidate items from the item database. This step is based on the relevance of the keywords to ensure that even new users can receive relevant recommendations. Then, the keywords are transformed into embedding vectors of users and items through a deep neural network. These vectors can represent the characteristics of users and items in the vector space, providing a mathematical basis for personalized recommendations. Further, combining the graph message passing mechanism and the Bayesian ranking algorithm, the set of candidate items is sorted. This step utilizes the user's immediate input and the real-time data of the items, enhancing the personalization and accuracy of the recommendation. Finally, the preliminarily sorted set of candidate items is input into a large language model, and the natural language processing ability of the model is used for re-ranking to ensure that the recommendation results are not only based on the user's immediate input but also take into account the context information of the items. This application can provide high-quality personalized recommendations for new users in the absence of user historical data to solve the problem in the prior art that accurate personalized recommendations cannot be provided for new users.
[0121] Embodiment 2
[0122] Please refer to Figure 3, which is a large model recommendation device provided by an embodiment of the present application based on keyword retrieval.
[0123] In this embodiment, the large model recommendation device based on keyword retrieval includes an acquisition module 10, a retrieval module 20, an input / output module 30, a preliminary sorting module 40, and a re-sorting module 50.
[0124] The acquisition module 10 is used to acquire keywords input by the user.
[0125] The retrieval module 20 is used to retrieve a first candidate item set based on user preferences according to the keywords and a preset item database.
[0126] As a preferred embodiment of the second embodiment, the retrieving a first candidate item set based on user preferences according to the keywords and a preset item database is specifically:
[0127] Extract meaningful noun phrases from the collected comments to form a keyword set representing users and items, and use these word sets as queries for cold-start users to obtain potential candidate items, and the potential candidate items are used as the first candidate item set.
[0128] The input / output module 30 is used to input the keywords and the first candidate item set into a preset deep neural network, and output respective user embedding vectors and respective item embedding vectors.
[0129] As a preferred embodiment of the second embodiment, the inputting the keywords and the first candidate item set into a preset deep neural network, and outputting respective user embedding vectors and respective item embedding vectors is specifically:
[0130] The present application generates embedding vectors of users and candidate items from keyword representations. For the keyword-based content recommendation designed by the present application, the portraits of all users (including cold-start users) are presented in the form of keyword sequences. Among them, the keyword sequence of a given user u is: where T represents the number of keywords of the user, and d is the dimension size of the keywords vectorized by the BERT model. Therefore, the above recommendation problem can be abstracted as where f is a learning function for estimating the score of the user-candidate item pair. Its interaction vector can be estimated by the inner product of p u and q r as follows:
[0131]
[0132] where u represents a certain user in the recommendation system, r represents a certain candidate item in the recommendation system, and p u is the latent vector representation of user u, and qr is the potential vector representation of project r. Then, the representations of the user and candidate project portraits are learned through an attention-based set pooling strategy, which is G(E u ), and it is defined as follows:
[0133]
[0134] where σ represents the softmax layer, is a trainable parameter. G(E u ) is the dot product attention mechanism, where the key and value correspond to the same representation, and the query is only a trainable parameter. Therefore, G(E u ) represents the weighted average of the feature encoding sequence. Among them, the learned entity features should be able to fully represent the user portrait.
[0135] To further optimize the proposed method, this application uses Bayesian personalized ranking for prediction, where r p is the candidate project liked by user u. Therefore, the optimization of the model is as follows.
[0136]
[0137] where, represents the relationship between user u and projects r p and r n , σ is the sigmoid function; λ Θ is the model regularization parameter. For the inference process, similar to the model training process, both stages involve encoding the keyword set.
[0138] Furthermore, the graph message passing mechanism of this application aims to allow nodes to exchange information and update their own feature representations based on the message passing mechanism in the graph neural network. Each node generates a message based on the information of its neighbor nodes, and then aggregates these messages and updates its own state, including the message generation, message aggregation, and node update processes.
[0139] The Bayesian ranking algorithm of this application aims to perform ranking by calculating the conditional probability of each project based on Bayes' theorem. This algorithm assumes that the features are independent of each other, and uses the prior probability and conditional probability to calculate the posterior probability, so as to rank the projects.
[0140] The preliminary ranking module 40 is used to obtain the second candidate project set with preliminary ranking according to the respective user embedding vectors and respective project embedding vectors.
[0141] As a preferred embodiment of the second embodiment, the obtaining of the second candidate project set with preliminary ranking according to the respective user embedding vectors and respective project embedding vectors is specifically:
[0142] Using content-based recommendation solutions cannot provide satisfactory embeddings for collaborative filtering prediction. Its main drawback is that the embedding function cannot encode the important collaborative signals hidden in the "keyword-candidate item" and "keyword-user" interactions. Drawing on the structured information of LightGCN, this application proposes a model based on a tripartite graph structure (user-keyword-candidate item). Two types of edges are established in the training data: (user-keyword) and (keyword-candidate item). When a user views the comments of a candidate item using a keyword, if the keyword is included in the comments, a connection is established at the edge of the graph, and the following node information is generated through information transmission between nodes.
[0143] q r = AGG(q w , w ∈ k r );
[0144] where w is the keyword used by the user during the query, k r is the set of comments of the candidate item, q w is the neighbor node information, and AGG is a function that aggregates information from neighboring nodes and also applies to q w .
[0145] Since the number of graph nodes may be extremely large (even reaching millions), this application proposes an unsupervised learning model to implement information processing. Based on a simple weighted sum information aggregator (AGG), which is similar to the representation method of LightGCN, the selection of parameter weights can be achieved without training. For candidate item nodes, the generation of messages is updated by multiplying the information of keyword nodes by the weights of the edges and then summing all the messages, as follows:
[0146]
[0147] where e w represents the embedding feature of the keyword node, while represents the connection between the keyword node w and the candidate item node r. Specifically, the edge between the keyword and the candidate item can represent the importance of the keyword to the candidate item, denoted as
[0148] Furthermore, this application also introduces a TF-IRF solution, similar to the TF-IDF algorithm, to measure the importance of keywords to candidate items. The edge weight between the candidate item and the keyword w is denoted as s w r, and its definition is as follows:
[0149]
[0150] Among them, represents the number of times the keyword w appears in the keyword set of the candidate item r, and q w is the total number of occurrences of this word in the entire training data, and f w represents the number of candidate items containing the word w. Therefore, the scoring matrix S of all candidate items can be defined in the following matrix form:
[0151]
[0152] Among them, represents the connection matrix between the cold-start user and their selected keywords. Then, the top k candidate items that may be recommended are selected through the following formula.
[0153] C k = argmax(S);
[0154] The above method does not require training and only needs to construct a graph to achieve the final prediction. If the keywords selected by the cold-start user do not exist in the training data, the present application replaces them with the semantically closest keywords. For this purpose, the present application uses a pre-trained BERT model to vectorize all keywords and ensures that semantically similar keywords are adjacent to each other. Among them, the closest keywords are searched through the nearest neighbor model.
[0155] The re-ranking module 50 is used to input the second candidate item set and the keywords into a preset large language model, and output a re-ranked third candidate item set.
[0156] As a preferred embodiment of the second embodiment, the inputting the second candidate item set and the keywords into a preset large language model to output a re-ranked third candidate item set is specifically:
[0157] By designing a prompt template to input information into the large language model, the designed prompt template is as follows.
[0158] Prompt template T:
[0159] Suppose you are a recommendation system in the e-commerce field. The recommendation mode is: H;
[0160] Input: Please recommend 10 items that are most suitable for me from the candidate set based on the user information and candidate item keywords I provide. I will purchase the above items.
[0161] Output: It must include the IDs of 10 items in the candidate item set, rather than keywords. The format is a string: item_id_1,item_id_2,...
[0162] This application uses a large language model to re-rank candidate items for each user and combines natural language instructions. By leveraging its reasoning and generation capabilities, user information and candidate item information are incorporated into the instructions, enabling the LLM to understand user preferences. Similar to retrieval models, user and item information is represented by keywords. This application adds statements to the prompt template to trigger the recommendation function of the LLM and describe the task instructions to the model.
[0163] This application proposes a general item recommendation prompt framework based on keywords, including: (1) user keywords; (2) the second candidate item set; (3) the item keyword set. This prompt framework is defined as [H z and [H f , representing the zero-shot and few-shot modes respectively.
[0164] Furthermore, it also includes:
[0165] (1) The zero-shot paradigm
[0166] This application provides meaningful keywords that can best describe the user's interests and keywords related to the items. These keywords are ranked according to their importance to the user and the items. By leveraging pre-trained knowledge, the large model can capture the user's interests and the characteristics of the candidate items. Among them, this application can first adopt the Zero-shot zero-shot technology to give zero-shot prompts to the large model, that is, instead of giving specific example prompts to the large model, only general requirements prompts are given. Therefore, the zero-shot prompt mode [H z can be represented as follows.
[0167] Mode: The zero-shot paradigm [H z ;
[0168] These are the keywords I often mention when selecting candidate items: {user keywords}.
[0169] The candidate item set is enclosed in square brackets and the item IDs are separated by commas (format: [item_id_1,item_id_2,...]): {candidate item set};
[0170] The keywords related to the candidate items are in the following format: item_id_1(keyword 1,keyword 2,...) belongs to {item key words sets}.
[0171] Since large language models are trained based on a large amount of rich information and datasets, zero-shot prompting requires meaningful keywords to process information and provide high-quality re-ranking results. When given user-related keywords, the large model can understand and predict the user's interests. Similarly, the large model can also understand the characteristics of the project and recommend the candidate items most relevant to the user based on the provided keywords.
[0172] (2) Few-shot prompting paradigm
[0173] Similar to human reasoning ability, the large model can better understand human intentions and the required answers through a few good examples. Therefore, few-shot learning often performs better than zero-shot. Shown below are examples of re-ranking prompts.
[0174] Pattern: Few-shot prompt [H f ;
[0175] The following are some example references.
[0176] # Repeat i ∈ {1,..., k}:
[0177] Example i:
[0178] These are the keywords that users often mention when selecting items: {user keywords}.
[0179] The candidate item set is enclosed in square brackets and the item IDs are separated by commas (format: [item_id_1, item_id_2,...]): {candidate item set};
[0180] The keywords related to the candidate items are in the following format: item_id_1 (keyword 1, keyword 2,...) belongs to {item keywords sets}.
[0181] The recommended ranking for the user should be as follows: {item_id_1, item_id_2,...};
[0182] Few-shot prompt [H f contains the examples and information in [H z and fills them into the template. In the prompts of this application, the keyword candidates are arranged in order to preserve the order of the retrieval model, which is based on the TF-IRF score. The examples are from users in the training set. For each example, the candidates are selected based on the number of overlaps with the selected user keywords. For each user's candidate set, the final sorted list is obtained by sorting the scores of the candidate items.
[0183] The reordering module 50 is further configured to obtain the recommendation of the keyword according to the third candidate item set.
[0184] The cold user startup items of this application are as Figure 2 As shown, the framework of the method proposed in this application includes two main stages: candidate retrieval and candidate reordering based on large language models. In the first stage, this application uses a keyword-driven retrieval model to identify potential candidates, which not only effectively solves the limitations of large language models in processing large amounts of text but also reduces the risk of generating misleading information. In the second stage, this application uses various prompting strategies of large language models (including zero-shot and few-shot methods) to reorder the candidates and directly embeds multiple examples into the prompt to improve the model's performance. Through actual comparative experiments, it is shown that the method proposed in this application can significantly improve the recommendation quality, especially in the reordering stage, the large language model combined with context instructions greatly enhances the effect of cold-start user recommendations.
[0185] This application captures the user's immediate interests by directly obtaining the keywords input by the user. This method does not rely on the user's historical data, thus providing a starting point for solving the cold-start problem. Then, these keywords are used to retrieve a preliminary set of candidate items from the item database. This step is based on the relevance of the keywords to ensure that even new users can receive relevant recommendations. Then, the keywords are transformed into embedding vectors of users and items through a deep neural network. These vectors can represent the characteristics of users and items in the vector space, providing a mathematical basis for personalized recommendations. Further, combining the graph message passing mechanism and the Bayesian ranking algorithm, the set of candidate items is sorted. This step utilizes the user's immediate input and the real-time data of the items to enhance the personalization and accuracy of the recommendation. Finally, the preliminarily sorted set of candidate items is input into a large language model, and the natural language processing ability of the model is used for reordering to ensure that the recommendation results are not only based on the user's immediate input but also take into account the context information of the items. This application can provide high-quality personalized recommendations for new users in the absence of the user's historical data to solve the problem in the prior art that accurate personalized recommendations cannot be provided for new users.
[0186] Embodiment 3:
[0187] The embodiment of this application provides a computer-readable storage medium. The computer-readable storage medium includes a stored computer program, wherein when the computer program runs, it controls the device where the computer-readable storage medium is located to execute the above-mentioned large model recommendation method based on keyword retrieval;
[0188] Among them, for the large model recommendation method based on keyword retrieval, when it is implemented in the form of software functional units and used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, to implement all or part of the processes in the above-mentioned embodiment methods of the present invention, it can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal, and software distribution medium, etc.
[0189] Embodiment 4
[0190] This application provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements any one of the large model recommendation methods based on keyword retrieval as described in Embodiment 1.
[0191] The above-mentioned specific embodiments have further elaborated on the purpose, technical solutions, and beneficial effects of this application. It should be understood that the above are only specific embodiments of this application and are not used to limit the protection scope of this application. It is particularly pointed out that for those skilled in the art, any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A large model recommendation method based on keyword retrieval, characterized in that: include: Get the keywords entered by the user; Retrieving a first set of candidate items based on user preferences according to the keywords and a preset item database; Inputting the keywords and the first candidate item set into a preset deep neural network, and outputting each user embedding vector and each item embedding vector; Obtaining a preliminarily ranked second candidate item set according to each user embedding vector and each item embedding vector; Inputting the second candidate item set and the keywords into a preset large language model, and outputting a re-ranked third candidate item set; The keyword recommendation is obtained according to the third candidate item set.
2. The large model recommendation method based on keyword retrieval according to claim 1 is characterized in that: The step of obtaining a preliminarily sorted second candidate item set according to each user embedding vector and each item embedding vector is specifically as follows: According to the graph message passing mechanism, the respective user embedding vectors and the respective item embedding vectors, evaluating and obtaining the correlation between the keyword and the first candidate item set; The first candidate item set is sorted according to the Bayesian sorting algorithm, each user embedding vector, each item embedding vector and the correlation to obtain a preliminarily sorted second candidate item set.
3. The large model recommendation method based on keyword retrieval according to claim 2 is characterized in that: The first candidate item set is sorted according to the Bayesian sorting algorithm, each user embedding vector and the correlation to obtain a preliminarily sorted second candidate item set, specifically: Determining a feature representation of the keyword according to each user embedding vector; Calculating, based on the feature representation of the keyword and the embedding vectors of the respective items, respective matching degrees between the keyword and respective candidate items in the first candidate item set; Obtaining comprehensive scores of the candidate items in the first candidate item set according to the Bayesian ranking algorithm and the correlation; According to the comprehensive scores, the items in the first candidate item set are sorted to obtain a second candidate item set.
4. The large model recommendation method based on keyword retrieval according to any one of claims 1 to 3, characterized in that: The step of inputting the second candidate item set and the keywords into a preset large language model and outputting a re-ordered third candidate item set is specifically: Inputting the keywords and the second candidate item set into a preset large language model in zero-shot mode, so that the large language model in zero-shot mode outputs a re-ordered third candidate item set and a recommendation instruction; The preset large language model in zero-shot mode can understand and complete tasks through task descriptions without labeled data or examples for specific tasks.
5. The large model recommendation method based on keyword retrieval according to claim 4 is characterized in that: The step of inputting the keywords and the second candidate item set into a preset large language model in zero-shot mode, so that the large language model in zero-shot mode outputs a re-ordered third candidate item set and a recommendation instruction, further includes: Get the embedding vectors of each user and each item; The user embedding vector and the item embedding vector are input into a large language model in a few-shot mode, so that the large language model in the few-shot mode outputs a re-ranked fourth candidate item set.
6. A large model recommendation device based on keyword retrieval, characterized in that: It includes an acquisition module, a retrieval module, an input and output module, a preliminary sorting module and a re-sorting module; The acquisition module is used to obtain keywords input by users; The retrieval module is used to retrieve a first candidate project set based on user preferences according to the keywords and a preset project database; The input-output module is used to input the keywords and the first candidate item set into a preset deep neural network, and output each user embedding vector and each item embedding vector; The preliminary sorting module is used to obtain a preliminary sorted second candidate item set according to each user embedding vector and each item embedding vector; The reordering module is used to input the second candidate item set and the keywords into a preset large language model, and output a reordered third candidate item set; The keyword recommendation is obtained according to the third candidate item set.
7. The large model recommendation device based on keyword retrieval according to claim 6 is characterized in that: The step of obtaining a preliminarily sorted second candidate item set according to each user embedding vector and each item embedding vector is specifically as follows: According to the graph message passing mechanism, the respective user embedding vectors and the respective item embedding vectors, evaluating and obtaining the correlation between the keyword and the first candidate item set; The first candidate item set is sorted according to the Bayesian sorting algorithm, each user embedding vector, each item embedding vector and the correlation to obtain a preliminarily sorted second candidate item set.
8. The large model recommendation device based on keyword retrieval according to claim 7 is characterized in that: The first candidate item set is sorted according to the Bayesian sorting algorithm, each user embedding vector and the correlation to obtain a preliminarily sorted second candidate item set, specifically: Determining a feature representation of the keyword according to each user embedding vector; Calculating, based on the feature representation of the keyword and the embedding vectors of the respective items, respective matching degrees between the keyword and respective candidate items in the first candidate item set; Obtaining comprehensive scores of the candidate items in the first candidate item set according to the Bayesian ranking algorithm and the correlation; According to the comprehensive scores, the items in the first candidate item set are sorted to obtain a second candidate item set.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the large model recommendation method based on keyword retrieval as described in any one of claims 1 to 5.
10. A terminal device, characterized in that: It includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, it implements the large model recommendation method based on keyword retrieval as described in any one of claims 1 to 5.