A controllable simulated conversation method and system based on large language model

By preprocessing and annotating the corpus data in complex conversation scenarios and fine-tuning the large language model, the problem of how to effectively control the behavior of the conversation model is solved, and a high-reality simulated dialogue effect is achieved.

CN119226485BActive Publication Date: 2025-02-11杭州高新技术产业开发区(滨江)纪检监察信息中心
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411720485.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-02-11
Estimated Expiration
2044-11-28

AI Technical Summary

Technical Problem

In complex conversation scenarios, how to effectively control the behavior of dialogue models, especially through the evolution of emotions and logic, to simulate the thinking process of real characters, remains a technical challenge.

Method used

By obtaining the corpus data in the conversation scenario for preprocessing and annotation, a training set consisting of multiple question-and-answer pairs with progressive emotional characteristics is constructed. Based on this training set, the large language model is fine-tuned and trained to obtain a simulated dialogue model. This model outputs answers that conform to the laws of emotional evolution by retrieving enhanced generation mechanisms and dynamic transformations.

Benefits of technology

It realizes effective control of the behavior of dialogue models in complex conversation scenarios, improves the authenticity and practicality of the simulation, and enables the model to show a dialogue effect close to real people in specific conversation scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226485B_ABST
    Figure CN119226485B_ABST
Patent Text Reader

Abstract

The present application relates to a controllable simulated conversation method, system, electronic device and storage medium based on a large language model. Through multi-dimensional annotation of conversation data and emotion injection technology, the large language model can show different levels of emotional changes. From the resistance period of the conversation to the emotional fluctuation period, and then to the emotional breakdown period, the whole process conforms to the law of emotional evolution in complex conversation scenes, which improves the authenticity and practicality of the simulation. In scenes that require complex conversation capabilities, it can help practitioners improve their conversation skills and emotional guidance capabilities.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of artificial intelligence and natural language processing technology, and in particular, relates to a controllable conversation method, system, computer device and computer-readable storage medium based on a large language model. Background Art

[0002] Chatbot, also known as a conversation robot, is an artificial intelligence application based on computer programming that can simulate human conversations and complete conversation interactions by understanding text or voice information input by users and generating corresponding responses.

[0003] In terms of conversational robot technology, traditional rule- and template-based systems face many limitations, especially when dealing with complex and changing conversation scenarios, with low intelligence and poor interactive performance. However, by configuring large language models in scenarios, they can be adapted to specific professional conversation scenarios, such as medical consultation, legal Q&A, customer service, etc.

[0004] However, in some complex conversation scenarios, how to effectively control the behavior of the dialogue model, especially to simulate the thinking process of real people through the evolution of emotions and logic, and the comparison of objective facts, remains a technical challenge. Summary of the invention

[0005] The present application provides a controllable simulated conversation method, system, computer device and computer-readable storage medium based on a large language model, so as to at least solve the problem that the related technology cannot effectively control the behavior of the conversation model in a specific conversation scenario.

[0006] In a first aspect, an embodiment of the present application provides a controllable simulated conversation method based on a large language model, the method comprising:

[0007] Acquire corpus data in a conversation scenario, pre-process the corpus data, add annotations to the corpus data according to the situational features of the conversation scenario, and perform format conversion to obtain a training set consisting of multiple question-answer pairs with time-series association and progressive emotional features, wherein the annotations include emotional annotations, action annotations, and attitude annotations;

[0008] Fine-tune the large language model based on the training set to obtain a simulated dialogue model;

[0009] In response to the query statement of the conversation partner, a knowledge fragment corresponding to the query statement is obtained from a preset knowledge base through a retrieval enhancement generation mechanism, and the knowledge fragment is integrated with the query statement to obtain a retrieval enhancement result;

[0010] The trained simulated dialogue model continuously outputs the retrieval enhancement results based on dynamic changes to simulate the answering sentences of the person being talked to that conform to the law of emotional evolution.

[0011] In some embodiments, obtaining corpus data in a conversation scenario and preprocessing the corpus data includes:

[0012] Collecting corpus data in the conversation scenario, wherein the corpus data includes text data and conversation recordings, and converting the conversation recording data into text data by using speech recognition technology;

[0013] The corpus data is cleaned, classified and noise removed to obtain optimized corpus data, wherein the data cleaning includes: modal particle deletion, repeated word merging and language logic transcription.

[0014] In some embodiments, adding annotations to the corpus data according to the situational features of the conversation scene and performing format conversion includes:

[0015] adding attitude annotations to the optimized corpus data according to the attitude information of the interviewee during the answering process;

[0016] Adding emotion annotation to the optimized corpus data according to the tone information of the person being interviewed during the answering process;

[0017] According to the character actions of the person being interviewed during the answering process, adding action annotations to the optimized corpus data;

[0018] The optimized corpus data with the annotations added is formatted to obtain multiple question-answer pairs, wherein the question-answer pairs include a question part and an answer part, the question part includes role background information, answer constraints and historical conversation records, and the answer part is the answer of the person being interviewed to the question part.

[0019] In some embodiments, fine-tuning the large language model based on the training set to obtain the simulated dialogue model includes:

[0020] In the training set, the repeated character background information in the question part is deleted, and the constraint information used to constrain the model to generate the answer sentence is deleted to construct a valid training information set;

[0021] The effective training information set is used as a parameter for iteratively calculating a loss function to fine-tune the large language model to obtain the simulated dialogue model, wherein the loss function is used to determine the gap between the answer statement output by the simulated dialogue model and the real answer statement.

[0022] In some embodiments, the loss function is expressed by the following formula:

[0023]

[0024] in, represents the problem part of the current training round, represents the answer part of the current training round, Xt represents the tth character, and p(x) represents the probability of xt being generated when (x1 to xt-1) exists;

[0025] L is the loss function, T is the character background information and the constraint information;

[0026] In some embodiments, in any round of fine-tuning training, the process includes:

[0027] Through the input layer, word embedding processing is performed on the effective training information set to convert the effective training information set from a text format into a high-dimensional vector;

[0028] Through the intermediate layer, using linear transformation and nonlinear activation function, based on the high-dimensional vector and its corresponding annotation, multi-level iterative feature abstraction and extraction are performed to learn the sentiment transformation and logical association in the high-dimensional vector to obtain prediction features;

[0029] Through the output layer, based on the prediction features, the expected probability of outputting a certain answer sentence under the current conditions is predicted.

[0030] In some embodiments, during the overall fine-tuning training process, the method further includes:

[0031] The loss function is calculated based on the expected probability, and the loss value of the loss function obtained in each round of training is back-propagated to the input layer, the intermediate layer, and the output layer through a gradient descent method, so as to instruct the simulated dialogue model to optimize the internal parameters of the model according to the loss value to reduce the prediction error;

[0032] When the prediction error is less than or equal to a preset error threshold, the simulated dialogue model is obtained.

[0033] In a second aspect, an embodiment of the present application provides a controllable simulated conversation system based on a large language model, the system comprising: a corpus processing module, a model training module and a conversation simulation module, wherein:

[0034] The corpus processing module is used to obtain corpus data in a conversation scenario, and after preprocessing the corpus data, add annotations to the corpus data according to the situational features in the conversation scenario, and perform format conversion to obtain a training set consisting of multiple question-answer pairs with time-series association and progressive emotional features, wherein the annotations include emotional annotations, action annotations, and attitude annotations;

[0035] The model training module is used to perform fine-tuning training on the large language model based on the training set to obtain a simulated dialogue model;

[0036] The simulated dialogue module is used to respond to the query statement of the conversation partner, obtain the knowledge fragment corresponding to the query statement in the preset knowledge base through the retrieval enhancement generation mechanism, and integrate the knowledge fragment with the query statement to obtain the retrieval enhancement result.

[0037] The simulated dialogue model completed through training continuously outputs the retrieval enhancement results based on dynamic transformation, and is used to simulate the answering sentences of the person being talked to that conform to the law of emotional evolution.

[0038] In a third aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect above when executing the computer program.

[0039] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect above.

[0040] Compared with related technologies, the controllable simulated conversation method based on a large language model provided in the embodiment of the present application can enable the large language model to show different levels of emotional changes by performing multi-dimensional annotation and emotion injection technology on the conversation corpus data. The simulation of the conversation partner, from the resistance period at the beginning of the conversation to the emotional fluctuation period, and then to the emotional breakdown period, the whole process conforms to the law of emotional evolution in a real specific conversation scene, which improves the authenticity and practicality of the simulation. In scenarios that require complex conversation skills, it can help practitioners improve their conversation skills and emotional guidance capabilities. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0042] Figure 1 is a flow chart of a controllable simulated conversation method based on a large language model according to an embodiment of the present application;

[0043] Figure 2 is a structural block diagram of a controllable simulated conversation system based on a large language model according to an embodiment of the present application;

[0044] Figure 3 is a schematic diagram of a knowledge base according to an embodiment of the present application;

[0045] Figure 4 It is a schematic diagram of the internal structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0046] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0047] Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, the present application can also be applied to other similar scenarios based on these drawings without creative work. In addition, it can also be understood that although the efforts made in this development process may be complicated and lengthy, for ordinary technicians in this field related to the content disclosed in this application, some changes in design, manufacturing or production based on the technical content disclosed in this application are just conventional technical means, and should not be understood as insufficient content disclosed in this application.

[0048] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.

[0049] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantity limitation, and may indicate the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0050] In recent years, with the advancement of deep learning and pre-training models, conversation systems based on large language models (such as GPT, BERT, T5, etc.) have achieved remarkable results in many fields. Large language models are trained with massive corpus and have powerful natural language generation capabilities. They can not only answer simple questions, but also conduct contextually coherent conversations, and have demonstrated unique application potential in many professional fields.

[0051] In terms of conversational robot technology, traditional rule-based and template-based systems face many limitations, especially when dealing with complex and changeable conversation scenarios, with low intelligence and poor interactive performance. In some scenarios where the depth of the conversation needs to be gradually advanced, the reaction and emotional fluctuations of the conversation partner will gradually change as the conversation deepens, and traditional conversation systems are difficult to simulate complex logical thinking and psychological games. However, large language models are gradually breaking through these bottlenecks due to their powerful language understanding and generation capabilities, especially in simulated role-playing, emotional guidance and multi-round conversations, showing obvious advantages.

[0052] Current research and applications have shown that by fine-tuning large language models in scenarios, they can be adapted to general conversation scenarios, such as medical consultation, legal Q&A, customer service, etc. However, in complex and difficult scenarios, how to effectively control the behavior of the model, especially to simulate the thinking process of real people through the evolution of emotions and logic, remains a technical challenge.

[0053] In view of this, the present application scheme uses the powerful language generation and understanding capabilities of the large language model to develop an intelligent conversation system that can simulate the conversation process in complex scenarios. The system can not only simulate the logical reasoning and psychological state changes of the person being interviewed during the conversation, but also gradually adjust its behavior according to the way the interviewer asks questions, from the initial resistance and lying stage to the final emotional reversal and real communication or continued denial. Through this simulated scenario, the interviewer can exercise his conversation skills and case breakthrough ability in a safe and virtual environment.

[0054] Figure 1 is a flow chart of a controllable simulated conversation method based on a large language model according to an embodiment of the present application, such as Figure 1 As shown, the process includes the following steps:

[0055] S101, obtaining corpus data in a conversation scenario, preprocessing the corpus data, adding annotations to the corpus data according to the situational features of the conversation scenario, and performing format conversion to obtain a training set consisting of multiple question-answer pairs with time-series association and progressive emotional features, wherein the annotations include emotional annotations, action annotations, and attitude annotations;

[0056] First of all, it should be noted that this solution is implemented using a simulated conversation system, which includes a corpus processing module and a model training module. These two modules work together to implement the complete process from data collection to intelligent conversation generation, ensuring that the system can demonstrate conversation effects close to real people in specific business scenarios.

[0057] In this embodiment, it can be understood that, in the entire conversation process of this scene, the emotions of the person being talked to usually show the evolution law of human-like emotions;

[0058] After collecting the corpus data, since the corpus data may include text data, image data, audio data and video data, the collected identifiable data is converted into text data, and then cleaned using a variety of data methods and converted into a format to form the question-answer pairs required for fine-tuning training; the question part includes role background information, answer constraints and historical conversation records, and the answer part is the answer of the person being interviewed to the question part.

[0059] Furthermore, the situational features are used as annotations for corpus data, providing an important basis for subsequent model training. During model training, the model can learn the conversation patterns and language characteristics under different psychological states based on the data features of different emotional stages, thereby better simulating the emotional changes of the person being interviewed during the conversation.

[0060] Specifically, obtaining the corpus data in the conversation scenario and preprocessing the corpus data includes:

[0061] S1. Desensitize through real conversation recordings or text records. Then, use measures such as automatic speech recognition (ASR) technology to uniformly process them into text format, and clean and classify the text data, removing noise data and retaining high-quality content that conforms to the simulated scenario to obtain the above-mentioned corpus data;

[0062] S2. Delete modal particles: Remove modal particles in the corpus, such as "ah", "oh", "um", etc. These modal particles contribute less to semantics in many cases. Removing them can reduce data redundancy and improve the efficiency of subsequent processing;

[0063] S3. Merge repeated words: Merge continuously occurring repeated words. For example, "I I I" can be merged into "I". This can simplify the text and highlight key information;

[0064] S4. Transcribe language logic: Transcribe some non-standard or colloquial expressions into logical form to make them more in line with the norms of written language. For example, "Well, that is to say..." can be transcribed as "That is to say...". This helps to improve the quality and readability of the corpus;

[0065] S5. Further, classify the corpus data according to established rules. For example, it can be classified according to the topic of the conversation, participants, scenario, etc. Classification can help better organize and analyze the corpus in the future, and is also convenient for specific processing of specific types of corpus.

[0066] S6. Remove noise: Identify and remove noise data in the corpus. Noise may include incorrect characters, garbled codes, irrelevant symbols, etc. By removing noise, the purity and accuracy of the corpus can be improved.

[0067] After the above preprocessing process, optimized corpus data is obtained, providing a more reliable and effective data basis for subsequent language model training, analysis and other tasks.

[0068] In this embodiment, since the current emotions, attitudes and actions of the interlocutors cannot be accurately described only based on the conversation information. Therefore, in this solution, emotions, attitudes and actions are strictly labeled in a fixed format before training.

[0069] Since the labeled training data has clearer features and structures, the model can better learn the emotional evolution, logical self-consistency and coherence of multiple rounds of dialogue during the model training process; the labeling provides a basis for the injection of emotions in model training. By learning text data with different emotional labels, the model can more accurately grasp the emotional expression and show multi-level emotional changes in simulated dialogues, such as from the resistance period to the emotional fluctuation period and then to the emotional collapse period, making its simulation more in line with the emotional evolution law in real conversations.

[0070] Specifically, after the preprocessing is completed, the corpus is professionally annotated. During the annotation process, the corpus is classified and annotated. Among them, the classification annotation of a conversation scene is as follows:

[0071] The first type of answer content attitude annotation includes:

[0072] Silence,

[0073] Arrogant,

[0074] Cover up with physical discomfort,

[0075] Changing concepts and emotional stability, etc.

[0076] The second type of answer tone annotation includes:

[0077] The choices of tone include: "arrogant, silent, sighing, refuting, irritable, irritable, humble" etc.

[0078] The third category is to simulate character action annotation, including:

[0079] The action options include: "nodding in approval, feeling at a loss, touching hair, touching nose, spreading hands, clapping the table, looking up somewhere, lowering head in silence, staring" etc.

[0080] It is understandable that professionally annotated corpora provide high-quality data for the training of large language models. By learning these annotated corpora, the model can better understand the meanings of different types of answers, tones, and actions, as well as the relationship between them. This helps to screen and organize the corpus. For annotation types that appear frequently in different scenarios and have a greater impact on the simulation effect, more weight can be given during the training process, thereby optimizing the training effect of the model and enabling the model to more accurately generate dialogues that conform to real situations.

[0081] At the same time, these annotations provide such standards. When the model generates dialogue output, the system can check it according to the annotation content. For example, if the answer generated by the model should be "arrogant" in attitude, but the tone is too humble and does not match the normal association with the annotation, dynamic control can adjust the output to make the logic and emotional expression of the dialogue more reasonable.

[0082] Furthermore, after the annotation is completed, the optimized corpus data is formatted to obtain multiple question-answer pairs, which include a question part and an answer part. The question part includes role background information, answer constraints and historical dialogue records, and the answer part is the answer content of the role being interviewed to the current question part.

[0083] Multiple question-answer pairs with temporal associations can approximate the overall emotional evolution during the conversation and constitute the training set required for training the model.

[0084] Through the above steps, the optimized corpus data is processed into question-answer pairs containing detailed information. Since the question part covers a variety of key information, the system can flexibly adjust the generation of answers based on different background descriptions, answer constraints and historical conversation records, so that the dialogue model can more accurately simulate the real reactions of the characters being talked to in different scenarios. In complex conversation scenarios, the attitude, tone and actions of the person being talked to can be accurately analyzed from all aspects based on the rich information in these question-answer pairs, making the subsequent simulation training process more accurate and the operation process more realistic.

[0085] S102, fine-tuning the large language model based on the training set through the model training module to obtain a simulated dialogue model;

[0086] After the corpus data is prepared, the specific fine-tuning training process includes the following steps:

[0087] S1, in the training set, delete the repeated role background information in the question part, and delete the constraint information used to constrain the model to generate answer sentences, and construct a valid training information set;

[0088] It should be noted that the traditional fine-tuning method calculates the loss function based on the probability of the model answering a given output (response) under a given input (prompt), that is, the prompt loss will not be used in the iteration process of the model parameters. The specific formula is as follows, where I is the given input, C is the given response, P (A|B) is the probability of A under condition B, and L is the loss function of the corresponding algorithm.

[0089] In traditional solutions, when calculating the loss function, the loss is calculated only based on the probability of the model answering a given output (response) under a given input (prompt). This means that the model is mainly concerned with how to generate a response corresponding to a specific prompt, while ignoring the learning of emotional evolution and logic in the conversation. For example, in a simulated conversation, a traditional model may only be able to answer questions mechanically, and cannot show emotional fluctuations (such as from resistance to hesitation) and logical changes (such as from denial to partial admission) as the conversation progresses like a real interlocutor. This limitation causes the dialogue generated by the model to lack realism and depth, and it is difficult to play an effective role in complex scenarios that require in-depth exploration of emotional and logical interactions.

[0090] However, if the method of involving all prompt losses in the model parameter iteration process to solve the above problem is adopted, new problems will arise. Because prompts contain a lot of repeated role background information and model answer specifications, when the model repeatedly learns this information, it is easy to over-adapt to the training data, resulting in overfitting.

[0091] In this application, in order to ensure that the model learns the most relevant information and improve the efficiency of model training, the loss of questions and answers is included in the model parameter iteration in this training, and a large amount of repeated character background information and constraint information on the model's answers are not included in the parameter iteration. The advantage of this is that the model can fully learn the key information in the conversation, including the semantic relationship between questions and answers, language structure, and emotional expression.

[0092] By calculating the loss of questions and answers, the model can better understand how to generate accurate, reasonable, emotional and logical responses. In a simplified example, such as learning a conversation, the model can learn how to respond with appropriate emotions and logic in this situation from the loss calculation of the question "Did you participate in this event?" and the answer "I definitely did not participate (refute) (look up at the person talking)", thereby improving the ability to simulate real conversations. At the same time, a large amount of repeated character background information and constraint information on the model's answers are not included in the parameter iteration. This effectively avoids the model's over-learning of these repeated information and reduces the risk of overfitting.

[0093] The specific implementation is as follows: the part for calculating the loss function is defined as X, where X includes the question and the answer but does not include the character background information in the question and the constraint information on the model's answer, and the character background information and the constraint information on the model's answer are represented by T.

[0094] The loss function is expressed by the following formula:

[0095]

[0096] in, represents the problem part of the current training round, represents the answer part of the current training round, Xt represents the tth character, and p(x) represents the probability of xt being generated when (x1 to xt-1) exists;

[0097] L is the loss function, is the logarithm of the probability of the t-th element given the first t-1 characters, expressed in natural logarithm form, T is the character background information and the constraint information, is an indicator function, if Not , then the value is 1, otherwise it is 0. This shows the role background information and the constraint information of the model's answer.

[0098] S2, based on the effective training information set, iteratively calculates the parameters of the loss function, and fine-tunes the large language model to obtain a simulated dialogue model, wherein the loss function is used to determine the gap between the response content output by the large language model and the actual response content.

[0099] Among them, the traditional fine-tuning method has limitations. It only calculates the loss based on the probability of the model answering a given output under a given input, and cannot learn the emotional evolution and logic in the conversation. The new fine-tuning method redefines the loss function, and defines the part of the loss function to be calculated as X, where X includes the question and the answer but does not include the background information of the characters in the question and the constraint information on the model question and answer. In addition, it provides emotional injection in combination with the annotation information provided in the above step S101, which enables the model to better learn the emotional evolution, logical self-consistency and coherence of multiple rounds of conversations in the conversation, and the model can grasp the emotional expression more accurately.

[0100] In addition, the new loss function excludes character background information and model answer constraint information (represented by T) from participating in parameter iteration, effectively reducing repeated learning and the risk of overfitting, allowing the model to focus more on learning the core content of questions and answers, thereby improving the grasp of conversation emotion evolution, logical autonomy, and coherence of multiple rounds of conversations.

[0101] In addition, in the present application, in an exemplary embodiment, in any round of fine-tuning training, the large language model generates simulated response content including the following specific steps:

[0102] S1, through the input layer, performs word embedding processing on the effective training information set, converting the effective training information set from text to a high-dimensional vector;

[0103] The text data of questions and answers enters the input layer of the model. In this layer, the text is converted into numerical representations suitable for model processing, such as converting each word into a high-dimensional vector through word embedding technology.

[0104] S2, through the middle layer, uses linear transformation and nonlinear activation function to perform multi-level iterative feature abstraction and extraction based on high-dimensional vectors, learns the sentiment transformation and logical association in high-dimensional vectors, and obtains prediction features;

[0105] The word vector output by the previous layer enters the middle layer (which may be multiple hidden layers). The middle layer gradually abstracts and extracts the input features through a series of linear transformations and nonlinear activation functions.

[0106] In each layer, the model learns different levels of semantic information and logical relationships. For example, the lower layers may learn lexical and syntactic features, and the higher layers may learn more abstract semantic concepts and contextual relationships. The middle layer will continue to receive feature representations from the previous layer, perform specific calculations and processing, and then output new feature representations to the next layer.

[0107] S3, through the output layer, predicts the expected probability of outputting a certain reply content under the current conditions based on the prediction features.

[0108] The middle layer gradually abstracts and extracts the word vectors of the input questions and answers, and learns semantic information and logical relationships at different levels. This process enables the model to have a deeper understanding and representation of questions and answers, and the calculation of the loss function needs to rely on the model's understanding and representation of questions and answers.

[0109] By calculating the loss function, the model can evaluate the accuracy of its predictions for questions and answers under the current parameters. The loss function value reflects the accuracy of the model's predictions for questions and answers. This loss value is back-propagated to each layer of the model, including the middle layer, through an optimization algorithm (such as gradient descent). During the back-propagation process, the parameters of the middle layer are adjusted according to the gradient of the loss function, so that the model can better learn the information in the questions and answers and reduce the prediction error. By continuously adjusting the parameters of the middle layer, the model can gradually improve its ability to handle questions and answers, thereby gradually reducing the loss function value.

[0110] The above process is repeated and training is performed iteratively until the loss function converges or the preset number of training times is reached, and a simulated dialogue model that has been fine-tuned and trained is obtained.

[0111] Through experiments, we found that after using the above method, the overall accuracy of the model in the evolution of emotions in the conversation, logical consistency, and the coherence of multiple rounds of conversations increased by 9.65%, and the training time was saved by 5.72% compared to the model in which all questions and answers were included in the model parameter iteration.

[0112] S103, responding to the query statement of the conversation partner, obtaining the knowledge fragments corresponding to the query statement in the preset knowledge base through the retrieval enhancement generation mechanism, and integrating the knowledge fragments with the query statement to obtain the retrieval enhancement result.

[0113] Specifically, the Retrieval Augmented Generation (RAG) mechanism is adopted. When the simulated dialogue model generates dialogues or answers questions, relevant information is first retrieved from the preset knowledge base, and then the retrieved information is used to guide the generation of text, thereby improving the quality and accuracy of the prediction.

[0114] It can be understood that the background knowledge of a conversation is first stored as objective facts in a specific vector database. In the knowledge construction stage, text segmentation and cleaning, text vectorization, and finally storage in the vector database are required. This process converts the data into large vectors in the form of numerical representation, and then stores them in the vector database for subsequent document retrieval. The data can be unstructured (usually text), semi-structured, or structured (such as knowledge graphs).

[0115] When the user and the model have a conversation, the query sentence is first converted into a query vector, and the knowledge fragments related to the query vector are selected from the preset knowledge base. Through prompt engineering, the knowledge fragments are combined with the original query sentence and embedded into the preset prompt template to obtain the retrieval enhancement result. After retrieval enhancement, it is input into the trained large language model (LLM) to generate the required answer sentence output.

[0116] Figure 2 is a schematic diagram of a knowledge base according to an embodiment of the present application, with reference to Figure 2 From the content shown, it can be understood that through the above-mentioned retrieval enhancement mechanism, the latest information can be dynamically obtained from the external knowledge base to make the generated answers more timely. In addition, the introduction of external data to enhance the accuracy of the answers overcomes the problem of hallucinations in the language model. At the same time, these external knowledge is not directly exposed to the public network environment to participate in model training. Therefore, it not only improves the transparency and credibility of the answers, allowing users to verify the accuracy of the answers, but also improves data security.

[0117] In addition, according to different application scenarios and requirements, the appropriate knowledge base and retrieval method can be selected to customize and improve the simulated dialogue model. If no relevant context is retrieved, the question needs to be directly passed to the trained large language model for answer output.

[0118] It is understandable that after the actual deployment of this model, in the conversation scene, it can help new interviewers quickly get started, provide a simulation environment close to reality, and exercise their questioning skills and emotional guidance ability. At the same time, through the dynamic feedback mechanism of the large model, it helps interviewers discover the logical loopholes and emotional weaknesses of the interviewee, and improve their conversation business capabilities.

[0119] In addition, when conducting a conversation, one often needs to face different interviewees. Through this model, the interviewer can practice how to deal with different types of interviewees in a virtual scene. The system will adjust the rhythm and style of the conversation according to different situational responses, helping the interviewer hone his questioning skills.

[0120] In summary, through this model, interviewers can conduct multiple simulation training in a safe virtual environment to improve their conversation skills. For example, a newly hired interviewer may not be able to accurately judge the timing of the conversation or the logical breakthrough at the beginning. The simulation system can help the interviewer discover the other party's emotional and logical weaknesses through role-playing guidance, so as to conduct effective conversation guidance. As the training deepens, the interviewer can gradually master how to guide the interviewee to clarify the problem through questioning, guidance and psychological analysis. Through multiple trainings, the interviewer can become familiar with the conversation skills in different types of cases and learn how to gradually dig into the other party's psychological defenses through meticulous questioning. The logical changes, emotional fluctuations, and resistance mentality of the interviewee can all be realistically presented through the system, helping new interviewers to quickly respond to complex conversations in different scenarios.

[0121] Through the above steps S101 to S103, a multi-dimensional annotation and emotion injection technology for dialogue data is formed, which can enable the large language model to show different levels of emotional changes. For example, from the resistance period of the dialogue to the emotional fluctuation period, and then to the emotional breakdown period, the whole process conforms to the law of emotional evolution in real conversations, which improves the authenticity and practicality of the simulation. In addition, through the introduction of a dynamic feedback mechanism, the model can adjust the strategy in real time according to the content of the dialogue, making the simulation process more realistic, greatly improving the actual training effect of the user.

[0122] In a second aspect, the present application also provides a controllable simulated conversation system based on a large language model. Figure 3 is a structural block diagram of an intelligent battery replacement guidance system based on a hybrid timing network according to an embodiment of the present application, such as Figure 3 As shown, the system includes: a corpus processing module 30, a model training module 31, and a dialogue simulation module 32, wherein:

[0123] The corpus processing module 30 is used to obtain corpus data in a conversation scenario, and after preprocessing the corpus data, add annotations and format conversion to the corpus data according to the situational characteristics of the conversation scenario to obtain a training set, which includes multiple question-answer pairs with gradually progressive emotional stages;

[0124] The model training module 31 is used to fine-tune the large language model based on the training set to obtain a simulated dialogue model;

[0125] The simulated dialogue module 32 is used to continuously output simulated answer content with gradually progressive emotions through the trained simulated dialogue model for personnel training.

[0126] After the system is actually deployed, specific application examples for business training include:

[0127] It helps new interviewers get started quickly and provides a simulation environment close to reality to train their questioning skills and emotional guidance abilities. At the same time, through the dynamic feedback mechanism of the big model, it helps interviewers discover the logical loopholes and emotional weaknesses of the subject and improve their ability to break through cases.

[0128] When facing different interviewees, through this system, interviewers can practice how to deal with different types of interviewees in virtual scenes. The system will adjust the rhythm and style of the conversation according to different situational reactions, helping interviewers hone their questioning skills;

[0129] Specifically, the example includes:

[0130] Conversation scene setting: simulate the real case background and inject key knowledge points and factual information related to the case. The large language model simulates the logical thinking and emotional response of the person being interviewed through a customized knowledge base and fine-tuning technology.

[0131] Model fine-tuning and emotion control: In this scenario, the large language model can simulate the entire process of the person being interviewed from initial resistance to gradual emotional change and finally cooperating with the person to confess through emotion injection. The system will adjust the content of the conversation according to the person's questioning method and logic.

[0132] According to the above exemplary embodiments, the present application scheme successfully provides an efficient training tool for conversations with emotional logic changes through intelligent simulation of a large language model, allowing new interviewers to gradually transform from a lack of experience to mastering conversation skills in a short period of time and be able to deal with complex cases proficiently. This not only improves the professional ability of personnel, but also effectively reduces the risk of mistakes caused by lack of experience in actual conversations.

[0133] In one embodiment, Figure 4is a schematic diagram of the internal structure of an electronic device according to an embodiment of the present application, such as Figure 4 As shown, an electronic device is provided, which may be a server, and its internal structure diagram may be as shown in Figure 4 As shown. The electronic device includes a processor, a network interface, an internal memory and a non-volatile memory connected through an internal bus, wherein the non-volatile memory stores an operating system, a computer program and a database. The processor is used to provide computing and control capabilities, the network interface is used to communicate with an external terminal through a network connection, the internal memory is used to provide an environment for the operation of the operating system, the computer program is executed by the processor to implement a controllable simulated conversation method based on a large language model, and the database is used to store data.

[0134] Those skilled in the art will understand that Figure 4 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0135] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by hardware related to computer program instructions, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0136] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0137] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A controllable simulated conversation method based on a large language model, characterized in that: The method comprises: Acquire corpus data in a conversation scenario, pre-process the corpus data, add annotations to the corpus data according to the situational features of the conversation scenario, and perform format conversion to obtain a training set consisting of multiple question-answer pairs with time-series association and progressive emotional features, wherein the annotations include emotional annotations, action annotations, and attitude annotations; Fine-tune the large language model based on the training set to obtain a simulated dialogue model, specifically including: in the training set, deleting repeated character background information in the question part, and deleting constraint information used to constrain the model to generate answer sentences, to construct a valid training information set; The effective training information set is used as a parameter for iteratively calculating a loss function, and the large language model is fine-tuned to obtain the simulated dialogue model, wherein the loss function is used to determine the gap between the answer statement output by the simulated dialogue model and the real answer statement, and the loss function is expressed by the following formula: in, represents the problem part of the current training round, represents the answer part of the current training round, Xt represents the tth character, and p(x) represents the probability of xt being generated when (x1 to xt-1) exists; L is the loss function, T is the character background information and the constraint information; In response to the query statement of the conversation partner, a knowledge fragment corresponding to the query statement is obtained from a preset knowledge base through a retrieval enhancement generation mechanism, and the knowledge fragment is integrated with the query statement to obtain a retrieval enhancement result; Through the trained simulated dialogue model, the retrieval enhancement results based on dynamic changes are continuously output to simulate the answer sentences of the person being talked to that conform to the law of emotional evolution.

2. The method according to claim 1, characterized in that Acquiring corpus data in a conversation scenario and preprocessing the corpus data includes: Collecting corpus data in the conversation scenario, wherein the corpus data includes text data and conversation recordings, and converting the conversation recording data into text data by using speech recognition technology; The corpus data is cleaned, classified and noise removed to obtain optimized corpus data, wherein the data cleaning includes: modal particle deletion, repeated word merging and language logic transcription.

3. The method according to claim 2, characterized in that Adding annotations to the corpus data according to the situational features of the conversation scenario and performing format conversion includes: adding attitude annotations to the optimized corpus data according to the attitude information of the interviewee during the answering process; Adding emotion annotation to the optimized corpus data according to the tone information of the person being interviewed during the answering process; According to the actions of the person being interviewed during the answering process, adding action annotations to the optimized corpus data; The optimized corpus data with the annotations added is formatted to obtain multiple question-answer pairs, wherein the question-answer pairs include a question part and an answer part, the question part includes role background information, answer constraints and historical conversation records, and the answer part is the answer of the person being interviewed to the question part.

4. The method according to claim 1, characterized in that: Fine-tuning the large language model based on the training set to obtain a simulated dialogue model further includes: Through the input layer, word embedding processing is performed on the effective training information set to convert the effective training information set from a text format into a high-dimensional vector; Through the intermediate layer, using linear transformation and nonlinear activation function, based on the high-dimensional vector and its corresponding annotation, multi-level iterative feature abstraction and extraction are performed to learn the sentiment transformation and logical association in the high-dimensional vector to obtain prediction features; Through the output layer, based on the prediction features, the expected probability of outputting a certain answer sentence under the current conditions is predicted.

5. The method according to claim 4, characterized in that During the overall fine-tuning training process, the method further includes: The loss function is calculated based on the expected probability, and the loss value of the loss function obtained in each round of training is back-propagated to the input layer, the intermediate layer, and the output layer through a gradient descent method, so as to instruct the simulated dialogue model to optimize the internal parameters of the model according to the loss value to reduce the prediction error; When the prediction error is less than or equal to a preset error threshold, the simulated dialogue model is obtained.

6. A controllable simulated conversation system based on a large language model, characterized in that: The system comprises: a corpus processing module, a model training module and a dialogue simulation module, wherein: The corpus processing module is used to obtain corpus data in a conversation scenario, and after preprocessing the corpus data, add annotations to the corpus data according to the situational features in the conversation scenario, and perform format conversion to obtain a training set consisting of multiple question-answer pairs with time-series association and progressive emotional features, wherein the annotations include emotional annotations, action annotations, and attitude annotations; The model training module is used to fine-tune the large language model based on the training set to obtain a simulated dialogue model, specifically including: in the training set, deleting repeated role background information in the question part, and deleting constraint information used to constrain the model to generate answer sentences, to construct a valid training information set; The effective training information set is used as a parameter for iteratively calculating a loss function, and the large language model is fine-tuned to obtain the simulated dialogue model, wherein the loss function is used to determine the gap between the answer statement output by the simulated dialogue model and the real answer statement, and the loss function is expressed by the following formula: in, represents the problem part of the current training round, represents the answer part of the current training round, Xt represents the tth character, and p(x) represents the probability of xt being generated when (x1 to xt-1) exists; L is the loss function, T is the character background information and the constraint information; The simulated dialogue module is used to respond to the query statement of the conversation partner, obtain the knowledge fragment corresponding to the query statement in the preset knowledge base through the retrieval enhancement generation mechanism, and integrate the knowledge fragment with the query statement to obtain the retrieval enhancement result. The simulated dialogue model completed through training continuously outputs the retrieval enhancement results based on dynamic transformation, and is used to simulate the answering sentences of the person being talked to that conform to the law of emotional evolution.

7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Conversation text generation method and device, storage medium and electronic equipment

    CN117216223A

  • Large language model training method and device

    CN118349852A