Personalized dialogue generation method and system based on role description enhancement
Through a method based on role description enhancement, the data set is enhanced by using role description tags and corpus, combined with instruction fine-tuning and Lora fine-tuning, the large language model is optimized, and data scarcity and cross-domain migration problems in personalized dialogue generation are solved, the quality and coherence of dialogue generation are improved, and the natural generation of cross-domain personalized dialogue is realized.
Patent Information
- Application Number
- CN202510595853.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-08-22
AI Technical Summary
Personalized dialogue generation faces problems such as high cost of data acquisition and labeling, difficulty in fusion of user personality characteristics, insufficient generalization capabilities of model and difficulty in cross-domain migration.
Through a method based on role description enhancement, the role description label and corpus enhancement dataset are used, combined with instruction fine-tuning and Lora fine-tuning, the generation ability of large language models is optimized to achieve cross-domain and cross-scene personalized dialogue generation.
It improves the quality and coherence of multi-round dialogue generation, enhances the generalization ability of the model in a small sample scenario, realizes cross-domain personality migration, and improves the naturalness and emotional resonance of dialogue generation.
Smart Images

Figure CN120523908A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method and system for generating personalized dialogue based on enhanced role descriptions. Background Art
[0002] Personalized dialogue generation is currently a core research direction in natural language processing. With the rapid development of artificial intelligence (AI), user demand for dialogue systems has evolved from basic information exchange to deeper, more emotionally resonant, and personalized communication. Furthermore, personalized dialogue generation has broad application in areas such as intelligent customer service, virtual assistants, and social entertainment. For example, in e-commerce scenarios, customer service bots that can generate customized responses based on user history and preferences can significantly improve user experience and conversion rates.
[0003] However, personalized conversation generation currently faces multiple challenges. First, the acquisition and annotation of personalized data is expensive. Real conversation data often involves user privacy and requires annotation of multiple dimensions, which limits the data size. Second, dynamically integrating user personality traits with the current conversation context during the generation process remains a major challenge. For example, traditional methods often rely on static user profiles and struggle to adapt to real-time changes in emotions or topics during the conversation. Furthermore, the model's generalization ability is insufficient in low-sample scenarios, resulting in a lack of diversity and coherence in the generated content. Current methods based on large language models are able to deeply integrate conversation history with personality information through dynamic adjustment mechanisms, thereby generating responses that better meet user needs. Despite this, how to efficiently utilize limited data while ensuring privacy and security, and how to achieve personality transfer across domains and scenarios, remain key areas for future research. Summary of the Invention
[0004] Based on the technical problems existing in the background technology, the present invention proposes a personalized dialogue generation method and system based on role description enhancement, which improves the generation quality and coherence of the model in multi-round dialogues and realizes personality transfer across domains and scenarios.
[0005] The personalized dialogue generation method based on role description enhancement proposed in the present invention inputs role description and dialogue history into a trained personalized dialogue model and outputs personalized dialogue results;
[0006] The training process of the personalized dialogue model is as follows:
[0007] The role descriptions in the training set are respectively subjected to role description label construction and role description corpus enhancement to obtain role description labels and enhanced role descriptions, and then combined with the dialogue history to construct an enhanced dataset;
[0008] By enhancing the dataset, the baseline large language model is fine-tuned using a combination of instruction fine-tuning and Lora fine-tuning to output personalized conversation results.
[0009] Furthermore, the role description is constructed by the role description tag to obtain the role description tag, specifically:
[0010] Setting a prompt template for extracting role labels, and dividing the prompt template into a first part of prompt words and a second part of prompt words;
[0011] The role description to be filled is set between the first part of the prompt words and the second part of the prompt words as the input of the large language model. The role description label is obtained by extracting the label of the role description.
[0012] Furthermore, in the process of extracting labels from role descriptions, a scoring mechanism is used to evaluate the generated role description labels, specifically:
[0013] The prompt template, role description, and role description label output by the large language model are combined as the input of the large language model;
[0014] The role description label entered is evaluated using the set multi-dimensional evaluation template. If the comprehensive score of the multi-dimensional evaluation template is greater than the set evaluation threshold, the role description label is retained; otherwise, the role description label is regenerated until the comprehensive score is greater than the set evaluation threshold.
[0015] Furthermore, the role description is enhanced by enhancing the role description corpus, specifically:
[0016] Design structured prompt words, use role descriptions as input to the large language model, and generate extended corpus related to role descriptions;
[0017] Based on a dynamic optimization mechanism, role descriptions and extended corpus are used as input for the large language model;
[0018] The generated content is evaluated using the multi-dimensional indicators set in the large language model. If the evaluation score is greater than the corpus setting threshold, the extended corpus is retained. Otherwise, the extended corpus is regenerated or the original extended corpus is adjusted until the evaluation score is greater than the corpus setting threshold.
[0019] Furthermore, in fine-tuning the benchmark large language model using a combination of instruction fine-tuning and Lora fine-tuning, specifically:
[0020] Command fine-tuning: Adapting the model to the task through a large amount of command-response data, optimizing the command understanding ability of the baseline large model to accurately capture role characteristics and contextual information from the input;
[0021] Lora fine-tuning: Insert low-rank matrices into the key layers of the benchmark large language model, and combine them with the constructed fine-tuning loss function to learn specific optimization directions for input features.
[0022] Furthermore, in Lora fine-tuning, the key layer weights of the baseline large language model are adjusted as follows:
[0023] W′=W+A·B;
[0024] Where W′ is the adjusted weight matrix of the key layer of the baseline large language model, W is the original weight matrix of the baseline large language model; A and B are learnable low-rank matrices.
[0025] Furthermore, fine-tuning the loss function The formula is as follows:
[0026]
[0027] Where N is the total number of samples in the augmented dataset, is the cross entropy loss function, R i The predicted personalized dialogue results are output by the fine-tuned large language model. Personalize the conversation results for the target, and are the Frobenius norm of the low-rank matrix and B, respectively, is the KL divergence loss, λ, μ and v are regularization coefficients.
[0028] A personalized dialogue generation system based on role description enhancement inputs role descriptions and dialogue history into a trained personalized dialogue model and outputs personalized dialogue results.
[0029] The training process of the personalized dialogue model includes an enhanced dataset construction module and a fine-tuning module;
[0030] The enhanced dataset construction module is used to construct role description labels and enhance role descriptions in the training set through role description label construction and role description corpus enhancement, and then combine them with the dialogue history to construct an enhanced dataset.
[0031] The fine-tuning module is used to fine-tune the benchmark large language model by enhancing the dataset and combining instruction fine-tuning and Lora fine-tuning to output personalized dialogue results.
[0032] Furthermore, the enhanced dataset construction module includes a role description label construction module and a role description label evaluation module;
[0033] The role description label construction module is specifically used to: set a prompt template for role label extraction, and divide the prompt template into a first part of prompt words and a second part of prompt words; set the role description to be filled in between the first part of prompt words and the second part of prompt words as the input of the large language model, and obtain the role description label by extracting the label of the role description.
[0034] The role description label evaluation module is specifically used to combine the prompt template, role description and the role description label output by the large language model as the input of the large language model; the input role description label is evaluated through the set multi-dimensional evaluation template. If the comprehensive score of the multi-dimensional evaluation template is greater than the set evaluation threshold, the role description label is retained; otherwise, the role description label is regenerated until the comprehensive score is greater than the set evaluation threshold.
[0035] Furthermore, the enhanced dataset also includes a role description corpus enhancement module;
[0036] The role description corpus enhancement module is specifically used for:
[0037] Design structured prompt words, use role descriptions as input to the large language model, and generate extended corpus related to role descriptions;
[0038] Based on a dynamic optimization mechanism, role descriptions and extended corpus are used as input for the large language model;
[0039] The generated content is evaluated using the multi-dimensional indicators set in the large language model. If the evaluation score is greater than the corpus setting threshold, the extended corpus is retained. Otherwise, the extended corpus is regenerated or the original extended corpus is adjusted until the evaluation score is greater than the corpus setting threshold.
[0040] The advantages of the personalized dialogue generation method and system based on role description enhancement provided by the present invention are: by combining the thought chain prompt technology with the context understanding, reasoning and generation capabilities of the pre-trained large language model, data enhancement is performed on the personalized description of the role, and the enhanced data is used to fine-tune the baseline large language model, thereby alleviating the problem of reduced generation quality due to data scarcity. At the same time, compared with single prompt tuning (Prompt Tuning), this method can better adapt to the complexity of multi-dialogue scenarios and improve the generation quality and coherence of the model in multi-round dialogues. In addition, this method can also improve the generalization ability of the model in a small number of sample scenarios and realize cross-domain and cross-scenario personality transfer. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 It is a structural schematic diagram of the present invention. DETAILED DESCRIPTION
[0042] The technical solutions of the present invention are described in detail below through specific embodiments. Numerous specific details are set forth in the following description to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways than those described herein, and those skilled in the art may make similar modifications without departing from the scope of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0043] like Figure 1 As shown, the personalized dialogue generation method based on role description enhancement proposed by the present invention inputs the role description and dialogue history into the trained personalized dialogue model and outputs the personalized dialogue result.
[0044] That is, the task objective of this embodiment is: in the personalized dialogue task, the dialogue context is represented as C = {P, U}, where P = {P1, ···, P e} means that it contains e descriptive sentences related to personalization (e.g., 4≤e≤5) to provide background information of the machine interlocutor m, P e represents the e-th descriptive sentence related to personalization, and U={u h,1 ,u m,1 ,···,u h,n} represents the conversation context initiated by human h to capture the communication between human h and machine m, where u h,1 The first sentence initiated by human h, u m,1 For machine interlocutor m for u h,1 Reply sentence, u h,n The nth sentence initiated by human h. The ultimate goal of the task is to target u h,b Generate a personalized description that matches the machine interlocutor m and a response r=u that is consistent with the conversation context U m,n ,u m,n For machine interlocutor m for u h,n Reply sentence.
[0045] The model training of this embodiment mainly includes two parts: 1. Role description enhancement based on thought chain prompts: The role descriptions in the training set are respectively obtained through role description label construction and role description corpus enhancement to obtain role description labels and enhanced role descriptions, and combined with the dialogue history to construct an enhanced data set; 2. Personalized dialogue generation based on a large language model: Through the enhanced data set, the baseline large language model is fine-tuned by combining instruction fine-tuning and Lora fine-tuning to output personalized dialogue results.
[0046] 1. Enhanced character description based on thought chain prompts;
[0047] Prompt Engineering (herein referred to as prompt engineering) is an input method used to guide pre-trained language models to generate specific content or perform specific tasks. Through carefully designed text prompts, the model can more accurately understand the task intent and fully utilize the knowledge learned from large-scale data training for reasoning, understanding, and generation. In recent years, prompt engineering has been widely used in the field of natural language processing, demonstrating its powerful capabilities in tasks such as zero-shot learning, few-shot learning, and controllable text generation.
[0048] Currently, in the task of generating personalized dialogues, high-quality, large-scale personalized dialogue materials are relatively scarce because the acquisition of personalized dialogue data is limited by data privacy protection and annotation costs. However, with the rapid development of pre-trained large oracle models, it is also possible to design structured prompts (Prompt) to utilize the contextual understanding, reasoning and generation capabilities of large language models to semantically expand and enhance the diversity of limited data, and guide the model to perform data enhancement on the personalized description of the role according to the target role setting, thereby effectively alleviating the problem of data scarcity and improving the effect of personalized dialogue generation. This patent adopts the CoT method in prompt engineering to enhance the role description, so that the pre-trained large oracle model can have a deeper understanding of the role characteristics, emotional tendencies and expression styles when generating personalized dialogues. Through this method, we not only improve the consistency and coherence of the dialogue, but also enhance the embodiment of the personalized characteristics of the role, making the generated dialogue more natural and vivid, thereby optimizing the human-computer interaction experience. Among them, the role description enhancement based on the thought chain prompt is divided into two parts: role description label construction and role description expectation enhancement. Specifically:
[0049] a) Role description label construction;
[0050] In the generation of personalized dialogues, role description labels are a key step in the structured and hierarchical definition of the target role. By constructing a label system, the pre-trained large language model can be helped to deeply understand the characteristics and behavioral tendencies of the role, thereby improving the personalization of the generated content. Therefore, this embodiment designs a prompt template for role label extraction, which can automatically extract role features and generate corresponding labels with the help of a large language model. The prompt template generates a structured label system by guiding the model to identify the role's explicit features (such as name, age, occupation, interests and hobbies, etc.) and implicit features (such as emotional tendencies, language style, behavioral habits, etc.). The design of this prompt template makes full use of the contextual understanding and reasoning capabilities of the large language model, and can generate a complete label description that conforms to the role setting based on a small amount of input information, thereby providing accurate semantic guidance and data support for subsequent personalized dialogue generation.
[0051] When generating a role description label, a prompt template for extracting the role label is set, and the prompt template is divided into a first part of prompt words and a second part of prompt words; the role description to be filled is set between the first part of prompt words and the second part of prompt words as the input of the large language model, and the role description label is obtained by extracting the label of the role description.
[0052] That is, the input text of the Large Language Model (LLM) consists of a prompt template and a corresponding role description:
[0053] Label_Input={Text1:t1,…,t n ;Persona:P1,···,P e ;Text2:s1,…,s n};
[0054] Labels=LLM(Text1, Persona, Text2);
[0055] Among them, Label_Input is the label defined for the role description, Text1 is the first part of the prompt word in the prompt template, n is the nth prompt word in the first part of the prompt words; Persona is the role description text to be filled; Text2 is the second part of the prompt word in the prompt template, s n is the nth prompt word in the second part of the prompt words; Labels is the role description label extracted by the large language model.
[0056] The above-mentioned prompt template can be used to extract labels for the role description. However, relying solely on a single inference of a large language model may cause individual role labels to be biased or inaccurate. For example, insufficient understanding of certain implicit features or inconsistent interpretations of complex descriptions may affect the reliability of the labels. Therefore, this embodiment also proposes a scoring mechanism that uses the output results of the previous step, combined with preset scoring rules, to score the role labels through a large language model. In this scoring mechanism, the prompt template, the role description, and the role description label output by the large language model are combined as the input of the large language model; the input role description label is evaluated through a set multi-dimensional evaluation template. If the comprehensive score of the multi-dimensional evaluation template is greater than the set evaluation threshold, the role description label is retained, otherwise the role description label is regenerated until the comprehensive score is greater than the set evaluation threshold.
[0057] The prompt template, role description, and role description label output by the large language model are combined as the input of the large language model to ensure the accuracy and consistency of the scoring process. The input text is as follows:
[0058] Score_Input={Text3:t1,…,t n ;Persona:P1,···,P e ;Labels:L1,…,L n};
[0059] Among them, Score_Input is the scoring input of the large language model, Text3 is the prompt word set in the prompt template, which includes the preset scoring rules; Persona is the role description text to be filled in; Labels is the role description label output by the large language model in the previous step. Finally, the comprehensive score is obtained through multi-dimensional evaluation:
[0060] {Dimension1:S1,Dimension2:S1,Dimension n :S n ,Score com :S};
[0061] Among them, Dimension1, Dimension2, Dimension n For evaluation dimensions, S1, S2, S n Score is the score value of the corresponding dimension; com is the comprehensive score, and S is the comprehensive score value. If the comprehensive score does not exceed the set evaluation threshold, the label is regenerated to obtain a label that better matches the role description.
[0062] It should be noted that this embodiment uses the recall rate Dimension1, consistency Dimension2 (whether it is consistent with the original description), and accuracy Dimension n The three dimensions (whether the labels are classified correctly) are comprehensively evaluated to obtain a comprehensive score. In the actual experimental process, it is not limited to the dimensions recorded above, and specific dimensions can be set as needed.
[0063] b) Enhanced role description corpus;
[0064] After the character description tags are constructed, to further improve the quality of personalized dialogue generation, this embodiment proposes a method for enhancing the character description corpus to increase the diversity and adaptability of the corpus to multiple scenarios, and to optimize the ability to model character features during dialogue generation. Specifically, the character description corpus enhancement mainly includes the following three steps:
[0065] 1) Semantic extension based on hint engineering;
[0066] Design structured prompt words, use role descriptions as input to the large language model, and generate extended corpus related to the role descriptions.
[0067] Specifically, by designing structured prompts and combining the reasoning and self-reflection capabilities of CoT prompts, the pre-trained large language model can generate extended corpus related to character descriptions. Based on existing character labels, prompts are used to guide the model through a step-by-step analysis of character traits. Through self-questioning and self-answering, the model generates more contextual dialogue, descriptive text, or diverse language styles that align with these traits. This approach fully leverages the contextual understanding and reasoning capabilities of the large language model, ensuring the coherence and logical consistency of the output through self-reflection. This further enriches the corpus content and makes the expression of character traits more natural and diverse.
[0068] 2) Dynamic optimization of corpus quality;
[0069] In order to ensure the quality of the generated corpus, this embodiment also designs a dynamic optimization mechanism for the enhanced corpus to screen, score and reconstruct the generated corpus. Specifically, by introducing the scoring function of the large language model, the generated content is evaluated based on multi-dimensional indicators such as the semantic consistency, role characteristics and dialogue coherence of the corpus. That is, based on the dynamic optimization mechanism, the role description and the extended corpus are used as the input of the large language model; the generated content is evaluated by the multi-dimensional indicators set in the large language model. If the evaluation score is greater than the corpus set threshold, the extended corpus is retained, otherwise the extended corpus is regenerated or the original extended corpus is adjusted until the evaluation score is greater than the corpus set threshold. This process is iteratively optimized to ensure that the final generated extended corpus not only meets the role characteristics, but also can provide effective support in the actual dialogue generation task.
[0070] The extended corpus generated by this method significantly improves the diversity of character features and adaptability to conversational scenarios. Furthermore, we combine character description tags and conversation history (contextual information) to construct a character-enhanced dataset, laying a solid data foundation for personalized conversation generation tasks.
[0071] 2. Personalized dialogue generation based on large language models;
[0072] After classifying the character description labels and enhancing the expected role descriptions, a role enhancement dataset was further constructed. Then, instruction tuning was combined with Lora fine-tuning to guide the large model to complete the task of generating dialogues that are consistent with the personalized characteristics of the role and relevant to the context. Instruction Tuning adapts the model to the task through a large amount of instruction-response data, optimizes the instruction understanding ability of the baseline large model, enables it to accurately capture the role characteristics and context information from the input, and enables the baseline large model to better understand the prompts for dialogue generation; while LoRA fine-tuning inserts low-rank matrices into the key layers of the baseline large model (such as the attention layer and the feedforward layer) to learn the specific optimization direction of the input features. Only a small number of parameters need to be adjusted to achieve domain customization and efficient fine-tuning of the model, reducing training parameters and reducing the time cost of fine-tuning. Specifically, the input consists of an enhanced role description P, a role description label L, and a dialogue history (context information) C. The personalized dialogue result R generated by the fine-tuned baseline large model is expressed by the following formula:
[0073] R = f(P, L, C; θ);
[0074] Where f represents the generating function of the baseline large model after Instruction Tuning and LoRA fine-tuning, and θ is the parameter set of the model. In LoRA fine-tuning, some weights of the baseline large model (such as the weight matrix of the attention layer) are adjusted to:
[0075] W′=W+A·B;
[0076] Among them, W′ is the adjusted weight matrix of the key layer of the benchmark large language model, W is the original weight matrix of the benchmark large model, and is a learnable low-rank matrix, d represents the dimension of the original high-dimensional space, and r<<d represents the rank of the low-rank matrix. In this way, LoRA fine-tuning can efficiently adjust the model weights to adapt them to specific task requirements.
[0077] In order to ensure the effectiveness of LoRA fine-tuning, this embodiment designs a fine-tuning loss function based on the dialogue generation goal. It is used to minimize the error between the predicted personalized dialogue results and the target personalized dialogue results. Specifically, the fine-tuning loss function It can be expressed as:
[0078]
[0079] Among them, R i The predicted personalized dialogue results are output by the fine-tuned large language model. Personalize the conversation results for the target, is the cross entropy loss function, which is used to measure R i and The degree of match between and are the Frobenius norms of the low-rank matrices A and B, respectively, which are used to regularize the parameters of the low-rank matrices to prevent overfitting; is the KL divergence loss, which is used to measure the difference between the generated distribution and the target distribution; λ, μ and v are regularization coefficients used to balance the weights of the generation task loss and parameter regularization; N is the total number of samples in the augmented dataset.
[0080] By fine-tuning the loss function LoRA fine-tuning effectively optimizes the low-rank matrix parameters of the large baseline model, enabling accurate modeling of character traits and context within limited computing resources. Furthermore, the cross-entropy loss ensures the semantic accuracy of the generated content, while the regularization term limits overly complex parameter updates during the optimization process, further improving the model's generalization capabilities.
[0081] Therefore, the personalized dialogue generation method proposed in this embodiment includes two parts: character description data enhancement based on thought chain prompts and personalized dialogue generation. This method fully leverages the contextual understanding, reasoning, and generation capabilities of a pre-trained large language model. By combining thought chain prompts with a dynamic optimization mechanism, it significantly improves the quality and diversity of personalized dialogue generation. Regarding character description enhancement, the construction of character description labels and corpus expansion methods addresses the scarcity of personalized data, providing high-quality corpus support for dialogue generation. Regarding dialogue generation, the introduction of instruction tuning and LoRA fine-tuning techniques optimizes the model's instruction understanding and generation quality, ensuring that the generated content dynamically integrates character characteristics and dialogue context. Furthermore, this method exhibits excellent transferability and adaptability, not only improving the model's generalization capabilities in low-sample scenarios but also enabling personalized transfer across scenarios and domains. Through flexible design of prompt word templates and an efficient fine-tuning strategy, this method significantly reduces dependence on specific datasets and achieves high-quality personalized dialogue generation in multilingual and multi-domain tasks. At the same time, this method can be widely used in scenarios such as intelligent customer service, virtual assistants, and social chat. While improving the user interaction experience, it further optimizes the naturalness and emotional resonance of human-computer interaction.
[0082] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any technician familiar with the technical field, within the technical scope disclosed by the present invention, who makes equivalent replacements or changes based on the technical solution and inventive concept of the present invention, should be covered by the scope of protection of the present invention.
Claims
1. A personalized dialogue generation method based on role description enhancement, characterized by: Input the role description and conversation history into the trained personalized conversation model and output the personalized conversation results; The training process of the personalized dialogue model is as follows: The role descriptions in the training set are respectively subjected to role description label construction and role description corpus enhancement to obtain role description labels and enhanced role descriptions, and then combined with the dialogue history to construct an enhanced dataset; By enhancing the dataset, the baseline large language model is fine-tuned using a combination of instruction fine-tuning and Lora fine-tuning to output personalized conversation results.
2. The personalized dialogue generation method according to claim 1, characterized in that: The role description is constructed by the role description tag to obtain the role description tag, specifically: Setting a prompt template for extracting role labels, and dividing the prompt template into a first part of prompt words and a second part of prompt words; The role description to be filled is set between the first part of the prompt words and the second part of the prompt words as the input of the large language model. The role description label is obtained by extracting the label of the role description.
3. The personalized dialogue generation method according to claim 2, characterized in that: In the label extraction of role descriptions, a scoring mechanism is used to evaluate the generated role description labels, specifically: The prompt template, role description, and role description label output by the large language model are combined as the input of the large language model; The role description label entered is evaluated using the set multi-dimensional evaluation template. If the comprehensive score of the multi-dimensional evaluation template is greater than the set evaluation threshold, the role description label is retained; otherwise, the role description label is regenerated until the comprehensive score is greater than the set evaluation threshold.
4. The personalized dialogue generation method according to claim 1, characterized in that: The role description is enhanced by enhancing the role description corpus, specifically: Design structured prompt words, use role descriptions as input to the large language model, and generate extended corpus related to role descriptions; Based on a dynamic optimization mechanism, role descriptions and extended corpus are used as input for the large language model; The generated content is evaluated using the multi-dimensional indicators set in the large language model. If the evaluation score is greater than the corpus setting threshold, the extended corpus is retained. Otherwise, the extended corpus is regenerated or the original extended corpus is adjusted until the evaluation score is greater than the corpus setting threshold.
5. The personalized dialogue generation method according to claim 1, characterized in that: In fine-tuning the benchmark large language model using a combination of instruction fine-tuning and Lora fine-tuning, specifically: Command fine-tuning: Adapting the model to the task through a large amount of command-response data, optimizing the command understanding ability of the baseline large model to accurately capture role characteristics and contextual information from the input; Lora fine-tuning: Insert low-rank matrices into the key layers of the benchmark large language model, and combine them with the constructed fine-tuning loss function to learn specific optimization directions for input features.
6. The personalized dialogue generation method according to claim 5, characterized in that: In Lora fine-tuning, adjust the key layer weights of the baseline large language model, specifically: W′=W+A·B; Where W′ is the adjusted weight matrix of the key layer of the baseline large language model, W is the original weight matrix of the baseline large language model; A and B are learnable low-rank matrices.
7. The personalized dialogue generation method according to claim 5, characterized in that: Fine-tuning the loss function The formula is as follows: Where N is the total number of samples in the augmented dataset, is the cross entropy loss function, R i The predicted personalized dialogue results are output by the fine-tuned large language model. Personalize the conversation results for the target, and are the Frobenius norm of the low-rank matrix and B, respectively, is the KL divergence loss, λ, μ and v are regularization coefficients.
8. A personalized dialogue generation system based on role description enhancement, characterized by: Input the role description and conversation history into the trained personalized conversation model and output the personalized conversation results; The training process of the personalized dialogue model includes an enhanced dataset construction module and a fine-tuning module; The enhanced dataset construction module is used to construct role description labels and enhance role descriptions in the training set through role description label construction and role description corpus enhancement, and then combine them with the dialogue history to construct an enhanced dataset. The fine-tuning module is used to fine-tune the benchmark large language model by enhancing the dataset and combining instruction fine-tuning and Lora fine-tuning to output personalized dialogue results.
9. The personalized dialogue generation system according to claim 8, characterized in that: The enhanced dataset construction module includes a role description label construction module and a role description label evaluation module; The role description label construction module is specifically used to: set a prompt template for extracting role labels, and divide the prompt template into a first part of prompt words and a second part of prompt words; set the role description to be filled in between the first part of prompt words and the second part of prompt words as input to the large language model, and obtain the role description label by extracting the label from the role description; The role description label evaluation module is specifically used to combine the prompt template, role description and the role description label output by the large language model as the input of the large language model; the input role description label is evaluated through the set multi-dimensional evaluation template. If the comprehensive score of the multi-dimensional evaluation template is greater than the set evaluation threshold, the role description label is retained; otherwise, the role description label is regenerated until the comprehensive score is greater than the set evaluation threshold.
10. The personalized dialogue generation system according to claim 8, characterized in that: The enhanced dataset also includes a role description corpus enhancement module; The role description corpus enhancement module is specifically used for: Design structured prompt words, use role descriptions as input to the large language model, and generate extended corpus related to role descriptions; Based on a dynamic optimization mechanism, role descriptions and extended corpus are used as input for the large language model; The generated content is evaluated using the multi-dimensional indicators set in the large language model. If the evaluation score is greater than the corpus setting threshold, the extended corpus is retained. Otherwise, the extended corpus is regenerated or the original extended corpus is adjusted until the evaluation score is greater than the corpus setting threshold.
Citation Information
Cited By
Doctor-patient communication model training method and system based on synthetic roles
CN121148745A