Problem rewriting method and device, nonvolatile storage medium and electronic equipment

By determining the intent type in multi-round dialogues and using a question rephrasing model to perform rephrasing, the problem of insufficient context understanding in traditional methods is solved, and more accurate and coherent multi-round dialogue answers are achieved.

CN120611007APending Publication Date: 2025-09-09CHINA TELECOM CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510742070.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-04
Publication Date
2025-09-09

AI Technical Summary

Technical Problem

Traditional rule- and template-based natural language processing methods lack the ability to understand context in multi-round conversations, resulting in inaccurate answers. Especially in complex and changing multi-round conversation scenarios, it is difficult to maintain the coherence and accuracy of the conversation.

Method used

By determining the intent type based on historical conversation data and using the question rewriting model to rewrite it, including completing the question subject, context and semantic information, the model's understanding and rewriting capabilities are improved through thought chain reasoning and large model training.

Benefits of technology

It enhances the ability to understand and rephrase questions in multi-round dialogue scenarios, improves the accuracy and coherence of answers, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120611007A_ABST
    Figure CN120611007A_ABST
Patent Text Reader

Abstract

The invention discloses a problem rewriting method and device, a nonvolatile storage medium and electronic equipment. The method comprises the following steps: determining an intention type corresponding to a user question according to historical dialogue data; according to the historical dialogue data and the intention type, a rewriting judgment result corresponding to the user question is obtained, and the rewriting judgment result is used for indicating whether the user question needs to be rewritten or not; under the condition that the rewriting judgment result indicates that the user question needs to be rewritten, rewriting processing is conducted on the user question according to the intention type, and rewriting processing comprises at least one of question subject complementation, question context complementation and semantic information complementation. According to the method and the device, the technical problem of inaccurate question answering caused by lack of ability to understand multiple rounds of dialogues in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language processing, and more specifically, to a question rewriting method, apparatus, non-volatile storage medium, and electronic device. Background Art

[0002] With the advancement of artificial intelligence (AI), particularly the maturity of natural language processing (NLP), dialogue systems have evolved from simple single-round question-and-answer systems to complex multi-round interactions. In multi-round dialogues, the system needs to understand user intent, context, and conversation history to provide accurate and coherent responses. However, traditional rule- and template-based approaches often lack contextual understanding, struggle to cope with the complexity of diverse scenarios, and provide inaccurate responses to user questions.

[0003] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention

[0004] The embodiments of the present application provide a question rewriting method, device, non-volatile storage medium and electronic device to at least solve the technical problem of inaccurate question answers caused by the lack of understanding of multi-round dialogues in related technologies.

[0005] According to one aspect of an embodiment of the present application, a question rewriting method is provided, including: determining an intent type corresponding to a user question based on historical conversation data, wherein the intent type includes at least one of the following: a first type, a second type, and a third type, the first type is used to indicate starting a new topic, the second type is used to indicate following up on an answer in the historical conversation data, and the third type is used to indicate that the topic is the same as the question in the historical conversation data; obtaining a rewriting judgment result corresponding to the user question based on the historical conversation data and the intent type, wherein the rewriting judgment result is used to indicate whether the user question needs to be rewritten; if the rewriting judgment result indicates that the user question needs to be rewritten, rewriting the user question based on the intent type, wherein the rewriting processing includes at least one of the following: completing the question subject, completing the question context, and completing semantic information.

[0006] Optionally, determining the intent type corresponding to the user question based on the historical conversation data includes: performing semantic analysis on the historical conversation data and the user question to obtain semantic information data of the historical conversation data and semantic information data of the user question; inputting the semantic information data of the user question and the semantic analysis data of the historical conversation data into the question rewriting model to obtain the intent type output by the question rewriting model, wherein the question rewriting model is used to infer the intent type through a thinking chain and determine the intent type based on the inference result.

[0007] Optionally, based on historical conversation data and intent type, obtaining a rewriting judgment result corresponding to the user question includes: inputting the intent type, the semantic information data of the user question and the semantic information data of the historical conversation data into the question rewriting model, and obtaining the rewriting judgment result output by the question rewriting model, wherein the rewriting judgment result is obtained through thinking chain reasoning.

[0008] Optionally, rewriting the user question based on the intent type includes: when the intent type corresponding to the user question is the second type or the third type, rewriting the user question based on historical conversation data; when the user intent type corresponding to the user question is the first type, inferring the context information, semantic information and subject of the user question through a thinking chain, and rewriting the user question based on the reasoning result of the thinking chain.

[0009] Optionally, before determining the intent type corresponding to the user question based on historical conversation data, the method further includes: obtaining training data, wherein the training data includes multiple rounds of conversation data, a first training label corresponding to the multiple rounds of conversation data, the first training label includes the intent type corresponding to the multiple rounds of conversation data, a thinking chain reasoning process corresponding to the intent type, a question rewriting result corresponding to the multiple rounds of conversation data, and a thinking chain reasoning process corresponding to the question rewriting result; training a question rewriting model based on the training data, wherein the question rewriting model is used to determine the intent type corresponding to the user question, and when it is determined that the user question needs to be rewritten, rewrite the user question based on the intent type.

[0010] Optionally, obtaining training data includes: dividing a multi-round dialogue sample set into a first sample set and a second sample set based on a preset sampling probability; determining a first question and a first answer in the first sample set, wherein the first question is the question corresponding to the last round of dialogue of each multi-round dialogue sample in the first sample set, and the first answer is the answer corresponding to the last round of dialogue of each multi-round dialogue sample in the first sample set; determining the semantic similarity between the first question and each dialogue in the multi-round dialogue sample set; determining a target dialogue sample based on the semantic similarity, wherein the target dialogue sample is a multi-round dialogue sample corresponding to the dialogue with the highest semantic similarity to the first question; determining the question corresponding to the last round of dialogue of the target dialogue sample as the second question, and determining the answer corresponding to the last round of dialogue of the target dialogue sample as the second answer; replacing each first question in the first sample set with the second question corresponding to the first question, and replacing each first answer in the first sample set with the second answer corresponding to the first question; merging the replaced first sample set and second sample set as training data.

[0011] Optionally, obtaining training data includes: inputting a prompt word and multiple rounds of dialogue data into a label generation model, wherein the prompt word is used to instruct the label generation model to generate a training label; and obtaining a first training label generated by the label generation model.

[0012] Optionally, the question rewriting model includes a first question rewriting model and a second question rewriting model, and the number of parameters of the first question rewriting model is greater than the number of parameters of the second question rewriting model; training the question rewriting model based on the training data includes: performing multiple rounds of fine-tuning training on the first question rewriting model and the second question rewriting model based on the training data, wherein the values ​​of the training parameters in the multiple rounds of fine-tuning training are different; inputting the training data into the fine-tuned first question rewriting model to obtain the second training label output by the first question rewriting model; inputting the training data into the fine-tuned second question rewriting model to obtain the third training label output by the second question rewriting model; determining the difference value between the second training label and the third training label; performing a preset number of iterative training on the second question rewriting model based on the difference value; and using the iteratively trained second question rewriting model as the question rewriting model.

[0013] Optionally, after rewriting the user question according to the intent type, the method further includes: obtaining the user's rewriting judgment result on the user question, wherein the rewriting judgment result includes correct rewriting and wrong rewriting; when the rewriting judgment result is a rewriting error, obtaining the user's rewriting feedback information, wherein the rewriting feedback information includes at least one of the following: rewriting suggestion information, user rewriting result, and the user rewriting result is the user's modification result of the rewritten user question; when the rewriting feedback information includes rewriting suggestion information, extracting semantic information of the rewriting suggestion information, and determining the type of rewriting error based on the semantic information, wherein the type of rewriting error includes at least one of the following: subject error, question context error, and semantic information error; when the rewriting feedback information includes the user rewriting result, determining the difference between the rewritten user question and the user rewriting result, and determining the type of rewriting error based on the difference; updating training data based on the user question, historical conversation data of the user question, the type of rewriting error and the rewriting feedback; and retraining the question rewriting model based on the updated training data.

[0014] According to another aspect of an embodiment of the present application, a question rewriting device is also provided, including: a first processing module, used to determine the intent type corresponding to the user question based on historical conversation data, wherein the intent type includes at least one of the following: a first type, a second type and a third type, the first type is used to indicate the start of a new topic, the second type is used to indicate a follow-up question on the answer in the historical conversation data, and the third type is used to indicate the same topic as the question in the historical conversation data; a second processing module, used to obtain a rewriting judgment result corresponding to the user question based on the historical conversation data and the intent type, wherein the rewriting judgment result is used to indicate whether the user question needs to be rewritten; a third processing module, used to rewrite the user question according to the intent type when the rewriting judgment result indicates that the user question needs to be rewritten, wherein the rewriting processing includes at least one of the following: completing the question subject, completing the question context and completing semantic information.

[0015] According to another aspect of an embodiment of the present application, a non-volatile storage medium is provided, in which a program is stored. When the program is running, a device where the non-volatile storage medium is located is controlled to execute the problem rewriting method.

[0016] According to another aspect of an embodiment of the present application, an electronic device is provided, including: a memory and a processor, wherein the processor is configured to run a program stored in the memory, wherein the problem rewriting method is executed when the program is run.

[0017] According to another aspect of an embodiment of the present application, a computer program product is provided, including a computer program, which implements the problem rewriting method when executed by a processor.

[0018] In an embodiment of the present application, the intent type corresponding to the user question is determined based on historical conversation data, wherein the intent type includes at least one of the following: a first type, a second type, and a third type, the first type is used to indicate the start of a new topic, the second type is used to indicate a follow-up question on the answer in the historical conversation data, and the third type is used to indicate that the topic is the same as the question in the historical conversation data; based on the historical conversation data and the intent type, a rewriting judgment result corresponding to the user question is obtained, wherein the rewriting judgment result is used to indicate whether the user question needs to be rewritten; when the rewriting judgment result indicates that the user question needs to be rewritten, the user question is rewritten based on the intent type, wherein the rewriting processing includes at least one of the following methods: completing the question subject, completing the question context, and completing semantic information. By analyzing the user intent, the purpose of enhancing the model's problem understanding and accurate rewriting capabilities in multi-round conversation scenarios is achieved, thereby achieving the technical effect of improving the accuracy and coherence of multi-round conversation answers, and thus solving the technical problem of inaccurate question answers caused by the lack of understanding of multi-round conversations in related technologies. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0020] Figure 1 is a structural diagram of a computer terminal provided according to an embodiment of the present application;

[0021] Figure 2 1 is a flow chart of a question rewriting method provided according to an embodiment of the present application;

[0022] Figure 3 This is a flowchart of training and applying a question rewriting model according to an embodiment of the present application;

[0023] Figure 4 It is a structural diagram of a question rewriting device provided according to an embodiment of the present application. DETAILED DESCRIPTION

[0024] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.

[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0026] In order to better understand the embodiments of the present application, the technical terms involved in the embodiments of the present application are explained as follows:

[0027] Chain of Thought (CoT): This refers to the process of breaking down a complex problem into a series of smaller, more manageable sub-problems through step-by-step reasoning and decomposition, thereby gradually building a logical path to solve the problem. In the field of artificial intelligence, Chain of Thought is often used to enhance the reasoning capabilities of models, enabling them to better understand and solve complex tasks.

[0028] Large Models (LMs): These generally refer to machine learning models with numerous parameters and complex structures. Trained on large datasets, these models are able to capture complex patterns and relationships within the data, resulting in superior performance across a wide range of tasks. Large models are widely used in fields such as natural language processing and computer vision, and are capable of handling complex tasks such as text generation and image generation.

[0029] RAG (Retrieval-Augmented Generation): A hybrid model that combines retrieval and generation. It first retrieves relevant information from a large knowledge base or document collection, then combines this information with the input data to generate the final output.

[0030] Multi-Turn Dialogue (MTD): refers to multiple rounds of interaction between users and the system in a dialogue system. Each round of dialogue depends on the previous context information. The system needs to understand and remember the content of the previous dialogue in order to make appropriate responses in subsequent dialogues.

[0031] Question Rewriting (QR): refers to the process of reformulating the question raised by the user into another form so as to better match the system's knowledge base or model.

[0032] In related technologies, with the development of artificial intelligence (AI), especially the maturity of natural language processing (NLP), dialogue systems have evolved from simple single-round question-and-answer systems to complex multi-round interactions. In multi-round dialogues, the system needs to understand user intent, context, and conversation history in order to provide accurate and coherent responses. However, traditional rule- and template-based approaches often lack the ability to understand context and struggle to cope with the complexity of different scenarios.

[0033] RAG, an emerging technology, has demonstrated significant advantages in natural language generation (NLG) tasks. It combines the strengths of retrieval techniques and generative models, incorporating information from knowledge bases to improve answer accuracy. Particularly in multi-turn dialogue scenarios, RAG can better understand user requests by retrieving relevant documents and generate context-sensitive responses. However, RAG currently focuses primarily on single-turn dialogue tasks and can only handle simple multi-turn scenarios, but performs poorly in complex and varied multi-turn scenarios. Existing RAG technologies still face significant challenges in multi-turn dialogues. For example, when users' questions omit key content, are unclear, or exhibit semantic deviation, the system cannot accurately understand the user's true intent. Furthermore, effectively capturing and utilizing historical information in long conversations is challenging. In particular, in scenarios such as intelligent customer service assistants, maintenance and repair Q&A, and restaurant Q&A, traditional RAG question-answering technologies struggle to maintain conversational coherence and accuracy when faced with issues such as unclear pronouns, omitted key content, and semantic drift during multi-turn dialogues, severely impacting the user experience.

[0034] In order to solve the above problems, relevant solutions are provided in the embodiments of the present application, which are described in detail below.

[0035] According to an embodiment of the present application, a method embodiment of a problem rewriting method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0036] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal for implementing the problem rewriting method. Figure 1 As shown, the computer terminal 10 may include one or more (illustrated as 102a, 102b, ..., 102n in the figure) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It will be understood by those skilled in the art that Figure 1The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.

[0037] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuitry." The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuitry may be a single, independent processing module, or may be incorporated in whole or in part into any of the other components of the computer terminal 10. As described in the embodiments of the present application, the data processing circuitry serves as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0038] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the problem rewriting method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the above-mentioned problem rewriting method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0039] The transmission device 106 is configured to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by the communications provider of the computer terminal 10. In one embodiment, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device 106 may be a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.

[0040] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 .

[0041] In the above operating environment, the embodiment of the present application provides a method for rewriting a question, such as Figure 2 As shown, the method includes the following steps:

[0042] Step S202: Determine the intent type corresponding to the user question based on the historical conversation data, wherein the intent type includes at least one of the following: a first type, a second type, and a third type. The first type is used to indicate starting a new topic, the second type is used to indicate following up on the answer in the historical conversation data, and the third type is used to indicate the same topic as the question in the historical conversation data.

[0043] As an optional implementation, before determining the intent type corresponding to the user question based on historical conversation data, the method also includes: obtaining training data, wherein the training data includes multiple rounds of conversation data, a first training label corresponding to the multiple rounds of conversation data, the first training label includes the intent type corresponding to the multiple rounds of conversation data, a thinking chain reasoning process corresponding to the intent type, a question rewriting result corresponding to the multiple rounds of conversation data, and a thinking chain reasoning process corresponding to the question rewriting result; training a question rewriting model based on the training data, wherein the question rewriting model is used to determine the intent type corresponding to the user question, and when it is determined that the user question needs to be rewritten, rewrite the user question according to the intent type.

[0044] Optionally, the multi-round dialogue data includes multi-round dialogue data in a multi-round dialogue open source dataset and RAG multi-round dialogue data collected from business data.

[0045] Optionally, obtaining training data includes: dividing a multi-round dialogue sample set into a first sample set and a second sample set based on a preset sampling probability; determining a first question and a first answer in the first sample set, wherein the first question is the question corresponding to the last round of dialogue of each multi-round dialogue sample in the first sample set, and the first answer is the answer corresponding to the last round of dialogue of each multi-round dialogue sample in the first sample set; determining the semantic similarity between the first question and each dialogue in the multi-round dialogue sample set; determining a target dialogue sample based on the semantic similarity, wherein the target dialogue sample is a multi-round dialogue sample corresponding to the dialogue with the highest semantic similarity to the first question; determining the question corresponding to the last round of dialogue of the target dialogue sample as the second question, and determining the answer corresponding to the last round of dialogue of the target dialogue sample as the second answer; replacing each first question in the first sample set with the second question corresponding to the first question, and replacing each first answer in the first sample set with the second answer corresponding to the first question; merging the replaced first sample set and second sample set as training data.

[0046] Optionally, the multi-round conversation sample set is divided into a first sample set and a second sample set according to a preset sampling probability in order to generate difficult samples (i.e., it is more difficult to identify user intentions than ordinary samples). The last round of conversation data of this type of sample is replaced by data from other multi-round conversations that are highly similar but actually different, so as to improve the recognition ability of the question rewriting model.

[0047] Specifically, difficult samples are generated by the following method:

[0048] 1. Obtain multi-round dialogue data

[0049] 1.1 Collecting multi-round dialogue open source dataset Do x ∈{Do0,Do1,...,Do m}, m represents the number of open source datasets, respectively from Do x In , data is sampled according to probability P1, and the sampled data are merged to obtain the data set Do.

[0050] 1.2 Collect multi-round conversation data of all business RAGs and merge them to obtain the dataset Dc.

[0051] 1.3. Sample the dataset Do according to the probability P2 (i.e., the preset sampling probability) to obtain the dataset Do′, and the remaining dataset is Do″; sample the dataset Dc according to the probability P3 (i.e., the preset sampling probability) to obtain the dataset Dc′, and the remaining dataset is Dc″;

[0052] 2. Generate difficult samples for datasets Do′ and Dc′ (datasets Do′ and Dc′ are the first sample set, and datasets Do″ and Dc″ are the second sample set) using a representation model (i.e., Embedding, a semantic extraction model used to generate semantic vectors for multi-round conversations) to obtain the final dataset. The specific steps are as follows:

[0053] 2.1 Take out all the questions and answers of the multi-round dialogue in the dataset Do and dataset Dc respectively, pass all the questions through all the network layers of the representation model in turn, take out the output of [CLS] (the output is the semantic vector of the question), and form the question vector library N1 represents the number of vectors;

[0054] 2.2 Pass all answers through all network layers of the representation model in turn, take out the output of [CLS] (the output is the semantic vector of the answer), and form the answer vector library

[0055] 2.3 Merged Vector Library VQ x With vector library VA x , get the vector library

[0056] 2.4 For a data sample Do′1 in the dataset Do′, take the question of the last round of dialogue (i.e., the first question), denoted as Qtgt. Pass Qtgt through all the network layers of the representation model and take the output of [CLS] to obtain VQtgt (i.e., the semantic vector of the question of the last round of dialogue);

[0057] 2.5 Combine VQtgt with each vector VQA in the merged vector library x , the score is calculated by cosine similarity (i.e., semantic similarity), and the calculation formula is as follows:

[0058]

[0059] 2.6 Sort by cosine similarity score and take the VQA with the highest score x (i.e. the dialogue with the highest semantic similarity), the corresponding Q is obtained through the mapping relationship of the subscripts x and A x (i.e. the second question and the second answer), Q x and A x Replace the last round of dialogue (i.e. replace the first question and the first answer) and add it to the corresponding sample Do′1 to get the new data sample Do′ hard1 ;

[0060] 2.7 Generate difficult samples for each data sample in the dataset Do′ according to steps 2.4-2.6 to obtain the dataset Do′ hard , generate a difficult sample according to steps 2.4-2.6 for a data sample in the dataset Dc′ to obtain the dataset Dc′ hard ;

[0061] 2.8 Dataset Do′ hard , Dc′ hard , Do″, Dc″ are merged and randomly shuffled to obtain the final data set D final (That is, the first sample set and the second sample set after replacement are merged as training data).

[0062] Optionally, obtaining training data includes: inputting a prompt word and multiple rounds of dialogue data into a label generation model, wherein the prompt word is used to instruct the label generation model to generate a training label; and obtaining a first training label generated by the label generation model.

[0063] Optionally, use the large model 1 (i.e., the label generation model) to generate label data for RAG multi-round dialogue intention recognition and label data for the corresponding thought chain reasoning process. The specific steps are as follows:

[0064] 3.1 The intent of a multi-turn RAG conversation (i.e., the intent type corresponding to a user's question) is defined as follows: A. Starting a new topic (i.e., the first type); B. Following up on a previous answer (i.e., the second type); C. Asking the same question as the previous one (i.e., the third type);

[0065] 3.2. Design prompt word prompt1 for RAG multi-round dialogue intent recognition;

[0066] 3.3 Input prompt1 and multi-round dialogue data multidata into the large model 1 to obtain the multi-round dialogue intention recognition label labelA (i.e., the intention type corresponding to the multi-round dialogue data) and the thought chain reasoning process label rationaleA (i.e., the thought chain reasoning process corresponding to the intention type). The calculation formula is as follows:

[0067]

[0068] 3.4 For dataset D final Generate a label for each data according to steps 3.1-3.3

[0069] labelA x ∈{labelA1,labelA2,...,labelA M}

[0070] rationaleA x ∈{rationaleA1,rationaleA2,...,rationaleA M}

[0071] Optionally, for the dataset D final For each data, combined with the user intent obtained in the above steps, the large model 1 is used to generate the label data of the RAG multi-round dialogue question rewriting (i.e., the question rewriting result corresponding to the multi-round dialogue data) and the label data of the corresponding thought chain reasoning process (i.e., the thought chain reasoning process corresponding to the question rewriting result). The specific steps are as follows:

[0072] 4.1 Design prompt2 for rewriting RAG multi-round dialogue questions;

[0073] 4.2 Combine the results of the above steps labelA, rationaleA, and multi-round dialogue data into prompt2, input the large model 1, and output the multi-round dialogue question rewriting label labelB and the thought chain reasoning process label rationaleB. The calculation formula is as follows:

[0074]

[0075] 4.3 Dataset D final Generate a label for each data according to steps 4.1-4.2

[0076] labelB x ∈{labelB1,labelB2,...,labelB M}

[0077] rationaleB x∈{rationaleB1,rationaleB2,...,rationaleB M}

[0078] Optionally, the question rewriting model includes a first question rewriting model and a second question rewriting model, and the number of parameters of the first question rewriting model is greater than the number of parameters of the second question rewriting model; training the question rewriting model based on the training data includes: performing multiple rounds of fine-tuning training on the first question rewriting model and the second question rewriting model based on the training data, wherein the values ​​of the training parameters in the multiple rounds of fine-tuning training are different; inputting the training data into the fine-tuned first question rewriting model to obtain the second training label output by the first question rewriting model; inputting the training data into the fine-tuned second question rewriting model to obtain the third training label output by the second question rewriting model; determining the difference value between the second training label and the third training label; performing a preset number of iterative training on the second question rewriting model based on the difference value; and using the iteratively trained second question rewriting model as the question rewriting model.

[0079] Alternatively, use the dataset D final , the labels of RAG multi-round dialogue intent recognition, question rewriting labels, and corresponding thought chain labels (i.e., training data) are used to perform the following multi-round progressive iterative fine-tuning on the large model 2 (question rewriting model). The specific steps are as follows:

[0080] 5.1 Add the eight special characters [intention_label_s], [intention_label_e], [intention_rationale_s], [intention_rationale_e], [rewrite_label_s], [rewrite_label_e], [rewrite_rationale_s], and [rewrite_rationale_e] to the vocabulary of large model 2 and initialize them randomly;

[0081] 5.2 First round of training, using RAG multi-round dialogue intent recognition labels labelA x and corresponding thought chain labels rationaleA x , fine-tune the large model with LoRA (Low-Rank Adaptation of Large Language Models, LoRA). labelA x Add [intention_label_s] and [intention_label_e] before and after respectively, rationaleA xAdd [intention_rationale_s] and [intention_rationale_e] before and after respectively, and add multiple rounds of query and answer data to prompt1 to get x′. The calculation formula is as follows:

[0082]

[0083] τ A =λτ labelA +(1-λ)τ rationaleA

[0084] in, is the cross entropy loss function, f(x′ i ) is the model for x′ i The output of τ labelA is the loss about labelA, τ rationaleA is the loss about rationaleA, τ A The model is fine-tuned based on the total loss, and λ is the weight parameter. The parameter matrices updated during LoRA training are the Query and Value matrices in the self-attention layer and the first matrix in the feedforward neural network layer. This round primarily trains the model's ability to chain thoughts across multiple rounds of intent recognition.

[0085] 5.3 Second round of training: RAG multi-round dialogue intent recognition label according to 5.2 labelA x and corresponding thought chain labels rationaleA x Fine-tune LoRA. The difference is that the parameter matrix updated in LoRA training is changed to the query matrix and key matrix in the self-attention layer, and the feedforward neural network layer is changed to the second matrix. Different matrices are designed to learn different capabilities. This round mainly trains the model's ability to generate labels for multiple rounds of intent recognition.

[0086] 5.4 The third round of training, using multiple rounds of questions to rewrite labels labelB x , corresponding thinking chain label rationaleB x , perform LoRA fine-tuning on the large model. labelB x Add [rewrite_label_s] and [rewrite_label_e] before and after respectively, rationaleB x Add [rewrite_rationale_s] and [rewrite_rationale_e] before and after respectively. Prompt2 adds multiple rounds of query and answer data, and then adds RAG multi-round dialogue intent recognition tags.labelA x and corresponding thought chain labels rationaleA x It is recorded as x″ and used to assist in the training of problem rewriting ability. The calculation formula is as follows:

[0087]

[0088] τ B =λτ labelB +(1-λ)τ rationaleB

[0089] Where, f(x″ i ) is the output of the model for x″, τ labelB is the loss about labelB, τ rationaleB is the loss about rationaleB, τ B The model is fine-tuned based on the total loss, and λ is the weight parameter. The parameter matrices updated during LoRA training are the Query matrix and the Value matrix in the self-attention layer, and the first matrix in the feedforward neural network layer. This round primarily trains the model's ability to chain thought processes across multiple rounds of questions.

[0090] 5.5 The fourth round of training, the same method as 5.4 is used to rewrite the labels of RAG multiple rounds of questions labelB x and corresponding thought chain labels rationaleB x Fine-tune LoRA, add multi-round question and answer data to prompt2, and then add RAG multi-round dialogue intent recognition tags labelA x and corresponding thought chain labels rationaleA x To assist in question rewriting training, the parameter matrix updated in LoRA training is changed to the Query matrix and Key matrix in the self-attention layer and the second matrix in the feedforward neural network layer. This round mainly trains the model's ability to generate labels for multiple rounds of question rewriting.

[0091] 5.6 The last round of training, design prompt3, add multiple rounds of questions and answers data as x, and perform LoRA fine-tuning on the large model. The label design is as follows: [intention_rationale_s] rationaleA x [intention_rationale_e][intention_label_s] labelA x [intention_label_e][rewrite_rationale_s] rationaleBx [rewrite_rationale_e][rewrite_label_s] labelB x [rewrite_label_e]. The formula is as follows:

[0092]

[0093] The parameter matrices updated during LoRA training are the query, key, and value matrices in the self-attention layer, and the first and second matrices in the feedforward neural network layer. This round primarily trains the model's ability to simultaneously generate multiple rounds of intent recognition and question rephrasing.

[0094] 5.7 Follow the steps 5.2-5.6 above to train, and repeat them multiple times to produce a large model 3 after multiple rounds of iterative fine-tuning TeacherM sft (i.e., the fine-tuned rewriting model for the first question);

[0095] The knowledge of large model 3, which has undergone multiple rounds of iterative fine-tuning, is distilled into large model 4 (i.e., the second question rewriting model) (the number of parameters in the first question rewriting model is greater than that in the second question rewriting model), enabling it to obtain accurate multi-round dialogue question rewriting capabilities. The specific steps are as follows:

[0096] 6.1. Train the large model 4-org according to steps S5.1-S5.5 and repeat the process multiple times to obtain the large model 4-sft after multiple rounds of iterative fine-tuning. StudentM sft ;

[0097] 6.2. Add prompt3 to multiple rounds of query and answer data as x, and generate labels according to the method in 5.6 (that is, input the training data into the fine-tuned first question rewriting model, and obtain the second training labels output by the first question rewriting model). Use the large model 3 TeacherM sft For large models 4-sft StudentM sft Perform knowledge distillation, the formula is as follows:

[0098]

[0099] τ total =ατ label +(1-α)τ KL

[0100] For each input x i , the probability distribution of sampling teacher model and student model is and T is the length of the output token, α is the preset weight parameter, τ KL (p||q) is used to indicate the difference between the second training label and the third training label.

[0101] 6.3 Perform 3 rounds (i.e., the preset number of times) of knowledge distillation training according to step 6.2 to obtain the final large model 4 StudentM distil (i.e. the second question after iterative training).

[0102] 7. The latest user Splice historical questions and answers data (i.e. historical conversation data) and input into the big model 4 StudentM distil , the model output is recorded as y out , from ty uo The text information extracted between the two special characters [rewrite_label_s] and [rewrite_label_e] is the result of rewriting the multi-round dialogue question.

[0103] Optionally, after rewriting the user question according to the intent type, the method further includes: obtaining the user's rewriting judgment result on the user question, wherein the rewriting judgment result includes correct rewriting and wrong rewriting; when the rewriting judgment result is a rewriting error, obtaining the user's rewriting feedback information, wherein the rewriting feedback information includes at least one of the following: rewriting suggestion information, user rewriting result, and the user rewriting result is the user's modification result of the rewritten user question; when the rewriting feedback information includes rewriting suggestion information, extracting semantic information of the rewriting suggestion information, and determining the type of rewriting error based on the semantic information, wherein the type of rewriting error includes at least one of the following: subject error, question context error, and semantic information error; when the rewriting feedback information includes the user rewriting result, determining the difference between the rewritten user question and the user rewriting result, and determining the type of rewriting error based on the difference; updating training data based on the user question, historical conversation data of the user question, the type of rewriting error and the rewriting feedback; and retraining the question rewriting model based on the updated training data.

[0104] As an optional implementation, after rewriting the user question based on the intent type, an answer is given based on the rewritten user question, and the answer and the rewritten user question are displayed to the user to obtain the user's judgment on the rewriting of the user question. If the user chooses to rewrite incorrectly, the user's rewriting feedback information is actively requested. This information may include the user's direct rewriting suggestion (rewriting suggestion information) or the user's self-modified user question (user rewriting result).

[0105] When feedback includes rewriting suggestions, the model can be identified by extracting and understanding the semantic information contained within it, such as whether the rewriting error occurred, whether the subject was incorrect, the question context was incorrect, or whether the semantic information was incorrect. This classification helps improve the model in a targeted manner, preventing similar errors in future rewriting.

[0106] On the other hand, if the user's feedback information includes their own modification results to the question, the type of rewriting error is determined by comparing the specific differences between the original rewritten question and the user's version.

[0107] Based on user questions, historical conversation data of user questions, rewriting error types and rewriting feedback, updating training data includes: inputting the user's feedback information and the determined error type into the question rewriting model, and obtaining the various label data output again by the question rewriting model (including the intention type label corresponding to the multi-round conversation data, the thinking chain reasoning process label corresponding to the intention type, the question rewriting result label corresponding to the multi-round conversation data, and the thinking chain reasoning process label corresponding to the question rewriting result). For example, if the error type is determined to be a subject error, the large model will correct the question rewriting label related to the subject to ensure that the inheritance or correction of the subject is consistent with the context of the conversation. The historical conversation data of the user question and the newly generated label are used as new training data. Based on user questions, historical conversation data of the user question, rewriting error types and rewriting feedback, updating training data.

[0108] Retraining the question rewriting model based on the updated training data involves adding the updated label data and corresponding conversation data as new training samples to the dataset. Using the updated training dataset, the question rewriting model undergoes a new round of fine-tuning. Through continuous learning and optimization, the model can better understand the nuances of multi-round conversations, improve the accuracy of question rewriting and intent recognition, and enhance the coherence of the conversational system and user experience. This iterative optimization process helps the model gradually approach its ideal state, enabling it to stably and accurately perform question understanding and rewriting tasks in complex and changing multi-round conversation scenarios. This iterative optimization process not only promptly corrects model deficiencies but also, through direct user participation, continuously accumulates and learns from subtle contextual changes in multi-round conversations. This allows the model to become more sophisticated in its understanding and rewriting, making it more adaptable to complex and changing human-computer conversation environments, thereby significantly improving conversation quality and system performance.

[0109] In the technical solution provided in step S202, determining the intent type corresponding to the user question based on the historical conversation data includes: performing semantic analysis on the historical conversation data and the user question to obtain the semantic information data of the historical conversation data and the semantic information data of the user question; inputting the semantic information data of the user question and the semantic analysis data of the historical conversation data into the question rewriting model to obtain the intent type output by the question rewriting model, wherein the question rewriting model is used to infer the intent type through a thinking chain and determine the intent type based on the inference result.

[0110] Optionally, the question rewriting model infers the intent type based on the semantic information data of the user question and the semantic analysis data of the historical conversation data, and determines the intent type based on the inference result. In the output of the question rewriting model, the inference result begins with [intention_rationale_s] and ends with [intention_rationale_e], and the user intent type begins with [intention_label_s] and ends with [intention_label_e]. The following provides an intent type determination process for a multi-round conversation text scenario of an online intelligent customer service assistant:

[0111]

[0112]

[0113] Step S204: Obtain a rewriting judgment result corresponding to the user question based on the historical conversation data and the intent type, wherein the rewriting judgment result is used to indicate whether the user question needs to be rewritten.

[0114] In the technical solution provided in step S204, obtaining a rewriting judgment result corresponding to the user question based on the historical conversation data and the intention type includes: inputting the intention type, the semantic information data of the user question and the semantic information data of the historical conversation data into the question rewriting model, and obtaining the rewriting judgment result output by the question rewriting model, wherein the rewriting judgment result is obtained through thinking chain reasoning.

[0115] Optionally, the question rewriting model makes rewriting decisions based on the intent type, the semantic information data of the user question, and the semantic information data of the historical conversation data. For example, in a multi-round conversation scenario with an operator's online intelligent customer service assistant, the rewriting decision process is as follows, where the rewriting decision result begins with [rewrite_rationale_s] and ends with [rewrite_rationale_e]:

[0116]

[0117] As an optional implementation, when the question rewriting model infers user intent and the inference results indicate that user intent is difficult to determine, it first relies on historical conversation data to infer multiple topics or objects that are most likely to be involved. This process involves semantic extraction of the conversation history, parsing the content of each round of conversation, identifying key entities and frequently mentioned topics, and generating a candidate list of potential subjects and topics. Then, based on the contextual relevance of these entities and topics, as well as the user's behavioral patterns in historical conversations, the model evaluates each candidate's match with the user's intent, ultimately selecting a preset number of the most likely options.

[0118] After determining the likely user intent, the system asks the user whether they intend to use one of the following options (for example, asking if they are asking about information about xx). This provides the user with the opportunity to actively select the topic or subject, improving the accuracy of question rephrasing and significantly enhancing the user experience. Once the user confirms the intended topic or subject, this information is used to determine the intended type and rephrased the question, ensuring the question is complete and accurate, facilitating subsequent retrieval and answer generation. The rephrased question is more tailored to the user's actual needs, avoiding misunderstandings and unnecessary human-computer interaction cycles caused by incomplete information.

[0119] By asking users about their intent, we ensure quick and accurate question rephrasing even in complex contexts, continuously promoting smooth conversations and providing users with an efficient and accurate multi-turn conversation experience. This two-way communication model not only improves conversation efficiency but also provides a valuable source of data for the model's continuous learning and growth.

[0120] Step S206 , when the rewriting judgment result indicates that the user question needs to be rewritten, rewrite the user question according to the intention type, wherein the rewriting process includes at least one of the following: completing the question subject, completing the question context, and completing semantic information.

[0121] In the technical solution provided in step S206, rewriting the user question based on the intention type includes: when the intention type corresponding to the user question is the second type or the third type, rewriting the user question based on historical conversation data; when the user intention type corresponding to the user question is the first type, inferring the context information, semantic information and subject of the user question through the thinking chain, and rewriting the user question based on the reasoning result of the thinking chain.

[0122] Alternatively, taking the multi-round conversation scenario of an operator's online intelligent customer service assistant as an example, the process of rewriting user questions is as follows, where the rewritten user name begins with [rewrite_label_s] and ends with [rewrite_label_e]:

[0123]

[0124]

[0125] Alternatively, taking the multi-round dialogue scenario of an operator's online intelligent customer service assistant as an example, the overall process of rewriting and answering questions is as follows:

[0126]

[0127]

[0128]

[0129] Optionally, Figure 3 The figure shows a process of training and applying a question rewriting model, wherein the large model 1 uses a general large language model, and the number of large model parameters of the large model 2 is greater than the number of parameters of the large model 4, as shown in FIG. Figure 3 As shown, the process includes the following steps:

[0130] S301. Obtain multi-round conversation data. The specific steps are as follows:

[0131] S301.1. Collecting multi-round dialogue open source dataset Do x ∈{Do0,Do1,...,Do m}, including NaturalConv, CrossWOZ, KdConv, Douban Conversation Corpus, JD Dialog Challenge, respectively from Do x In the example, data is randomly sampled with a probability of 0.3, and the sampled data are merged to obtain the data set Do, which has 80,000 records.

[0132] S301.2. Collect the RAG multi-round conversation history data of the intelligent customer service assistant and merge them to obtain a dataset Dc, which contains 20,000 entries.

[0133] S301.3. In this embodiment, assume P1 = 0.5, randomly sample the dataset Do to obtain the dataset Do′, which has 40,000 entries, and the remaining dataset Do″, which has 4,000 entries. Assume P2 = 0.6, randomly sample the dataset Dc to obtain the dataset Dc′, which has 12,000 entries, and the remaining dataset Dc″, which has 8,000 entries.

[0134] S302. Generate difficult samples for datasets Do′ and Dc′ using representation model l to obtain the final dataset. The specific steps are as follows:

[0135] S302.1. Take all the questions and answers from the multi-round dialogues in the dataset Do and dataset Dc, pass all the questions through all the network layers of the representation model, and take the output of [CLS], the vector representation of which is F QCLS =[0.834,-0.045,...,0.584] 1×768 All questions form the vector library VQ x ∈{VQ1,VQ2,...,VQ 80000}, characterized by:

[0136] S302.2. Pass all answers through all the network layers of the representation in turn, take the output of [CLS], and the representation of the vector is F ACLS =[0.726,-0.283,...,1.932] 1×768 . Composition of the answer vector library VA x ∈{VA1,VA2,...,VA 80000}, characterized by:

[0137] S302.3. Merged Vector Library VQ x With vector library VA x , get the vector library VQA x ∈{VQ1,VA1,...,VQ N ,VA N}, characterized by

[0138] S302.4. For a data sample Do1′ in the dataset Do′, the text is [Q: “What did you do tonight?”, A: “I went to the movies”, Q: “What movie did you see?”, A: “Interstellar”, Q: “Is it good?”, A: “It’s great!”], take the question from the last round of the conversation, Q: “Is it good?”, denoted as Qtgt, pass Qtgt through all the network layers of the representation model, take the output of [CLS], and obtain VQtgt. The vector representation is:

[0139] S302.5. Characterize VQtgt, With the merged vector

[0140] Each vector in the library VQA x , characterized by The cosine similarity score of the vector is calculated using the cosine function. The calculation formula is as follows:

[0141]

[0142] Get the cosine similarity score matrix

[0143] S302.6. Sort by cosine similarity score and take the VQA with the highest score x , the score is 0.879, and the corresponding Q is obtained through the mapping relationship of the subscript x and A x , here is [Q: "Does my dress look good?", A: "I think it's time to change it",], x and A x Replace the last round of dialogue with [Q: "What did you do tonight?", A: "I went to the movies", Q: "What movie did you watch?", A: "Interstellar", Q: "Does my dress look good?", A: "I think I should change it"] and add it to the corresponding sample Do1' to get the new data sample Do' hard1 .

[0144] S302.7. Generate difficult samples for each data sample in the dataset Do′ according to steps S302.4-S302.6 to obtain the dataset Do′ hard , the number is 40,000, and a data sample in the data set Dc′ is generated according to steps S302.4-S302.6 to obtain the data set Dc′ hard , the number is 12,000;

[0145] S302.8. Data set Do′ hard , Dc′ hard , Do″, Dc″ are merged to obtain the final data set D final The total number is 100,000.

[0146] S303. Use GPT4 to generate label data for RAG multi-round dialogue intention recognition and label data for the corresponding thought chain reasoning process. The specific steps are as follows:

[0147] S303.1. Define the intentions of RAG multi-round dialogue as follows: A. Starting a new topic; B. Continuing to ask questions about the previous answer; C. The same topic as the previous question.

[0148] S303.2. Design the RAG multi-round dialogue intention recognition prompt prompt1, where prompt1 is as follows:

[0149] You are a user conversation intent analysis assistant. Please identify user conversation intent according to the following requirements:

[0150] Determine whether the user's intention is A. starting a new topic; B. continuing to ask a question about the previous answer; C. asking the same question as the previous question. Consider and output the reasoning process, which begins with [intention_rationale_s] and ends with [intention_rationale_e].

[0151] According to the reasoning process of user intention, the user intention is output. The user intention starts with [intention_label_s] and ends with [intention_label_e].

[0152] History Q&A:\n{history}\n

[0153] Current question:\n{query}\n

[0154] User intention reasoning process and user intention:

[0155] ”';

[0156] S303.3. Input multi-round conversation data multidata into prompt1. For example, concatenate the text from S302.4 into prompt1 to obtain x′:”'. You are a user conversation intent analysis assistant. Please identify user conversation intent according to the following requirements:

[0157] Determine whether the user's intention is A. starting a new topic; B. continuing to ask a question about the previous answer; C. asking the same question as the previous question. Consider and output the reasoning process, which begins with [intention_rationale_s] and ends with [intention_rationale_e].

[0158] According to the reasoning process of user intention, the user intention is output. The user intention starts with [intention_label_s] and ends with [intention_label_e].

[0159] History Quiz:\nUser: What did you do tonight?\nAssistant: I went to the movies\nUser: What movie did you see?\nAssistant: Interstellar\n

[0160] Current question:\nUser: Does it look good?\n

[0161] User intention reasoning process and user intention:

[0162] ”’, input GTP4 model, output multi-round dialogue intention recognition label labelA, and thought chain reasoning process label rationaleA. The following formula:

[0163] label A, rationale A=LLM GPT4 (prompt 1,multidata)

[0164] The user intention thought chain reasoning process label rationaleAx output by GPT4 is: [intention_rationale_s] Analyze user intention

[0165] Step 1: Review Historical Questions and Answers

[0166] User: What did you do tonight? Assistant: I went to the movies. User: What movie did you see?

[0167] Assistant: Interstellar

[0168] Step 2: Analyze the current problem

[0169] User: Does it look good?

[0170] Step 3: Determine the context of the problem

[0171] The current question, "Is it good?", is clearly based on the previous conversation, in which the user asked what movie they were watching, and the assistant replied "Interstellar."

[0172] Step 4: Determine the Intent of the Question

[0173] A. Start a new topic: The current question, "Is it good?", does not introduce a new theme or topic. Instead, it continues the topic of "watching the movie." Therefore, option A is not applicable.

[0174] B. Following up on the previous answer: The current question, "Is it good?", is a follow-up to the assistant's answer, "Interstellar," asking about the film's quality or impression. This meets the definition of option B.

[0175] C. Same topic as the previous question: The current question, "Is it good?", still revolves around the topic of "watching a movie," and falls into the same topic as the previous question, "What movie did you watch?" Therefore, option C also applies. However, it has a lower priority than option B. [intention_rationale_e]

[0176] The user intention label labelAx output by GPT4 is: [intention_label_s]B. Follow-up question on the previous answer [intention_label_e].

[0177] S303.4. Sequentially analyze the dataset D finalEach data generates label labelA according to steps S303.1-S303.3 x ∈{labelA1,labelA2,...,labelA 100000}, rationaleA x ∈{rationaleA1,rationaleA2,...,rationaleA 100000}

[0178] S304. For data set D final For each data, combined with the user intent obtained in step S303, GPT4 is used to generate label data for rewriting the RAG multi-round dialogue question and label data for the corresponding thought chain reasoning process. The specific steps are as follows:

[0179] S304.1. Design the RAG multi-round dialogue question rewriting prompt prompt2. Here prompt2 is as follows:

[0180] "'Please play the role of an intelligent question rewriting and completion robot. Based on the user's previous questions and corresponding answers, please rewrite the last sentence according to the following process:

[0181] 1. Refer to the reasoning process and user intention to provide a basis for your rewrite;

[0182] 2. Rewrite the user's question based on the user's conversation history. Pay attention to completing contextual information, subject inheritance, and missing semantic information. Question rewriting begins with thinking about and outputting the reasoning process. The reasoning process begins with [rewrite_rationale_s] and ends with [rewrite_rationale_e].

[0183] 3. Based on the user's intent and the reasoning process of question rewriting, the question rewriting result is output. The question rewriting result starts with [rewrite_label_s] and ends with [rewrite_label_e];

[0184] History Q&A:\n{history}\n

[0185] User intention reasoning process:\n{intention_rationale}\n

[0186] User intent:\n{intention}\n

[0187] Question to be rewritten:\n{query}\n

[0188] Start rewriting:

[0189] ”'

[0190] S304.2. Input the results of step S303, labelA, rationaleA, and multiple rounds of conversation data into prompt2. For example, prompt2 gets x″:”'. Please play the role of an intelligent question rewriting and completion robot. Based on the user's previous questions and corresponding answers, please rewrite the last sentence as follows:

[0191] 1. Refer to the reasoning process and user intention to provide a basis for your rewrite;

[0192] 2. Rewrite the user's question based on the user's conversation history. Pay attention to completing contextual information, subject inheritance, and missing semantic information. Question rewriting begins with thinking about and outputting the reasoning process. The reasoning process begins with [rewrite_rationale_s] and ends with [rewrite_rationale_e].

[0193] 3. Based on the user's intent and the reasoning process of question rewriting, the question rewriting result is output. The question rewriting result starts with [rewrite_label_s] and ends with [rewrite_label_e];

[0194] History Quiz:\nUser: What did you do tonight?\nAssistant: I went to the movies\nUser: What movie did you see?\nAssistant: Interstellar\n

[0195] User intent reasoning process:\nAnalyze user intent

[0196] Step 1: Review Historical Questions and Answers

[0197] User: What did you do tonight? Assistant: I went to the movies. User: What movie did you see?

[0198] Assistant: Interstellar

[0199] Step 2: Analyze the current problem

[0200] User: Does it look good?

[0201] Step 3: Determine the context of the problem

[0202] The current question, "Is it good?", is clearly based on the previous conversation, in which the user asked what movie they were watching, and the assistant replied "Interstellar."

[0203] Step 4: Determine the Intent of the Question

[0204] A. Start a new topic: The current question, "Is it good?", does not introduce a new theme or topic. Instead, it continues the topic of "watching the movie." Therefore, option A is not applicable.

[0205] B. Following up on the previous answer: The current question, "Is it good?", is a follow-up to the assistant's answer, "Interstellar," asking about the film's quality or impression. This meets the definition of option B.

[0206] C. Same topic as the previous question: The current question, "Is it good?", still revolves around the topic of "watching a movie," and falls into the same topic as the previous question, "What movie did you watch?" Therefore, option C also applies. However, it has lower priority than option B.

[0207] User intent:\nB. Follow up on the previous answer\n

[0208] Question to be rephrased: \nIs it good looking? \n

[0209] Start rewriting: "', input the GTP4 model, output the multi-round dialogue question rewriting label labelB and the thinking chain reasoning process label rationaleB. The following formula:

[0210] labelB,rationaleB=LLM GPT4 (prompt2,labelA,rationaleA,multidata)

[0211] The user question output by the GPT4 model rewrites the thinking chain reasoning process label rationaleBx as: [rewrite_rationale_s] Reasoning process:

[0212] The current question is "Is it good?", which is a question asking for a movie review.

[0213] According to the history quiz, the previous subject was the movie Interstellar.

[0214] According to the user's intention, the question is a follow-up to the previous answer, and the previous answer is the movie "Interstellar".

[0215] Therefore, the question requires a subject-inherited rewrite of the previous answer. [rewrite_rationale_e]

[0216] The rewritten label labelBx of the user question output by the GPT4 model is: [rewrite_label_s] Is Interstellar good? [rewrite_label_e]

[0217] S304.3. Sequentially analyze the dataset D finalEach data generates label labelB according to steps S304.1-S304.2 x ∈{labelB1,labelB2,...,labelB 100000}, rationaleB x ∈{rationaleB1,rationaleB2,...,rationaleB 100000}

[0218] S305. Using Dataset D final , the labels of RAG multi-round dialogue intent recognition, question rewriting labels, and corresponding thought chain labels are used to perform the following multi-round progressive iterative fine-tuning on Qwen2-72B. The specific steps are as follows:

[0219] S305.1. Add the eight special characters [intention_label_s], [intention_label_e], [intention_rationale_s], [intention_rationale_e], [rewrite_label_s], [rewrite_label_e], [rewrite_rationale_s], and [rewrite_rationale_e] to the Qwen2-72B vocabulary and initialize them randomly.

[0220] S305.2. First round of training, using RAG multi-round dialogue intent recognition labels labelA x and corresponding thought chain labels rationaleA x Combined with prompt1, LoRA fine-tuning is performed on the large model. labelA x Add [intention_label_s] and [intention_label_e] before and after respectively, rationaleA x Add [intention_rationale_s] and [intention_rationale_e] before and after respectively. Prompt1 adds multiple rounds of query and answer data to obtain x′. The specific example of x′ is shown in x′ in step S303.3. rationaleA x For a specific example, see step S303.3 rationaleA x , labelA x For a specific example, see step S303.3 labelA x , the formula is as follows:

[0221]

[0222] τ A =λτ labelA +(1-λ)τ rationaleA

[0223] is the cross entropy loss function. The parameter matrix updated by LoRA training is the Query matrix and Value matrix in the self-attention layer, and the first matrix in the feedforward neural network layer. In the formula, λ is set to 0.2. f(x′ i ) represents x′ i The matrix output by the large model is To calculate the loss, you need to take out F out 'The last 20 lines of To calculate the loss, you need to take out F out The first 342 lines of This round mainly trains the model's thinking chain ability for multi-round intent recognition.

[0224] S305.3. Second round of training, follow S305.2 to identify the labels of RAG multi-round dialogue intentions labelA x and corresponding thought chain labels rationaleA x Fine-tune LoRA. The difference lies in that the parameter matrix updated during LoRA training is changed to the query and key matrices in the self-attention layer, and the feedforward neural network layer is replaced by the second matrix. Different matrices are designed to learn different capabilities. In the formula, λ is set to 0.8. This round focuses on training the model's ability to generate labels for multiple rounds of intent recognition.

[0225] S305.4. The third round of training, using multiple rounds of questions to rewrite labels labelB x , corresponding thinking chain label rationaleB x , perform LoRA fine-tuning on the large model. labelB x Add [rewrite_label_s] and [rewrite_label_e] before and after respectively, rationaleB x Add [rewrite_rationale_s] and [rewrite_rationale_e] before and after respectively. Prompt2 adds multiple rounds of query and answer data, and then adds RAG multi-round dialogue intent recognition tags. labelA x and corresponding thought chain labels rationaleAx Note it as x″, which is used to assist in question rewriting ability training. For a specific example of x″, see x″ in step S304.2. rationaleB x For a specific example, see step S304.2 rationaleB x , labelB x For a specific example, see step S304.2 labelB x , the formula is as follows:

[0226]

[0227] τ B =λτ labelB +(1-λ)τ rationaleB

[0228] The parameter matrix updated during LoRA training is the Query matrix and the Value matrix in the self-attention layer, and the first matrix in the feedforward neural network layer. In the formula, λ is set to 0.2. i ) represents x″ i The matrix output by the large model is. To calculate the loss, you need to take out F out The last 10 lines of To calculate the loss, you need to take out F out The first 105 lines of This round mainly trains the model's thinking chain ability to rewrite multiple rounds of questions.

[0229] S305.5. The fourth round of training also uses the S305.4 method to rewrite the labels of RAG multiple rounds of questions labelB x and corresponding thought chain labels rationaleB x Fine-tune LoRA, add multiple rounds of query and answer data to prompt2, and then add RAG multiple rounds of dialogue intent recognition tags labelA x and corresponding thought chain labels rationaleA x This method is used to assist in question rewriting training. The difference lies in that the parameter matrices updated during LoRA training are now the query and key matrices in the self-attention layer and the second matrix in the feedforward neural network layer. The value of λ in the formula is 0.8. This round primarily trains the model's ability to generate labels for multiple rounds of question rewriting.

[0230] S305.6. For the final round of training, design prompt 3. Here prompt 3 is as follows:

[0231] "'Please play the role of an intelligent question rewriting and completion robot. Based on the user's previous questions and corresponding answers, please rewrite the last sentence according to the following process:

[0232] 1. Determine whether the user's intention is A. starting a new topic; B. continuing to ask a question about the previous answer; or C. asking the same question about the previous question. Consider and output the reasoning process, which begins with [intention_rationale_s] and ends with [intention_rationale_e].

[0233] 2. Output the user intention based on the reasoning process of the user intention. The user intention starts with [intention_label_s] and ends with [intention_label_e];

[0234] 3. Refer to the reasoning process of the user's intent and the user's intention, and combine the user's conversation history to rewrite the user's question. Pay attention to completing the context information, subject inheritance, and completing missing semantic information. Question rewriting first thinks about and outputs the reasoning process. The reasoning process begins with [rewrite_rationale_s] and ends with [rewrite_rationale_e].

[0235] 4. Based on the user's intent and the reasoning process of question rewriting, the question rewriting result is output. The question rewriting result starts with [rewrite_label_s] and ends with [rewrite_label_e];

[0236] History Q&A:\n{history}\n

[0237] Question to be rewritten:\n{query}\n

[0238] Start reasoning and rewrite:

[0239] ”', prompt3 adds multiple rounds of query and answer data as x, and an example of x is:”'Please play the role of an intelligent question rewriting and completion robot. Based on the user's historical questions and corresponding answers, please rewrite the last sentence according to the following process:

[0240] 1. Determine whether the user's intention is A. starting a new topic; B. continuing to ask a question about the previous answer; or C. asking the same question about the previous question. Consider and output the reasoning process, which begins with [intention_rationale_s] and ends with [intention_rationale_e].

[0241] 2. Output the user intention based on the reasoning process of the user intention. The user intention starts with [intention_label_s] and ends with [intention_label_e];

[0242] 3. Refer to the reasoning process of the user's intent and the user's intention, and combine the user's conversation history to rewrite the user's question. Pay attention to completing the context information, subject inheritance, and completing missing semantic information. Question rewriting first thinks about and outputs the reasoning process. The reasoning process begins with [rewrite_rationale_s] and ends with [rewrite_rationale_e].

[0243] 4. Based on the user's intent and the reasoning process of question rewriting, the question rewriting result is output. The question rewriting result starts with [rewrite_label_s] and ends with [rewrite_label_e];

[0244] History Quiz:\nUser: What did you do tonight?\nAssistant: I went to the movies\nUser: What movie did you see?\nAssistant: Interstellar\n

[0245] Question that needs to be rewritten:\nUser: Does it look good?\n

[0246] Start reasoning and rewrite:

[0247] ”’, perform LoRA fine-tuning on the large model. The label design is as follows: [intention_rationale_s] rationaleA x [intention_rationale_e][intention_label_s] labelA x [intention_label_e][rewrite_rationale_s] rationaleB x [rewrite_rationale_e][rewrite_label_s] labelB x [rewrite_label_e]. Here the label example is:

[0248] [intention_rationale_s] Analyze user intent

[0249] Step 1: Review Historical Questions and Answers

[0250] User: What did you do tonight? Assistant: I went to the movies. User: What movie did you see?

[0251] Assistant: Interstellar

[0252] Step 2: Analyze the current problem

[0253] User: Does it look good?

[0254] Step 3: Determine the context of the problem

[0255] The current question, "Is it good?", is clearly based on the previous conversation, in which the user asked what movie they were watching, and the assistant replied "Interstellar."

[0256] Step 4: Determine the Intent of the Question

[0257] A. Start a new topic: The current question, "Is it good?", does not introduce a new theme or topic. Instead, it continues the topic of "watching the movie." Therefore, option A is not applicable.

[0258] B. Following up on the previous answer: The current question, "Is it good?", is a follow-up to the assistant's answer, "Interstellar," asking about the film's quality or impression. This meets the definition of option B.

[0259] C. Same topic as the previous question: The current question, "Is it good?", still revolves around the topic of "watching movies," and falls into the same topic as the previous question, "What movie did you watch?" Therefore, option C is also applicable, but it has lower priority than option B. [intention_rationale_e][intention_label_s]B. A follow-up question to the previous answer [intention_label_e][rewrite_rationale_s] Reasoning process:

[0260] The current question is "Is it good?", which is a question asking for a movie review.

[0261] According to the history quiz, the previous subject was the movie Interstellar.

[0262] According to the user's intention, the question is a follow-up to the previous answer, and the previous answer is the movie "Interstellar".

[0263] Therefore, the question requires a subject-inherited rewrite of the previous answer. [rewrite_rationale_e][rewrite_label_s]Is Interstellar a good movie? [rewrite_label_e]. The formula is as follows:

[0264]

[0265] The parameter matrices updated during LoRA training are the Query matrix, Key matrix, and Value matrix in the self-attention layer, and the first and second matrices in the feedforward neural network layer. i ) represents x i The matrix output by the large model is This round mainly trains the model's ability to simultaneously generate multiple rounds of intent recognition and question rephrasing.

[0266] S305.7. Follow the steps S305.2-S305.6 above to train, and repeat them multiple times to produce a model that has undergone multiple rounds of iterative fine-tuning. TeacherM sft .

[0267] S306. After multiple rounds of iterative fine-tuning, the model TeacherM sft The knowledge is then distilled into the Qwen2-7B model to enable it to accurately rewrite multi-round dialogue questions. The specific steps are as follows:

[0268] S306.1. Train the Qwen2-7B model according to steps S305.1-S305.5 and repeat the steps multiple times to obtain a model after multiple rounds of iterative fine-tuning. StudentM sft ;

[0269] S306.2. Add prompt3 to multiple rounds of query and answer data as x, and generate labels according to S305.6. The specific examples of x and label are shown in step S305.6. Use the model TeacherM sft Model StudentM sft Perform knowledge distillation, the formula is as follows:

[0270]

[0271] τ total =ατ label +(1-α)τ KL

[0272] For each input x i , the probability distribution of sampling teacher model and student model is and T is the length of the output token, and α is 0.1.

[0273] S306.3. Perform three rounds of knowledge distillation training according to step S306.2 to obtain the final model StudentM distil .

[0274] S307. User queryq new Example: Is it good? Combining historical query and answer data, for example: User: What did you do tonight? Assistant: I went to the movies. User: What movie did you see? Assistant: Interstellar. Enter prompt3 and get: "'Please play the role of an intelligent question rewriting and completion robot. Based on the user's historical questions and corresponding answers, please rewrite the last sentence as follows:

[0275] 1. Determine whether the user's intention is A. starting a new topic; B. continuing to ask a question about the previous answer; or C. asking the same question about the previous question. Consider and output the reasoning process, which begins with [intention_rationale_s] and ends with [intention_rationale_e].

[0276] 2. Output the user intention based on the reasoning process of the user intention. The user intention starts with [intention_label_s] and ends with [intention_label_e];

[0277] 3. Refer to the reasoning process of the user's intent and the user's intention, and combine the user's conversation history to rewrite the user's question. Pay attention to completing the context information, subject inheritance, and completing missing semantic information. Question rewriting first thinks about and outputs the reasoning process. The reasoning process begins with [rewrite_rationale_s] and ends with [rewrite_rationale_e].

[0278] 4. Based on the user's intent and the reasoning process of question rewriting, the question rewriting result is output. The question rewriting result starts with [rewrite_label_s] and ends with [rewrite_label_e];

[0279] History Quiz:\nUser: What did you do tonight?\nAssistant: I went to the movies\nUser: What movie did you see?\nAssistant: Interstellar\n

[0280] Question that needs to be rewritten:\nUser: Does it look good?\n

[0281] Start reasoning and rewrite:

[0282] ”', input model StudentM distil , the model output is recorded as y out ,y outExample: [intention_rationale_s] Analyze user intent

[0283] Step 1: Review Historical Questions and Answers

[0284] User: What did you do tonight? Assistant: I went to the movies. User: What movie did you see?

[0285] Assistant: Interstellar

[0286] Step 2: Analyze the current problem

[0287] User: Does it look good?

[0288] Step 3: Determine the context of the problem

[0289] The current question, "Is it good?", is clearly based on the previous conversation, in which the user asked what movie they were watching, and the assistant replied "Interstellar."

[0290] Step 4: Determine the Intent of the Question

[0291] A. Start a new topic: The current question, "Is it good?", does not introduce a new theme or topic. Instead, it continues the topic of "watching the movie." Therefore, option A is not applicable.

[0292] B. Following up on the previous answer: The current question, "Is it good?", is a follow-up to the assistant's answer, "Interstellar," asking about the film's quality or impression. This meets the definition of option B.

[0293] C. Same topic as the previous question: The current question, "Is it good?", still revolves around the topic of "watching movies," and falls into the same topic as the previous question, "What movie did you watch?" Therefore, option C is also applicable, but it has lower priority than option B. [intention_label_e][intention_label_s]B. A follow-up question to the previous answer [intention_label_e][rewrite_rationale_s] Reasoning process:

[0294] The current question is "Is it good?", which is a question asking for a movie review.

[0295] According to the history quiz, the previous subject was the movie Interstellar.

[0296] According to the user's intention, the question is a follow-up to the previous answer, and the previous answer is the movie "Interstellar".

[0297] Therefore, the question needs to be rewritten by subject inheritance of the previous answer. [rewrite_rationale_e][rewrite_label_s]Is Interstellar good? [rewrite_label_e]. out Extracting the text between the two special characters [rewrite_label_s] and [rewrite_label_e] is the result of rewriting the multi-round dialogue question. Here is: Is "Interstellar" good?

[0298] Through the above steps, user questions can be rewritten. By analyzing user intentions, the model's ability to understand and accurately rewrite questions in multi-round dialogue scenarios is enhanced, thereby achieving the technical effect of improving the accuracy and coherence of answers in multi-round dialogues, and thus solving the technical problem of inaccurate answers to questions caused by the lack of understanding of multi-round dialogues in related technologies. Specifically, this application first collects a large amount of multi-round conversation data and uses a semantic similarity model to construct conversation samples as a training data set; then, the large model 1 is used to evaluate the user intention of the last round of multi-round conversations, and an inference path is generated based on the thought chain. At the same time, the results of intention recognition are used to assist in generating question rewriting based on the content of the previous rounds of conversations, as well as the corresponding thought chain reasoning steps; then, a multi-round asymptotic iterative fine-tuning strategy is used to fine-tune the large model 2 based on the intention recognition, question rewriting results and thought chain results generated by the large model 1 to obtain the large model 3, and the large model 3 is further distilled into a large model 4 with a small parameter scale to reduce resource consumption and accelerate the reasoning process; finally, the large model 4 is used to realize automatic rewriting of questions in multi-round conversations, so as to more accurately retrieve and recall relevant information, thereby supporting the large model to generate more accurate and coherent answers. This invention helps improve the accuracy of multi-round dialogue scenarios, providing users with a smoother and more natural interactive experience. It also expands applications in multiple areas such as intent recognition and dialogue rewriting, and can dynamically adjust user input questions based on the context, thereby improving the overall performance of the multi-round dialogue system. This not only improves the user experience, but also further promotes the practical application of multi-round dialogue. The method embodiments of this application also have the following advantages:

[0299] By constructing difficult samples, we generate intent auxiliary labels and question rewriting labels, as well as their corresponding thought chain labels. Using thought chains and user intent types as aids, we adopt a multi-round progressive iterative fine-tuning strategy, and use large-model distillation technology to distill the capabilities of large models into smaller models, which is conducive to actual production implementation. This solves problems such as user input of pronouns, information omissions, and semantic deviations during the RAG system's multi-round dialogue scenarios, as well as the poor coherence and accuracy of the RAG system's dialogues. This helps improve the user multi-round dialogue experience in application scenarios such as intelligent customer service assistants, installation and maintenance Q&A, and catering Q&A. Compared with ordinary question rewriting methods, this method can better understand the semantic information of the context and rewrite multi-round dialogues more accurately.

[0300] The embodiment of the present application provides a question rewriting device, Figure 4 is a structural diagram of the device, such as Figure 4 As shown, the device includes: a first processing module 40, which is used to determine the intention type corresponding to the user question based on historical conversation data, wherein the intention type includes at least one of the following: a first type, a second type and a third type, the first type is used to indicate the start of a new topic, the second type is used to indicate a follow-up question on the answer in the historical conversation data, and the third type is used to indicate the same topic as the question in the historical conversation data; a second processing module 42, which is used to obtain a rewriting judgment result corresponding to the user question based on the historical conversation data and the intention type, wherein the rewriting judgment result is used to indicate whether the user question needs to be rewritten; a third processing module 44, which is used to rewrite the user question according to the intention type when the rewriting judgment result indicates that the user question needs to be rewritten, wherein the rewriting processing includes at least one of the following: completing the question subject, completing the question context and completing the semantic information.

[0301] In some embodiments of the present application, the first processing module 40 determines the intent type corresponding to the user question based on the historical conversation data, including: performing semantic analysis on the historical conversation data and the user question, obtaining the semantic information data of the historical conversation data and the semantic information data of the user question; inputting the semantic information data of the user question and the semantic analysis data of the historical conversation data into the question rewriting model, and obtaining the intent type output by the question rewriting model, wherein the question rewriting model is used to infer the intent type through a thinking chain, and determine the intent type based on the inference result.

[0302] In some embodiments of the present application, the second processing module 42 obtains a rewriting judgment result corresponding to the user question based on the historical conversation data and the intention type, including: inputting the intention type, the semantic information data of the user question and the semantic information data of the historical conversation data into the question rewriting model, and obtaining the rewriting judgment result output by the question rewriting model, wherein the rewriting judgment result is obtained through thinking chain reasoning.

[0303] In some embodiments of the present application, the third processing module 44 rewrites the user question according to the intent type, including: when the intent type corresponding to the user question is the second type or the third type, rewriting the user question according to the historical conversation data; when the user intent type corresponding to the user question is the first type, inferring the context information, semantic information and subject of the user question through the thinking chain, and rewriting the user question according to the reasoning result of the thinking chain.

[0304] In some embodiments of the present application, before determining the intent type corresponding to the user question based on historical conversation data, the first processing module 40 is also used to: obtain training data, wherein the training data includes multiple rounds of conversation data, a first training label corresponding to the multiple rounds of conversation data, the first training label includes the intent type corresponding to the multiple rounds of conversation data, the thinking chain reasoning process corresponding to the intent type, the question rewriting result corresponding to the multiple rounds of conversation data, and the thinking chain reasoning process corresponding to the question rewriting result; train a question rewriting model based on the training data, wherein the question rewriting model is used to determine the intent type corresponding to the user question, and when it is determined that the user question needs to be rewritten, rewrite the user question according to the intent type.

[0305] In some embodiments of the present application, the first processing module 40 obtains training data including: dividing a multi-round dialogue sample set into a first sample set and a second sample set according to a preset sampling probability; determining a first question and a first answer in the first sample set, wherein the first question is the question corresponding to the last round of dialogue of each multi-round dialogue sample in the first sample set, and the first answer is the answer corresponding to the last round of dialogue of each multi-round dialogue sample in the first sample set; determining the semantic similarity between the first question and each dialogue in the multi-round dialogue sample set; determining a target dialogue sample based on the semantic similarity, wherein the target dialogue sample is a multi-round dialogue sample corresponding to the dialogue with the highest semantic similarity to the first question; determining the question corresponding to the last round of dialogue of the target dialogue sample as the second question, and determining the answer corresponding to the last round of dialogue of the target dialogue sample as the second answer; replacing each first question in the first sample set with the second question corresponding to the first question, and replacing each first answer in the first sample set with the second answer corresponding to the first question; merging the replaced first sample set and second sample set as training data.

[0306] In some embodiments of the present application, the first processing module 40 obtains training data including: inputting prompt words and multi-round dialogue data into a label generation model, wherein the prompt words are used to instruct the label generation model to generate training labels; and obtaining a first training label generated by the label generation model.

[0307] In some embodiments of the present application, the question rewriting model includes a first question rewriting model and a second question rewriting model, and the number of parameters of the first question rewriting model is greater than the number of parameters of the second question rewriting model; the first processing module 40 trains the question rewriting model based on the training data, including: performing multiple rounds of fine-tuning training on the first question rewriting model and the second question rewriting model based on the training data, wherein the values ​​of the training parameters in the multiple rounds of fine-tuning training are different; inputting the training data into the fine-tuned first question rewriting model to obtain the second training label output by the first question rewriting model; inputting the training data into the fine-tuned second question rewriting model to obtain the third training label output by the second question rewriting model; determining the difference value between the second training label and the third training label; performing a preset number of iterative training on the second question rewriting model based on the difference value; and using the iteratively trained second question rewriting model as the question rewriting model.

[0308] In some embodiments of the present application, after the third processing module 44 rewrites the user question according to the intent type, the first processing module 40 is further used to: obtain the user's rewriting judgment result on the user question, wherein the rewriting judgment result includes correct rewriting and wrong rewriting; when the rewriting judgment result is a rewriting error, obtain the user's rewriting feedback information, wherein the rewriting feedback information includes at least one of the following: rewriting suggestion information, user rewriting result, and the user rewriting result is the user's modification result of the rewritten user question; when the rewriting feedback information includes rewriting suggestion information, extract the semantic information of the rewriting suggestion information, and determine the type of rewriting error based on the semantic information, wherein the type of rewriting error includes at least one of the following: subject error, question context error, and semantic information error; when the rewriting feedback information includes the user rewriting result, determine the difference between the rewritten user question and the user rewriting result, and determine the type of rewriting error based on the difference; update the training data based on the user question, historical conversation data of the user question, the type of rewriting error and the rewriting feedback; and retrain the question rewriting model based on the updated training data.

[0309] It should be noted that the various modules in the above-mentioned problem rewriting device can be program modules (for example, a set of program instructions that implement a certain specific function) or hardware modules. For the latter, it can be expressed in the following forms, but is not limited to this: the expression form of each of the above-mentioned modules is a processor, or the functions of each of the above-mentioned modules are implemented by a processor.

[0310] An embodiment of the present application provides a non-volatile storage medium, in which a program is stored, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the following question rewriting method: determining the intent type corresponding to the user question based on historical conversation data, wherein the intent type includes at least one of the following: a first type, a second type, and a third type, the first type is used to indicate the start of a new topic, the second type is used to indicate a follow-up question on an answer in the historical conversation data, and the third type is used to indicate the same topic as the question in the historical conversation data; obtaining a rewriting judgment result corresponding to the user question based on the historical conversation data and the intent type, wherein the rewriting judgment result is used to indicate whether the user question needs to be rewritten; when the rewriting judgment result indicates that the user question needs to be rewritten, rewriting the user question based on the intent type, wherein the rewriting processing includes at least one of the following: completing the question subject, completing the question context, and completing semantic information.

[0311] An embodiment of the present application provides an electronic device, comprising: a memory and a processor, the processor being configured to run a program stored in the memory, wherein the following question rewriting method is executed when the program is run: determining an intent type corresponding to a user question based on historical conversation data, wherein the intent type comprises at least one of the following: a first type, a second type, and a third type, the first type being used to indicate starting a new topic, the second type being used to indicate following up on an answer in the historical conversation data, and the third type being used to indicate the same topic as the question in the historical conversation data; obtaining a rewriting judgment result corresponding to the user question based on the historical conversation data and the intent type, wherein the rewriting judgment result is used to indicate whether the user question needs to be rewritten; in a case where the rewriting judgment result indicates that the user question needs to be rewritten, rewriting the user question based on the intent type, wherein the rewriting processing comprises at least one of the following: completing the question subject, completing the question context, and completing semantic information.

[0312] An embodiment of the present application provides a computer program product, including a computer program, which implements the following question rewriting method when executed by a processor: determining an intent type corresponding to a user question based on historical conversation data, wherein the intent type includes at least one of the following: a first type, a second type, and a third type, the first type is used to indicate starting a new topic, the second type is used to indicate following up on an answer in the historical conversation data, and the third type is used to indicate the same topic as the question in the historical conversation data; obtaining a rewriting judgment result corresponding to the user question based on the historical conversation data and the intent type, wherein the rewriting judgment result is used to indicate whether the user question needs to be rewritten; if the rewriting judgment result indicates that the user question needs to be rewritten, rewriting the user question based on the intent type, wherein the rewriting processing includes at least one of the following: completing the question subject, completing the question context, and completing semantic information.

[0313] In the above embodiments of the present application, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0314] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0315] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0316] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0317] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the relevant technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0318] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A question rephrasing method, characterized in that: include: Determining an intent type corresponding to the user's question based on the historical conversation data, wherein the intent type includes at least one of the following: a first type, a second type, and a third type, wherein the first type indicates starting a new topic, the second type indicates following up on an answer in the historical conversation data, and the third type indicates the topic is the same as the question in the historical conversation data; Obtaining a rewriting judgment result corresponding to the user question based on the historical conversation data and the intent type, wherein the rewriting judgment result is used to indicate whether the user question needs to be rewritten; When the rewriting judgment result indicates that the user question needs to be rewritten, the user question is rewritten according to the intention type, wherein the rewriting process includes at least one of the following: completing the question subject, completing the question context, and completing semantic information.

2. The question rewriting method according to claim 1, characterized in that: The intent types corresponding to user questions determined based on historical conversation data include: Performing semantic analysis on the historical conversation data and the user questions to obtain semantic information data of the historical conversation data and semantic information data of the user questions; The semantic information data of the user question and the semantic analysis data of the historical conversation data are input into the question rewriting model to obtain the intention type output by the question rewriting model, wherein the question rewriting model is used to infer the intention type through a thinking chain and determine the intention type based on the inference result.

3. The question rewriting method according to claim 2, characterized in that: Obtaining a rewriting judgment result corresponding to the user question based on the historical conversation data and the intent type includes: The intention type, the semantic information data of the user question and the semantic information data of the historical conversation data are input into the question rewriting model to obtain a rewriting judgment result output by the question rewriting model, wherein the rewriting judgment result is obtained through thought chain reasoning.

4. The question rewriting method according to claim 1, characterized in that: Rewriting the user question according to the intent type includes: When the intent type corresponding to the user question is the second type or the third type, rewriting the user question according to the historical conversation data; When the user intention type corresponding to the user question is the first type, the context information, semantic information and subject of the user question are inferred through the thinking chain, and the user question is rewritten according to the reasoning result of the thinking chain.

5. The question rewriting method according to claim 1, characterized in that: Before determining the intent type corresponding to the user question based on historical conversation data, the method further includes: Acquiring training data, wherein the training data includes multi-round dialogue data, first training labels corresponding to the multi-round dialogue data, the first training labels including an intent type corresponding to the multi-round dialogue data, a thought chain reasoning process corresponding to the intent type, a question rewriting result corresponding to the multi-round dialogue data, and a thought chain reasoning process corresponding to the question rewriting result; A question rewriting model is trained based on the training data, wherein the question rewriting model is used to determine the intent type corresponding to the user question, and when it is determined that the user question needs to be rewritten, the user question is rewritten based on the intent type.

6. The question rewriting method according to claim 5, characterized in that: Obtaining training data includes: Dividing the multi-round dialogue sample set into a first sample set and a second sample set according to a preset sampling probability; Determining a first question and a first answer in the first sample set, wherein the first question is a question corresponding to a last round of dialogue in each of the multiple rounds of dialogue samples in the first sample set, and the first answer is an answer corresponding to the last round of dialogue in each of the multiple rounds of dialogue samples in the first sample set; Determining semantic similarity between the first question and each dialogue in the multi-round dialogue sample set; Determining a target dialogue sample based on the semantic similarity, wherein the target dialogue sample is a multi-round dialogue sample corresponding to a dialogue with the highest semantic similarity to the first question; Determining the question corresponding to the last round of dialogue of the target dialogue sample as the second question, and determining the answer corresponding to the last round of dialogue of the target dialogue sample as the second answer; Replacing each first question in the first sample set with the second question corresponding to the first question, and replacing each first answer in the first sample set with the second answer corresponding to the first question; The first sample set and the second sample set after replacement are merged as the training data.

7. The question rewriting method according to claim 5, characterized in that: Obtaining training data includes: Inputting a prompt word and multi-round dialogue data into a label generation model, wherein the prompt word is used to instruct the label generation model to generate training labels; Obtain the first training label generated by the label generation model.

8. The question rewriting method according to claim 5, characterized in that: The question rewriting model includes a first question rewriting model and a second question rewriting model, wherein the number of parameters of the first question rewriting model is greater than the number of parameters of the second question rewriting model; Training the problem rewriting model based on the training data includes: performing multiple rounds of fine-tuning training on the first question rewriting model and the second question rewriting model based on the training data, wherein the values ​​of training parameters in the multiple rounds of fine-tuning training are different; Inputting the training data into the fine-tuned first question rewriting model to obtain a second training label output by the first question rewriting model; Inputting the training data into the fine-tuned second question rewriting model to obtain a third training label output by the second question rewriting model; Determine a difference value between the second training label and the third training label; Performing a preset number of iterative training on the second question rewriting model according to the difference value; The second question rewriting model after iterative training is used as the question rewriting model.

9. The question rewriting method according to claim 5, characterized in that: After rewriting the user question according to the intent type, the method further includes: Obtaining a rewriting judgment result of the user on the user question, wherein the rewriting judgment result includes a correct rewriting and an incorrect rewriting; If the rewriting judgment result is a rewriting error, obtaining rewriting feedback information from the user, wherein the rewriting feedback information includes at least one of the following: rewriting suggestion information and a user rewriting result, wherein the user rewriting result is a modification result of the user on the user question after the rewriting process; In the case where the rewriting feedback information includes rewriting suggestion information, extracting semantic information of the rewriting suggestion information, and determining a type of rewriting error based on the semantic information, wherein the type of rewriting error includes at least one of the following: subject error, question context error, and semantic information error; In a case where the rewriting feedback information includes a user rewriting result, determining a difference between the rewritten user question and the user rewriting result, and determining a type of rewriting error based on the difference; Updating training data based on the user question, historical conversation data of the user question, the rewriting error type and the rewriting feedback; The question rewriting model is trained again based on the updated training data.

10. A question rewriting device, characterized in that: include: a first processing module, configured to determine an intent type corresponding to a user question based on historical conversation data, wherein the intent type includes at least one of the following: a first type, a second type, and a third type; the first type indicates starting a new topic; the second type indicates following up on an answer in the historical conversation data; and the third type indicates the topic is the same as the question in the historical conversation data; A second processing module is configured to obtain a rewriting judgment result corresponding to the user question based on the historical conversation data and the intent type, wherein the rewriting judgment result is used to indicate whether the user question needs to be rewritten; The third processing module is used to rewrite the user question according to the intention type when the rewriting judgment result indicates that the user question needs to be rewritten, wherein the rewriting processing includes at least one of the following: completing the question subject, completing the question context, and completing semantic information.

11. A non-volatile storage medium, characterized in that: The non-volatile storage medium stores a program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the question rewriting method according to any one of claims 1 to 9.

12. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is configured to run a program stored in the memory, wherein the program executes the question rewriting method according to any one of claims 1 to 9 when running.

13. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the question rephrasing method according to any one of claims 1 to 9 is implemented.