Adaptive retrieval enhanced large language model construction and question answering method and system, storage medium and program product
Patent Information
- Application Number
- CN202411303314.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2025-01-03
AI Technical Summary
Traditional large language models face problems such as high resource consumption, low Q&A efficiency and poor answer accuracy when dealing with complex Q&A. Especially when specific or real-time updates are required, external information cannot be effectively utilized, resulting in inaccurate answers or inability to answer. .
通过一种自适应检索增强的方法,利用创新的模型训练策略,自适应地决定是否利用信息检索来辅助问答,通过收集问答数据、判断初始答案与标准答案的一致性来构建训练数据,并通过微调训练生成特殊标记<RETRIEVAL>,以决定是否获取外部信息。
It achieves a balance between resource utilization and answer quality, reduces overall resource consumption, improves the efficiency and accuracy of the Q&A system, reduces unnecessary computing burden, and provides a more efficient and accurate Q&A experience.
Smart Images

Figure CN119248916A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to an adaptive retrieval enhanced large language model construction and question-answering method, system, storage medium and program product. Background Art
[0002] With the rapid development of artificial intelligence and natural language processing technology, large language models (LLMs) have become the core components for processing complex language tasks and providing intelligent interactions. These models are trained with massive data and can not only understand the context, but also generate high-quality texts. They have a wide range of applications, covering various fields from customer service automation to knowledge management systems.
[0003] In the field of question-answering technology, traditional LLMs rely on the model's own parameter memory to generate answers, that is, they only rely on the model's own capabilities to complete question-answering, which performs well when dealing with questions in routine or known fields. However, as users' expectations for model question-answering quality continue to increase, and application scenarios become increasingly complex, traditional LLMs face two major challenges: one is how to efficiently use computing resources to reduce unnecessary computing burdens while ensuring answer quality; the other is how to accurately answer within the model's knowledge boundaries, especially when dealing with questions that rely on external unencoded knowledge.
[0004] For example, when encountering information that requires specific, fine-grained, or real-time updates, the model may be limited by the lack of ability to access external information immediately, resulting in inaccurate answers or failure to answer. At this time, knowledge base retrieval is usually combined to achieve model question and answer of professional knowledge. Retrieval-Augmented Generation is a relatively mature large model question and answer method. This method combines the knowledge base with a large language model to achieve domain knowledge question and answer. However, this method still has the following disadvantages:
[0005] First, the problem of resource consumption and question-answering efficiency. In conventional retrieval-enhanced question-answering methods, relevant knowledge content will be retrieved from the database based on the user's question, and then the retrieved content will be filtered through some screening mechanisms or ranking models, and finally the large model will give an answer as part of the input of the large model. In this way, before the large language model can answer, it is necessary to go through steps such as retrieval and sorting. When the amount of knowledge base data is large, this step may have a delay of 0.5 to 1 second. On the one hand, such a pre-step will consume a certain amount of computing resources, and on the other hand, it will also affect the response time of the overall question-answering system.
[0006] Second, there is the problem of interference from searched content. Since the knowledge base is often a limited domain database, in real question-answering scenarios, users will ask all kinds of questions. Such a search step sometimes introduces some invalid information into the model. Although the retrieved content may be related to the user's question, it is not helpful in answering the question itself, and sometimes even interferes with the model's answer.
[0007] In summary, the existing large language model question-answering technology cannot achieve a balance between resource utilization and answer quality, and cannot solve the problems of high resource consumption, low question-answering efficiency, and poor answer accuracy. Summary of the invention
[0008] In view of the shortcomings of the prior art, the present invention provides a method for constructing a large language model, a question-answering method, a system, a storage medium, and a program product that can adaptively decide whether to use information retrieval enhancement to answer questions. The invention aims to enable the model to adaptively decide whether to directly answer user questions or to assist in question-answering by triggering external information retrieval through an innovative model training strategy. The invention aims to improve the adaptive ability of the model, to achieve a balance between resource utilization and answer quality, and to optimize the efficiency and accuracy of the model's answers through an intelligent decision-making mechanism.
[0009] In a first aspect, the present invention provides a method for constructing an adaptive retrieval enhanced large language model, comprising the following steps:
[0010] Collect question-answering data, including questions, model answers, and reference context;
[0011] Use a large language model to answer questions and get initial answers;
[0012] Determine whether the initial answer and the standard answer are consistent, and construct training data according to the determination result;
[0013] Based on the training data, the large language model is fine-tuned to obtain an adaptive retrieval enhanced large language model.
[0014] As a further improvement of the present invention, the collecting of question and answer data includes generating the question and answer data using a large language model.
[0015] As a further improvement of the present invention, the step of judging whether the initial answer and the standard answer are consistent and constructing training data according to the judgment result includes: when the initial answer and the standard answer are consistent, constructing first training data according to the question and the standard answer.
[0016] As a further improvement of the present invention, the format of the first training data is:<prompt,answer> , where the prompt is <Answer the question: Question, if you need help please answer<retrieval>To acquire additional knowledge. >, the answer is the standard answer.
[0017] As a further improvement of the present invention, the method of judging whether the initial answer and the standard answer are consistent and constructing training data according to the judgment result includes: when the initial answer and the standard answer are inconsistent, constructing second training data and third training data according to the question, the standard answer and the reference context.
[0018] As a further improvement of the present invention, the format of the second training data is:<prompt,answer> , where the prompt is <Answer the question: Question, if you need help please answer <retrieval>To obtain additional knowledge. >, the answer is <retrieval>;
[0019] The format of the third training data is:<prompt,answer> , where the prompt is <Answer the question: Question, please refer to the following content to give an answer: Reference context>, and the answer is the standard answer.
[0020] In a second aspect, the present invention provides a question answering method using an adaptive retrieval enhanced large language model, using the adaptive retrieval enhanced large language model described in the first aspect, comprising the following steps:
[0021] Input question;
[0022] Adaptive retrieval enhances the large language model to answer questions and determine whether additional knowledge is needed;
[0023] According to the judgment result, output answer as the final answer.
[0024] As a further improvement of the present invention, the adaptive retrieval enhances the large language model to answer questions and determines whether additional knowledge needs to be acquired, and the method includes:
[0025] Prompt for enhancing large language models based on adaptive retrieval: <Answer the question: Question, please answer if you need help <retrieval>To gain additional knowledge. >, get answer;
[0026] Determine whether the answer is <retrieval>, when the answer of the adaptive retrieval augmented large language model is not <retrieval>When , the adaptive retrieval enhanced large language model does not need to acquire additional knowledge;
[0027] When adaptive retrieval enhances the answer of a large language model, <retrieval>When , adaptive retrieval augments the large language model, additional knowledge needs to be acquired.
[0028] As a further improvement of the present invention, outputting answer as the final answer according to the judgment result includes:
[0029] When the adaptive retrieval enhanced large language model does not need to acquire additional knowledge, the answer of the adaptive retrieval enhanced large language model is directly used as the final answer;
[0030] When the adaptive retrieval enhanced large language model needs to obtain additional knowledge, the reference context is formed through the retrieval enhancement module, the question and the reference context are spliced, the adaptive retrieval enhanced large language model is used to answer, and the answer of the adaptive retrieval enhanced large language model is used as the final answer.
[0031] As a further improvement of the present invention, the reference context is formed by the retrieval enhancement module, the question and the reference context are spliced, and the adaptive retrieval enhancement large language model is used to answer, including:
[0032] According to the semantic information and keywords in the question, the knowledge information with the highest similarity to the question is retrieved from the database to form a reference context;
[0033] The question and reference context are spliced into the prompt of the adaptive retrieval enhanced large language model: <Answer the question: Question, please refer to the following content to give the answer: Reference context>, and the adaptive retrieval enhanced large language model gives the answer.
[0034] In a third aspect, the present invention provides a computer system comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the second aspect.
[0035] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the second aspect.
[0036] In a fifth aspect, the present invention provides a computer program product, comprising a computer program, which implements the steps of the method described in the second aspect when executed by a processor.
[0037] Compared with the prior art, the present invention has the following beneficial effects:
[0038] First, fine-tuning training strategy and training set construction method: This invention describes an innovative training data set construction process, which uses the triple information of <question, answer, reference context> to design training samples based on the model's initial ability to answer questions. This training sample construction method enables the model to more accurately judge when to directly answer questions and when to request retrieval enhancement to obtain additional information after fine-tuning training.
[0039] Second, special marks <retrieval>Generation: By fine-tuning the trained large language model, it is possible to generate special tags <retrieval>This special tag will serve as a signal for the model to request enhanced external information retrieval, allowing the large model to better express its demand for external information.
[0040] Third, adaptive retrieval-enhanced question-answering mechanism: By designing a set of adaptive retrieval-enhanced question-answering methods, the large language model can adaptively decide whether to trigger external information retrieval to assist in answering based on the content of the question. Such a question-answering method can better balance resource utilization and answer quality, effectively reduce overall resource consumption, and improve the efficiency and accuracy of the question-answering system. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 A flow chart of a method for constructing an adaptive retrieval enhanced large language model disclosed in the present invention;
[0042] Figure 2 This is a flow chart of a question-answering method using an adaptive retrieval enhanced large language model disclosed in the present invention. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the present invention will combine the accompanying drawings to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments, wherein steps S11, S12... in the embodiments described in the present invention do not limit the only execution steps of the present invention; the various models described in the present invention are not the only limiting methods of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0044] In the present invention, computer devices / equipment / systems refer to related entities applied to computers, such as hardware, a combination of hardware and software, software or software in execution, etc. In detail, for example, software includes but is not limited to a process running on a processor, a processor, an object, executable software, an execution thread, a program and / or a computer. In addition, an application or script program running on a server, a server can also be software. One or more software can be in an execution process and / or thread, and the software can be localized on one computer and / or distributed between two or more computers, and can be run by various computer-readable media.
[0045] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application may be combined with each other.
[0046] The principle of the present invention is that the method for constructing a large language model for adaptive retrieval enhancement, the question-answering method, the system, the storage medium and the program product proposed by the present invention can train the model to enable the model to learn when to use additional information retrieval modules to assist in answering questions. The core of the present invention is to train the large model to generate a special tag <retrieval>, to instruct the model to obtain additional information when it is uncertain about the answer to a question; and when the model can directly answer the user's question, it directly generates the answer, thereby building a smarter and more resource-saving question-answering system.
[0047] First, we use a question-answering dataset in the question-answering field of interest to generate model training data through an innovative strategy to obtain a training dataset. Then we fine-tune the large model (LLM) so that the model can learn when to use additional information retrieval modules.
[0048] When receiving a user's question, the trained large model can dynamically determine the most appropriate answer strategy based on the specific circumstances of the question, that is, by generating a special tag or not. <retrieval>That is, when the model is confident that it can answer directly, it uses the model's internal knowledge; otherwise, it triggers the retrieval enhancement module to assist the model in answering.
[0049] In a first aspect, an embodiment of the present invention provides a method for constructing an adaptive retrieval enhanced large language model, such as Figure 1 As shown, the specific process can be as follows:
[0050] S11: Collect question-answering data, including questions, standard answers, and reference context;
[0051] Preferably, said collecting question-answering data comprises generating question-answering data using a large language model.
[0052] The present invention collects a large amount of question-answering data for the question-answering field of interest. The collected data needs to include the following content: question, answer, and reference context. A powerful large language model can be used to generate training data. For example, GPT4 can be used to generate questions and answers for a large amount of text or paragraphs, thereby obtaining triple data such as <question, answer, reference context>.
[0053] In one embodiment of the present invention, GPT4 is used to collect question-answering data.<Q,A,C> to replace questions, model answers and reference context.
[0054] S12: Use the large language model to answer the question and get the initial answer;
[0055] In one embodiment of the present invention, GPT4 is used to collect question-answering data.<Q,A,C> to replace the question, model answer and reference context.<Q,A,C> The triples of let the large language model (LLM) try to answer question Q without relying on external knowledge, and directly let LLM answer question Q and get the initial answer ans_1.
[0056] S13: Determine whether the initial answer is consistent with the standard answer, and construct training data according to the determination result;
[0057] In one embodiment of the present invention, the ability of GPT4 can be used to assist in determining whether the initial answer and the standard answer are consistent.
[0058] Preferably, the determining whether the initial answer and the standard answer are consistent and constructing training data according to the determination result comprises: when the initial answer and the standard answer are consistent, constructing first training data according to the question and the standard answer.
[0059] Preferably, the format of the first training data is:<prompt,answer> , where the prompt is <Answer the question: Question, if you need help please answer <retrieval>To acquire additional knowledge. >, the answer is the standard answer.
[0060] In one embodiment of the present invention, GPT4 is used to collect question-answering data.<Q,A,C> to replace the question, model answer and reference context.<Q,A,C> The LLM tries to answer question Q without relying on external knowledge. The initial answer ans_1 is obtained by directly answering question Q. Next, we determine whether the initial answer ans_1 given by the LLM is consistent with the standard answer A. If the initial answer ans_1 given by the LLM is consistent with the standard answer A, it means that the LLM can answer the question with the help of its own knowledge. Therefore, we can directly construct a training data based on question Q and standard answer A. The prompt is <Answer question: Q. If you need help, please answer <retrieval>To obtain additional knowledge. >, the answer is A. Constructing training data in this way enables the large language model to answer directly when it knows the correct answer after training, without generating <retrieval>This special character.
[0061] Preferably, the determining whether the initial answer and the standard answer are consistent and constructing training data according to the determination result includes: when the initial answer and the standard answer are inconsistent, constructing second training data and third training data according to the question, the standard answer and the reference context.
[0062] Preferably, the format of the second training data is:<prompt,answer> , where the prompt is <Answer the question: Question, if you need help please answer <retrieval>To obtain additional knowledge. >, the answer is <retrieval>;
[0063] The format of the third training data is:<prompt,answer> , where the prompt is <Answer the question: Question, please refer to the following content to give an answer: Reference context>, and the answer is the standard answer.
[0064] In another embodiment of the present invention, GPT4 is used to collect question-answering data.<Q,A,C> to replace the question, model answer and reference context.<Q,A,C> The large language model (LLM) tries to answer question Q without relying on external knowledge. The initial answer ans_1 is obtained by directly letting LLM answer question Q. Next, it is determined whether the initial answer ans_1 answered by the large language model is consistent with the standard answer A. When the initial answer ans_1 answered by the large language model is inconsistent with the standard answer A, it means that the large model cannot answer the question with the help of its own knowledge. It may be that the model answers incorrectly or the model indicates that it does not know the answer. In this case, the large language model can answer with the help of externally retrieved knowledge. Here, two fine-tuning training data are constructed in sequence, namely the second training data and the third training data.
[0065] The prompt for the second training data is <Answer the question: Q. Please answer if you need help <retrieval>To gain additional knowledge. >, the answer is <retrieval>This training data allows the large language model to answer a special character when it is not sure about the answer. <retrieval>To express that you are not clear or sure about the answer to the question.
[0066] The third training data is to give the large language model additional information reference, so that the model can directly give the answer to the question. The training data format is: prompt is <Answer question: Q, please refer to the following content to give the answer: C>, answer is A. This training data means that the large model can give a reasonable answer when given additional information reference.
[0067] S14: Based on the training data, fine-tune the large language model to obtain an adaptive retrieval enhanced large language model.
[0068] Fine-tuning training does not interfere with the capabilities of the large language model itself, but only enables the large language model to give answers when it is uncertain. <retrieval>Such a special character. The large language model with adaptive retrieval enhancement obtained through training can better support the question-answering system in this method.
[0069] In a second aspect, the present invention provides a question-answering method using an adaptive retrieval-enhanced large language model. The question-answering method uses the adaptive retrieval-enhanced large language model described in the first aspect and can determine whether additional information needs to be retrieved based on the output question content of the model, thereby determining how to obtain the final answer. Figure 2 As shown, the specific process can be as follows:
[0070] S21: Input question;
[0071] S22: Adaptive retrieval enhances the large language model to answer questions and determine whether additional knowledge is needed;
[0072] Preferably, the adaptive retrieval enhances the large language model to answer questions and determines whether additional knowledge needs to be acquired, and the method includes:
[0073] Prompt for enhancing large language models based on adaptive retrieval: <Answer the question: Question, please answer if you need help <retrieval>To gain additional knowledge. >, get answer;
[0074] Determine whether the answer is <retrieval>, when the answer of the adaptive retrieval augmented large language model is not <retrieval>When , the adaptive retrieval enhanced large language model does not need to acquire additional knowledge;
[0075] In one embodiment of the present invention, a user question Q is input, and the adaptive retrieval enhanced large language model is first allowed to directly answer the question according to the prompt of the adaptive retrieval enhanced large language model: <Answer question: Q, please answer if you need help <retrieval>To obtain additional knowledge. >, get the answer, capture the first few characters of the answer, and the model output is not <retrieval>, indicating that adaptive retrieval to enhance the large language model does not require the acquisition of additional knowledge.
[0076] Determine whether the answer is <retrieval>, when the answer of adaptive retrieval augmented with large language model is <retrieval>When , adaptive retrieval augments the large language model, additional knowledge needs to be acquired.
[0077] In another embodiment of the present invention, a user question Q is input, and the adaptive retrieval enhanced large language model is first allowed to directly answer the question according to the prompt of the adaptive retrieval enhanced large language model: <Answer question: Question, please answer if you need help <retrieval>To obtain additional knowledge. >, get the answer, capture the first few characters of the answer, and the model output is <retrieval>, indicating that adaptive retrieval to enhance large language models requires the acquisition of additional knowledge.
[0078] S23: Based on the judgment result, output answer as the final answer.
[0079] Preferably, outputting answer as the final answer according to the judgment result includes:
[0080] When the adaptive retrieval enhanced large language model does not need to acquire additional knowledge, the answer of the adaptive retrieval enhanced large language model is directly used as the final answer;
[0081] In one embodiment of the present invention, a user question Q is input, and the adaptive retrieval enhanced large language model is first allowed to directly answer the question according to the prompt of the adaptive retrieval enhanced large language model: <Answer question: Q, please answer if you need help <retrieval>To obtain additional knowledge. >, get the answer, capture the first few characters of the answer, and the model output is not <retrieval>, indicating that the adaptive retrieval enhanced large language model does not need to obtain additional knowledge, allowing the model to continue outputting and directly obtain the complete answer to the question, taking answer as the final answer.
[0082] When the adaptive retrieval enhanced large language model needs to obtain additional knowledge, the reference context is formed through the retrieval enhancement module, the question and the reference context are spliced, the adaptive retrieval enhanced large language model is used to answer, and the answer of the adaptive retrieval enhanced large language model is used as the final answer.
[0083] Preferably, forming a reference context through a retrieval enhancement module, concatenating the question and the reference context, and answering using an adaptive retrieval enhancement large language model include:
[0084] According to the semantic information and keywords in the question, the knowledge information with the highest similarity to the question is retrieved from the database to form a reference context;
[0085] The question and reference context are spliced into the prompt of the adaptive retrieval enhanced large language model: <Answer the question: Question, please refer to the following content to give the answer: Reference context>, and the adaptive retrieval enhanced large language model gives the answer.
[0086] In another embodiment of the present invention, a user question Q is input, and the adaptive retrieval enhanced large language model is first allowed to directly answer the question according to the prompt of the adaptive retrieval enhanced large language model: <Answer question: Q, please answer if you need help <retrieval>To obtain additional knowledge. >, get the answer, capture the first few characters of the answer, and the model output is <retrieval>, indicating that the adaptive retrieval enhanced large language model needs to acquire additional knowledge. At this time, the retrieval enhancement module is triggered. The retrieval enhancement module retrieves and recalls some knowledge information with the highest similarity to the user's question from the database based on the semantic information in the user's question and some keyword content, forming a reference context C. After the retrieval is completed, the large model is called again, and the question Q and the reference context C are spliced in the prompt of the adaptive retrieval enhanced large language model: <Answer the question: Q, please refer to the following content to give the answer: C>, so that the adaptive retrieval enhanced large language model can give the answer. At this time, the output of the large model is the final answer to the question.
[0087] The adaptive retrieval enhanced large model question answering method provided by the present invention enables the question answering system to realize an intelligent decision-making process. When facing the user's question, the system allows the model to try to answer it autonomously. <retrieval>When a signal is received, the search enhancement module is activated to obtain additional knowledge from the database, and then the knowledge is used as the input of the model to allow the model to give more accurate answers. This question-answering method can reduce unnecessary computing burden to improve the average response speed and reduce overall resource consumption, while optimizing resource allocation and providing users with a more efficient and accurate question-answering experience.
[0088] In a third aspect, the present invention provides a computer system comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the second aspect.
[0089] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the second aspect.
[0090] In a fifth aspect, the present invention provides a computer program product, comprising a computer program, which implements the steps of the method described in the second aspect when executed by a processor.
[0091] The present invention proposes a method for constructing a large language model, a question-answering method, a system, a storage medium, and a program product that can adaptively decide whether to use information retrieval enhancement to answer questions. Through an innovative model training strategy, the model can adaptively decide whether to directly answer user questions or to assist in question-answering by triggering external information retrieval. The question-answering method improves the adaptive ability of the model, can achieve a balance between resource utilization and answer quality, and optimizes the efficiency and accuracy of the model's answers through an intelligent decision-making mechanism.< / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval> < / retrieval>
Claims
1. A method for constructing an adaptive retrieval enhanced large language model, characterized in that: The following steps are involved: Collect question-answering data, including questions, model answers, and reference context; Use a large language model to answer questions and get initial answers; Determine whether the initial answer and the standard answer are consistent, and construct training data according to the determination result; Based on the training data, the large language model is fine-tuned to obtain an adaptive retrieval enhanced large language model.
2. The method for constructing an adaptive retrieval enhanced large language model according to claim 1, characterized in that: The collecting of question-answering data includes generating question-answering data using a large language model.
3. The method for constructing an adaptive retrieval enhanced large language model according to claim 1, characterized in that: The determining whether the initial answer is consistent with the standard answer and constructing training data according to the determination result includes: when the initial answer is consistent with the standard answer, constructing first training data according to the question and the standard answer.
4. The method for constructing an adaptive retrieval enhanced large language model according to claim 3, characterized in that: The format of the first training data is:<prompt,answer> , where the prompt is <Answer the question: Question, if you need help please answer <retrieval> To acquire additional knowledge. >, the answer is the standard answer.< / retrieval> 5. The method for constructing an adaptive retrieval enhanced large language model according to claim 1, characterized in that: The determining whether the initial answer is consistent with the standard answer and constructing training data according to the determination result includes: when the initial answer is inconsistent with the standard answer, constructing second training data and third training data according to the question, the standard answer and the reference context.
6. The method for constructing an adaptive retrieval enhanced large language model according to claim 5, characterized in that: The format of the second training data is:<prompt,answer> , where the prompt is <Answer the question: Question, if you need help please answer <retrieval>To obtain additional knowledge. >, the answer is <retrieval> ;< / retrieval> < / retrieval> The format of the third training data is:<prompt,answer> , where the prompt is <Answer the question: Question, please refer to the following content to give an answer: Reference context>, and the answer is the standard answer.
7. A question answering method for adaptive retrieval enhancement of a large language model, characterized in that: Using the adaptive retrieval enhanced large language model as described in any one of claims 1 to 6 comprises the following steps: Input question; Adaptive retrieval enhances the large language model to answer questions and determine whether additional knowledge is needed; According to the judgment result, output answer as the final answer.
8. The question answering method of adaptive retrieval enhanced large language model according to claim 7, characterized in that: The adaptive retrieval enhances the large language model to answer questions and determine whether additional knowledge needs to be acquired, and the method includes: Prompt for enhancing large language models based on adaptive retrieval: <Answer the question: Question, please answer if you need help <retrieval> To gain additional knowledge. >, get answer;< / retrieval> Determine whether the answer is <retrieval>, when the answer of the adaptive retrieval augmented large language model is not <retrieval> When , the adaptive retrieval enhanced large language model does not need to acquire additional knowledge;< / retrieval> < / retrieval> When adaptive retrieval enhances the answer of a large language model, <retrieval> When , adaptive retrieval augments the large language model, additional knowledge needs to be acquired.< / retrieval> 9. The question answering method of adaptive retrieval enhanced large language model according to claim 7, characterized in that: According to the judgment result, the answer is output as the final answer, including: When the adaptive retrieval enhanced large language model does not need to acquire additional knowledge, the answer of the adaptive retrieval enhanced large language model is directly used as the final answer; When the adaptive retrieval enhanced large language model needs to obtain additional knowledge, the reference context is formed through the retrieval enhancement module, the question and the reference context are spliced, the adaptive retrieval enhanced large language model is used to answer, and the answer of the adaptive retrieval enhanced large language model is used as the final answer.
10. The question answering method of adaptive retrieval enhanced large language model according to claim 9, characterized in that: The reference context is formed by the retrieval enhancement module, the question and the reference context are spliced, and the adaptive retrieval is used to enhance the large language model to answer, including: According to the semantic information and keywords in the question, the knowledge information with the highest similarity to the question is retrieved from the database to form a reference context; The question and reference context are spliced into the prompt of the adaptive retrieval enhanced large language model: <Answer the question: Question, please refer to the following content to give the answer: Reference context>, and the adaptive retrieval enhanced large language model gives the answer.
11. A computer system comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 7 to 10.
12. 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 of the method according to any one of claims 7 to 10 are implemented.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 7 to 10 are implemented.
Citation Information
Cited By
Error positioning method for retrieval enhancement generation system, electronic equipment and medium
CN119474276A
Question and answer generation method and system based on big language model preference alignment
CN119938863A
LLM-RAG sample construction method and device, and storage medium
CN120705581A
A medical question and answer generation method and system based on adaptive retrieval enhancement
CN122817429A
