Intelligent agent construction method and system for large model and intelligent recommendation
By building an agent based on a large language model, combining the Milvus vector database and feedback learning mechanism, the problem that the intelligent recommendation system cannot understand complex user needs is solved, personalized and interpretable recommendations are realized, and user experience and system flexibility is improved.
Patent Information
- Application Number
- CN202510765642.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-07-08
- Estimated Expiration
- 2045-06-10
AI Technical Summary
The existing intelligent recommendation system cannot understand complex user needs, lacks task planning and decision-making capabilities, poor recommendation interpretation, lacks continuous optimization mechanisms, and is difficult to meet the changing needs of users.
Build an agent based on a large language model, combine it with the Milvus vector database to realize the memory mechanism, recommendation mechanism and feedback learning mechanism, store and recommend data through the combination of long and short-term memory, use nearest neighbor search and reward functions for personalized recommendation, and use virtual digital people to perform voice interaction.
It realizes efficient task decomposition and processing of user needs, provides personalized and interpretable recommendations, can dynamically adjust recommendation strategies, and improve user experience and trust.
Smart Images

Figure CN120277272A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent recommendation, and particularly to a method and system for constructing an intelligent agent for large models and intelligent recommendation. Background Art
[0002] Currently, intelligent recommendation systems are widely used in various fields, such as e-commerce, social media, music, and video platforms. These systems recommend relevant content to users based on their interests, behaviors, and preferences, thereby improving the user experience and user stickiness of the platform. However, the existing intelligent recommendation systems mainly have the following problems:
[0003] 1. Unable to understand complex user needs: Traditional recommendation systems usually recommend based on users' historical behaviors and preferences, and it is difficult to understand and process users' complex needs and personalized preferences.
[0004] 2. Lack of task planning and decision-making capabilities; Traditional recommendation systems lack task planning and decision-making capabilities and are unable to perform effective task decomposition and resource allocation according to users' needs.
[0005] 3. Poor recommendation interpretability: Traditional recommendation systems usually do not provide recommendation explanations, and it is difficult for users to understand the basis of the recommendation results, reducing users' trust in the recommendation system.
[0006] 4. Lack of a continuous optimization mechanism: Traditional recommendation systems lack a continuous optimization mechanism and are difficult to dynamically adjust the recommendation strategy according to user feedback, resulting in the recommendation results being difficult to meet the ever-changing needs of users.
[0007] To solve the above problems, the present invention proposes a method for constructing an intelligent agent for large models and intelligent recommendation, as well as an application system of the constructed intelligent agent, aiming to construct an intelligent recommendation agent that can understand and process complex user needs, perform task planning, and use tools such as recommendation systems, thereby realizing a more accurate, personalized, and interpretable intelligent recommendation service. Summary of the Invention
[0008] The object of the present invention is to provide a method and system for constructing an intelligent agent for large models and intelligent recommendation, which uses a large language model to construct an intelligent recommendation agent that can understand and process complex user needs, perform task planning, and use tools such as recommendation systems.
[0009] To achieve the above object, on the one hand, the present invention provides a method for constructing an intelligent agent for large models and intelligent recommendation, including:
[0010] Constructing a basic intelligent agent based on a large language model based on prompt engineering;
[0011] Construct a memory mechanism and a recommendation mechanism based on the Milvus vector database and the large language model, and construct a feedback learning mechanism based on the recommendation mechanism;
[0012] Embed the memory mechanism, the recommendation mechanism, and the feedback learning mechanism into the basic intelligent agent to construct an intelligent agent, where the input of the intelligent agent is user information and the output is a recommendation list and a recommendation explanation.
[0013] Optionally, constructing the memory mechanism includes:
[0014] Construct long-term memory based on the Milvus vector database and construct short-term memory based on the context of the large language model, where constructing the long-term memory includes:
[0015] Obtain user and item data and perform preprocessing, where the user and item data includes user data, item data, and user-item interaction data;
[0016] Extract features from the preprocessed user and item data, and perform vectorization processing on the extracted features and the behavior and results of the intelligent agent in each recommendation task to obtain vector data;
[0017] Store the vector data in the Milvus vector database and establish an index to complete the storage of long-term memory.
[0018] Optionally, constructing the recommendation mechanism includes:
[0019] Use the nearest neighbor search function of the Milvus vector database to screen the top n recommendations with the highest similarity to the user vector data;
[0020] Sort and screen the recommendations to obtain a recommendation list, and generate a recommendation explanation based on the user information and the recommendation list.
[0021] Optionally, constructing the feedback learning mechanism includes:
[0022] Collect the feedback behavior of the user on the recommendation list;
[0023] Evaluate the feedback behavior through a reward function to obtain the user satisfaction and store it as historical experience, and add it to the next recommendation task.
[0024] Optionally, the reward function assigns values to the user feedback behavior, takes the mean of several behavior assignments, and determines the user satisfaction corresponding to the mean through a preset satisfaction interval.
[0025] To further achieve the above objectives, on the other hand, the present invention also provides an intelligent agent application system for large models and intelligent recommendations, which is implemented based on the intelligent agent constructed by the above method, and includes:
[0026] A user request module, configured to receive a user request and perform format conversion on the user request;
[0027] A task planning module, configured to perform task decomposition and planning based on the user request after format conversion to obtain task information;
[0028] An intelligent recommendation module, configured to input the task information into an intelligent agent and output a recommendation list and recommendation explanations;
[0029] A memory storage module, configured to record the intelligent agent work logs, including previous behaviors and external knowledge, as well as interaction records with users.
[0030] Optionally, the system realizes the reception of requests and the output of recommendation results by performing voice interaction with the user.
[0031] Optionally, the system adopts the form of a virtual digital human, and the virtual digital human is designed and generated through 3Dmax by collecting the user's voice information and body information.
[0032] The beneficial effects of the present invention are as follows:
[0033] A method and system for constructing an intelligent agent for large models and intelligent recommendation provided by the present invention can efficiently decompose and process the user's recommendation instructions; can realize the effective storage and fast access of data by the intelligent agent through the combination of long-term memory and short-term memory; can enhance the relevance and personalization of recommendations through intelligent recommendation and provide recommendation explanations that cannot be provided by traditional recommendation systems; an effective feedback learning mechanism can dynamically adjust the recommendation strategy according to the user's language and behavior feedback to achieve continuous optimization of intelligent recommendation; the present invention integrates a large model and a recommendation system to construct an intelligent agent capable of performing complex recommendation tasks and its application system, realizing the purpose of completing recommendations in the form of a dialogue between the user and the intelligent agent and providing recommendation explanations. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0035] Figure 1 It is a flowchart of a method for constructing an intelligent agent for large models and intelligent recommendation according to an embodiment of the present invention;
[0036] Figure 2 It is a flowchart of a feedback learning mechanism according to an embodiment of the present invention;
[0037] Figure 3 It is the flowchart of the voice interaction operation in the embodiment of the present invention;
[0038] Figure 4 It is the flowchart of the intelligent agent application of the large model and intelligent recommendation in the embodiment of the present invention. Specific implementation manners
[0039] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0040] To make the above objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific implementation manners.
[0041] On the one hand, this embodiment provides a method for constructing an intelligent agent of a large model and intelligent recommendation, as Figure 1 shown, including:
[0042] Constructing a basic intelligent agent based on a large language model based on prompt engineering;
[0043] Constructing a memory mechanism and a recommendation mechanism based on the Milvus vector database and the large language model, and constructing a feedback learning mechanism based on the recommendation mechanism;
[0044] Embedding the memory mechanism, the recommendation mechanism, and the feedback learning mechanism into the basic intelligent agent to construct an intelligent agent, where the input of the intelligent agent is user information, and the output is a recommendation list and a recommendation explanation.
[0045] Further, constructing a basic intelligent agent based on a large language model based on prompt engineering includes:
[0046] Using the Prompt Chaining technology to construct an intelligent agent based on a large language model. Its core idea is to decompose a large problem into a series of smaller and more specific sub-problems. After determining the sub-tasks, the prompt words of the sub-tasks are provided to the language model, and the obtained result is used as part of the new prompt words, which can enable the large model to complete very complex tasks;
[0047] The specific steps include: determining the overall task of the agent, that is, understanding and responding to user needs, providing personalized services and continuously optimizing the user experience by integrating data and making intelligent recommendations; decomposing the overall task, that is, dividing it into the agent waiting for user recommendation instructions, calling the recommendation system, the agent providing recommendation explanations, and the agent executing the feedback learning mechanism; designing initial prompt words for the three subtasks of the agent waiting for user recommendation instructions, the agent providing recommendation explanations, and the agent executing the feedback learning mechanism; sequentially replacing and running the prompt words of the large language model for the above subtasks, and integrating the output of each subtask into the prompt words of the next task until all subtasks are completed.
[0048] Further, constructing the memory mechanism includes:
[0049] Constructing long-term memory based on the Milvus vector database and short-term memory based on the context of the large language model. Among them, constructing long-term memory includes:
[0050] Obtaining user and item data and performing preprocessing. Among them, user and item data include user data, item data, and user-item interaction data;
[0051] Performing feature extraction on the preprocessed user and item data, and vectorizing the extracted features as well as the behavior and results of the agent in each recommendation task to obtain vector data;
[0052] Storing the vector data in the Milvus vector database and establishing an index to complete the storage of long-term memory.
[0053] Specifically, performing data preprocessing on user data, item data, and user-item interaction data, including removing noise, handling missing values, etc.; user feature extraction methods include user activity, matrix factorization, etc., and the calculation formulas are as follows:
[0054] ;
[0055] Among them, represents the set of users ; represents the interaction set of the th item, represents the number of items;
[0056] Matrix factorization decomposes the user-item rating matrix R into two low-dimensional matrices and , is the user latent factor, is the item latent factor. Through the user's historical behavior, represented by explicit ratings, the matching relationship between user interests and item attributes is mined:
[0057] ;
[0058] Among them, represents the transposed matrix of the potential factor of the i-th item, is the user-item rating matrix.
[0059] For text data, the BertTokenizer and BertModel in the transformers library are used for word segmentation and encoding to obtain the output vector of the BERT model. The steps for word segmentation based on BertTokenizer include:
[0060] 1) Split the original text content into atomic-level tokens, such as individual Chinese characters:
[0061] ;
[0062] Among them, tokenize represents the word segmentation method provided by BertTokenizer; text represents the original text content; represents the th token, .
[0063] 2) Map the tokens to their corresponding integer IDs. The basic principle is as follows:
[0064] ;
[0065] Among them, dict represents the vocabulary after pre-training of BertTokenizer; [CLS] represents the sentence start marker; [SEP] represents the sentence end / separator marker.
[0066] Secondly, the steps for encoding based on BertModel include:
[0067] 1) Calculate the initial hidden state , and the formula is as follows:
[0068] ;
[0069] Among them, represents the learnable weight matrix; represents the learnable bias term; P represents the position encoding; S represents the segment embedding, represents the integer ID after token mapping.
[0070] 2) Extract semantic features from local to global through multiple layers of Transformer encoders :
[0071]
[0072] ;
[0073] Among them, represents the global number of layers, represents the semantic features of the layer, represents the semantic features of the layer, LN represents the layer normalization layer; Att represents the self-attention mechanism, capturing the global dependencies of all positions within the sequence; FNN represents the feed-forward network, performing a non-linear transformation on the result of layer normalization to learn complex local feature interactions;
[0074] Then, the discrete features are vectorized through the nn.Embedding layer of the PyTorch framework, and its discrete-to-continuous mapping relationship is:
[0075] ;
[0076] Among them, represents the discrete category index, such as the item ID; is the weight matrix, represents the feature vector.
[0077] For each recommendation task, the historical behaviors and experience summaries of the agent are vectorized using the same BERT model as above; the obtained vector data is stored in the Milvus database and indexed to optimize the search efficiency, realizing the storage and fast access of long-term memory data.
[0078] Furthermore, the construction of the recommendation mechanism includes:
[0079] Using the nearest neighbor search function of the Milvus vector database, screen the top n recommendations with the highest similarity to the user vector data;
[0080] Sort and screen the recommendations to obtain a recommendation list, and generate recommendation explanations based on the user information and the recommendation list.
[0081] Specifically, implementing the recommendation based on vectorized Embedding includes:
[0082] 1) In the recall stage, using the nearest neighbor search function of the Milvus vector database, efficiently screen out hundreds to thousands of items that are most similar to the user Embedding vector from a large number of items through the ANN algorithm; the optimization goal of this stage is to given the user vector , find n most similar vectors from the item vector database , expressed as:
[0083] ;
[0084] To efficiently find the nearest neighborhood in the database, the HNSW (Hierarchical Navigable Small World) indexing method of the ANN algorithm is adopted. It organizes data points into a multi-layer graph, with each layer containing a lower-layer subgraph and a higher-layer subgraph. Each node maintains pointer jumps to other nodes to ensure traversing the graph structure within a constant number of steps. When inserting a new node, a greedy strategy is adopted and the jump pointers are updated. When searching, starting from the query point, traverse upward / downward along the jump pointers to gradually approach the nearest neighbor.
[0085] 2) In the sorting stage, combining the feature Embedding vectors of users and items, a convolutional neural network CNN is used to predict the click probability or rating of users for items; select the top items with the highest click probability or rating as the recommendation list. The calculation mechanism in this stage is:
[0086] ;
[0087] Among them, represents the activation function; represents CNN feature extraction; represents the outer product operation of user-item Embedding, represents the click probability or rating of the user for the item.
[0088] Use the user information and the recommendation list as the context input to the large language model, and specify the recommendation explanation template to guide the large language model to generate explanations. In this embodiment, the large language model can be tools such as a pre-trained BERT model, the PyTorch framework, and other recommendation systems.
[0089] Furthermore, constructing a feedback learning mechanism includes:
[0090] Collect the feedback behavior of users on the recommendation list;
[0091] Evaluate the feedback behavior through a reward function, obtain the user satisfaction and store it as historical experience, and add it to the next recommendation task.
[0092] Among them, the reward function assigns values to the user feedback behavior, takes the mean of several behavior assignments, and judges the user satisfaction corresponding to the mean through a preset satisfaction interval.
[0093] Specifically, as Figure 2 shown, the feedback learning mechanism includes:
[0094] As the external environment for interaction, the user gives subjective feedback on the recommendation list; the reward function evaluates the user behavior feedback to obtain the user satisfaction level; based on the user language and satisfaction level, the agent generates a text summary as historical experience and stores it in the long-term memory to guide the next recommendation task;
[0095] The construction method of the reward function includes:
[0096] 1) Set a rule-based reward function to assign a certain score to a user behavior; the classification and assignment rules for feedback behaviors are shown in Table 1:
[0097] Table 1
[0098] Behavior type Weight rule Example assignment Show positive feedback The user actively expresses preference (such as collection, rating ≥ 4 stars, purchase) 5~10 Implicit positive feedback The user's high interaction behavior with the item (such as click, slide, dwell time) 0~5 Neutral feedback The user completes browsing but does not further interact (such as only exposure without click) 0.5 Explicit negative feedback The user clearly expresses dissatisfaction (such as rating ≤ 2 stars, report, cancel collection) -5~-1 No feedback The user does not perform any behavior on the recommended list 0
[0099] Therefore, the user for the item The feedback evaluation calculation formula can be as follows:
[0100] ;
[0101] Among them, represents the number of explicit positive feedbacks; represents the time when the user gets the first exposure to the item , unit: second, ; represents the number of days from the last explicit negative feedback time of the user for the item to the current time, represents the user for the item Feedback evaluation assignment.
[0102] 2) Take the mean of the total scores of multiple behaviors, determine which numerical interval the mean is in, and obtain the corresponding user satisfaction level. Therefore, the user satisfaction calculation formula is as follows:
[0103] ;
[0104] Among them, represents the set of all items in the user historical interaction, represents the user Satisfaction level. The satisfaction interval and feedback level division are shown in Table 2:
[0105] Table 2
[0106] Satisfaction interval Level Business meaning Trigger strategy [0.8,1.0] Grade A The user is highly satisfied and the recommended result is accurate Strengthen the recommendation of relevant items and increase the exposure weight [0.6,0.8) Grade B The user is satisfied, but there is room for improvement Optimize the recommendation diversity and introduce minor adjustments [0.4,0.6) Grade C The user's satisfaction is average Trigger the re-ranking mechanism and reduce the weight of low-score items <0.4 Grade D The user is dissatisfied and the recommended result needs to be adjusted urgently Trigger the re-ranking mechanism and reduce the weight of low-score items
[0107] On the other hand, this embodiment also provides an intelligent agent application system for large models and intelligent recommendations, which is implemented based on the intelligent agent constructed by the above method. The specific working process of the intelligent agent application is as follows: Figure 4 As shown, the application system includes the following modules:
[0108] A user request module, which is used to receive user requests and convert the format of user requests;
[0109] A task planning module, which is used to decompose and plan tasks based on the user request after format conversion to obtain task information;
[0110] An intelligent recommendation module, which is used to input task information into the intelligent agent and output a recommendation list and recommendation explanations;
[0111] A memory storage module, which is used to record the intelligent agent work log, including previous behaviors and external knowledge, as well as interaction records with users.
[0112] Furthermore, the system realizes the reception of requests and the output of recommendation results by performing voice interaction with users.
[0113] Specifically, the voice interaction function includes: receiving user voice, triggering whisper processing to recognize the voice content after identifying keywords based on a small model; based on the LLaMA 3.1 model, providing feedback on the voice content and executing user instructions.
[0114] As Figure 3 shown, this embodiment records an audio file in wav format through the pyaudio library. During the recording process, parameters such as the size of each audio block read, audio format, number of channels, sampling rate, recording duration, and the name of the saved file are set. For example, the size of each audio block read is set to 1024, the audio format is 16-bit, mono, the sampling rate is 44.1 kHz, the recording duration is 5 seconds, and the recorded audio file is saved as "output.wav".
[0115] Call the whisper model to transcribe the recorded audio file into text. This step is achieved by loading the whisper model and calling its transcribe method. The transcribed text can be used for subsequent natural language processing and instruction parsing.
[0116] Deploy the model locally through LM Studio and enable the API service. It can receive the user's voice instructions, convert them into text for processing. Finally, provide feedback to the user according to the model output and complete the user instructions.
[0117] Furthermore, the system adopts the form of a virtual digital human, and the virtual digital human is designed and generated through 3Dmax by collecting the user's voice information and body information.
[0118] Specifically, the user is first required to enter key human body parameters such as gender, age, height, weight, and BMI. The input methods for these parameters include voice input and text input, ensuring the convenience of user operations. The entered data is then stored in the user information database. The system extracts the user's human body parameters from the database and makes an accurate match in the 3D model library based on these parameters to select a model that matches the user's characteristics. Subsequently, the model is transmitted to the front-end page for display. Using three.js, the system loads an external 3D model file that matches the user data and performs high-quality scene rendering on it. The size of the model can be dynamically adjusted according to the changes in the browser window to ensure the best display effect on different devices. At the same time, the specific human characteristics of the model, such as body shape and proportion, are also adjusted in real time according to the data entered by the user. To improve the user experience, various interactive functions, such as rotating the model, are added, enabling the user to observe the model from all directions. In addition, the useMemo hook of the React framework is used to effectively avoid unnecessary repeated rendering, significantly improving the rendering performance and response speed.
[0119] The embodiments described above are only descriptions of the preferred embodiments of the present invention and do not limit the scope of the present invention. Without departing from the design spirit of the present invention, various deformations and improvements made by those of ordinary skill in the art to the technical solutions of the present invention shall fall within the protection scope determined by the claims of the present invention.
Claims
1. An intelligent agent construction method for large models and intelligent recommendations, characterized in that, Including: Construct a basic agent based on large language models based on prompt engineering; Construct a memory mechanism and a recommendation mechanism based on the Milvus vector database and the large language model, and construct a feedback learning mechanism based on the recommendation mechanism; Embed the memory mechanism, recommendation mechanism, and feedback learning mechanism into the basic agent to construct an agent, where the input of the agent is user information and the output is a recommendation list and recommendation explanations.
2. The method for constructing an intelligent agent for large models and intelligent recommendation according to claim 1, wherein, Constructing the memory mechanism includes: Construct long-term memory based on the Milvus vector database and short-term memory based on the context of the large language model. Among them, constructing the long-term memory includes: Obtain user and item data and perform preprocessing, where the user and item data includes user data, item data, and user-item interaction data; Extract features from the preprocessed user and item data, and vectorize the extracted features, as well as the behaviors and results of the agent in each recommendation task, to obtain vector data; Store the vector data in the Milvus vector database and establish an index to complete the storage of long-term memory.
3. The method for constructing an intelligent agent for large models and intelligent recommendation according to claim 2, wherein Constructing the recommendation mechanism includes: Use the nearest neighbor search function of the Milvus vector database to screen the top n recommendations with the highest similarity to the user vector data; Sort and screen the recommendations to obtain a recommendation list, and generate recommendation explanations based on user information and the recommendation list.
4. The method for constructing an intelligent agent for large models and intelligent recommendation according to claim 3, wherein, Constructing the feedback learning mechanism includes: Collect the feedback behaviors of users on the recommendation list; Evaluate the feedback behaviors through a reward function to obtain user satisfaction and store it as historical experience, and add it to the next recommendation task.
5. The method for constructing an intelligent agent for large models and intelligent recommendation according to claim 4, wherein The reward function assigns values to user feedback behaviors, takes the mean of several behavior assignments, and determines the user satisfaction corresponding to the mean through a preset satisfaction interval.
6. An intelligent agent application system for large models and intelligent recommendation, implemented by an intelligent agent constructed based on the method according to any one of claims 1-5, characterized in that, Including: A user request module for receiving user requests and converting the formats of the user requests; A task planning module for decomposing and planning tasks based on the user requests after format conversion to obtain task information; An intelligent recommendation module for inputting the task information into the agent and outputting a recommendation list and recommendation explanations; A memory storage module for recording the working logs of the agent, including previous behaviors and external knowledge, as well as interaction records with users.
7. The intelligent agent application system of the large model and intelligent recommendation according to claim 6, wherein The system realizes the reception of requests and the output of recommendation results through voice interaction with users.
8. The intelligent agent application system of the large model and intelligent recommendation according to claim 6, wherein, The system adopts the form of a virtual digital human, and the virtual digital human is designed and generated through 3Dmax by collecting user voice information and body information.
Citation Information
Patent Citations
Movie recommendation method and system based on knowledge graph and reinforcement learning
CN113051468A
Interactive recommendation method and system based on offline user environment and dynamic reward
CN113449183A
Commodity search recommendation system based on AI
CN118967259A
Product recommendation method and device based on intelligent agent and medium
CN119128277A
Intelligent agent architecture based on multi-modal large model
CN120046645A