Retrieval enhancement generation method based on large language model and related products
By identifying the problem difficulty type and generating the associated second problem text for vectorization, the problem of low retrieval accuracy of user input different expressions is solved, and more accurate knowledge base search and reply generation are achieved.
Patent Information
- Application Number
- CN202410933420.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2024-11-26
AI Technical Summary
In the prior art, problems entered by users are often scattered or inconsistently the same as those in the knowledge base, resulting in low accuracy of the knowledge fragments retrieving from the knowledge base related to problems with different expressions.
By receiving the problem text, calling the preset large language model to identify the difficulty type of the problem, generating the associated second problem text, and vectorizing the first problem text and the second problem text, parallelizing it in the preset knowledge base Search to improve the accuracy of search.
Improve the accuracy of user inputting different expressions, thereby improving the accuracy of generating reply text.
Smart Images

Figure CN119025637A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a retrieval enhancement generation method based on a large language model and related products. Background Art
[0002] With the development of technology, large language models such as ChatGPT have continuously improved their ability to understand and generate natural language, providing strong support for various applications. However, they may still provide misleading feedback due to outdated learned information, low timeliness in processing specific knowledge, and lack of knowledge in professional fields. To this end, Retrieval Augmented Generation (RAG) is a strategy to provide external knowledge sources for large language models, that is, it provides a method to optimize the output of large language models with target information without modifying the underlying model itself. Targeted information can be more timely and more focused on a specific organization and industry than large language models, which means that generative artificial intelligence systems can provide more contextually appropriate answers to user questions, and can also provide these answers based on the latest data. In short, RAG technology can help large language models (LLMs) give better answers.
[0003] However, since the questions input by users are often scattered or not exactly the same as the statements in the knowledge base, and the document knowledge base lacks multiple types of indexes when it is established, it is difficult to be retrieved by customer questions. Therefore, it is a challenging problem to accurately retrieve knowledge fragments related to questions with different statements from the knowledge base. Summary of the invention
[0004] The main purpose of this application is to provide a retrieval enhancement generation method based on a large language model and related products, which can at least solve the problem of low accuracy of retrieving knowledge fragments related to questions with different expressions from the knowledge base in the related technology.
[0005] To achieve the above-mentioned objectives, the first aspect of the present application provides a retrieval enhancement generation method based on a large language model, the method comprising: receiving a first question text, and calling a preset large language model to identify the difficulty type of the first question text, and generating a second question text associated with the first question text based on the difficulty type; vectorizing the first question text and the second question text to obtain multiple question text vectors; querying a preset knowledge base for reference answer texts associated with each question text vector; and generating an answer text for the first question text based on all reference answer texts and the preset large language model.
[0006] The second aspect of the present application provides an intelligent question-answering system based on a large language model, including a terminal device and a server, wherein a user can input a first question text through the terminal device, and the server deploys a preset knowledge base and a large language model, wherein the preset knowledge base is used to collect and store reference answer texts in the form of vectors; the large language model is used to respond to the first question text input by the user, call the preset knowledge base and process the first question text according to the retrieval enhancement generation method based on the large language model provided in the first aspect of the present application to obtain an answer text of the first question text, and output the answer text to the terminal device.
[0007] The third aspect of the present application provides an electronic device, including: a memory and a processor, wherein the processor is used to execute a computer program stored in the memory, and when the processor executes the computer program, it implements the steps of the retrieval enhancement generation method based on a large language model provided in the first aspect of the present application.
[0008] The fourth aspect of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the retrieval enhancement generation method based on a large language model provided in the first aspect of the present application are implemented.
[0009] As can be seen from the above, according to the large language model-based retrieval enhancement generation method and related products provided by the present application scheme, the difficulty type of the first question text is identified by calling the preset large language model, and the related second question text is generated according to the difficulty of the first question text through the large language model, and then the first question text and the second question text are used to perform parallel searches for corresponding reference answer texts in the knowledge base. As a result, the accuracy of knowledge base retrieval when customers ask questions with different expressions can be improved, thereby improving the accuracy of the generated answer text. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0011] Figure 1 An application scenario diagram of a retrieval enhancement generation method based on a large language model provided in an embodiment of the present application; Figure 2 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application; Figure 3 A schematic diagram of the basic flow of a retrieval enhancement generation method based on a large language model provided in an embodiment of the present application; Figure 4 A detailed flowchart of a retrieval enhancement generation method based on a large language model provided in one embodiment of the present application; Figure 5 A schematic diagram of a detailed process of another retrieval enhancement generation method based on a large language model provided in an embodiment of the present application; Figure 6 A module diagram of a retrieval enhancement generation device based on a large language model provided in one embodiment of the present application. DETAILED DESCRIPTION
[0012] In order to make the purpose, features, and advantages of the invention of this application more obvious and easy to understand, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0013] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0014] In order to solve the problem of low accuracy of results retrieved from a knowledge base based on user questions in the related art, the present application provides a retrieval enhancement generation method, device, electronic device and computer-readable storage medium based on a large language model.
[0015] like Figure 1An application scenario diagram of a retrieval enhancement generation method based on a large language model provided in an embodiment of the present application, the retrieval enhancement generation method based on a large language model is applied to an intelligent question-answering system. The intelligent question-answering system includes a terminal device 101 and a server 102, and the terminal device 101 and the server 102 are connected in communication. The user can input a first question text through the terminal device 101, and the server 102 deploys a preset knowledge base and a large language model, wherein the preset knowledge base is used to collect and store reference answer texts in the form of vectors; the large language model is used to respond to the first question text input by the user, call the preset knowledge base and process the first question text according to the retrieval enhancement generation method based on a large language model provided in one or more embodiments of the present application, and obtain the answer text of the first question text. After the server 102 obtains the answer text, it is output to the terminal device 101, and the terminal device 101 displays it to the user. The terminal device 101 can be a mobile phone, a computer, a tablet, a robot, a self-service terminal, etc. The server 102 can be a network server, an application server, etc., which is not limited here.
[0016] like Figure 2 A schematic diagram of the structure of an electronic device provided in one embodiment of the present application, the electronic device can be used to implement the retrieval enhancement generation method based on a large language model provided in one or more embodiments of the present application, the electronic device mainly includes: a memory 201, a processor 202, and a computer program 203 stored in the memory 201 and executable on the processor 202, the memory 201 and the processor 202 are connected by communication. When the processor 202 executes the computer program 203, the aforementioned method of retrieval enhancement generation based on a large language model is implemented. Among them, the electronic device can be a mobile phone, a computer, an intelligent voice interaction device and other devices, and can also be a server.
[0017] In an optional embodiment, the number of processors may be one or more. The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), neural network chips or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0018] In an optional implementation, the memory is used to store a computer program corresponding to the retrieval enhancement generation method based on a large language model provided in one or more embodiments of the present application, so that the processor can read the program when processing, thereby realizing the processing of the retrieval enhancement generation process. It should be noted that the memory can be set independently or integrally with the processor, and it can be a high-speed random access memory (RAM) memory or a non-volatile memory, such as a disk memory, which is not limited here.
[0019] The embodiment of the present application also provides a computer-readable storage medium, which may be provided in the above-mentioned electronic device, and the computer-readable storage medium may be the memory in the aforementioned embodiment. The computer-readable storage medium stores a computer program, and when the program is executed by the processor, the retrieval enhancement generation method based on the large language model in the aforementioned embodiment is implemented. The computer-storable medium may also be a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a RAM, a disk or an optical disk, and other media that can store program codes.
[0020] The embodiment of the present application also provides a computer program product comprising instructions, and when the computer program product is executed on a computer or a processor, the process of the aforementioned retrieval enhancement generation method based on a large language model can be implemented.
[0021] like Figure 3 A basic flow chart of a retrieval enhancement generation method based on a large language model provided in one embodiment of the present application, the retrieval enhancement generation method includes the following steps 301 to 304.
[0022] Step 301: Receive a first question text, call a preset large language model to identify the difficulty type of the first question text, and generate a second question text associated with the first question text based on the difficulty type.
[0023] When a question query instruction is received, a first question text input by the user is obtained, and a large language model is called to identify the difficulty type of the first question text, so as to generate a second question text associated with the first question text according to the difficulty type of the first question text, wherein the user may input the question text in the form of voice, text, etc. When it is voice input, the voice is converted into text, and the question text is a natural language text, for example, it may be Chinese, English, or other languages.
[0024] In one embodiment, the preset large language model includes a recognition layer, which recognizes the difficulty type of the first question text and generates different types of second question texts according to the first question texts of different difficulty types. The difficulty types of the questions in this embodiment can be divided into simple and complex types, which can be recognized by the large language model, which is equivalent to inputting the first question text into the large language model and asking the large language model the difficulty type of the first question text. For example, after receiving question A, calling the large language model, and inputting the question of the large language model: Is question A a simple question or a complex question? Please output the judgment result. The recognition layer in the large language model has a strong semantic analysis and understanding ability, which can accurately judge the difficulty type of the question. In addition, the explanations of simple and complex questions can also be generally input into the large language model to accurately judge whether the first question text is a simple or complex question through the recognition layer of the large language model. Of course, the large language model can also be trained in advance so that its recognition layer can more accurately judge the type of question.
[0025] In some implementations of the present embodiment, the second question text is a similar question text and / or sub-question text of the first question text, and the second question text associated with the first question text is generated based on the difficulty type, including: when the first question text is a simple question text, a preset number of similar question texts are generated as the second question text; when the first question text is a complex question text, a preset number of sub-question texts are generated as the second question text.
[0026] For simple question texts, the corresponding related texts can usually be directly searched from the preset knowledge base, while for complex questions, it is usually necessary to search the question text from the preset knowledge base in multiple dimensions, and then summarize the searched texts to obtain the related texts. Therefore, for simple questions and complex questions, the logic of the generated second question text is different from that of the first question text.
[0027] In one embodiment, the preset large language model further includes a rewriting layer. When the large language model identifies that the question text to be queried is a simple question text, the rewriting layer of the large language model is called to rewrite the question text to be queried into M (M≥1) second question texts similar to the original question text. Taking M=2 as an example, for example, the first question text is "Does the Astra+ module support the alignment of color and depth images?" When the recognition layer of the large language model is called to identify that the difficulty type of the first question text is a simple type, the rewriting layer of the large language model can be continuously called to generate two second question texts similar to the first question text, such as "Does the Astra+ camera support D2C?" and "How to align the depth map and color map when using Astra+." After the original question text is rewritten into similar question texts, in subsequent retrieval, it can avoid the situation that the user inputs a fragmented question or the expression is not exactly the same as that in the knowledge base, or may not even be a special term in the field, thereby improving the efficiency and success rate of retrieval.
[0028] In one embodiment, the large language model also includes a disassembly layer. When the identification layer in the large language model identifies that the question text to be queried is a complex question text, the large language model disassembly layer is called to disassemble the question text to be queried into M sub-question texts related to the original question text. The sub-question text is more in-depth than the original question text, and it can be a detailed question text of multiple aspects of the original question text. Taking M=2 as an example, when the first question text is "Introduce the Femto Mega module", the identification layer in the large language model is called to identify that the difficulty type is complex, and the disassembly layer in the large language model can continue to be called to generate two sub-questions (i.e., the second question text) of the first question text, such as "Can you introduce the performance of the Femto Mega module in deep computing" and "What are the main advantages of the Femto Mega module?" Therefore, by disassembling the complex question text into related sub-question texts, the retrieved text blocks can be made richer and more accurate, and the accuracy of subsequent replies can be improved.
[0029] Step 302: vectorize the first question text and the second question text to obtain multiple question text vectors.
[0030] In this embodiment, since each reference answer text block in the preset knowledge base is stored in the form of a vector, the retrieval of the question text is performed by vector matching. Therefore, the large language model also includes a conversion layer for vectorizing each question text before retrieval to convert the text data into a vector for easy matching analysis with the knowledge base.
[0031] Step 303: call a preset knowledge base and query the preset knowledge base for reference answer text blocks associated with each question text vector.
[0032] In this embodiment, after each question text is converted into a question text vector, each question text vector can be queried in parallel in the knowledge base for a reference answer text block associated therewith to obtain N reference answer text blocks.
[0033] In some implementations of the present embodiment, a reference answer text block associated with each question text vector is queried in a preset knowledge base, including: respectively calculating the similarity score between each reference answer text block vector in the knowledge base and each question text vector; sorting the reference answer text block vectors corresponding to each question text vector from high to low according to the similarity score; obtaining the first n reference answer text block vectors corresponding to each question text vector as the associated text block vector of the question text vector, and determining the reference answer text block corresponding to each question text vector according to the n associated text block vectors of each question text vector; wherein, n≥1; n can be a value such as 1, 2, 3, 4, 5, etc., which can be reasonably selected according to demand and efficiency.
[0034] In this embodiment, the similarity score between each question text vector and each reference answer text block vector in the knowledge base can be calculated, and the multiple reference answer text block vectors corresponding to each question text vector can be sorted in order of high to low similarity scores to obtain a reference answer text block vector sequence corresponding to each question text vector. In each reference answer text block vector sequence, the first n target text block vectors are selected as the associated text block vectors of the question text vector. According to the n associated text block vectors corresponding to each question text vector, the reference answer text corresponding to each question text vector is determined, that is, all question text vectors are matched in the knowledge base, and (M+1)*n reference answer text blocks can be obtained (if M=2, then N=3n).
[0035] In addition, the more reference answer text blocks that are obtained, the higher the accuracy and satisfaction of the subsequent responses generated based on these reference answer text blocks can be to a certain extent, but there is also interference from reference answer text blocks with lower similarity. In order to reduce the interference problem caused by reference answer text blocks with lower similarity, the obtained reference answer text blocks can be screened again, for example, the reference answer text block vectors with a similarity score greater than or equal to a similarity score threshold are selected from the n target text block vectors obtained as the reference answer text blocks. In some embodiments, the reference answer text blocks with a similarity score greater than a score threshold for each question text vector can also be obtained as the associated text blocks for each question text vector.
[0036] In some other implementations of the present embodiment, the reference answer text block vector includes a knowledge text block vector corresponding to the knowledge text block and a hypothetical question text block vector corresponding to the knowledge text block, and the reference answer text block corresponding to each question text vector is determined according to the n associated text block vectors of each question text vector, including: distinguishing the knowledge text block vectors and the hypothetical question text block vectors in the n associated text block vectors; taking the knowledge text block vector corresponding to the hypothetical question text block vector in the n associated text block vectors as the reference answer text block; taking all the knowledge text block vectors in the n associated text block vectors as the reference answer text blocks.
[0037] Specifically, the method for obtaining the hypothetical question text block vector includes: generating one or more hypothetical questions for each knowledge text block, and the hypothetical questions corresponding to each knowledge text block can be the same or different. For example, the knowledge text blocks "OrbbecViewer for OpenNI2 obtains infrared gain value" and "OrbbecViewer for OpenNI2 sets infrared gain value" both correspond to a hypothetical question text "How to set the exposure value of the infrared camera in OrbbecViewer". The hypothetical question and the text block are converted into vectors to obtain the hypothetical question text block vector, and stored in the knowledge base. In the process of retrieving text blocks from the knowledge base based on the question text vector, the hypothetical question text block vector also participates in the retrieval. The retrieval process can also adopt a similarity matching method. When the question text vector matches the hypothetical question text block vector, the corresponding knowledge text block vector is used as a reference answer text block, instead of the hypothetical question text block vector as a reference answer text block; and the knowledge text block vectors of other non-hypothetical question text block vectors are directly used as reference answer text blocks. By setting two types of matching text block vectors, the robustness and comprehensiveness of the retrieval can be improved, thereby improving the efficiency, accuracy and robustness of the retrieval.
[0038] Step 304: Generate a response text for the first question text based on all reference response texts and a preset large language model.
[0039] In this embodiment, the large language model also includes a response layer. After a reference response text block is obtained by querying the knowledge base based on the first question text and the second question text, the reference response text block is input into the response layer of the large language model. The response layer organizes the reference response text block by understanding the context awareness to obtain an accurate and coherent response text.
[0040] In some implementations of the present embodiment, a reply text for the first question text is generated based on all reference reply text blocks and a preset large language model, including: deduplicating and merging all reference reply texts to obtain a target text block; and transferring the target text block to the reply layer in the large language model to obtain an output reply text.
[0041] In this embodiment, there may be repeated text blocks in the reference answer text blocks queried based on the first question text and the second question text, so the obtained text blocks can be deduplicated, and then the similarity score between each text block and the corresponding question text is obtained, and all text blocks are merged in order of similarity scores from high to low and transmitted to the answer layer in the large language model, so that the answer layer in the large language model generates the answer text of the user's query question based on these text blocks.
[0042] In some other implementations of this embodiment, the large language model also includes an analysis layer, and the retrieval enhancement generation method also includes: inputting the first question text into the analysis layer in the large language model to analyze the intent information corresponding to the first question text, and inputting the intent information and the target text block into the reply layer to obtain the reply text corresponding to the first question, thereby making the reply more humane and improving the user experience.
[0043] Specifically, the analysis layer in the large language model is used to analyze the intention of the user's query. For example, when the user's query is "I need a 3D camera with a network interface, what models do you have that can meet my needs", the analysis layer of the large language model is called to analyze the intention as "the user needs to make purchase inquiries"; the target text block and the intent information are transmitted to the reply layer in the large language model. The reply layer generates a reply text based on these text blocks and intent information, so that the reply text can be more appealing. For example, if it is recognized that the user's intention is to make after-sales inquiries, some common after-sales courtesy expressions will be added to the reply text generated by the reply layer, such as: "I hope the following methods can solve your problem", so that the reply is more humane.
[0044] Based on the technical solution of the embodiment of the present application, a first question text is received, and a preset large language model is called to identify the difficulty type of the first question text, and a second question text associated with the first question text is generated based on the difficulty type; the first question text and the second question text are vectorized to obtain multiple question text vectors; a reference answer text block associated with each question text vector is searched in a preset knowledge base; and a reply text of the first question text is generated based on all reference answer text blocks and a preset large language model. Through the implementation of the solution of the present application, the large language model generates corresponding related questions according to the difficulty of the required query question, and then the related questions and the required query question are searched in parallel in the knowledge base, thereby improving the accuracy of the search results.
[0045] In some embodiments, the large language model also includes a judgment layer, which is used to determine whether the first question text is a refusal to answer question when the first question text is received in step 301. If the first question text is a refusal to answer question, the subsequent steps are stopped and a first fixed reply of polite refusal is returned, for example, "Sorry, as a company customer service assistant, I can only provide relevant information about the company's products and services. If you have any related questions, I am happy to answer them for you"; if the first question text is an acceptance question, the first question text is input into the recognition layer in the large language model, and the recognition layer determines its difficulty type and executes the subsequent steps.
[0046] Specifically, refused-to-answer questions include small talk questions, such as "How is the weather today?" and "What is the hit song of XX star?"; accepted-to-answer questions may include product consulting questions, product after-sales questions, etc. A refused-to-answer question library and an accepted-to-answer question library may be pre-set, and the first question text may be input into the judgment layer of the large language model. The judgment layer calls the preset refused-to-answer question library and the preset accepted-to-answer question library, and queries the first question text in the refused-to-answer question library and the accepted-to-answer question library to determine whether the first question text is a refused-to-answer question, so that the language model can make a more accurate judgment. Alternatively, the explanation of the refused-to-answer question, the explanation of the accepted-to-answer question, and the first question text may be input into the judgment layer of the large language model together to improve the accuracy of the judgment of the large language model.
[0047] In addition, in step 304, if a reference answer text block that is irrelevant to the question text is retrieved and sent to the answer layer of the large language model, the answer layer generating a reply based on the received reference answer text block is actually misleading, and the reply generated by the large language model based on the text block may contain "hallucinations", that is, there may be some irrelevant, absurd or untrue content, which may not necessarily solve the customer's problem well. There are often problems in returning the reply generated directly by the large language model to the customer.
[0048] To this end, in some embodiments, the large language model also includes an association layer, which deduplicates and merges all reference answer text blocks to obtain a target text block, and inputs the target text block and the first question text into the association layer of the large language model. The association layer is used to calculate the correlation between the target text block and the first question text, and determines whether the target text block is related to the first question text based on whether the correlation satisfies the correlation condition. If the correlation does not satisfy the correlation condition, it means that the two are not related. At this time, the answer layer can directly output a second fixed answer, such as "The content you want to find is not found in the knowledge base, please ask again"; if the correlation satisfies the correlation condition, it means that the target text block is related to the first question text, and the target text block or the target text block and the user's intention are input into the answer layer in the large language model to generate the answer text, thereby constraining the generation of the illusion of the entire process, thereby effectively improving the accuracy of the answer text.
[0049] Optionally, the association condition is expressed as a preset score threshold. If the association degree is greater than or equal to the preset score threshold, the association condition is met, and if it is less than the preset score threshold, the association condition is not met; wherein the association degree includes an authenticity score and a validity score. The authenticity score refers to the extent to which there is content in the target text block that is irrelevant or fabricated with the first question text, and the validity score refers to the extent to which the target text block solves the first question text.
[0050] In another embodiment, whether the reference reply text is related to the first question text can also be determined by comparing the numerical relationship between the authenticity score and the validity score in the association degree and the preset score threshold; if both the authenticity score and the validity score are greater than the preset score threshold, it means that the reference reply text is related to the first question text, and the target text block or the target text block and the user intention are input into the reply layer in the large language model to generate the reply text; if either the authenticity score or the validity score is less than the preset score threshold, it means that the association condition is not met, and the reply layer can directly output the second fixed reply.
[0051] It should be noted that each unit layer in the above-mentioned large language model, such as the recognition layer, the disassembly layer, the reply layer, etc., can also be a different large language model or a different neural network model, and the layers are integrated to obtain the large language model of the present application. In addition, each unit layer constituting the large language model of the present application can be a large language model commonly used in the prior art, such as ChatGPT, Wenxin Yiyan, Tongyi Qianwen, iFlytek Spark, etc., and the present application does not limit this.
[0052] Figure 4 The method in is a refined retrieval enhancement generation method based on a large language model provided in an embodiment of the present application, and the retrieval enhancement generation method includes: Step 401: Receive a first question text, call a recognition layer in a preset large language model to identify a difficulty type of the first question text, and call an analysis layer in a preset large language model to identify intent information corresponding to the first question text; Step 402: when the first question text is a simple question text, a preset number of similar question texts are generated as second question texts through the rewriting layer in the large language model; Step 403: when the first question text is a complex question text, a preset number of sub-question texts are generated as the second question text through the decomposition layer in the large language model; Step 404: vectorize the first question text and the second question text to obtain a plurality of question text vectors; Step 405: querying a preset knowledge base for a reference answer text block associated with each question text vector; Step 406: De-duplicate and merge all reference reply text blocks to obtain a target text block; Step 407: Input the target text block and the intention information into the response layer in the large language model to obtain the output response text.
[0053] It should be understood that the order of execution of the steps in this embodiment does not necessarily mean the order in which the steps are executed. The order in which the steps are executed should be determined by their functions and internal logic, and should not constitute the sole limitation on the implementation process of the embodiment of this application. Figure 3 The contents of the relevant steps in the corresponding embodiments are not repeated here.
[0054] For example Figure 5 The schematic diagram of the retrieval enhancement generation method based on the large language model shown in the figure, in this embodiment, the recognition layer and the analysis layer in the preset large language model respectively identify the difficulty of the first question text input by the user and analyze the user's intention. When the question difficulty is simple, similar questions 1 and similar questions 2 are generated through the rewriting layer. When the question difficulty is complex, sub-questions 1 and sub-questions 2 are generated through the disassembly layer. Similar questions 1 and similar questions 2 or sub-questions 1 and sub-questions 2 are used as the second question text, and then the first question text and the second question text are converted into question text vectors, that is, ( The user question, similar question 1 and similar question 2) or (user question, sub-question 1 and sub-question 2) is converted into a question text vector, and then queried in the preset knowledge base to obtain reference answer text blocks associated with each question text vector, such as reference answer text blocks 1, 2, and 3. The reference answer text blocks 1, 2, and 3 are deduplicated and merged to obtain a merged text block (i.e., the target text block), and combined with the user's intention to input the answer layer of the large language model. The large language model generates a reply text based on the merged text block, the user's intention and the first question, thereby obtaining a reply text for the first question text. Therefore, this embodiment reconstructs, subdivides and decomposes the question that the user needs to query into a series of related similar questions and sub-questions, and searches in the knowledge base in a parallel manner, thereby improving the success rate of the query and the accuracy of the query results, and generates a reply text in combination with the user's intention information, which can improve the appeal of the reply text.
[0055] Figure 6 A retrieval enhancement generation device based on a large language model is provided in one embodiment of the present application. The retrieval enhancement generation device can be applied to the aforementioned retrieval enhancement generation method based on a large language model. Figure 6 As shown, the retrieval enhancement generation device mainly includes: The first generation module 601 is used to receive a first question text, call a preset large language model to identify the difficulty type of the first question text, and generate a second question text associated with the first question text based on the difficulty type; the vectorization module 602 is used to vectorize the first question text and the second question text to obtain multiple question text vectors; the query module 603 is used to call a preset knowledge base and query the reference answer text blocks associated with each question text vector in the preset knowledge base; the second generation module 604 is used to generate an answer text for the first question text based on all the reference answer text blocks and the preset large language model.
[0056] It should be noted that the retrieval enhancement generation methods based on a large language model in the aforementioned embodiments can all be implemented based on the retrieval enhancement generation device based on a large language model provided in this embodiment. Ordinary technical personnel in the relevant field can clearly understand that for the convenience and conciseness of description, the specific working process of the retrieval enhancement generation device based on a large language model described in this embodiment can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0057] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of modules is only a logical function division. There may be other division methods in actual implementation, such as multiple modules 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 devices or modules, which can be electrical, mechanical or other forms.
[0058] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0059] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.
[0060] If the integrated module is implemented in the form of a software function module 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, or the part that contributes to the prior art, 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 readable storage medium, including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned readable storage medium includes: U disk, mobile hard disk, ROM, RAM, disk or CD-ROM and other media that can store program codes.
[0061] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0062] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0063] The above is a description of the retrieval enhancement generation method based on a large language model and related products provided in this application. For technicians in this field, according to the ideas of the embodiments of this application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on this application.
Claims
1. A retrieval enhancement generation method based on a large language model, characterized in that: include: receiving a first question text, calling the preset large language model to identify a difficulty type of the first question text, and generating a second question text associated with the first question text based on the difficulty type; Performing vectorization processing on the first question text and the second question text to obtain a plurality of question text vectors; Calling a preset knowledge base, and querying the preset knowledge base for reference answer text blocks associated with each of the question text vectors; Generate a response text for the first question text based on all of the reference response text blocks and the preset large language model.
2. The search enhancement generation method according to claim 1, characterized in that: The second question text is a similar question text and / or a sub-question text of the first question text, and the step of generating the second question text associated with the first question text based on the difficulty type includes: When the first question text is a simple question text, generating a preset number of similar question texts as the second question text; When the first question text is a complex question text, a preset number of sub-question texts are generated as the second question text.
3. The search enhancement generation method according to claim 1, characterized in that: The step of searching the preset knowledge base for reference answer text blocks associated with each of the question text vectors includes: Calculating the similarity scores of each reference answer text block vector and each question text vector in the knowledge base respectively; Sort the reference answer text block vectors corresponding to each question text vector from high to low according to the similarity score; Obtain the first n reference answer text block vectors corresponding to each question text vector as the associated text block vector of the question text vector; wherein n≥1; The reference answer text block corresponding to each question text vector is determined based on the n associated text block vectors of each question text vector.
4. The search enhancement generation method according to claim 3, characterized in that: The text block vector includes a knowledge text block vector and the hypothetical question text block vector corresponding to the knowledge vector text block, and determining the reference answer text block corresponding to each question text vector according to the n associated text block vectors of each question text vector includes: Distinguishing the knowledge text block vector and the hypothetical question text block vector from among the n associated text block vectors; Using the knowledge text block vector corresponding to the hypothetical question text block vector among the n associated text block vectors as the reference answer text block; The knowledge text block vectors among the n associated text block vectors are all used as the reference reply text blocks.
5. The search enhancement generation method according to claim 1, characterized in that: The step of generating a response text for the first question text based on all the reference response text blocks and the preset large language model includes: De-duplicate and merge all the reference reply text blocks to obtain a target text block; The target text block is transmitted to the preset large language model to obtain a response text corresponding to the first question.
6. The search enhancement generation method according to claim 5, characterized in that: Said also includes: Identifying the intent information corresponding to the first question text; The target text block and the intention information are input into the preset large language model to obtain a reply text corresponding to the first question.
7. The search enhancement generation method according to claim 5 or 6, characterized in that: The method further comprises: Calculating the correlation between the target text block and the first question text, and judging whether the target text block is related to the first question text according to whether the correlation satisfies a correlation condition; If the correlation does not satisfy the correlation condition, a fixed answer is output; if the correlation satisfies the correlation condition, the target text block and the intention information are input into the preset large language model to obtain the answer text corresponding to the first question.
8. An intelligent question-answering system based on a large language model, characterized in that: include: A terminal device, used for inputting a first question text; The server deploys a preset knowledge base and a large language model; wherein the preset knowledge base is used to collect and store reference answer texts in the form of vectors; the large language model is used to respond to a first question text input by a user, and to process the first question text in combination with the preset knowledge base and according to the retrieval enhancement generation method based on the large language model as described in any one of claims 1 to 7 to obtain an answer text for the first question text.
9. An electronic device, characterized in that: The device comprises a memory and a processor, wherein: The processor is used to execute the computer program stored in the memory; When the processor executes the computer program, the steps in the retrieval enhancement generation method based on a large language model as claimed in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps in the retrieval enhancement generation method based on a large language model as claimed in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Knowledge base question and answer method and device, electronic equipment and storage medium
CN117290492A
Question and answer method and device, equipment and storage medium
CN118035415A
Knowledge retrieval enhancement-based large language model question and answer method and device
CN118113836A
Diversity-enhanced text retrieval enhancement generation method and system
CN118260406A
Cited By
Method and device for processing user questions and answers and storage medium
CN119357367A
Method, device and storage medium for processing user questions and answers
CN119357367B
Question query processing method and electronic equipment
CN120256587A
Airworthiness text quality determination method and device based on airworthiness certification platform
CN121597785A
