A method and system for augmenting conversation data using a large language model
By obtaining dialogue paths and preset prompt information, using a large language model to generate dialogue data that conforms to the path, solving the diversity and controllability problems of dialogue data augmentation in the existing technology, and achieving high-quality and diversified dialogue data generation.
Patent Information
- Application Number
- CN202411146127.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2044-08-20
AI Technical Summary
The existing dialogue data augmentation method based on large language models has problems such as relying on source training data, lack of diversity, lack of logic and controllability, and it is difficult to generate high-quality multi-round dialogue data.
By obtaining dialogue paths and preset prompt information, a pre-trained or fine-tuned large language model is used to generate complete dialogue data that conforms to the dialogue path, a circular or non-cyclical method is used to iterate the dialogue data, and control the content by updating the prompt information, introducing a dialogue path constraint generation process.
It improves the diversity, logical reasoning and controllability of dialogue data, expands the coverage of scenes, and the generated dialogue data is more personalized and diverse, and has higher quality.
Smart Images

Figure CN119204210B_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 augmenting conversation data using a large language model. Background Art
[0002] Conversational data refers to a collection of text or voice messages exchanged between two or more participants. This data typically records verbal interactions between people in specific contexts and can be used to train and evaluate natural language processing (NLP) and dialogue systems. Conversational data can be actual conversation transcripts or text information extracted from various sources, such as user interactions, social media, or text files, for model training and analysis.
[0003] Data from different sources has varying characteristics and noise. Before extracting or using this data, conversational data needs to be preprocessed to improve its quality. High-quality conversational data can improve model performance, enhance the model's contextual understanding, address diverse user needs, support complex tasks and application scenarios, and reduce bias and discrimination. Even with preprocessing, high-quality conversational data remains extremely limited despite the enormous demand. Therefore, one of the key goals in the current data field is to improve the quality and increase the amount of high-quality conversational data, namely, to perform data augmentation on conversational data.
[0004] Effective means of augmenting conversation data include text generation technology. Various text generation technologies have been widely used in pre-trained language models. The application of data augmentation technology helps to improve the quality and quantity of conversation data.
[0005] However, different data augmentation methods improve the multidimensional features of conversational data to varying degrees. For example, using a large language model (LLM) can enhance the diversity of conversational data, while adversarial augmentation can help improve the security of conversational data. Currently, common methods utilizing large language models focus on generating conversations through manually designed scenario or task prompts. However, this approach has several limitations. It relies on the limited source training datasets in LLMs, neglects other text sources, and lacks control over the content of the generated conversational data. This can easily lead to poor quality of the generated conversational data, with numerous issues such as sparse scenarios, lack of logic, and a single model.
[0006] Existing methods for augmenting conversation data based on large language models to generate text have certain limitations, mainly including: (1) They rely on the source training data used to train the large language model, and the augmented conversation data is similar to the source training data, lacks diversity, and is difficult to cover rare scenarios and extended scenarios. (2) By augmenting text through knowledge graphs, only triples are expanded into single sentences, and there is no augmentation method to convert multi-node paths into multi-round conversations. (3) The expansion method of expanding single-round conversations into multi-round conversation data cannot be effectively extended to text from other sources, resulting in the augmented conversation data lacking sufficient diversity and breadth. (4) Whether it is the method of generating conversation data based on prompt templates or the method of generating conversation data based on single-round conversations, each round of multi-round conversation data is generated by the initial prompt template, which cannot effectively control the content of the generated conversation and lacks controllability. Summary of the Invention
[0007] In view of this, embodiments of the present invention provide a method and system for augmenting conversation data using a large language model to eliminate or improve one or more deficiencies in the prior art.
[0008] One aspect of the present invention provides a method for augmenting conversation data using a large language model, the method comprising the following steps: obtaining a conversation path and preset prompt information; wherein the conversation path is extracted from text information from different sources, and the conversation path includes a plurality of conversation nodes arranged in sequence and the relationships between the conversation nodes; and generating complete conversation data satisfying the conversation path using the large language model according to the prompt information, wherein the large language model is a pre-trained large language model or a fine-tuned pre-trained large language model.
[0009] In some embodiments of the present invention, the method also includes the step of extracting a dialogue path from text information from different sources, including: when the source of the text information is structured data, retrieving and selecting or randomly selecting multiple dialogue nodes from the structured data, arranging the order of the selected dialogue nodes according to a predefined combination method, and filling in the relationship between the dialogue nodes to obtain a dialogue path extracted from the text information; when the source of the text information is unstructured data, extracting dialogue nodes and the relationship between dialogue nodes from the unstructured data using rules and / or models, performing secondary processing on the extracted dialogue nodes including replacing keywords, rewriting or adding and deleting, arranging the order of the dialogue nodes after the secondary processing according to a predefined combination method, and filling in the relationship between the dialogue nodes to obtain a dialogue path extracted from the text information; wherein the unstructured data includes existing dialogue data, network text, news text and audio and video data containing text information.
[0010] In some embodiments of the present invention, the types of preset prompt information include system prompts, task prompts, sample prompts and thought chain prompts; the preset prompt information includes basic content and additional content, the basic content is used to promote the generation of dialogue data through prompts, and the additional content is used to add additional requirements for complete dialogue data in the process of generating complete dialogue data that meets the dialogue path.
[0011] In some embodiments of the present invention, when a non-cyclic dialogue generation method is adopted, the step of using the large language model to generate complete dialogue data that satisfies the dialogue path according to the prompt information includes: calling the large language model, inputting the dialogue path and the preset prompt information into the large language model, and the large language model outputting the complete dialogue data that has a mapping relationship with each dialogue node of the dialogue path at one time according to the preset prompt information.
[0012] In some embodiments of the present invention, when a cyclic dialogue generation method is adopted, the step of using the large language model to generate complete dialogue data that satisfies the dialogue path according to the prompt information includes: calling the large language model, inputting the preset prompt information as the initial prompt into the large language model, inputting the dialogue path into the large language model, and generating a first round of single-round dialogue; judging whether the generation of the complete dialogue path is completed according to preset conditions, if the end condition is not met, obtaining updated preset prompt information, inputting the updated preset prompt information and dialogue path into the large language model, and generating the next round of single-round dialogue; when the end condition is met, integrating all rounds of single-round dialogue to obtain complete dialogue data.
[0013] In some embodiments of the present invention, the preset prompt information includes basic content and additional content, the basic content includes a conversation history consisting of a single-round conversation in a previous round, a current conversation node, and prompt description change information, and the additional content includes tags or other conversation paths for adding additional requirements for complete conversation data; between the generation of single-round conversations in different rounds, the step of obtaining updated preset prompt information includes: updating the conversation history, current conversation node, and prompt description change information contained in the basic content, and obtaining the updated additional content.
[0014] In some embodiments of the present invention, the method further includes a step of pre-fine-tuning the pre-trained large language model, including: obtaining a pre-constructed basic data set containing mapping pairs of dialogue paths and dialogue data; obtaining weight parameters of the pre-trained large language model with different fine-tuning times; a fine-tuning step of fine-tuning the parameters contained in the large language model; the fine-tuning operation includes setting fine-tuning hyperparameters including a learning rate, a fine-tuning parameter amount, or a training number, and also includes pre-processing the basic data set; testing the performance of the large language model after the fine-tuning operation, and if a preset stopping condition is not met, screening dialogue data that meets preset quality requirements from the dialogue data generated by the large language model after the fine-tuning operation and integrating it into the basic data set, and returning to the fine-tuning step; wherein the preset stopping condition is reaching a specified number of fine-tuning times or the basic data set reaching a specified size; stopping when the preset stopping condition is met, and selecting the large language model weight parameters with the best performance after fine-tuning as the large language model weight parameters for generating complete dialogue data.
[0015] Another aspect of the present invention provides a conversation data augmentation system using a large language model, comprising a processor, a memory, and a computer program / instructions stored in the memory, wherein the processor is configured to execute the computer program / instructions. When the computer program / instructions are executed, the system implements the steps of the method described in any one of the above embodiments.
[0016] Another aspect of the present invention provides a computer-readable storage medium having a computer program / instruction stored thereon, which implements the steps of the method described in any one of the above embodiments when the computer program / instruction is executed by a processor.
[0017] Another aspect of the present invention provides a computer program product, comprising a computer program / instruction, which implements the steps of the method described in any one of the above embodiments when executed by a processor.
[0018] The present invention's method and system for augmenting conversation data using a large language model introduces a conversation path to constrain the content of generated conversation data. This method and system utilizes a large language model to generate complete conversation data that conforms to the order of conversation nodes in the input conversation path and satisfies the relationships between conversation nodes. Furthermore, a turn-by-turn, quasi-node-level conversation data generation method is proposed. Between turns, prompt information is updated to adjust the generated conversation data for the next turn. This allows for more convenient and rapid generation of personalized conversation data that meets individual needs, resulting in greater diversity in the generated conversation data.
[0019] Additional advantages, objects, and features of the present invention will be set forth in part in the following description and will become apparent to those skilled in the art upon examination of the following or may be learned from practice of the present invention. The objects and other advantages of the present invention may be realized and obtained by the structures particularly pointed out in the description and drawings.
[0020] Those skilled in the art will understand that the purposes and advantages that can be achieved by the present invention are not limited to the above specific descriptions, and the above and other purposes that can be achieved by the present invention will be more clearly understood based on the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention. In the drawings:
[0022] Figure 1 Flowchart of a method for augmenting conversation data using a large language model according to one embodiment of the present invention.
[0023] Figure 2 This is a flowchart of using a large language model to cyclically generate a complete dialogue in one embodiment of the present invention.
[0024] Figure 3 This is a flowchart of non-cyclically generating a complete dialogue using a large language model in one embodiment of the present invention.
[0025] Figure 4 FIG1 is a flowchart of fine-tuning a trainable pre-trained large language model in one embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments and the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0027] It should also be noted that, in order to avoid obscuring the present invention due to unnecessary details, the accompanying drawings only show structures and / or processing steps closely related to the solutions according to the present invention, while other details that are not closely related to the present invention are omitted.
[0028] It should be emphasized that the term "include / comprises" when used herein refers to the existence of features, elements, steps or components, but does not exclude the existence or addition of one or more other features, elements, steps or components.
[0029] It should also be noted that, unless otherwise specified, the term "connection" herein may refer not only to a direct connection but also to an indirect connection involving an intermediate.
[0030] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. In the accompanying drawings, the same reference numerals represent the same or similar components, or the same or similar steps.
[0031] In order to solve the problems existing in the prior art, this application proposes a method for conversation data augmentation. This method aims to augment conversation data by integrating text information from multiple data sources, converting text information from multiple sources into a universal and concise conversation path, and then embedding it into a prompt template to more effectively utilize external text data. By following the prompt template containing the conversation path, iteratively calling the large language model to generate text and update the prompt, controlling the specific content in the conversation data augmentation, and thus accurately controlling the generation of conversation data and the evolution of the conversation path. It can effectively improve the quality of conversation data, including expanding the scene coverage of conversation data, enhancing logical reasoning and enriching the diversity of conversation patterns. In addition, by generating multi-round conversation data through a multi-stage prompt method, a multi-round conversation data augmentation method is added to enhance the controllability of the augmentation method.
[0032] The basic idea of this method is expressed in mathematical language as follows:
[0033] The large language model generates complete conversation data U={u1,u2,···,u n},u i Refers to a single-round statement in the dialogue data, P is the prompt information at the i-th round, and is expressed as follows:
[0034] u i =LLM(P,u1,u2,···u i-1 );
[0035] Get u i After that, iteratively call the large language model to generate u i+1 Until u n , stop calling and get the generated complete dialogue U.
[0036] The preset prompt information P generally includes the system prompt p s , task prompt p a , sample prompt p few-shot (optional), thought chain prompts p cot (Not necessary) (Chain-of-Thought, CoT), that is, P = {p s ,p a ,(p few-shot ),(p cot )}.
[0037] This method extracts or obtains the dialogue path R={n1,r1,n2,r2,…,n n}, such as Node-relation->Node-relation->Node…. Embed the conversation path R or its node information n1 into the prompt P to obtain the prompt P n1 , after calling LLM, we get the dialogue statement u1=LLM(P n1 ), update the prompt containing the dialogue path to get P n2 , call LLM to generate u2=LLM(P n2 ,u1), the iterative step gets u n =LLM(P nn ,u1,u2,…,u n-1 ), and finally get the complete dialogue U.
[0038] First, an overall explanation of the concepts mentioned in this solution:
[0039] (1) Pretrained language model: A language model is a computer program that can understand or generate text. They are usually trained using large amounts of text data. A pretrained language model is a language model that has been trained unsupervised on a large amount of unlabeled text data. This data usually comes from the internet, such as books, articles, and code. The pretraining phase of a pretrained language model can help learn and master the basic structures and patterns of a language, such as sentence structure and vocabulary relationships. Continuing training based on a pretrained language model allows for easy customization of language models with different capabilities.
[0040] (2) Large Language Model (LLM): A large language model is a pre-trained model that is large in scale and has many parameters. Parameters are variables used in a language model to learn text patterns. The more parameters a language model has, the more capable it is at learning complex text patterns. Currently, large language models typically have billions or even trillions of parameters. These models can learn very complex text patterns and can demonstrate excellent performance in a variety of natural language processing tasks.
[0041] (3) Prompt: A prompt is a phrase or sentence used to guide the language model in generating text. Prompts can be additional textual information given to the model during training or guiding input provided during the inference phase after the model is deployed. Through carefully designed prompts, users can effectively control and guide the model's behavior, enabling it to generate more precise and complex outputs for specific tasks or scenarios.
[0042] (4) Relationship between pre-trained language models, large language models, and prompts: Assume that there is a pre-trained large language model that has learned to identify the subject and predicate in a sentence and can generate sentences based on simple prompts, such as "I love you." If you want to generate more complex sentences based on this, such as "I love you, just like the sea loves its waves," you can use corresponding prompts to guide the pre-trained language model, such as "Please generate a sentence that uses a metaphor to express deep affection."
[0043] (5) Data Augmentation: Data augmentation is a technique for automatically expanding training data by generating new training data through specific transformations of existing data. This technique is particularly important in deep learning because it helps the model learn more diverse patterns and features from a limited dataset. Deep learning models usually require a large amount of high-quality data to support their training process. In practical applications, due to problems such as the high cost of obtaining high-quality data, the difficulty of labeling, or the uneven distribution of data, insufficient training data or poor model robustness are often caused. Data augmentation can solve these problems to a certain extent and improve the generalization ability and performance of the model.
[0044] In order to solve the problems existing in the prior art, the present invention proposes a method for augmenting conversation data using a large language model. Figure 1 This is a flow chart of a method for augmenting conversation data using a large language model in one embodiment of the present invention. The method includes the following steps:
[0045] Step S110: Acquire a dialogue path and preset prompt information; wherein the dialogue path is extracted from text information from different sources, and the dialogue path includes a plurality of dialogue nodes arranged in sequence and the relationships between the dialogue nodes.
[0046] In a specific implementation process, the method further includes the step of pre-extracting a dialogue path from text information of different sources, including two cases: (1) when the source of the text information is structured data, a plurality of dialogue nodes are retrieved and selected or randomly selected from the structured data, the order of the selected dialogue nodes is arranged according to a predefined combination method, and the relationship between the dialogue nodes is filled in to obtain a dialogue path extracted from the text information; (2) when the source of the text information is unstructured data, dialogue nodes and the relationship between dialogue nodes are extracted from the unstructured data using rules and / or models, the extracted dialogue nodes are subjected to secondary processing including replacing keywords, rewriting or adding and deleting, the order of the dialogue nodes after the secondary processing is arranged according to a predefined combination method, and the relationship between the dialogue nodes is filled in to obtain a dialogue path extracted from the text information; wherein the unstructured data includes existing dialogue data, network text, news text and audio and video data containing text information.
[0047] Step S120: using a large language model to generate complete dialogue data that satisfies the dialogue path according to the prompt information, where the large language model is a pre-trained large language model or a fine-tuned pre-trained large language model.
[0048] Furthermore, if a non-loop dialogue generation method is used in step S120, step S120 includes: (1) obtaining the dialogue path and preset prompt information; (2) calling the large language model to input the prompt into the large language model; (3) the large language model outputs the complete dialogue data that has a mapping relationship with each dialogue node of the dialogue path at one time according to the preset prompt information, specifically as follows: Figure 3 shown.
[0049] If a cyclic dialogue generation method is used in step S120, step S120 includes: (1) calling the large language model, inputting the preset prompt information as the initial prompt into the large language model, inputting the dialogue path into the large language model, and generating the first round of single-round dialogue; (2) judging whether the traversal of the complete dialogue path is completed according to the preset conditions; (3) if the end condition is not met, obtaining the updated preset prompt information, and repeating steps (1) and (2) with the updated preset prompt information and dialogue path. If the end condition is met, go to step (4); (4) when the end condition is met, integrating all rounds of single-round dialogues to obtain complete dialogue data, as shown in the following example. Figure 2 shown.
[0050] The proposed method and system for augmenting conversation data using a large language model introduces a conversation path to constrain the content of generated conversation data. This system can utilize the large language model to generate complete conversation data that conforms to the order of conversation nodes in the input conversation path and satisfies the relationships between conversation nodes. Furthermore, a turn-by-turn, quasi-node-level conversation data generation method is proposed. Between turns, prompt information is updated to adjust the generated conversation data for the next turn. This allows for more convenient and rapid generation of personalized conversation data that meets individual needs, resulting in greater diversity in the generated conversation data.
[0051] In some embodiments of the present invention, the types of the preset prompt information include multiple types of system prompts, task prompts, sample prompts and thought chain prompts.
[0052] By adopting the embodiment of the present invention, the generation of the dialogue data can be limited by different types of prompt information.
[0053] In some embodiments of the present invention, the preset prompt information includes basic content and additional content, the basic content is used to prompt the generation of dialogue data, and the additional content is used to add additional requirements for complete dialogue data in the process of generating complete dialogue data that meets the dialogue path.
[0054] By adopting this embodiment of the invention, the additional content can supplement some additional requirements for the dialogue data to be generated during the non-cyclic generation of dialogue data, thereby generating dialogue data in a more personalized manner.
[0055] In some embodiments of the present invention, when a cyclic dialogue path generation method is adopted in step S120, the preset prompt information includes basic content and additional content. The basic content includes the dialogue history composed of a single-round dialogue in the previous round, the current dialogue node and prompt description change information. The additional content includes tags or other dialogue paths for adding additional requirements for complete dialogue data.
[0056] Corresponding to the above embodiment, in step S120, between different rounds of single-round dialogue generation, the step of obtaining updated preset prompt information includes: updating the dialogue history, current dialogue node, and prompt description change information contained in the basic content, and obtaining the updated additional content. The content and type of the tag can be customized. For example, the tag type can be an emotional tag such as frustrated, happy, confused, angry, etc., a topic tag such as movies, music, food, etc., or other dialogue paths, interspersing two paths to generate a dialogue.
[0057] In some embodiments of the present invention, the method further comprises the step of fine-tuning the pre-trained large language model in advance. Figure 4 This is a flowchart of fine-tuning a trainable pre-trained large language model in one embodiment of the present invention. The fine-tuning steps include:
[0058] Step S410: Obtain a pre-constructed basic data set containing mapping pairs of dialogue paths and dialogue data.
[0059] Step S420: Fine-tune the large language model based on the dataset. The fine-tuning operation includes setting fine-tuning hyperparameters including learning rate, fine-tuning parameter amount or training times, and also includes pre-processing the basic dataset.
[0060] Step S430: Check whether the fine-tuned pre-trained large language model meets the stopping condition. If it does not meet the preset stopping condition, proceed to step S440. If it does meet the stopping condition, proceed to step S450. The preset stopping condition is either reaching a specified number of fine-tuning times or the base dataset reaching a specified size.
[0061] Step S440: Update the dataset. The fine-tuned large language model generates new conversation data based on prompts from the base dataset or prompts similar to those in the base dataset. Select conversation data from the new conversation data that meets preset quality requirements and add them to the base dataset. The process then returns to step S420.
[0062] Step S450: Select the best performing large language model weight parameters after fine-tuning as the large language model weight parameters for generating complete conversation data. The evaluation indicators for the best performance are relatively sensitive, and the following are reference evaluation indicators: (1) the percentage of generated new conversation data that meets the quality requirements; (2) the average conversation quality of the generated new conversation data, whether manually or automatically evaluated.
[0063] The specific implementation method of fine-tuning the pre-trained large language model will be given in the subsequent content.
[0064] Figure 2 This is a flowchart of a method for cyclically generating a complete conversation using a large language model in one embodiment of the present invention. The method includes five steps.
[0065] Step S210: Obtaining the dialogue path and preset prompt information;
[0066] Step S220: calling the large language model to generate a single-round dialogue;
[0067] Step S230: Determine whether the process is in the end state;
[0068] Step S240: updating the prompt information including the dialogue path;
[0069] Step S250: extract the final conversation.
[0070] During step S210, it is necessary to obtain the dialogue path, which is ultimately in the form of A->B->C-(r)->D, where capital letters represent different dialogue nodes, arrows represent the order of different nodes in the dialogue, and (r) in the arrow indicates that there is a relationship r between the nodes.
[0071] Dialogue paths can be obtained from text information from different sources. The processing methods for text information from different sources are different, but the final form is the same. The methods for obtaining dialogue paths include: (1) When the text information source is structured data such as existing knowledge graphs, retrieval, random selection, and combination from structured data can be performed. The combination method can be freely defined and can be based on similarity, subject, distribution sampling, etc. For example, X gets X's car repaired-(as a result, X wants)->X wants to pay their bill...; (2) When the text information source is unstructured data such as existing dialogue data, network text, news text, book text, etc., nodes and relationships can be extracted using rules and / or models and combined into dialogue paths. Extract conversation paths from unstructured data. The extraction type can be event extraction or keyword extraction. Extraction tools include Spacy, ChatGPT, BERT-based extraction models, etc. After extraction, secondary processing (such as replacing keywords, rewriting, adding and deleting, etc.) can be performed. The extracted conversation path is such as Inquiring about messages->Informing about atelephone call from David Brown.
[0072] Table 1 shows an example of a complete conversation path and the corresponding conversation. The conversations in Table 1 are from the CICERO dataset, extracted using ChatGPT.
[0073] Table 1
[0074]
[0075]
[0076] Based on the conversation path, task design prompts are generated according to the conversation. First, a prompt template is designed, and then the conversation path is applied to the template.
[0077] Table 2 shows an example of a prompt template that replaces $(DIALOGUE PATH) with the dialog path extracted into canonical form.
[0078] Table 2
[0079]
[0080] The preset prompt information is a template designed for generating dialogue paths and dialogue data, and calls the large language model to generate dialogue. There are two ways to call it:
[0081] Method 1: Loop: This method repeatedly calls the large language model in a round-by-round fashion until a complete conversation is generated. A single round of conversation data is generated in a single pass, completing a single node or portion of the conversation path. During this loop, additional information or labels can be added to the conversation by controlling the prompts in step 4.
[0082] Method 2: Non-looping: A single call generates complete conversation data that satisfies the entire conversation path. This method generates conversation data based on the conversation path and preset prompts. The call targets include the Large Language Model API and a trainable large language model to generate conversations.
[0083] The implementation process in method 1 is as follows Figure 2 As shown, Figure 2 This is a flowchart of using a large language model to cyclically generate a complete dialogue in one embodiment of the present invention. Figure 2 The process includes the following steps: Step S210: Obtain the conversation path and preset prompt information as the initial prompt, and then proceed to Step S220; Step S220: Invoke the large language model based on the prompt to generate a single-turn conversation, and then proceed to Step S230; Step S230: Check the stopping condition. If the stopping condition is met, the call is stopped and the process proceeds to Step S250; if the stopping condition is not met, the process proceeds to Step S240. The reference stopping condition is that the conversation path has been traversed and all nodes have generated a conversation; Step S240: Update the prompt containing the conversation path and then proceed to Step S230. The updated prompt content includes basic content and additional content. The basic content ensures the progress of the conversation data augmentation task, and the additional content is used to control the augmentation process to meet specific requirements. The basic content is the conversation history, with changes in the conversation nodes and prompt descriptions. Additional content is added based on demand and is omitted if there is no specific requirement. Additional content can include emotional tags such as frustrated, happy, confused, angry, etc., topic tags such as movies, music, food, etc., or other conversation paths. Two paths are interspersed to generate a conversation; Step S250: Extract the final conversation. The final format of the extracted conversation can be customized, such as conversation path and conversation data mapping pairs, label information, etc.
[0084] The implementation process of method 2 is as follows Figure 3 As shown, Figure 3 This is a flowchart of non-cyclically generating a complete dialogue using a large language model in one embodiment of the present invention. Figure 3 The process includes the following steps: step S310, obtaining the dialogue path and preset prompt information; step S320, calling the large language model to generate the dialogue; step S330, extracting the final dialogue.
[0085] The large language model used here can be a directly callable API service, such as ChatGPT, or a trainable pre-trained large language model. Both generate conversations by providing a large language model as a prompt.
[0086] Table 3 shows an example of calling a large language model to generate a single-round dialogue.
[0087] Table 3
[0088]
[0089]
[0090] For the latter, the trainable pre-trained large language models (such as LLaMa, LLaMa2 series models, ChatGLM series models, BLOOM series models, Flan-T5 series models, Pythia series models, Mistral series models, GPT-J series models, MPT series models, Falcon series models, etc.) can be fine-tuned to further improve the generation effect. The specific steps are as follows:
[0091] Step S410: Obtain or construct a basic data set. The key elements include mapping pairs of dialogue paths and dialogue data, which can be obtained through manual design, extraction from existing models, etc., extracting dialogue paths from existing dialogue data, and generating dialogue data based on existing dialogue paths. Since the large language model has been pre-trained on massive data, fine-tuning does not require large-scale data. Generally speaking, the scale of the constructed mapping pairs is between 100 and 10,000, that is, the scale of the basic data set is generally between 100 and 10,000. Below this range, the training effect is poor, and it is necessary to adjust the screening criteria in the subsequent step S440 and the number of cycles in the stop condition of step S430. Above this range, the training effect is good, and steps S430 and S440 are not required. The large language model obtained in step S420 can be directly used as the calling model.
[0092] Step S420: Fine-tune the large language model based on the dataset. Fine-tuning the large language model involves freezing most parameters and adjusting a few to adapt to the data. This fine-tuning step involves setting hyperparameters such as the learning rate, number of fine-tuning parameters, number of training runs, and dataset preprocessing. It also involves adjusting the dataset from step S410 to a format that is easy to train, including text length, masking, and adding task prompts.
[0093] Step S430: Check whether the stopping condition is met. If not, execute step S440. If the stopping condition is met, execute step S450. The stopping condition may be to stop the loop after reaching a specified number of iterations or a data set size.
[0094] Step S440: Based on the trained model, inference is performed to generate conversation data, and this conversation data is selected to update the dataset. The trained large language model can generate conversation data based on conversation paths, thus generating a large amount of conversation data from a large number of conversation paths. High-quality conversation data is selected from this data and integrated into the base dataset, resulting in a higher-quality, larger dataset. Updating the dataset involves adding the inference-generated conversation dataset and conversation path mapping pairs to the dataset from the previous iteration. This mapping pair typically requires screening. Screening methods include removing conversation data that is similar to existing conversations in the dataset, removing conversation data containing negative or sensitive information, and manually screening to remove conversation data with low scores.
[0095] Step S450: Select the large language model with the best performance in multiple cycles as the large language model called in the final step S120.
[0096] exist Figure 2 In step S230, a determination is made as to whether the process is in the End state. Since the prompt information (preset prompt template) in step S220 is designed to generate only one round of dialogue at a time, it only contains part of the dialogue path. If the entire dialogue path has been generated, the process is in the End state; if not, the process is not in the End state.
[0097] exist Figure 2 In step S240, if the result of step S230 is that the session is not in the final state, the prompt containing the dialogue path is updated to facilitate the generation of subsequent dialogue content in step S220. The updated content includes integrating the historically generated dialogue into the dialogue history $(DIALOGUE HISTORY); updating the current node $(CURRENT NODE); and modifying the prompt template to adapt to the changes in the dialogue history and nodes.
[0098] exist Figure 2 In step S250, the process is in the end state, and the final conversation is extracted. The final conversation is the complete conversation history and has a mapping relationship with the conversation path.
[0099] Table 4 shows the modified prompt template with the appropriate conversation history and node changes. Table 5 shows the conversation using the modified prompt template in Table 4. Table 6 shows the final complete conversation history and the conversation path with the mapping relationship.
[0100] Table 4
[0101]
[0102]
[0103] Form 5
[0104]
[0105]
[0106] Table 6
[0107]
[0108]
[0109] In summary, the method and system for augmenting conversation data using a large language model proposed in this invention introduces a conversation path to constrain the content of generated conversation data. This allows the large language model to generate complete conversation data that conforms to the order of conversation nodes in the input conversation path and satisfies the relationships between conversation nodes. Furthermore, a turn-by-turn, quasi-node-level conversation data generation method is proposed. Between turns, prompt information is updated to adjust the generated conversation data for the next turn. This allows for more convenient and rapid generation of personalized conversation data that meets individual needs, resulting in greater diversity in the generated conversation data.
[0110] The advantages of this method are described in detail as follows:
[0111] (1) This approach uses text information from other sources to augment conversation data, which can be applied to a variety of text information sources. Text information from different sources, such as knowledge graphs, news, and books, is processed into a unified conversation path format to augment conversation data, improving its quality. This augmentation makes conversation data less affected by the training data from the model source, resulting in greater diversity, authenticity, wider scenario coverage, and lower repetition.
[0112] (2) By utilizing text information from other sources to augment conversation data, we can broadly expand the conversation data and increase its magnitude. Prompt-based conversation generation requires differentiated prompts to generate different conversation data, such as topics, single-round conversation inductions, and triples. By utilizing other text information, we can easily obtain a large number of differentiated prompts, which helps generate more suitable conversation data.
[0113] Furthermore, the prompt template (example) used in the present invention can fully utilize text information from different sources to augment conversation data in the form of conversation paths, effectively improving the quality and quantity of conversation data from the perspective of data sources.
[0114] (3) The method of generating dialogue data based on dialogue paths can integrate text information from different sources, unify the prompt form, and improve the efficiency and quality of the dialogue data augmentation task.
[0115] At the same time, by introducing the dialogue path to generate dialogue data, the content generated during the dialogue data augmentation process can be constrained. From the perspective of content, the final dialogue data quality is higher, such as ease of use and security.
[0116] (4) By generating dialogue data based on the dialogue path, the generated content of the dialogue data can be controlled by modifying the form of the dialogue path, thereby increasing controllability.
[0117] (5) Using a method for generating conversation data based on the conversation path, especially a multi-round iterative generation method, the conversation content can be controlled in each round, such as changing the prompt content, adding noise nodes, adding emotional expressions, adding entity information, repeatedly generating samples, checking sensitive content, etc. This method provides more detailed control to meet different generation requirements. In addition, generating conversation data round by round and node by node makes it easy to add customized or required content information. From the perspective of control methods, controlling the sub-steps of the augmentation method provides an effective way to increase the diversity of conversation data and improve the stability and efficiency of conversation data augmentation.
[0118] Corresponding to the above method, the present invention also provides a conversation data augmentation system using a large language model, the system including a computer device, the computer device including a processor and a memory, the memory storing computer instructions, the processor being used to execute the computer instructions stored in the memory, and when the computer instructions are executed by the processor, the system implements the steps of the method described above.
[0119] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the aforementioned edge computing server deployment method. The computer-readable storage medium may be a tangible storage medium, such as a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a floppy disk, a hard disk, a removable storage disk, a CD-ROM, or any other form of storage medium known in the art.
[0120] An embodiment of the present invention further provides a computer program product, comprising a computer program / instruction, which implements the steps of the method described in any one of the above embodiments when executed by a processor.
[0121] It should be understood by those skilled in the art that the various exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is specifically performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier.
[0122] It should be understood that the present invention is not limited to the specific configurations and processes described above and illustrated in the figures. For the sake of brevity, a detailed description of known methods is omitted. In the above embodiments, several specific steps are described and illustrated as examples. However, the method of the present invention is not limited to the specific steps described and illustrated. Those skilled in the art may make various changes, modifications, and additions, or change the order of the steps after understanding the spirit of the present invention.
[0123] In the present invention, features described and / or illustrated for one embodiment may be used in the same or similar manner in one or more other embodiments, and / or combined with or replace features of other embodiments.
[0124] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations to the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.
Claims
1. A method for augmenting conversation data using a large language model, characterized in that: The method comprises the following steps: Obtaining a dialogue path and preset prompt information; wherein the dialogue path is extracted from text information from different sources, and the dialogue path includes a plurality of dialogue nodes and relationships between the dialogue nodes arranged in sequence; the step of extracting the dialogue path from text information from different sources includes: when the source of the text information is structured data, retrieving and selecting or randomly selecting a plurality of dialogue nodes from the structured data, arranging the order of the selected dialogue nodes according to a predefined combination method, and filling in the relationships between the dialogue nodes to obtain the dialogue path extracted from the text information; when the source of the text information is unstructured data, extracting the dialogue nodes and the relationships between the dialogue nodes from the unstructured data using rules and / or models, performing secondary processing on the extracted dialogue nodes, including replacing keywords, rewriting, or adding and deleting, arranging the order of the dialogue nodes after the secondary processing according to a predefined combination method, and filling in the relationships between the dialogue nodes to obtain the dialogue path extracted from the text information; wherein the unstructured data includes existing dialogue data, network text, news text, and audio and video data containing text information; Generate complete dialogue data that satisfies the dialogue path according to the prompt information using a large language model, where the large language model is a pre-trained large language model or a fine-tuned pre-trained large language model; When a cyclic dialogue generation method is adopted, the step of using a large language model to generate complete dialogue data that satisfies the dialogue path according to the prompt information includes: Calling a large language model, inputting the preset prompt information as an initial prompt into the large language model, inputting the dialogue path into the large language model, and generating a first round of single-turn dialogue; Determining whether generation of the complete dialogue path is complete according to preset conditions; if the termination conditions are not met, obtaining updated preset prompt information, inputting the updated preset prompt information and the dialogue path into the large language model, and generating the next single-turn dialogue; wherein the single-turn dialogue is a single node or part of the dialogue path; When the end condition is met, all rounds of single-round dialogue are integrated to obtain complete dialogue data; Among them, the types of preset prompt information include system prompts, task prompts, sample prompts and thought chain prompts; the preset prompt information includes basic content and additional content, the basic content is used to promote the generation of dialogue data through prompts, and the additional content is used to add additional requirements for complete dialogue data in the process of generating complete dialogue data that meets the dialogue path, and the additional content includes emotional tags, topic tags and other dialogue paths.
2. The method according to claim 1, characterized in that When a non-cyclic dialogue generation method is adopted, the step of using a large language model to generate complete dialogue data that satisfies the dialogue path according to the prompt information includes: The large language model is called, and the dialogue path and the preset prompt information are input into the large language model. The large language model outputs complete dialogue data that has a mapping relationship with each dialogue node of the dialogue path at one time according to the preset prompt information.
3. The method according to claim 1, characterized in that The preset prompt information includes basic content and additional content. The basic content includes a conversation history consisting of a single-round conversation in a previous round, the current conversation node, and prompt description change information. The additional content includes tags or other conversation paths used to add additional requirements for complete conversation data. Between different rounds of single-round dialogue generation, the step of obtaining updated preset prompt information includes: updating the dialogue history, current dialogue node and prompt description change information included in the basic content, and obtaining the updated additional content.
4. The method according to claim 1, wherein The method further includes the step of fine-tuning the pre-trained large language model in advance, including: Obtain a pre-constructed basic dataset containing mapping pairs between dialogue paths and dialogue data; Get the weight parameters of the pre-trained large language model with different fine-tuning times; A fine-tuning step is performed on the parameters of the large language model; the fine-tuning operation includes setting fine-tuning hyperparameters including learning rate, fine-tuning parameter amount or training times, and also includes preprocessing of the basic data set; Testing the performance of the fine-tuned large language model; if the performance does not meet a preset stopping condition, selecting conversation data that meets a preset quality requirement from the conversation data generated by the fine-tuned large language model and integrating it into the basic dataset, and returning to the fine-tuning step; wherein the preset stopping condition is reaching a specified number of fine-tuning times or the basic dataset reaching a specified size; The process stops when the preset stopping conditions are met, and the weight parameters of the large language model with the best performance after fine-tuning are selected as the weight parameters of the large language model used to generate complete conversation data.
5. A system for augmenting conversational data using a large language model, comprising a processor, a memory, and a computer program / instructions stored in the memory, characterized in that: The processor is configured to execute the computer program / instructions. When the computer program / instructions are executed, the system implements the steps of the method according to any one of claims 1 to 4.
6. A computer-readable storage medium having a computer program / instruction stored thereon, characterized in that: When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
7. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Multi-round dialogue data enhancement method and device, computer equipment and storage medium
CN117851550A
Insurance industry dialogue data enhancement method based on large model
CN118095218A