Multi-round dialogue recognition and rewriting method and device and storage medium
Through the identification of reference relationships between dialogue data sets and recognition results, the current round of user questions is rewritten, combined with the fine-tuning of large models with small parameters, to solve the problems of missing user question components and low rewriting efficiency in multi-round dialogue systems, achieving high efficiency and Accurate multi-turn dialogue recognition and rewriting.
Patent Information
- Application Number
- CN202410777178.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-10-15
AI Technical Summary
The missing components of user questions in traditional multi-turn dialogue systems lead to low semantic recognition accuracy, and rewriting using large models is time-consuming and inefficient.
By obtaining the dialogue data set, inputting it into the multi-turn dialogue recognition model, identifying the referential relationship, rewriting the current round of user questions based on the recognition results, and fine-tuning the large model with small parameters to improve the accuracy of the model.
The accuracy and efficiency of multi-round dialogue recognition and rewriting are improved, efficient recognition and rapid rewriting at the semantic level are achieved, and the response time of the dialogue system is reduced.
Smart Images

Figure CN118780291A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing technology, and in particular to a multi-round dialogue recognition and rewriting method, device and storage medium. Background Art
[0002] In the information age, human-computer interaction has become an indispensable part of people's daily life and work. In particular, multi-round dialogue systems are widely used in scenarios such as intelligent customer service and voice assistants. In traditional multi-round dialogue systems, a series of dialogue processes are designed to flow to the next step based on the user's input, and then the word slots in the previous round of user questions are extracted and filled in the current round of dialogue. However, due to the missing components of user questions in multi-round dialogues, the semantic recognition accuracy of user questions is low. In addition, using large models with large parameters to rewrite user questions is time-consuming and inefficient.
[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention
[0004] The embodiments of the present invention provide a multi-round dialogue recognition and rewriting method, device and storage medium, which effectively improve the accuracy and efficiency.
[0005] On the one hand, an embodiment of the present invention provides a multi-round dialogue recognition and rewriting method, comprising the following steps:
[0006] Get the conversation dataset;
[0007] Inputting the conversation data set into a multi-round conversation recognition model to obtain a multi-round conversation recognition result;
[0008] According to the dialogue data set and the multi-round dialogue recognition results, performing reference relationship recognition to obtain a reference relationship recognition result;
[0009] Rewrite the current round of user questions according to the reference relationship recognition result and the previous round of user questions to obtain multi-round dialogue rewriting results;
[0010] The multi-round dialogue recognition model is obtained by the following steps:
[0011] Obtain a multi-round dialogue training set, wherein the data classification in the multi-round dialogue training set includes: user questions, predicted questions for the next round of multi-round dialogue users, predicted questions for the next round of multi-round dialogue users after rewriting multi-round dialogues, and predicted questions for non-multi-round dialogue users;
[0012] According to the multi-round dialogue training set, the large model with small parameters is fine-tuned to obtain the multi-round dialogue recognition model.
[0013] In some embodiments, inputting the conversation dataset into a multi-turn conversation recognition model to obtain a multi-turn conversation recognition result includes:
[0014] Extracting the previous round of dialogue content and the current round of user questions from the dialogue data set, wherein the previous round of dialogue content includes the previous round of user questions and the previous round of answers;
[0015] The previous round of dialogue content and the current round of user questions are input into a multi-round dialogue recognition model to obtain the multi-round dialogue recognition result.
[0016] In some embodiments, performing reference relationship recognition according to the conversation dataset and the multiple rounds of conversation recognition results to obtain the reference relationship recognition result includes:
[0017] Extracting the previous round of user questions and the current round of user questions from the conversation dataset;
[0018] According to the multi-round dialogue recognition results, a preset mask expansion model is used to perform reference relationship recognition on the previous round of user questions and the current round of user questions to obtain the reference relationship recognition result.
[0019] In some embodiments, when the referential relationship recognition result is that a referential relationship exists, rewriting the current round of user questions according to the referential relationship recognition result and the previous round of user questions to obtain multi-round dialogue rewriting results includes:
[0020] According to the referential relationship recognition result, the referential word in the current round of user questions is replaced with the referred word in the previous round of user questions to obtain the multi-round dialogue rewriting result.
[0021] In some embodiments, when the referential relationship recognition result is that there is no referential relationship, rewriting the current round of user questions according to the referential relationship recognition result and the previous round of user questions to obtain multi-round dialogue rewriting results includes:
[0022] If the current round of user questions lacks a subject, the current round of user questions is completed with the subject in the previous round of user questions through a subject inheritance strategy according to the referential relationship recognition result, to obtain the multi-round dialogue rewriting result;
[0023] If the current round of user questions lacks a predicate, the current round of user questions is completed with the predicate in the previous round of user questions through a predicate inheritance strategy according to the referential relationship identification result, to obtain the multi-round dialogue rewriting result.
[0024] In some embodiments, obtaining a multi-round dialogue training set includes:
[0025] Obtain human-computer interaction data;
[0026] Processing the human-computer interaction data using a large model to generate data to be sorted;
[0027] The data that does not meet the preset requirements in the data to be sorted are deleted to obtain the multi-round dialogue training set.
[0028] In some embodiments, fine-tuning the large model with small parameters according to the multi-round dialogue training set to obtain the multi-round dialogue recognition model includes:
[0029] Constructing a model input according to the multi-round dialogue training set, the preset input format, and the preset output format;
[0030] According to the model input, fine-tuning the small parameter and large model is performed using a preset low-order adaptive method;
[0031] The fine-tuned small-parameter-large model is deployed using a preset inference service library to obtain the multi-round dialogue recognition model.
[0032] On the other hand, an embodiment of the present invention provides a multi-round dialogue recognition and rewriting device, including:
[0033] The first module is used to obtain the dialogue dataset;
[0034] The second module is used to input the dialogue data set into a multi-round dialogue recognition model to obtain a multi-round dialogue recognition result;
[0035] A third module is used to perform reference relationship recognition based on the dialogue data set and the multi-round dialogue recognition results to obtain a reference relationship recognition result;
[0036] The fourth module is used to rewrite the current round of user questions according to the reference relationship recognition result and the previous round of user questions to obtain multi-round dialogue rewriting results;
[0037] The multi-round dialogue recognition model is obtained by the following steps:
[0038] Obtain a multi-round dialogue training set, wherein the data classification in the multi-round dialogue training set includes: user questions, predicted questions for the next round of multi-round dialogue users, predicted questions for the next round of multi-round dialogue users after rewriting multi-round dialogues, and predicted questions for non-multi-round dialogue users;
[0039] According to the multi-round dialogue training set, the large model with small parameters is fine-tuned to obtain the multi-round dialogue recognition model.
[0040] In another aspect, an embodiment of the present invention provides a computer device, comprising:
[0041] at least one processor;
[0042] at least one memory for storing at least one program;
[0043] When the at least one program is executed by the at least one processor, the at least one processor implements the described method.
[0044] On the other hand, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0045] The beneficial effects of the present invention are as follows:
[0046] The present invention first obtains a dialogue data set, then inputs the dialogue data set into a multi-round dialogue recognition model to obtain a multi-round dialogue recognition result, then performs reference relationship recognition based on the dialogue data set and the multi-round dialogue recognition result to obtain a reference relationship recognition result, and finally rewrites the current round of user questions based on the reference relationship recognition result and the previous round of user questions to obtain a multi-round dialogue rewriting result, thereby realizing multi-round dialogue recognition and rewriting, and improving accuracy and efficiency. Among them, the multi-round dialogue recognition model is obtained by fine-tuning a large model with a small parameter amount based on a multi-round dialogue training set, thereby improving the accuracy of the model.
[0047] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0049] Figure 1 A flowchart of a multi-round dialogue recognition and rewriting method according to an embodiment of the present invention;
[0050] Figure 2 This is a flow chart of obtaining a multi-round dialogue recognition model according to an embodiment of the present invention;
[0051] Figure 3 The figure is a schematic diagram of an overall identification and rewriting process according to an embodiment of the present invention. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. 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. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0053] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0054] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0055] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0056] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.
[0057] Retrieval-augmented Generation (RAG): It is one of the most popular cutting-edge technologies for big models. The retrieval-augmented generation model combines language models and information retrieval technology. Specifically, when the model needs to generate text or answer questions, it will first retrieve relevant information from a large document collection, and then use the retrieved information to guide the generation of text, thereby improving the quality and accuracy of the prediction. Big model knowledge retrieval enhancement technology usually uses big models directly for conversations in vertical fields, which will lead to inaccurate responses from big models. It can be connected to an external knowledge base to assist the big model in generating more accurate responses.
[0058] Multi-round dialogue: multiple human-computer interactions with coherent dialogue, rather than a question-and-answer dialogue mode.
[0059] Lora (Low-Rank Adaptation) is a method for fine-tuning large pre-trained language models (such as GPT-3 or BERT). Its core idea is to add small, low-rank matrices to the key layers of the model to adjust the behavior of the model, rather than directly changing the structure of the entire model. The advantage of this is that the model can be effectively adjusted without adding too much additional computational burden while maintaining its original performance.
[0060] Qlora (Quantized Low-Rank Adaptation) is an efficient model fine-tuning method that introduces a deep quantization process based on lora. The core features of Qlora include quantization technology, which uses a new high-precision technology to quantize the pre-trained model into 4-bit. This technology includes a low-precision storage data type (4-bitNormalfloat, abbreviated as NE4) and a calculation data type (16-bit BrainFloat). This can reduce storage requirements while keeping the accuracy loss of the entire model minimal.
[0061] vLLM is an open source high-speed inference framework for large language models, designed to greatly improve the throughput and memory usage efficiency of language model services in real-time scenarios. vLLM is a fast and easy-to-use library for LLM inference and services, which can be seamlessly integrated with HuggingFace. vLLM uses a new attention algorithm, PagedAttention, to effectively manage attention keys and values. In terms of throughput, vLLM performs 24 times better than HuggingFace Transformers (HF) and 3.5 times better than Text Generation Inference (TGI).
[0062] The BERT-derived model (Improving Pre-training by Representing and PredictingSpans, SpanBERT) is an improved model based on BERT, especially in span selection tasks. The main goal of SpanBERT is to improve the semantic understanding of long texts. By improving the masking strategy and training objectives, SpanBERT can better capture local context information, thereby achieving better results in tasks such as question answering and reference resolution.
[0063] Coreference is a concept in natural language processing, which refers to the linguistic phenomenon that two or more mentions in a text or sentence refer to the same entity. Coreference is very common in natural language, and people use different expressions to refer to the same entity, such as pronouns, titles, and abbreviations.
[0064] In the related technology, in the information age, human-computer interaction has become an indispensable part of people's daily life and work. In particular, in scenarios such as intelligent customer service and voice assistants, the application of multi-round dialogue systems is becoming more and more widespread. However, traditional multi-round dialogue systems often cannot understand and handle complex dialogue situations, such as dealing with reference resolution and long dependency problems in dialogues, which brings difficulties to providing high-quality dialogue services. Now the latest technologies, such as knowledge retrieval enhanced question-answering systems based on large models, usually need to retrieve text fragments in the recall knowledge base, and then generate answers and replies from the large model. Due to the missing components in user questions in multi-round dialogues, such as subjects, predicates or objects, the retrieval will be inaccurate, and the replies generated by the dialogue system will also be inaccurate. At the same time, in traditional multi-round dialogue systems, a series of dialogue processes are usually designed, and the flow will be transferred to the next step according to the user's input, and then the word slots in the previous round of user questions will be extracted and filled in this round of dialogue. However, this process-based dialogue based on artificial rules will make users feel very stiff and have a poor interactive experience. In addition, artificial rules cannot exhaust all possible situations, and there will often be problems with user questions and design processes that are inconsistent. After the breakthrough of big model technology, it is usually directly splicing the previous rounds of human-computer dialogue records and inputting them into the big model, so that the big model can generate responses that meet the requirements. However, if there is knowledge retrieval enhancement, directly splicing the previous dialogue records will greatly reduce the retrieval accuracy. If the dialogue records are not spliced, there is also the problem of insufficient understanding of the semantics of user questions, and the retrieval accuracy will also be greatly reduced. In addition, when directly using a big model for multi-round dialogue recognition and rewriting, if a large model with a small number of parameters such as 1.5B is used, the quality of the questions rewritten by the large model will be uncontrollable and the semantics will be too different from the original user questions. If a large model with a large number of parameters such as 14B is used, it will take a long time, usually more than 1s, which will affect the response time of the entire dialogue system.
[0065] To solve the above problems, the present invention provides a multi-round dialogue recognition and rewriting method, device and storage medium, which can efficiently recognize multiple semantic rounds of user questions at a fast speed, and can rewrite user questions, thereby improving the retrieval accuracy of the RAG system and the performance of the entire dialogue system.
[0066] A multi-round dialogue recognition and rewriting method provided in an embodiment of the present application relates to the field of natural language processing technology. A multi-round dialogue recognition and rewriting method provided in an embodiment of the present application can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or a server cluster or distributed system composed of multiple physical servers, and can also be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms and other basic cloud computing services. The server can also be a node server in a blockchain network; the software can be an application that implements a multi-round dialogue recognition and rewriting method, etc., but is not limited to the above forms.
[0067] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0068] The following is a detailed explanation of the embodiments of the present application in conjunction with the accompanying drawings:
[0069] Figure 1 is an optional flowchart of a multi-round dialogue recognition and rewriting method provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S104.
[0070] Step S101, obtaining a dialogue data set;
[0071] Step S102: input the conversation data set into the multi-round conversation recognition model to obtain the multi-round conversation recognition result;
[0072] Step S103, performing reference relationship recognition based on the dialogue data set and the multi-round dialogue recognition results to obtain a reference relationship recognition result;
[0073] Step S104: rewrite the current round of user questions according to the referential relationship recognition result and the previous round of user questions to obtain multi-round dialogue rewriting results;
[0074] Steps S101 to S104 shown in the embodiment of the present application implement multi-round dialogue recognition and rewriting, thereby improving accuracy and efficiency.
[0075] In step S101 of some embodiments, during the user conversation process, after the user inputs a user question, a conversation data set may be obtained from the conversation context. After obtaining the conversation data set, the conversation data set may be sorted to delete data that does not meet preset requirements and to standardize the format.
[0076] In some embodiments, in step S102, inputting the conversation dataset into the multi-turn conversation recognition model to obtain the multi-turn conversation recognition result may include but is not limited to the following steps:
[0077] Extract the previous round of conversation content and the current round of user questions from the conversation dataset. The previous round of conversation content includes the previous round of user questions and the previous round of answers.
[0078] The content of the previous round of dialogue and the user questions of the current round are input into the multi-round dialogue recognition model to obtain the multi-round dialogue recognition results.
[0079] In some embodiments, a multi-round dialogue recognition model is used to determine whether there is a multi-round dialogue relationship in the dialogue data set. The previous round of dialogue content and the current round of user questions can be extracted from the dialogue data set first, wherein the previous round of dialogue content includes the previous round of user questions and the previous round of answers. Exemplarily, the previous round of dialogue content can be constructed as: {Q_pre: "What is the process for foreign vehicles to enter the center", Answer_pre: "Enterprise WeChat contacts the person in charge of vehicle management to apply for foreign vehicle registration."}, and the current round of user questions can be constructed as: {Q: "Where is your own car"}. Among them, Q_pre is used to characterize the previous round of user questions, and Answer_pre is used to characterize the previous round of answers. Then the previous round of dialogue content and the current round of user questions are input into the multi-round dialogue recognition model to obtain the multi-round dialogue recognition result. Exemplarily, if the returned multi-round dialogue recognition result output is: {'res':'yes'}, it means that there is a multi-round dialogue relationship between the previous round of dialogue content and the current round of user questions. If the returned multi-round dialogue recognition result output is: {'res':'no'}, it means that there is no multi-round dialogue relationship between the previous round of dialogue content and the current round of user questions. It can be understood that, using the deployed multi-round dialogue recognition model, after the current round of user question Q is input, combined with the previous round of dialogue content {Q_pre, Answer_pre}, the prompt format input during fine-tuning is constructed, and after inputting the multi-round dialogue recognition model, the fine-tuned multi-round dialogue recognition model will accurately return {'res':'yes'} or {'res':'no'} to determine whether there is a multi-round relationship.
[0080] In some embodiments, in step S103, performing reference relationship recognition based on the conversation dataset and the multi-round conversation recognition results to obtain the reference relationship recognition result may include but is not limited to the following steps:
[0081] Extract the previous round of user questions and the current round of user questions from the conversation dataset;
[0082] According to the recognition results of multiple rounds of dialogues, a preset mask expansion model is used to identify the referential relationship between the previous round of user questions and the current round of user questions to obtain the referential relationship recognition results.
[0083] In some embodiments, the previous round of user questions and the current round of user questions can be first extracted from the dialogue data set, and then according to the multi-round dialogue recognition results, after the fine-tuned multi-round dialogue recognition model determines that there is a multi-round dialogue relationship J, the preset mask expansion model is used to input the previous round of user questions Q_pre and the current round of user questions Q into the reference resolution recognition module Z_m to perform reference relationship recognition to determine whether there is a reference relationship, and obtain the reference relationship recognition result Z(Q_pre,Q). If there is no multi-round dialogue relationship J, the current round of user questions Q is directly passed to the output module for output. Among them, the preset mask expansion model may include but is not limited to the SpanBERT model. It can be understood that the reference resolution recognition module can be obtained by deploying a reference resolution model to identify whether there is a reference relationship. Reference resolution refers to identifying content fragments in a text and content fragments with the same reference in other texts, and identifying their reference relationships. The coreference resolution model uses the open source SpanBERT model. If the recognition result is a "coreference" and "anaphora" relationship, the output is yes, and the character fragments of the "coreference" and "anaphora" relationship are identified; otherwise, the output is no. For example, if the model input is: {Q_pre: "The shared folder cannot be accessed", Q: "It is displayed in red"}, the model output Z(Q_pre,Q) can be obtained as: {'Is there a coreference relationship': 'yes', 'span1': 'shared folder', 'span1_pos': [1,6], 'span2': 'it', 'span2_pos': [11,12], 'type': 'coreference'}.
[0084] In some embodiments, in step S104, when the referential relationship recognition result is that a referential relationship exists, the current round of user questions are rewritten according to the referential relationship recognition result and the previous round of user questions to obtain a multi-round dialogue rewriting result, which may include but is not limited to the following steps:
[0085] According to the results of the reference relationship recognition, the reference words in the current round of user questions are replaced with the referenced words in the previous round of user questions to obtain the results of multi-round dialogue rewriting.
[0086] In some embodiments, after the reference resolution identification module Z_m determines that there is a reference relationship, that is, the reference relationship identification result Z(Q_pre,Q) is yes, then the user question is rewritten by rewriting rule F, and the reference word in the current round of user questions is replaced with the referenced word in the previous round of user questions, so that the reference relationship is replaced, and the missing sentence components are completed to obtain a new user question F(Q), that is, the rewriting result of multiple rounds of dialogue, and finally F(Q) is passed to the output module for output. If the reference relationship identification result Z(Q_pre,Q) is no, the missing sentence components are completed and then passed to the output module for output. Exemplarily, when there is a reference relationship, the reference word span2 of the current user question Q can be replaced by the referenced word span1 in the previous user question Q_pre. The input is: {Q_pre: "The shared folder cannot be accessed", Q: "It is displayed in red"}, and the output is: {F(Q): "The shared folder is displayed in red"}. Then, it is determined whether {F(Q): "The shared folder is displayed in red"} has a missing subject or predicate. If so, the subject inheritance and predicate inheritance strategies are adopted to replace it with the subject or predicate of Q_pre.
[0087] In some embodiments, in step S104, when the referential relationship recognition result is that there is no referential relationship, the current round of user questions is rewritten according to the referential relationship recognition result and the previous round of user questions to obtain multi-round dialogue rewriting results, including:
[0088] If the current round of user questions lacks a subject, the subject in the previous round of user questions is used to complete the current round of user questions through the subject inheritance strategy according to the result of the reference relationship recognition, and the multi-round dialogue rewriting result is obtained;
[0089] If the current round of user questions lacks a predicate, the predicate in the previous round of user questions is used to complete the current round of user questions through the predicate inheritance strategy based on the result of the reference relationship recognition, and the multi-round dialogue rewriting result is obtained.
[0090] In some embodiments, when the result of the reference relationship identification is that there is no reference relationship, it is directly determined whether the subject or predicate of the current round of user question Q is missing. If the current round of user question lacks a subject, then according to the result of the reference relationship identification, the subject in the previous round of user question Q_pre is used to complete the current round of user question through the subject inheritance strategy, and the result of multi-round dialogue rewriting is obtained; if the current round of user question lacks a predicate, then according to the result of the reference relationship identification, the predicate in the previous round of user question Q_pre is used to complete the current round of user question through the predicate inheritance strategy, and the result of multi-round dialogue rewriting is obtained. Exemplarily, the previous round of dialogue is: {Q_pre: "Enterprise WeChat cannot log in", Answer_pre: "Please log out and re-enter the account password and log in again"}, and the current round of user question is: {Q: "Stuck"}, it can be judged that the subject of the current round of user question is missing, and the subject inheritance strategy is adopted to replace it with the subject of Q_pre. After replacement, the current round of user question is: {Q: "Enterprise WeChat is stuck"}.
[0091] In some embodiments, Figure 2 As shown, the specific implementation process of obtaining the multi-round dialogue recognition model includes but is not limited to steps S201 to S202:
[0092] Step S201, obtaining a multi-round dialogue training set, wherein the data in the multi-round dialogue training set includes: user questions, predicted questions for the next round of multi-round dialogue users, predicted questions for the next round of multi-round dialogue users after rewriting multi-round dialogues, and predicted questions for non-multi-round dialogue users;
[0093] Step S202: fine-tune the large model with small parameters according to the multi-round dialogue training set to obtain a multi-round dialogue recognition model.
[0094] In some embodiments, in step S201, obtaining a multi-round dialogue training set may include but is not limited to the following steps:
[0095] Obtain human-computer interaction data;
[0096] Use the big model to process the human-computer interaction data and generate data to be sorted;
[0097] The data to be sorted that does not meet the preset requirements are deleted to obtain a multi-round dialogue training set.
[0098] In some embodiments, the human-computer interaction data D of the user can be collected and sorted first. After obtaining the human-computer interaction data, the human-computer interaction data is processed using a large model to generate data to be sorted, and then the data that does not meet the preset requirements in the data to be sorted is deleted, and the format of data classification is standardized to obtain a batch of multi-round dialogue training sets for fine-tuning. Among them, the data classification in the multi-round dialogue training set includes: user questions, multi-round dialogue user prediction questions for the next round, multi-round dialogue rewritten user prediction questions for the next round, and non-multi-round dialogue user prediction questions. Exemplarily, the user question can be constructed as: "What process does an external vehicle have to go through to enter the center", the multi-round dialogue user prediction question can be constructed as: "Where is your own car", the multi-round dialogue rewritten user prediction question can be constructed as: "What process does your own vehicle have to go through to enter the center", and the non-multi-round dialogue user prediction question (completely unrelated to the previous round) can be constructed as: "Email account password expired". It can be understood that due to the generalization of the small parameter large model, only a few hundred similar data need to be collected and sorted as the multi-round dialogue training set.
[0099] In some embodiments, in step S202, fine-tuning the large model with small parameters is performed according to the multi-round dialogue training set to obtain the multi-round dialogue recognition model, which may include but is not limited to the following steps:
[0100] Construct model input based on multi-round dialogue training sets, preset input formats, and preset output formats;
[0101] Based on the model input, a preset low-order adaptive method is used to fine-tune a large model with small parameters;
[0102] The preset inference service library is used to deploy the fine-tuned large model with small parameters to obtain a multi-round dialogue recognition model.
[0103] In some embodiments, a large model M with a small number of parameters (the number of parameters does not exceed 2B, such as 1.5B) is selected and fine-tuned using a well-organized multi-round dialogue training set, so that it can learn the ability to judge semantic-level multi-round dialogues, and obtain a fine-tuned multi-round dialogue recognition model. The model input prompt can be constructed based on the multi-round dialogue training set, the preset input format, and the preset output format. For example, the model input can be "Please judge whether the current round of user questions and the previous round of dialogue have a strong contextual relationship based on the previous round of dialogue and the current round of user questions. The output judgment label is: yes or no. The output result is in the following format: {'res':"}, the previous round of dialogue is in the following format: {Q_pre, Answer_pre}, and the current round of user questions is in the following format: {Q}". Among them, Q is used to characterize the current round of user questions, and res is used to characterize the output result. It can be understood that prompt refers to the input provided by the user to the model in the context of a large language model (such as an AI assistant like me), that is, it is used to "prompt" or "guide" AI to give a specific answer or execution. The text for performing specific tasks. Then, according to the model input, a preset low-order adaptive method is used to fine-tune the large model with small parameters, wherein qwen_1.8B or other large models less than 2B can be used, and the preset low-order adaptive method may include but is not limited to the lora method and the qlora method. Finally, the preset reasoning service library is used to deploy the fine-tuned large model with small parameters to obtain a multi-round dialogue recognition model. Among them, the preset reasoning service library may include but is not limited to the vLLM library. It can be understood that vLLM is a fast and easy-to-use library designed for reasoning and services of large language models (LLM). It significantly improves the reasoning speed of LLM and reduces video memory usage through PagedAttention technology, continuous batch processing, CUDA core optimization, and distributed reasoning support.
[0104] In some embodiments, the overall process of multi-round dialogue recognition and rewriting is as follows: Figure 3 As shown, the data can be sorted through the multi-round dialogue data module first, and then the model can be fine-tuned through the small parameter large model fine-tuning module for multi-round dialogue judgment, and then the user question can be input into the multi-round dialogue judgment module for judgment. If there is no multi-round dialogue relationship, it is output to the output module; if there is a multi-round dialogue relationship, the reference relationship is identified through the reference resolution recognition module, and if there is no reference relationship, it is output to the output module; if there is no reference relationship, the question is rewritten through the user question rewriting module, and finally output to the output module.
[0105] The beneficial effects of implementing the embodiments of the present invention include: the present invention first obtains a dialogue data set, then inputs the dialogue data set into a multi-round dialogue recognition model to obtain a multi-round dialogue recognition result, then performs reference relationship recognition based on the dialogue data set and the multi-round dialogue recognition result to obtain a reference relationship recognition result, and finally rewrites the current round of user questions based on the reference relationship recognition result and the previous round of user questions to obtain a multi-round dialogue rewriting result, thereby realizing multi-round dialogue recognition and rewriting, and improving accuracy and efficiency. Among them, the multi-round dialogue recognition model is obtained by fine-tuning a large model with a small number of parameters based on a multi-round dialogue training set, thereby improving the accuracy of the model.
[0106] In some embodiments, the semantic-level multi-round dialogue recognition method of this embodiment has high recognition accuracy, fast speed, and short time consumption, which is less than 100ms. The multi-round dialogue rewriting method of this embodiment first uses the reference resolution recognition module to identify the reference relationship, and then rewrites the user's question to complete the correct sentence components, thereby improving the knowledge retrieval accuracy of RAG. In addition, this embodiment collects and organizes less sample data, and utilizes the generalization of a small parameter (no more than 2B, such as 1.5B) large model. It only needs to collect and organize a small amount of sample data, and fine-tune the small parameter large model, so that the small parameter large model can learn the ability to judge semantic-level multi-round dialogues, thereby improving the model calculation speed.
[0107] The embodiment of the present invention also provides a multi-round dialogue recognition and rewriting device, including:
[0108] The first module is used to obtain the dialogue dataset;
[0109] The second module is used to input the dialogue data set into the multi-round dialogue recognition model to obtain the multi-round dialogue recognition result;
[0110] The third module is used to perform reference relationship recognition based on the dialogue data set and the multi-round dialogue recognition results to obtain the reference relationship recognition results;
[0111] The fourth module is used to rewrite the current round of user questions based on the referential relationship recognition results and the previous round of user questions to obtain multi-round dialogue rewriting results;
[0112] Among them, the multi-round dialogue recognition model is obtained through the following steps:
[0113] Obtain a multi-round dialogue training set. The data classification in the multi-round dialogue training set includes: user questions, predicted questions for the next round of multi-round dialogue users, predicted questions for the next round of multi-round dialogue users after rewriting multi-round dialogues, and predicted questions for non-multi-round dialogue users;
[0114] Based on the multi-round dialogue training set, the large model with small parameters is fine-tuned to obtain a multi-round dialogue recognition model.
[0115] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0116] An embodiment of the present invention further provides a computer device, comprising:
[0117] at least one processor;
[0118] at least one memory for storing at least one program;
[0119] When at least one program is executed by at least one processor, the at least one processor implements Figure 1 The method shown.
[0120] The contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0121] The embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, Figure 1 The method shown.
[0122] The contents of the above method embodiments are all applicable to the present storage medium embodiments. The functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0123] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A multi-round dialogue recognition and rewriting method, characterized in that: The following steps are involved: Get the conversation dataset; Inputting the conversation data set into a multi-round conversation recognition model to obtain a multi-round conversation recognition result; According to the dialogue data set and the multi-round dialogue recognition results, performing reference relationship recognition to obtain a reference relationship recognition result; Rewrite the current round of user questions according to the reference relationship recognition result and the previous round of user questions to obtain multi-round dialogue rewriting results; The multi-round dialogue recognition model is obtained by the following steps: Obtain a multi-round dialogue training set, wherein the data classification in the multi-round dialogue training set includes: user questions, predicted questions for the next round of multi-round dialogue users, predicted questions for the next round of multi-round dialogue users after rewriting multi-round dialogues, and predicted questions for non-multi-round dialogue users; According to the multi-round dialogue training set, the large model with small parameters is fine-tuned to obtain the multi-round dialogue recognition model.
2. The method according to claim 1, characterized in that The step of inputting the conversation data set into a multi-round conversation recognition model to obtain a multi-round conversation recognition result includes: Extracting the previous round of dialogue content and the current round of user questions from the dialogue data set, wherein the previous round of dialogue content includes the previous round of user questions and the previous round of answers; The previous round of dialogue content and the current round of user questions are input into a multi-round dialogue recognition model to obtain the multi-round dialogue recognition result.
3. The method according to claim 1, characterized in that The performing of referential relationship recognition according to the dialogue data set and the multi-round dialogue recognition results to obtain a referential relationship recognition result includes: Extracting the previous round of user questions and the current round of user questions from the conversation dataset; According to the multi-round dialogue recognition results, a preset mask expansion model is used to perform reference relationship recognition on the previous round of user questions and the current round of user questions to obtain the reference relationship recognition result.
4. The method according to claim 1, characterized in that: When the referential relationship recognition result is that a referential relationship exists, rewriting the current round of user questions according to the referential relationship recognition result and the previous round of user questions to obtain multi-round dialogue rewriting results, including: According to the referential relationship recognition result, the referential word in the current round of user questions is replaced with the referred word in the previous round of user questions to obtain the multi-round dialogue rewriting result.
5. The method according to claim 1, characterized in that: When the referential relationship recognition result is that there is no referential relationship, rewriting the current round of user questions according to the referential relationship recognition result and the previous round of user questions to obtain multi-round dialogue rewriting results, including: If the current round of user questions lacks a subject, the current round of user questions is completed with the subject in the previous round of user questions through a subject inheritance strategy according to the referential relationship recognition result, to obtain the multi-round dialogue rewriting result; If the current round of user questions lacks a predicate, the current round of user questions is completed with the predicate in the previous round of user questions through a predicate inheritance strategy according to the referential relationship identification result, to obtain the multi-round dialogue rewriting result.
6. The method according to claim 1, characterized in that The step of obtaining a multi-round dialogue training set includes: Obtain human-computer interaction data; Processing the human-computer interaction data using a large model to generate data to be sorted; The data that does not meet the preset requirements in the data to be sorted are deleted to obtain the multi-round dialogue training set.
7. The method according to claim 1, characterized in that The method of fine-tuning a large model with a small number of parameters according to the multi-round dialogue training set to obtain the multi-round dialogue recognition model includes: Constructing a model input according to the multi-round dialogue training set, the preset input format, and the preset output format; According to the model input, fine-tuning the small parameter and large model is performed using a preset low-order adaptive method; The fine-tuned small-parameter-large model is deployed using a preset inference service library to obtain the multi-round dialogue recognition model.
8. A multi-round dialogue recognition and rewriting device, characterized in that: include: The first module is used to obtain the dialogue dataset; The second module is used to input the dialogue data set into a multi-round dialogue recognition model to obtain a multi-round dialogue recognition result; A third module is used to perform reference relationship recognition based on the dialogue data set and the multi-round dialogue recognition results to obtain a reference relationship recognition result; The fourth module is used to rewrite the current round of user questions according to the reference relationship recognition result and the previous round of user questions to obtain multi-round dialogue rewriting results; The multi-round dialogue recognition model is obtained by the following steps: Obtain a multi-round dialogue training set, wherein the data classification in the multi-round dialogue training set includes: user questions, predicted questions for the next round of multi-round dialogue users, predicted questions for the next round of multi-round dialogue users after rewriting multi-round dialogues, and predicted questions for non-multi-round dialogue users; According to the multi-round dialogue training set, the large model with small parameters is fine-tuned to obtain the multi-round dialogue recognition model.
9. A computer device, characterized in that: include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
