Multi-round dialogue generation method and device based on RAG and medium

By generating a vector database and semantic rewriting mechanism, the problem of not being able to accurately understand user needs in multiple rounds of dialogue systems is solved, the response speed and accuracy are improved, and natural user interaction is achieved.

CN120407737APending Publication Date: 2025-08-01INSPUR ZHUOSHU BIG DATA IND DEV CO LTD
View PDF 0 Cites 6 Cited by

Patent Information

Application Number
CN202510469186.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-15
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

The existing multi-round dialogue generation system based on RAG cannot quickly and accurately understand the actual needs of users, especially when topics change, and cannot accurately respond to users' information needs.

Method used

By generating a vector database, encoding paragraph keywords and paragraph vectors are performed, and combining semantic rewriting and completion mechanisms, we can improve our understanding of dialogue problems.

Benefits of technology

It enhances the system's contextual understanding of continuous dialogue, improves the response speed and accuracy of multiple rounds of dialogue systems, and provides a natural and smooth interactive experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407737A_ABST
    Figure CN120407737A_ABST
Patent Text Reader

Abstract

The invention discloses an RAG-based multi-round dialogue generation method and device and a medium, and the method comprises the steps: determining a current dialogue question as a to-be-queried dialogue question when the current dialogue question is the first round of question and answer; when the question answering is not the first round of question answering, judging whether semantic rewriting is carried out on the current dialogue question or not; when semantic rewriting is needed, performing semantic rewriting on the current dialogue problem according to historical dialogue problems before the current dialogue problem, and determining the semantic rewritten dialogue problem as a to-be-queried dialogue problem; when semantic rewriting is not needed, determining the current dialogue question as a to-be-queried dialogue question; when semantic rewriting is not needed, representing that the current dialogue question and the historical dialogue question belong to topics in different topic directions; and in the vector database, performing keyword retrieval and vector retrieval on the to-be-queried dialogue question to obtain a reference so as to generate answer information of the current dialogue question according to a preset large language model. And the multi-round dialogue generation accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular, to a multi-turn dialogue generation method, device, and medium based on RAG. Background Art

[0002] With the rapid development of artificial intelligence technology, the application of natural language processing in multi-turn dialogue systems has become increasingly widespread, and the application of RAG technology has been increasing day by day. These systems achieve continuous and coherent interaction with users by simulating human conversations, and have extensive applications in fields such as intelligent customer service, virtual assistants, educational tutoring, and medical consultations.

[0003] Currently, in the process of multi-turn dialogue generation based on RAG, usually only the surface words of the current dialogue question are analyzed, and then documents are retrieved based on keywords. However, the user's input questions are usually colloquial and have abbreviated expressions in multi-turn conversations, resulting in the inability to quickly and accurately understand the actual needs of the user's current conversation. Especially when the topic changes, it is impossible to accurately and quickly respond with the answer information that the user wants. Summary of the Invention

[0004] Embodiments of this application provide a multi-turn dialogue generation method, device, and medium based on RAG, which are used to solve the problem of being unable to quickly and accurately understand the actual needs of the user's current conversation.

[0005] Embodiments of this application adopt the following technical solutions:

[0006] On the one hand, embodiments of this application provide a multi-turn dialogue generation method based on RAG. The method includes: generating a vector database for the client dialogue system; the vector database includes paragraph keywords and paragraph vectors; when a user inputs a dialogue, determining whether the current dialogue question is the first round of Q&A; when it is the first round of Q&A, determining the current dialogue question as the dialogue question to be queried; when it is not the first round of Q&A, determining whether to perform semantic rewriting on the current dialogue question; when semantic rewriting is required, performing semantic rewriting on the current dialogue question according to the historical dialogue questions before the current dialogue question, and determining the semantically rewritten dialogue question as the dialogue question to be queried; when semantic rewriting is not required, determining the current dialogue question as the dialogue question to be queried; when semantic rewriting is not required, indicating that the current dialogue question and the historical dialogue questions belong to different topic directions; in the vector database, performing keyword retrieval and vector retrieval on the dialogue question to be queried to obtain reference documents; generating a prompt word according to the dialogue question to be queried and the reference documents; and generating the answer information for the current dialogue question by reasoning on the prompt word according to a preset large language model.

[0007] In one example, generating the vector database of the client dialogue system specifically includes: extracting redundant information from the document set of the client dialogue system to obtain a preprocessed document set; dividing the preprocessed document set into paragraphs, and determining the keywords and summaries of each paragraph; encoding the paragraph information and summary of each paragraph to obtain paragraph vectors, storing the paragraph vectors in the vector database, and assigning a unique ID to each paragraph; storing the keywords in scalar form in the non-vector fields of the vector database.

[0008] In one example, determining whether to semantically rewrite the current dialogue question specifically includes: evaluating the sentence integrity of the current dialogue question; when the current dialogue question is incomplete, determining to semantically rewrite the current dialogue question; when the current dialogue question is complete, determining whether there is a historical dialogue question related to the current dialogue question; when there is a related historical dialogue question, determining to semantically rewrite the current dialogue question; when there is no related historical dialogue question, determining not to semantically rewrite the current dialogue question.

[0009] In one example, semantically rewriting the current dialogue question according to the historical dialogue question before the current dialogue question specifically includes: when there is a related historical dialogue question, performing lexical anaphora conversion on the current dialogue question according to the related historical dialogue question; when the sentence is incomplete, completing the current dialogue question according to the historical dialogue question before the current dialogue question.

[0010] In one example, determining whether there is a historical dialogue question related to the current dialogue question specifically includes: respectively extracting the keywords of the current dialogue question and the historical dialogue question; counting the number of overlapping keywords between the current dialogue question and the historical dialogue question; when the number of overlaps exceeds the preset number threshold, determining that the content between the historical dialogue question and the current dialogue question is relevant; when the number of overlaps is less than or equal to the preset number threshold, determining that the content between the historical dialogue question and the current dialogue question is not relevant.

[0011] In one example, the keyword search and vector search are performed on the dialogue question to be queried to obtain reference documents for the dialogue question to be queried, specifically including: when it is the first round of question and answer or when semantic rewriting is not required, the keyword search and vector search are performed on the dialogue question to be queried to obtain a first initial reference document; determining the relevance between the first initial reference document and the dialogue question to be queried, and sorting the multiple first initial reference documents by relevance from high to low; sequentially selecting a preset number of first initial reference documents with high rankings as reference documents for the dialogue question to be queried; when semantic rewriting is required, the keyword search and vector search are performed on the dialogue question to be queried to obtain a second initial reference document; and obtaining the reference document for the dialogue question to be queried based on the second initial reference document and the reference documents of the historical dialogue question.

[0012] In one example, obtaining the reference documents of the dialogue question to be queried based on the second initial reference documents and the reference documents of the historical dialogue question specifically includes: removing duplicates and merging the second initial reference documents with the reference documents of the historical dialogue question to obtain a summarized reference document; determining the relevance between the summarized reference document and the dialogue question to be queried, and sorting the relevance of each summarized reference document from high to low; and selecting a preset number of summarized reference documents with the highest ranking in turn as the reference documents of the dialogue question to be queried.

[0013] In one example, after inferring the prompt word based on a preset large language model to generate answer information for the current dialogue question, the method further includes: storing the current dialogue question and the answer information in a historical dialogue management library; and storing references to the current dialogue question in a historical reference management library.

[0014] On the other hand, an embodiment of the present application provides a RAG-based multi-round dialogue generation device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute any one of the above-mentioned RAG-based multi-round dialogue generation methods.

[0015] On the other hand, an embodiment of the present application provides a non-volatile computer storage medium for generating multi-round conversations based on RAG, which stores computer-executable instructions, and the computer-executable instructions can execute any of the above-mentioned methods for generating multi-round conversations based on RAG.

[0016] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:

[0017] By generating a vector database, the retrieval efficiency for paragraph keywords and paragraph vectors can be rapidly improved.

[0018] Regarding the semantic rewriting and completion mechanism for non-first-round Q&A, when the current question is related to the historical conversation (continuing the same theme), the user input is clarified in terms of intent (such as pronoun replacement, omission and supplementation) based on the historical question, avoiding ambiguity caused by context dependence, and enhancing the system's robustness to colloquial and fragmented expressions.

[0019] Topic bifurcation handling: If the current question is not related to the historical conversation (no rewriting is required), directly retrieve using the original question, avoiding interference from historical information to the new topic and maintaining the flexibility of the conversation.

[0020] Thereby enhancing the system's context understanding ability for continuous conversations and improving the naturalness of interaction.

[0021] By dynamically managing historical references and context information, the system can quickly adapt to topic switching, accurately distinguish between new and old topics, ensure the coherence and consistency of the conversation, effectively improve the response speed and accuracy of the multi-round conversation system, and provide users with a more natural and fluent interaction experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] To more clearly illustrate the technical solutions of the present application, some embodiments of the present application will be described in detail below with reference to the accompanying drawings, in which:

[0023] Figure 1 is a schematic flowchart of a multi-round conversation generation method based on RAG provided by an embodiment of the present application;

[0024] Figure 2 is a schematic flowchart of another multi-round conversation generation method based on RAG provided by an embodiment of the present application;

[0025] Figure 3 is a schematic structural diagram of a multi-round conversation generation device based on RAG provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0026] To make the objectives, technical solutions, and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with specific embodiments and the corresponding accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the scope of protection of the present application.

[0027] Some embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0028] Figure 1 A schematic flowchart of a multi-round dialogue generation method based on RAG provided by an embodiment of the present application. This method can be applied to different business fields, such as the Internet finance business field, the e-commerce business field, the instant messaging business field, the game business field, the official business field, etc. Some input parameters or intermediate results in this process allow manual intervention and adjustment to help improve accuracy.

[0029] The implementation of the analysis method involved in the embodiments of the present application can be a terminal device or a server, and the present application does not make special restrictions on this. For the convenience of understanding and description, the following embodiments will be described in detail by taking the server as an example.

[0030] It should be noted that the server can be a single device or a system composed of multiple devices, that is, a distributed server, and the present application does not make specific limitations on this.

[0031] Figure 1 The process in

[0032] S101: Generate a vector database for the client dialogue system; the vector database includes paragraph keywords and paragraph vectors.

[0033] In some embodiments of the present application, text information extraction and semantic segmentation are introduced to improve the accuracy of information retrieval.

[0034] Specifically, redundant information is extracted from the document set of the client dialogue system to obtain a preprocessed document set. Then, the preprocessed document set is divided into paragraphs, and the keywords and summaries of each paragraph are determined. Then, the paragraph information and summary of each paragraph are encoded to obtain paragraph vectors, the paragraph vectors are stored in the vector database, and a unique ID is assigned to each paragraph. Then, the keywords are stored in the non-vector field of the vector database in scalar form.

[0035] For example, the text information of different types of documents is extracted, and redundant information such as headers and footers is removed through the characteristics of different types of documents. The text information is divided into multiple semantically coherent and flexible paragraphs by combining models and technologies such as Cross-Segment BERT, SeqModel, and Meta-Chunking, and the keywords and summaries of each paragraph are summarized. Then, the embedding model is used to encode the paragraph information combined with the summary into vectors.

[0036] It should be noted that the keywords are stored in the non-vector field of the vector database in scalar form, and appropriate indexing is performed on the vectors to improve the speed and accuracy of retrieval. At the same time, a unique ID number is assigned to each paragraph as an identifier.

[0037] The above technical solution, through the dual indexing capabilities of semantics and keywords: the paragraph vector (combined with abstract encoding) supports fuzzy retrieval at the semantic level, can capture the implicit semantic associations (such as synonyms, context-related expressions) between the user's question and the document paragraphs, and solves the limitation of "Exact Match" in traditional keyword retrieval. The paragraph keywords, as scalar fields, provide the ability of exact matching, which is suitable for the rapid positioning of strong keywords such as domain terms and proper nouns, and avoids the "semantic drift" problem that may occur in pure vector retrieval.

[0038] Effect: Realize the complementary advantages of "exact retrieval" and "semantic retrieval", and improve the recall rate and accuracy of reference documents.

[0039] Flexible paragraph division and unique identification: The document is divided into semantically coherent paragraphs through models such as Cross-Segment BERT, avoiding information redundancy in long text processing. At the same time, a unique ID is assigned to each paragraph to facilitate the accurate positioning and deduplication of subsequent retrieval results.

[0040] Effect: Reduce the storage complexity of the vector database and improve the matching efficiency of fragmented information during retrieval.

[0041] S102: When the user inputs a conversation, determine whether the current conversation question is the first-round Q&A.

[0042] Among them, check whether there are historical conversation Q&As during the current conversation. If there are, it is a non-first-round Q&A; if not, it is a first-round Q&A.

[0043] S103: When it is the first-round Q&A, determine the current conversation question as the to-be-query conversation question.

[0044] That is to say, when it is the first-round Q&A, since there is no historical Q&A information in the current conversation process, therefore, there is no need to perform semantic rewriting on the current conversation question, and directly execute S107.

[0045] S104: When it is a non-first-round Q&A, determine whether to perform semantic rewriting on the current conversation question.

[0046] In some embodiments of the present application, the judgment process is as follows:

[0047] First, evaluate the sentence integrity of the current conversation question.

[0048] Among them, a classification model can be used for integrity evaluation. For example, the classification model can classify sentences into two categories: complete and incomplete. The model will learn the characteristics of complete sentences and incomplete sentences, such as sentence structure, grammar rules, lexical integrity, etc., and then classify the input conversation question sentence according to these characteristics to determine whether it is complete.

[0049] Then, when the current dialogue question is an incomplete sentence, determine to perform semantic rewriting on the current dialogue question.

[0050] When the current dialogue question is a complete sentence, determine whether there is a historical dialogue question related to the current dialogue question.

[0051] Among them, keyword matching can be used to determine whether the content is relevant, and the process is as follows:

[0052] First, extract the keywords in the current dialogue question and the historical dialogue question. Then, judge the relevance by calculating the coincidence degree of the keywords.

[0053] For example, the bag-of-words model can be used to count the number of coincidences of the same keywords between the current dialogue question and the historical dialogue question. When the number of coincidences exceeds the preset number threshold, it is determined that the content between the historical dialogue question and the current dialogue question is relevant. When the number of coincidences is lower than or equal to the preset number threshold, it is determined that the content between the historical dialogue question and the current dialogue question is not relevant.

[0054] When there is a relevant historical dialogue question, determine to perform semantic rewriting on the current dialogue question.

[0055] When there is no relevant historical dialogue question, determine not to perform semantic rewriting on the current dialogue question.

[0056] S105: When semantic rewriting is required, according to the historical dialogue question before the current dialogue question, perform semantic rewriting on the current dialogue question, and determine the semantically rewritten dialogue question as the dialogue question to be queried.

[0057] In some embodiments of the present application, when there is a relevant historical dialogue question, perform lexical anaphora conversion on the current dialogue question according to the relevant historical dialogue question.

[0058] Among them, the way of context correlation analysis can be adopted, that is, analyze the context correlation between the current sentence and the previous text: check whether there is a corresponding antecedent and pronoun in the previous relevant historical text.

[0059] It should be noted that semantic rewriting is to make the intention more clear. For example, when the user asks for the first time "How about the company's revenue last year?", and the user's current question is "Then which business departments do these growths mainly come from?", the system determines that it is not the first-round question, evaluates the sentence integrity as complete, analyzes that the current dialogue question is related to the previous question of "revenue situation", so the new question is semantically rewritten according to the historical Q&A as "Which business departments does the company's revenue growth mainly come from last year?".

[0060] In some embodiments of the present application, when the sentence is incomplete, the current conversation question is completed according to the historical conversation questions before the current conversation question.

[0061] It should be noted that generally, because the current conversation question has a context semantic connection relationship with one or several historical conversation questions, the conversation question input by the user is incomplete. And the completion operation can only be performed when there is a context semantic connection relationship.

[0062] Among them, completion can include filling in the missing parts of the sentence, eliminating unclear references, and reconstructing the question.

[0063] For example, if the user currently asks "What about other aspects?", and the system detects that the question is incomplete, based on the conversation content of the last three rounds (the Q&A about revenue and growth sources), the question is completed to "What about the other business departments of the company last year except for the business departments with revenue growth?"

[0064] S106: When semantic rewriting is not required, determine the current conversation question as the conversation question to be queried; when semantic rewriting is not required, it means that the current conversation question and the historical conversation question belong to different topic directions.

[0065] It should be noted that the current conversation question has no association with the historical conversation question and is an independent different topic, such as the revenue topic and the personnel recruitment topic.

[0066] That is to say, after the user inputs a conversation question, the system first determines whether this is the first question. If so, both keyword retrieval and vector retrieval are used to query the vector database to obtain relevant references.

[0067] If it is not the first question, for a complete sentence, the system further analyzes its relevance to the previous Q&A. When it is not relevant, it directly queries the vector database. When it is relevant, the new question is semantically rewritten according to the relevant historical Q&A (such as replacing lexical references) to clarify the intention and then query.

[0068] When it is detected that the conversation question is incomplete, the system semantically rewrites the question (such as completing) based on the conversation content of the last few rounds, and submits the completed conversation question to the vector database for retrieval.

[0069] In summary, the above process ensures the accuracy of question processing and the effectiveness of querying.

[0070] Based on this, for the semantic rewriting and completion mechanism for non-first-round questions and answers, when the current question is related to the historical conversation (continuation of the same topic), the user input is clarified based on the historical question (such as reference replacement, omission and supplement), avoiding ambiguity caused by context dependence and improving the system's robustness to colloquial and fragmented expressions.

[0071] Topic bifurcation processing: If the current question is not related to the historical conversation (no need to rewrite), directly search with the original question to avoid the interference of historical information on the new topic and maintain the flexibility of the conversation.

[0072] This enhances the system's ability to understand the context of continuous conversations, reduces user repetitive input, and improves the naturalness of interactions.

[0073] S107: Perform keyword search and vector search on the dialogue question to be queried in the vector database to obtain references.

[0074] In some embodiments of this application, for questions in the first round or unrelated to historical conversations, a re-ranking model is used to sort the retrieved reference fragments, and highly relevant fragments are selected based on their scores as the final references. For questions in continuous conversations, new and old references are de-duplicated and merged, then re-ranked to generate a true reference set that integrates the latest query and historical information, ensuring the provision of information resources that best meet user needs. This not only improves the relevance and accuracy of search results, but also optimizes the user experience.

[0075] In some embodiments of the present application, when it is the first round of question answering or semantic rewriting is not required, keyword search and vector search are performed on the query dialogue question to obtain the first initial reference.

[0076] The relevance between the first initial reference document and the dialogue question to be queried is determined, and the multiple first initial reference documents are sorted in descending order of relevance.

[0077] A preset number of first initial references with the highest ranking are selected in sequence as references for the dialogue question to be queried.

[0078] In some embodiments of the present application, when semantic rewriting is required, keyword search and vector search are performed on the query dialogue question to obtain a second initial reference.

[0079] According to the second initial reference and the reference of the historical dialogue question, the reference of the dialogue question to be queried is obtained.

[0080] The process of obtaining the references of the dialogue question to be queried based on the second initial reference and the references of the historical dialogue question is as follows:

[0081] Deduplicate and merge the second initial reference with the reference of the historical dialogue question to obtain a summary reference.

[0082] Determine the relevance between the summary reference and the dialogue question to be queried, and sort each summary reference in descending order of relevance.

[0083] Select a preset number of summary references with higher rankings in turn as the references for the dialogue question to be queried.

[0084] In summary, for the re-ranking and deduplication mechanism: in the first round or for irrelevant questions, high-relevance fragments are screened by the re-ranking model to avoid interference from low-quality information; in continuous conversations, new and old documents are merged and deduplicated to ensure that the answers are based on the latest and non-redundant information

[0085] Thus, it ensures the provision of information resources that best meet the needs, improves the quality of references, reduces the noisy input during the inference of the large model, and optimizes the accuracy and logic of the answers.

[0086] S108: Generate a prompt word according to the dialogue question to be queried and the reference.

[0087] Among them, the question and the reference are assembled together to form a new prompt.

[0088] S109: Infer the prompt word according to a preset large language model to generate the answer information for the current dialogue question.

[0089] In some embodiments of the present application, the current dialogue question and the answer information are stored in the historical dialogue management library. The reference of the current dialogue question is stored in the historical reference management library.

[0090] It should be noted that in the historical reference management library, the question-and-answer information of each conversation process can be saved in the short term.

[0091] It should be noted that historical dialogue management only saves the user's questions and the answers of the large model, without retaining references, thus reducing information noise. This method makes it more efficient when evaluating question relevance and rewriting questions, improving both the processing speed and ensuring the accuracy and timeliness of the response. This can effectively optimize the process and improve the overall efficiency of the system.

[0092] Historical reference management adopts an independent mechanism, which can retain the literature records of the recent several rounds during the current conversation process for literature supplementation for context-related questions. This method ensures the integrity and accuracy of information, improves the query accuracy and user experience.

[0093] Based on this, redundant knowledge slices are removed through the historical conversation assembly process, the context length is shortened, and the Q&A efficiency is improved. Finally, a historical knowledge short-term memory block is used to save query fragments to provide more relevant references for old topics in subsequent conversations.

[0094] It should be noted that although the embodiments of the present application are described with reference to Figure 1 to introduce and explain steps S101 to S109 in sequence, this does not mean that steps S101 to S109 must be executed in a strict order. The reason why the embodiments of the present application introduce and explain steps S101 to S109 in the Figure 1 shown order is to facilitate those skilled in the art to understand the technical solution of the embodiments of the present application. In other words, in the embodiments of the present application, the order between steps S101 to S109 can be appropriately adjusted according to actual needs.

[0095] Through the Figure 1 method, text information is efficiently extracted and divided into semantically coherent paragraphs, while redundant information is removed to generate high-quality knowledge slices. Secondly, the paragraphs are encoded into vectors and stored in a vector database. Combining keyword indexing and unique ID identification significantly improves the speed and accuracy of retrieval. Finally, through intelligent question processing, semantic rewriting, anaphora resolution, and re-ranking models, the accurate expression of question intent and the high relevance of retrieval results are ensured. At the same time, the historical dialogue management and reference mechanism are optimized to reduce information noise and improve the system response speed and overall performance.

[0096] In summary, by dynamically managing historical references and context information, the system can quickly adapt to topic switching, accurately distinguish new and old topics, ensure the coherence and consistency of the dialogue, effectively improve the response speed and accuracy of the multi-round dialogue system, and provide users with a more natural and fluent interaction experience.

[0097] Based on this, efficient knowledge management, accurate retrieval and generation, and intelligent question processing are realized in a multi-round dialogue scenario, significantly improving the accuracy, timeliness, and user experience of the system.

[0098] More intuitively, Figure 2 is a schematic flowchart of another RAG-based multi-round dialogue generation method provided by the embodiments of the present application.

[0099] In Figure 2 , the process of constructing a vector database is: document data - document information extraction - removing redundancies such as headers and footers - dividing paragraphs using a semantic partitioning model - extracting keywords and abstracts - encoding paragraphs using an embedding model - index establishment - vector database.

[0100] After the user inputs a question, the process is as follows: Is it the first round of Q&A? If so, retrieve the reference documents.

[0101] If not, check whether the sentence is complete.

[0102] If it is, is it relevant to the historical conversation? If not, retrieve the reference documents. If so, perform semantic rewriting (lexical substitution) and retrieve the reference documents.

[0103] If the sentence is incomplete, perform semantic rewriting (complete the sentence (such as pronoun elimination)) and retrieve the reference documents.

[0104] Assemble the reference documents and the conversation question into a prompt, so that the large model infers and generates an answer, and the user receives the answer.

[0105] Based on the same idea, some embodiments of the present application also provide devices and non-volatile computer storage media corresponding to the above method.

[0106] Figure 3 FIG. is a schematic structural diagram of a multi-round dialogue generation device based on RAG provided by an embodiment of the present application, including: [[ID=,20]]

[0107] At least one processor; and,

[0108] A memory communicatively connected to the at least one processor; wherein,

[0109] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute a multi-round dialogue generation method based on RAG as described in any one of the above.

[0110] A non-volatile computer storage medium for multi-round dialogue generation based on RAG provided by some embodiments of the present application stores computer-executable instructions, and the computer-executable instructions can execute a multi-round dialogue generation method based on RAG as described in any one of the above.

[0111] The embodiments in the present application are all described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for the relevant parts, reference can be made to the partial description of the method embodiments.

[0112] The devices and media provided by the embodiments of the present application correspond one-to-one to the methods. Therefore, the devices and media also have beneficial technical effects similar to those of the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the devices and media will not be elaborated here.

[0113] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) that contain computer-usable program code.

[0114] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the specified functions in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0115] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means that implement the specified functions in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0116] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the specified functions in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0117] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and a memory.

[0118] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). The memory is an example of computer-readable media.

[0119] A computer-readable medium includes both permanent and non-permanent, removable and non-removable media and can implement information storage by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transitory medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer-readable medium does not include transitory computer-readable media such as modulated data signals and carrier waves.

[0120] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.

[0121] The above description is only for the embodiments of the present application and is not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the technical principles of the present application shall fall within the protection scope of the present application.

Claims

1. A multi-turn dialogue generation method based on RAG, characterized in that, The method includes: Generating a vector database for the client dialogue system; the vector database includes paragraph keywords and paragraph vectors; When the user inputs a dialogue, determining whether the current dialogue question is the first-round Q&A; When it is the first-round Q&A, determining the current dialogue question as the dialogue question to be queried; When it is not the first-round Q&A, determining whether to semantically rewrite the current dialogue question; When semantic rewriting is required, semantically rewriting the current dialogue question according to the historical dialogue questions before the current dialogue question, and determining the semantically rewritten dialogue question as the dialogue question to be queried; When semantic rewriting is not required, determining the current dialogue question as the dialogue question to be queried; when semantic rewriting is not required, it means that the current dialogue question and the historical dialogue question belong to topics in different theme directions; In the vector database, performing keyword retrieval and vector retrieval on the dialogue question to be queried to obtain reference documents; Generating a prompt word according to the dialogue question to be queried and the reference documents; Performing reasoning on the prompt word according to a preset large language model to generate the answer information for the current dialogue question.

2. The method according to claim 1, characterized in that, The generating of the vector database for the client dialogue system specifically includes: Extracting redundant information from the document set of the client dialogue system to obtain a preprocessed document set; Dividing the preprocessed document set into paragraphs and determining the keywords and summaries of each paragraph; Encoding the paragraph information and summary of each paragraph to obtain a paragraph vector, storing the paragraph vector in the vector database, and assigning a unique ID to each paragraph; Storing the keywords in scalar form in the non-vector field of the vector database.

3. The method according to claim 1, wherein The determining whether to semantically rewrite the current dialogue question specifically includes: Evaluating the sentence integrity of the current dialogue question; When the current dialogue question is incomplete, determining to semantically rewrite the current dialogue question; When the current dialogue question is complete, determining whether there are historical dialogue questions related to the current dialogue question; When there are related historical dialogue questions, determining to semantically rewrite the current dialogue question; When there are no related historical dialogue questions, determining not to semantically rewrite the current dialogue question.

4. The method according to claim 3, characterized in that The semantically rewriting the current dialogue question according to the historical dialogue questions before the current dialogue question specifically includes: When there are related historical dialogue questions, performing lexical anaphora conversion on the current dialogue question according to the related historical dialogue questions; When the sentence is incomplete, completing the current dialogue question according to the historical dialogue questions before the current dialogue question.

5. The method according to claim 3, wherein Determining whether there are historical dialogue questions related to the current dialogue question specifically includes: Respectively extracting the keywords of the current dialogue question and the historical dialogue questions; Counting the number of overlapping keywords between the current dialogue question and the historical dialogue questions; When the number of overlaps exceeds the preset quantity threshold, determining that the content between the historical dialogue question and the current dialogue question is relevant; When the number of overlaps is lower than or equal to the preset quantity threshold, determining that the content between the historical dialogue question and the current dialogue question is not relevant.

6. The method according to claim 1, characterized in that The performing keyword search and vector search on the dialogue question to be queried to obtain references for the dialogue question to be queried specifically includes: When it is the first round of question answering or semantic rewriting is not required, keyword search and vector search are performed on the dialogue question to be queried to obtain a first initial reference; Determining the relevance between the first initial reference document and the dialogue question to be queried, and sorting the relevance of the plurality of first initial reference documents from high to low; sequentially selecting a preset number of first initial reference documents ranked at the top as reference documents for the dialogue question to be queried; When semantic rewriting is required, keyword search and vector search are performed on the dialogue question to be queried to obtain a second initial reference; The reference document of the dialogue question to be queried is obtained according to the second initial reference document and the reference document of the historical dialogue question.

7. The method according to claim 6, characterized in that The step of obtaining the reference document for the dialogue question to be queried based on the second initial reference document and the reference document for the historical dialogue question specifically includes: The second initial reference is combined with the references of the historical dialogue question to remove duplications and obtain a summary reference; Determining the relevance between the summarized references and the dialogue question to be queried, and ranking each summarized reference in descending order of relevance; A preset number of top-ranked summary references are selected in sequence as references for the dialogue question to be queried.

8. The method according to claim 1, characterized in that, After inferring the prompt word according to the preset large language model to generate answer information for the current dialogue question, the method further includes: Storing the current conversation question and the answer information in a historical conversation management library; The references of the current dialogue question are stored in a historical reference management library.

9. A multi-turn dialogue generation device based on RAG, characterized in that, include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the RAG-based multi-round dialogue generation method described in any one of claims 1 to 8.

10. A non-volatile computer storage medium for multi-turn dialogue generation based on RAG, storing computer-executable instructions, characterized in that, The computer-executable instructions can execute the RAG-based multi-round dialogue generation method described in any one of claims 1 to 8.

Citation Information

Cited By

  • Government affair field question and answer method and system based on large model and multi-round guidance and application

    CN120578748A

  • Medical dialogue search term rewriting method and device, equipment and storage medium

    CN120994798A

  • Retrieval enhancement method and system for multi-round dialogue type questions and answers and application

    CN121029952A

  • Retrieval enhancement generation method and system and computer

    CN121935356A

  • A method, system and computer program product for retrieval augmented generation

    CN121935356B