Method for enhancing role perception of large language model
Through dialogue data processing, memory mechanism establishment, user graph construction and graph neural network prompt learning, the problem that personalized dialogue generation methods in the existing technology are difficult to effectively utilize personalized information, and the deep user portrait mining and dialogue structure maintenance of the large language model in multi-session dialogue is achieved, which improves the consistency and richness of reply.
Patent Information
- Application Number
- CN202411946733.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-12-27
AI Technical Summary
Existing multi-session personalized dialogue generation methods are difficult to effectively scale and utilize personalized information, resulting in insufficient consistency and richness of responses and neglecting the importance of dialogue structure in understanding dialogue context.
A method to enhance the role perception of large language models is designed, and a memory mechanism is established by processing dialogue data sets, combining user personality information and knowledge graphs to build user graphs, and using graph neural networks for prompt learning to improve the role perception ability of large language models.
Effectively explore deeper user portraits, maintain dialogue structure, improve the understanding of multi-session dialogue information by large language models, generate replies consistent with personality information and dialogue history, and improve user participation.
Smart Images

Figure CN119760095A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing and deep learning technology, and in particular to a method for enhancing role perception of a large language model. Background Art
[0002] Personalized dialogue generation has become a key issue and important challenge in open-domain dialogue systems. Its goal is to generate responses that are consistent with personality information and dialogue history. Personality information can make the generated responses more specific and comprehensive, thereby enhancing user engagement. Existing multi-session personalized dialogue generation methods mainly focus on history modeling and personality modeling.
[0003] Historical modeling can be mainly divided into establishing a memory mechanism and expanding the context window. Reference [1] integrates the forgetting curve into the memory mechanism of a large language model and uses a retrieval model to retrieve relevant dialogue information. Although this method allows the large language model to obtain relevant historical information, it usually destroys the dialogue structure and hinders the dialogue model's understanding of the dialogue history. Reference [2] expands the input scale by modifying the internal architecture of the large language model. This method is prone to losing key historical information or introducing noise.
[0004] Personality information modeling is mainly divided into explicit personality modeling and implicit personality modeling. Explicit personality methods usually input data containing personality information into a large language model. For example, reference [3] combines the user's personal background and knowledge information on Wikipedia to generate customized dialogue responses. However, faced with a long dialogue history and brief character information, the large language model is likely to fail to pay attention to the role information and output responses that are inconsistent with the role information. Implicit personality-based methods represent personality information with vectors to cover more role attributes. For example, reference [4] automatically learns the user's implicit profile by analyzing the user's historical dialogue records, and designs a personalized decoder that combines the two strategies of generation and replication to generate responses that are more in line with the user's personality. However, the role information in the dialogue is often sparse, and the large language model lacks effective prior knowledge, resulting in the generated results being not rich enough and not attractive enough to users [5].
[0005] Although previous methods focusing on history modeling and role modeling have advanced the field, these methods have ignored the importance of dialogue structure in helping large language models understand the context of dialogue. In addition, these methods fail to effectively expand and utilize personality information, thus reducing the consistency of responses.
[0006] References:
[0007] [1] Zhong, W., Guo, L., Gao, Q., Ye, H. and Wang, Y. 2024.MemoryBank: Enhancing Large Language Models with Long-Term Memory.Proceedings of the AAAI Conference on Artificial Intelligence. 38, 17 (Mar.2024), 19724-19731. DOI:https: / / doi.org / 10.1609 / aaai.v38i17.29946.
[0008] [2] Jia-Nan Li, Quan Tu, Cunli Mao, Zhengtao Yu, Ji-Rong Wen, and RuiYan. 2024.
[0009] StreamingDialogue: Prolonged Dialogue Learning via Long ContextCompression with Minimal Losses. arXiv:2403.08312 [cs.CL] https: / / arxiv.org / abs / 2403.08312
[0010] [3] Jang, Y., Lim, J., Hur, Y., Oh, D., Son, S., Lee, Y., Shin, D.,Kim, S. and Lim, H. 2022. Call for Customized Conversation: CustomizedConversation Grounding Persona and Knowledge. Proceedings of the AAAIConference on Artificial Intelligence. 36, 10 (Jun. 2022), 10803-10812. DOI:https: / / doi.org / 10.1609 / aaai.v36i10.21326.
[0011] [4] Zhengyi Ma, Zhicheng Dou, Yutao Zhu, Hanxun Zhong, and Ji-RongWen. 2021. One Chatbot Per Person: Creating Personalized Chatbots based onImplicit User Profiles. In Proceedings of the 44th International ACM SIGIRConference on Research and Development in Information Retrieval (SIGIR '21). Association for Computing Machinery, New York, NY, USA, 555–564. https: / / doi.org / 10.1145 / 3404835.3462828
[0012] [5] Shixuan Fan, Wei Wei, Wendi Li, Xian-Ling Mao, Wenfeng Xie, andDangyang Chen. 2024. Position Debiasing Fine-Tuning for Causal Perception inLongTerm Dialogue. In Proceedings of the Thirty-Third International Joint Conference on Artificial Intelligence, IJCAI-24, Kate Larson (Ed.). International Joint Conferences on Artificial Intelligence Organization,6261–6269. https: / / doi.org / 10.24963 / ijcai.2024 / 692 Main Track. Summary of the invention
[0013] In order to solve the above problems and enable the large language model to understand the conversation context and mine deep user portraits in multi-session personalized conversations, the present invention designs a method for enhancing role perception for the large language model, which can not only effectively mine deeper user portraits but also maintain the conversation structure and understand the conversation information of multi-session conversations.
[0014] The present invention provides a method for enhancing role perception of a large language model, comprising:
[0015] S1. Process the conversation dataset to obtain several conversations and corresponding labels;
[0016] S2. Establish a memory mechanism to obtain long-term and short-term historical conversations related to the current query;
[0017] S3. Combine the user's personality information and knowledge graph to build a user graph for the user;
[0018] S4. Train using prompt learning through graph neural networks.
[0019] Furthermore, in step S1, the conversation data includes the user's personality information, the chatbot's personality information, all conversation histories, and the time intervals between different conversations, and the processed data includes the user's personality information, the chatbot's personality information, the user's current query, the chatbot's standard response, and past conversation histories.
[0020] Furthermore, in step S2, for the long-term conversation history, the top k conversation histories related to the current query are ranked and retrieved according to similarity, and the order of the conversation history is adjusted.
[0021] Furthermore, the method of adjusting the order of the dialogue history includes: using the ConvED method, calculating the dialogue edit distance of the utterances in the k dialogue histories, obtaining scores, and adjusting the order according to the scores.
[0022] Furthermore, in step S2, for the short-term dialogue history, the topic relevance between the short-term dialogue history and the current query is evaluated through a topic transition detector; if the utterance in the short-term dialogue is irrelevant to the topic of the current query, it is discarded.
[0023] Furthermore, in step S3, the method for constructing the user graph includes:
[0024] Process the knowledge graph and filter out irrelevant personality information;
[0025] Using a personality triple extractor, traverse the conversation data set in step S1, and extract the personality triples that appear from the predefined personality information and conversation history;
[0026] Calculate the similarity between all extracted personality triples and the triples in the knowledge graph, set a certain threshold, and link the knowledge graph triples and personality triples whose similarity is greater than the threshold;
[0027] A user graph is constructed, wherein the nodes of the user graph include personality information or personality attributes, and the edges of the user graph consist of the relationships between the personality information or personality attributes.
[0028] Furthermore, the knowledge graph contains common sense about characters and connections between characters.
[0029] Furthermore, in step S4, it includes:
[0030] (1) Input the representation of nodes and edges in the graph into the embedding layer of the large language model to obtain the corresponding encoding vector;
[0031] (2) Input the query into the embedding layer of the large language model to obtain the encoding vector of the query, and calculate the weight of the encoding vector of the query and the encoding vector of the node in the graph through the attention mechanism;
[0032] (3) Aggregate the representations of all neighboring nodes of a node according to different relationships in the user graph to update the representation of the current node. Through the pooling operation, the user portrait representation vector is obtained.
[0033] (4) Replace the predefined special characters in the prompt word with the user portrait representation vector: set hyperparameters, calculate the loss between the content generated by the large language model and the standard answer, and use backpropagation for training.
[0034] Furthermore, during the training process, the parameters of the large language model are frozen, and the parameters of the graph neural network and the MLP are updated. The beneficial effects of the present invention are as follows:
[0035] (1) This paper proposes a new memory mechanism to retrieve relevant conversation history for the large language model while ensuring the conversation structure information, thereby improving the large language model's ability to understand the conversation history context.
[0036] (2) The present invention constructs a unique user graph for users to expand and mine the user's personality information, and designs a graph neural network based on the graph to enhance the role perception ability of the large language model.
[0037] (3) The present invention achieves good results on the MSC dataset, indicating that the present method can achieve good performance in multi-session dialogue generation tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0039] Figure 1A schematic diagram of a flow chart of a method for enhancing role perception of a large language model according to an embodiment of the present invention;
[0040] Figure 2 A schematic diagram of a flow chart of establishing a memory mechanism according to an embodiment of the present invention;
[0041] Figure 3 A schematic diagram of a process for constructing a user graph according to an embodiment of the present invention;
[0042] Figure 4 A schematic diagram of a prompt learning training process according to an embodiment of the present invention;
[0043] Figure 5 The figure is a schematic diagram of the workflow of a trained large language model according to an embodiment of the present invention. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be checked and described in full in combination with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0045] The present invention provides a method for enhancing role perception of a large language model, such as Figure 1 As shown, the method comprises the following steps:
[0046] S1. Clean and segment the conversation dataset to obtain several conversations and corresponding labels.
[0047] S2. Establish a memory mechanism to obtain long-term and short-term historical conversations related to the current query;
[0048] S3. Combine the user's personality information and knowledge graph to build a user graph for the user;
[0049] S4. Use prompt learning and training through graph neural network.
[0050] In step S1, the input text contains a conversation data set, and the conversation data includes the user's personality information, the chatbot's personality information, all conversation histories, and the time intervals between different conversations. All conversation data are described in natural languages such as English and Chinese. In order to facilitate subsequent model training, the input text is processed, the conversation histories of different conversations are segmented according to the time intervals in the text, and sensitive information appearing in open domain conversations is filtered out. Each piece of data in the processed text contains the user's personality information, the chatbot's personality information, the user's current query, the chatbot's standard response, and the previous conversation history.
[0051] In the multi-session dialogue generation task, there will be multiple dialogue interactions between users, which can be divided into multiple sessions according to the time interval. Among them, the long-term historical dialogue refers to the dialogue content in the previous session, and the short-term historical dialogue refers to the dialogue content of the current session.
[0052] In step S2, if Figure 2 As shown, in order to retrieve memories related to semantics and query topic information from historical conversations while retaining the original conversation structure as much as possible, the present invention establishes a memory mechanism for a large language model, and designs topic-aware retrieval strategies for long-term historical conversations and short-term historical conversations respectively, thereby obtaining long-term historical conversations and short-term historical conversations related to the query.
[0053] (1) For long-term conversation histories, the top k conversation histories related to the current query are ranked and retrieved based on similarity, including queries and responses. The relevance can be calculated using the DPR model, Hamming distance, etc. The DPR model (Dense Passage Retrieval) was proposed by Facebook AI Research and is a model for information retrieval that aims to improve the efficiency and accuracy of retrieval through dense vector representation. It converts user-entered questions and documents into vectors, and then evaluates the similarity by calculating the dot product between the query vector and the paragraph vector, thereby selecting the most relevant paragraph as the retrieval result.
[0054] Then, the order of the first k conversation histories is adjusted, for example, by time.
[0055] In one embodiment, the ConvED method is used to calculate the dialogue edit distance of the utterances in the k dialogue histories, obtain scores, and adjust the order according to the scores to retain the structural information in the dialogue as much as possible. The formula is as follows:
[0056]
[0057] in, and They represent the i-th token of the first sentence and the j-th token of the second sentence respectively. and are their corresponding representations, and are their distance scores,
[0058] ConvED (Conversation Edit Distance) is a conversation similarity measurement method that combines edit distance and distributional semantics, taking into account factors such as sentence semantics, conversation flow, and participants in the conversation. This method can reorder the retrieved conversations according to the distance of the conversations to restore the conversation structure of the conversations sorted by relevance to a certain extent.
[0059] (2) For short-term conversation histories, the topic transition detector is used to evaluate the topic relevance between the short-term conversation history and the current query. If the topic transition detector determines that a certain utterance in the short-term conversation is irrelevant to the topic of the current query, it is discarded. Finally, all conversation histories that are relevant to the current query topic and maintain the conversation structure are obtained.
[0060] Topic transition detectors can be trained with topic transition-aware conversation modeling datasets such as TIAGE. TIAGE is a human-annotated conversation dataset that focuses on topic transition behaviors in open-domain conversations. It provides three tasks: topic transition detection, topic transition-triggered response generation, and topic-aware conversation generation to study topic transition modeling in conversation settings.
[0061] In step 3, if Figure 3As shown, in order to overcome the problem of sparse personality information (persona) in multi-session personalized dialogues, the present invention introduces a knowledge graph containing common sense of characters and connections between characters to expand the personality information, such as PeaCoK. First, the knowledge graph is processed to filter out irrelevant personality information; then, the personality triple extractor is trained using the natural language inference (NLI) task (such as the DNLI dataset), and the dialogue dataset in step S1 is traversed to extract the personality triples that appear from the predefined personality information and dialogue history. Then, in order to better link the knowledge graph, the triples are converted into sentence form, for example, the triple <I am a double bass player, features, like music> is converted to "I am a double bass player, here are my features, like music", and the knowledge graph is linked by calculating semantic similarity (for example, using the DPR model), that is, similarity is calculated for all extracted personality triples and triples in the knowledge graph, and a certain threshold is set, and the knowledge graph triples and personality triples with similarity greater than the threshold are linked together, and then a user graph is constructed for each user based on all extracted triples and linked triples. The nodes of the user graph include personality information or personality attributes, and the edges of the user graph are composed of relationships between personality information or personality attributes. The relationships between personality attributes include: having a family, having a job, favorite hobbies, etc.
[0062] In step S4, in order to better mine user portraits and filter irrelevant information, the present invention designs a query-driven graph neural network. Compared with the existing graph neural network, an attention mechanism is added to calculate the weights of the encoding vector of the query and the encoding vector of the node in the graph, such as Figure 4 As shown, the representation of each node in the graph is updated by introducing the weight of the query encoding vector. The specific operations are as follows:
[0063] (1) Input the representation of nodes and edges in the graph into the embedding layer of the large language model to obtain the corresponding encoding vector;
[0064] (2) Input the query into the embedding layer of the large language model to obtain the encoding vector of the query, and calculate the weight of the encoding vector of the query and the encoding vector of the nodes in the graph through the attention mechanism. Assigning weights is a filtering method. Since the weights of irrelevant nodes are relatively low, after summing the weights, the irrelevant nodes contribute little to the final representation, which is equivalent to filtering out irrelevant nodes in the graph. Existing graph neural networks usually only focus on the structure and node information on the graph, while ignoring whether the nodes in the graph are related to the current conversation or the current query. Therefore, the query-driven graph neural network of the present invention can alleviate the impact of irrelevant noise on conversation generation and mine deeper user portrait representations by filtering nodes that are irrelevant to the current query and guiding node aggregation and updating representations.
[0065] (3) Aggregate the representations of all neighboring nodes of a node according to different relationships in the user graph to update the representation of the current node. Through pooling operations, that is, averaging and maximizing the representations of all nodes in the graph, we obtain the user portrait representation vector. The formula is as follows:
[0066]
[0067] Among them, Representation Node In relationship The neighbor index set under Is a node and neighbors In relationship The attention score under is the query representation in the current utterance, and it is initialized in the same way as the nodes in the graph. , , , is a learnable parameter in the graph neural network. is the weight, and the user portrait is pooled by all node representations, that is, all h are pooled to obtain the final user portrait.
[0068] DNLI (Dialogue Natural Language Inference) is a method that converts the consistency problem in dialogue into a natural language inference (NLI) task. It trains the model by creating a new NLI dataset containing sentence pairs marked as entailment, neutral, or contradictory to rearrange utterances in the dialogue model to improve the consistency of the dialogue agent. In this paper, we introduce this dataset to train the personality triple extractor.
[0069] There are two main advantages of converting user representation into vectors. First, in multi-session dialogue generation, each person shows a lot of personality information. If it is described in the form of language, the content input to the large language model will be a lot, but the large language model has a length limit, which poses a challenge to the input scale. The vector constructed by the present invention only occupies one character (that is, in the subsequent input, [CHATBOTPERSONA], which only occupies one character, is replaced with a user portrait representation) to summarize the user's personality information. Most existing methods input personality information in the form of text, which generally has hundreds to thousands of characters, often exceeding the input length limit of the large language model, and not all personality information has an obvious and direct connection with the current dialogue, so the present invention can summarize a person's personality information with just one character, which is much shorter than the length of the input personality information text. Secondly, it is difficult to fully summarize a person's personality characteristics in language, so we describe the personality information in an abstract vector manner (that is, the user portrait vector).
[0070] (4) Replace the predefined special characters in the prompt word with the user portrait representation vector: set hyperparameters, calculate the loss between the content generated by the large language model and the standard answer, and use backpropagation for training.
[0071] The large language model inputs the following content: "As a communication expert with excellent communication habits, you embody the role of CHATBOT in the following conversation. Here are some of your unique personal traits: [CHATBOTPERSONA].\n<Conversation history>\nYour recent conversation with the user:\n[CONTEXT]\n\nNow, please play the role of CHATBOT and continue the conversation between CHATBOT and the user.\nThe user just said: [QUERY]\nPlease reply to the user in the following format (up to 50 words, must be in Chinese):\nReply:\n", the input command prompt contains the personality information, conversation history, current query, character description and other key information required for the task, which can be constructed by yourself. Among them, the predefined special characters [CHATBOTPERSONA] in the prompt word are replaced with the user portrait representation vector according to the following formula:
[0072]
[0073] Where E is the embedding vector form of user input (including query, prompt, etc.), , Represents tokens and user portrait representation vector, is the dimension of the large language model, is a graph neural network, Represents graph, q represents query, MLP is a multi-layer perceptron that represents the semantic space and user portrait space of its large language model, sets hyperparameters such as learning rate and number of iterations, uses cross entropy as the loss function, calculates the loss between the content generated by the large language model and the standard answer, and uses back propagation for training. During the training process, the parameters of the original large language model are frozen, and the parameters of the graph neural network and MLP are updated to finally obtain a trained model.
[0074] When the trained model is used, Figure 5 As shown in the figure, the user inputs the query, conversation history, and personality information. The user first processes the conversation history, retrieves the relevant conversation history while ensuring the conversation structure, then extracts triples from the conversation history and personality information, and introduces the knowledge graph to link the triples to construct a user graph. The graph and query are then calculated through a graph neural network to obtain a user portrait representation. Finally, the query, retrieved conversation history, and user portrait representation are input into the large language model to obtain personalized conversation output. The user portrait representation is inserted after the large language model converts the text into a vector.
[0075] User input includes prompt words, current query, conversation history, and personality information.
[0076] Based on the establishment of a memory mechanism, the present invention designs a user graph and prompt learning based on a graph neural network, which can not only maintain the dialogue structure so that the large language model can fully understand the dialogue context of long-term dialogues, but also enable the large language model to deeply understand and mine user portraits, generate replies that are consistent with the dialogue history and personalized information, and attract users' interest in dialogue.
[0077] Experimental verification:
[0078] In one embodiment, the input text is a corpus MSC dataset. The 2022 ACL conference paper Beyond Goldfish Memory: Long-Term Open-Domain Conversation first proposed open-domain conversations for multi-session conversations and proposed this dataset.
[0079] The present invention effectively enhances the performance of large language models on the MSC dataset. As shown in Table 1, experiments were conducted on the MSC dataset using ChatGLM-6B and Llama2-7B and the method of the present invention, and BlenderBot, HAHT, ChatGLM-6B (Base), Llama2-7B (Base), ChatGPT, CPD, StreamingDialogue, and LD-Agent were used as baseline models for comparison on BLEU-1, BLEU-2, BLEU-3, and ROUGE-L indicators.
[0080] BlenderBot is an advanced open-domain dialogue model developed by large-scale pre-training on large-scale datasets, combined with a retrieval-refinement mechanism and an optimized decoding strategy. HAHT is a model that adopts hierarchical encoding and attention mechanisms to maintain and utilize long-term historical dialogue memory to generate context-relevant replies through a history-aware response generator. ChatGPT is a closed-source large language model based on the GPT architecture, and we use the API service of OpenAI's gpt-3.5-turbo model. CPD is a causal-aware multi-turn dialogue framework that uses a perturbation-based causal variable discovery method to extract statements with high causal relevance from historical dialogues, thereby enhancing the causal awareness of large language models. StreamingDialogue is a model that effectively handles long-context dialogues by compressing the dialogue history into a "dialogue attention sink" and adopting short-term memory reconstruction (SMR) and long-term memory activation (LMR) learning strategies. LD-Agent is a dialogue agent framework that supports coherent dialogues by integrating event memory and personalized role modeling. It is the previous state-of-the-art method on the MSC dataset. As shown in Table 1, the best result is in bold and the second best result is underlined.
[0081] Table 1
[0082] Model BLEU-1 BLEU-2 BLEU-3 ROUGE-L BlenderBot - 4.91 1.53 16.06 HAHT - 5.10 1.59 16.58 ChatGLM(Base) 19.20 5.54 1.50 16.49 Llama2(Base) 17.34 4.37 1.21 10.29 ChatGPT 18.96 5.77 1.51 16.84 CPD 12.45 4.41 - 12.14 StreamingDialogue 19.33 - - 15.86 LD-Agent <![CDATA[ 19.54 ]]> 7.31 2.51 18.44 Ours(ChatGLM) 19.44 <![CDATA[ 7.51 ]]> <![CDATA[ 2.52 ]]> 19.67 Ours(Llama2) 20.56 8.05 <![CDATA[ 2.53 ]]> <![CDATA[ 18.72 ]]>
[0083] Those skilled in the art will appreciate that the foregoing embodiments are merely intended to illustrate the technical solutions of the present invention rather than to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art will appreciate that the technical solutions described in the foregoing embodiments may be modified or some or all of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope defined by the claims of the present invention.
Claims
1. A method for enhancing role perception of a large language model, characterized in that: The method comprises: S1. Process the conversation dataset to obtain several conversations and corresponding labels; S2. Establish a memory mechanism to obtain long-term and short-term historical conversations related to the current query; S3. Combine the user's personality information and knowledge graph to build a user graph for the user; S4. Train using prompt learning through graph neural networks.
2. The method according to claim 1, characterized in that In step S1, the conversation data includes the user's personality information, the chatbot's personality information, all conversation histories, and the time intervals between different conversations. The processed data includes the user's personality information, the chatbot's personality information, the user's current query, the chatbot's standard response, and past conversation histories.
3. The method according to claim 1, characterized in that In step S2, for the long-term conversation history, the top k conversation histories related to the current query are ranked and retrieved according to similarity, and the order of the conversation history is adjusted.
4. The method according to claim 3, characterized in that Methods for adjusting the order of dialogue histories include: using a ConvED method, calculating dialogue edit distances of utterances in k dialogue histories, obtaining scores, and adjusting the order according to the scores.
5. The method according to claim 1, characterized in that In step S2, for the short-term dialogue history, the topic relevance between the short-term dialogue history and the current query is evaluated by a topic transition detector; if the utterance in the short-term dialogue is irrelevant to the topic of the current query, it is discarded.
6. The method according to claim 1, characterized in that In step S3, the method for constructing the user graph includes: Process the knowledge graph and filter out irrelevant personality information; Using a personality triple extractor, traverse the conversation data set in step S1, and extract the personality triples that appear from the predefined personality information and conversation history; Calculate the similarity between all extracted personality triples and the triples in the knowledge graph, set a certain threshold, and link the knowledge graph triples and personality triples whose similarity is greater than the threshold; A user graph is constructed, wherein the nodes of the user graph include personality information or personality attributes, and the edges of the user graph consist of the relationships between the personality information or personality attributes.
7. The method according to claim 6, characterized in that The knowledge graph contains common knowledge about characters and the connections between them.
8. The method according to claim 1, characterized in that: In step S4, it includes: (1) Input the representation of nodes and edges in the graph into the embedding layer of the large language model to obtain the corresponding encoding vector; (2) Input the query into the embedding layer of the large language model to obtain the encoding vector of the query, and calculate the weight of the encoding vector of the query and the encoding vector of the node in the graph through the attention mechanism; (3) Aggregate the representations of all neighboring nodes of a node according to different relationships in the user graph to update the representation of the current node. Through the pooling operation, the user portrait representation vector is obtained. (4) Replace the predefined special characters in the prompt word with the user portrait representation vector: set hyperparameters, calculate the loss between the content generated by the large language model and the standard answer, and use backpropagation for training.
9. The method according to claim 8, characterized in that During the training process, the parameters of the large language model are frozen, and the parameters of the graph neural network and MLP are updated.
Citation Information
Patent Citations
Personalized dialogue generation method and system based on large language model
CN117787293A
Large language model dialogue recommendation method based on enhanced knowledge selection
CN117891924A
Personality detection method based on large language model text enhancement
CN118364111A
Role dialogue method based on large model, intelligent agent, equipment and storage medium
CN119047578A
Context-aware and persona-based generative ai interpretation device and method for controlling the same
KR102692549B1
Cited By
Film and television role playing method based on emotion retrieval and role consistency control
CN121009185A