A method for reasoning and generating knowledge-intensive problems based on LLM
By designing knowledge-intensive problem reasoning and generation methods on LLM, using thinking chains and search enhancement mechanisms, the limitations of traditional information retrieval systems when dealing with complex problems and the lack of knowledge and 'illusion' of LLM in open-field problems are solved. The phenomenon has achieved higher logical accuracy and reliability.
Patent Information
- Application Number
- CN202411272971.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-09-12
AI Technical Summary
Traditional search engines and information retrieval systems are limited in reasoning and solving capabilities when dealing with problems with rich semantic context and high complexity, and large language models (LLMs) may encounter insufficient knowledge and illusions when solving open-field problems. 'The problem of phenomenon.
Design a knowledge-intensive problem reasoning and generation method based on LLM, realize problem decomposition and gradual reasoning through the thinking chain structure, and combine the search enhancement mechanism to dynamically obtain the required information from external knowledge sources to optimize the reasoning process. This method adopts a two-layer searcher and a multi-factor verification mechanism to improve the authenticity and reliability of the search information, and uses the interactive verification and correction of the intermediate reasoning steps of external knowledge-driven thinking chains.
It improves the logical accuracy and reliability of content generated by large language models, overcomes the problems of insufficient knowledge and miscommunication, and enhances the flexibility and accuracy of the thinking chain.
Smart Images

Figure CN118798367B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of natural language processing and retrieval enhancement generation, and specifically relates to a knowledge-intensive problem reasoning and generation method based on LLM. Background Art
[0002] In today's era of information explosion, people are faced with the challenge of processing and utilizing massive amounts of knowledge. In particular, traditional search engines and information retrieval systems often face many limitations when dealing with knowledge-intensive problems. These systems usually rely on keyword matching and statistical methods, but their reasoning and solving capabilities are significantly limited when dealing with problems with rich semantic context and high complexity.
[0003] In recent years, with the rapid development of artificial intelligence and natural language processing (NLP) technology, large language models (LLMs) trained on massive corpora have performed well in various NLP tasks. LLMs are able to answer complex questions by generating step-by-step natural language reasoning steps under appropriate prompts. However, for many open-domain problems, LLMs still encounter some problems in the process of solving the problems: first, the model parameters do not always contain all the required knowledge, and second, LLMs may experience "hallucination" phenomena. Therefore, it becomes very necessary to retrieve additional information from external sources (i.e., retrieval enhancement), which can greatly improve the reliability and accuracy of the content generated by the model.
[0004] A simple way to combine LLM and retrieval enhancement generation is to perform a one-time retrieval from an external knowledge base based on the question, and then directly input a large amount of retrieval information into the LLM, converting the question-answering task into a reading comprehension task. For knowledge-intensive questions, although this method can successfully enhance many relevant fact-based knowledge for LLM, the large amount of retrieval information may not only make it difficult for LLM to fully understand, but the irrelevance of the retrieval information to the question may also cause misunderstandings of LLM. For such questions, humans usually break down complex questions into multiple simple questions, and then retrieve and answer them step by step. Therefore, the interaction between the retrieval and reasoning steps is particularly important. However, recent studies either enhance the ability of the retriever to retrieve external knowledge or improve the ability of LLM to extract answers from the retrieval information. Few studies have utilized the understanding and reasoning capabilities of LLM and combined external knowledge to improve the intermediate reasoning steps to promote the answering effect of LLM.
[0005] Therefore, it is necessary to design a knowledge-intensive problem reasoning and generation method based on LLM, which can verify and modify the intermediate reasoning steps of LLM by interacting with external knowledge, so as to overcome the "hallucination" and error propagation and solve the above problems. Summary of the invention
[0006] To solve the above problems, the present invention discloses a method for reasoning and generating knowledge-intensive problems based on LLM, in order to meet the demand for difficult to retrieve answers to knowledge-intensive problems. This method relies on the powerful reasoning ability of the large language model, realizes problem decomposition and step-by-step reasoning through the thought chain structure, and combines the retrieval enhancement mechanism to dynamically obtain the required information from the external knowledge source to optimize the reasoning process; this method greatly improves the authenticity and reliability of the retrieved information through the double-layer retriever of the knowledge base retrieval module and the multiple verifications of the retrieval evaluation module; this method not only overcomes the limitations of traditional methods caused by insufficient knowledge or error propagation, but also improves the logical accuracy and reliability of the content generated by the large language model by driving the thought chain with external knowledge, interactive verification and correction of the intermediate reasoning steps.
[0007] To achieve the above object, the technical solution of the present invention is as follows:
[0008] A method for reasoning and generating knowledge-intensive problems based on LLM, comprising the following steps:
[0009] S1: For user questions to be answered , processed by the knowledge assessment module to determine the problem Can the problem be solved using the internal knowledge of the large language model? If so, the large language model will directly generate the answer. Otherwise, the problem will be solved by Incoming knowledge base retrieval module and CoT-LLM reasoning module;
[0010] S2: Knowledge base retrieval module targets questions Retrieve relevant factual information, CoT-LLM reasoning module combines questions and retrieved information to generate a structured dynamic reasoning chain ;
[0011] S3: The knowledge base retrieval module uses a two-layer retriever to target sub-questions in the reasoning chain. Search the knowledge base to obtain information that is helpful in answering sub-questions relevant information;
[0012] S4: The retrieval evaluation module re-evaluates the retrieved information. If the retrieved information is consistent with the sub-question If the matching degree is higher than the threshold, it will enter the generation module, otherwise it will skip the sub-question Modification, return to the knowledge base search stage, search relevant information;
[0013] S5: Generate module based on the retrieved relevant information and sub-questions , generate candidate answers ;
[0014] S6: The verification module selects a more appropriate answer from the original answer and the candidate answer as an improvement to the CoT reasoning chain. If a sub-chain in the reasoning chain is modified, then enter the CoT-LLM reasoning module to adjust the subsequent sub-chains accordingly based on this modification, obtain a new reasoning chain, and then process the next sub-question in the current reasoning chain. ;
[0015] S7: Loop and repeat steps S2 - S6 until the CoT reasoning chain is completed. Then, determine whether the final answer can be obtained through the <final answer>< / final answer> tag. If this tag exists, output the answer in the tag; otherwise, it means the question cannot be answered.
[0016] Furthermore, the specific method for constructing the knowledge evaluation module in S1 is as follows:
[0017] (1) Collect Q&A pair data D that conforms to the characteristics of multi-hop questions (i.e., questions that require two or more steps of reasoning to complete the answer). Among them, D contains questions and their corresponding correct answers for multiple Q&A pairs;
[0018] (2) Construct a Q&A pair data set for training the knowledge evaluation model ; specifically, first extract the questions in D and input them to the large language model LLM. Through few-shot prompting and in-context learning, enable the model LLM to generate answers for each question . At this time, the generated answers are completely dependent on the internal knowledge of the model. Then, according to the comparison result with the correct answer , divide the questions into two groups. If is the same as , then these questions belong to , that is, questions that the model can solve by itself; otherwise, they belong to , that is, questions that the model cannot solve by itself. Finally, form the final training data set . Among them, for the answer is: know, and for the answer is: don't know;
[0019] (3) Use the standard conditional language modeling objective to train the large language model LLM on the data set to obtain a knowledge evaluation model for judging whether a question can be solved by the internal knowledge of the model.
[0020] Furthermore, the specific method for constructing the knowledge base retrieval module of S2 is as follows:
[0021] (1) Use bge-large-zh as a dense retriever to capture deeper semantic information of text paragraphs to retrieve relevant text. Specifically, dense vectors are used to represent text, and the similarity scores between vectors are calculated using cosine similarity, which is calculated as follows:
[0022] ;
[0023] in is the vectorized representation of the query statement. is the vectorized representation of the document;
[0024] (2) Use BM25 as a sparse retriever to capture vocabulary information in text paragraphs. Specifically, relevant text is retrieved by calculating the similarity score between the document and the query condition. The calculation formula is as follows:
[0025] ;
[0026] in, Indicates the problem, Represents a document, Represents the i-th word in the query statement, is the number of words in the query, is the inverse document frequency, is the number of occurrences of the i-th word in the document, and To adjust the parameters, is the length of the document, is the average length of documents in the document collection;
[0027] (3) In order to consider both vocabulary and semantic information, a hybrid method is used to combine the sparse retriever and the dense retriever, that is, the implementation of a two-layer retriever. The combined similarity score calculation formula is as follows:
[0028] ;
[0029] in, and It is to balance the weights of the two retrievers and adjust them according to actual needs and experimental results;
[0030] Based on the above combined similarity scores, the top-3 text fragments are selected as the retrieved relevant texts, thereby obtaining a knowledge base retrieval module. Compared with a retriever that only relies on vocabulary or semantic information, the content retrieved by the double-layer retriever will be more closely matched with the user's question.
[0031] Furthermore, the specific method for constructing the CoT-LLM inference module in S2 is as follows:
[0032] (1) Construct a CoT demonstration set for in-context learning of the large language model: Specifically, first, manually write several accurate CoT demonstrations as the benchmark set, and use these demonstrations as the starting point for constructing the complete set; then, use the multi-hop questions collected in S1 as the training set; then, use an iterative algorithm to gradually expand the benchmark set until the construction of the complete CoT set is finally completed. Specifically, in each iteration, select the demonstration with the highest cosine similarity to the question in the training set from the benchmark set as the context prompt, and use ChatGPT to generate a structured CoT reasoning chain, and append the question and the generated reasoning chain to the benchmark set until each question in the training set has completed the iteration; finally, the complete CoT set is presented in the format of <Q, CoT reasoning chain>;
[0033] (2) For each question proposed by the user , select the demonstration with the highest cosine similarity to the question from the above-mentioned completed CoT complete set (the role of the demonstration is to help the large language model LLM understand how to generate a suitable CoT reasoning chain); the large language model LLM executes reasoning and generates a reasoning chain according to the complete instruction combining the question , the demonstration, and the retrieved information.
[0034] Furthermore, the specific method for constructing the retrieval and evaluation module in S4 is as follows:
[0035] (1) Select bge-raranker-large as the base model for the retrieval and evaluation module, which has good text matching and evaluation capabilities;
[0036] (2) Set the matching degree threshold threshold: used to determine whether the retrieved information meets the requirements, ensuring that only high-quality matching results are selected. This threshold can be optimized and adjusted through experiments and verification to meet the needs of specific application scenarios;
[0037] (3) Preprocessing of the input information: Standardize the retrieved information, including preprocessing steps such as removing redundant spaces and punctuation mark processing, to ensure the consistency of the input information format;
[0038] (4) Calculation of the matching degree score: Input the preprocessed retrieved information into the bge-reranker-large model to calculate the matching degree score of each piece of information;
[0039] (5) Screening of retrieved information: The retrieved information is screened according to the matching score. Only the retrieved information with a score higher than the threshold will be selected as the reference document for modifying the CoT sub-chain. If the matching scores of all the retrieved information are lower than the threshold, the modification of the current sub-chain will be skipped.
[0040] Further, the specific method for constructing the generation module of S5 is as follows:
[0041] (1) Construct a training dataset. In the training data, each data point contains a question, a set of reference documents, and an answer. Among them, the answer consists of two parts: one is the cited document (marked with the <citation>< / citation> tag), and the other is the question answer (marked with the <answer>< / answer> tag), and there needs to be a certain reasoning process between these two parts (i.e., the explanation for obtaining the answer based on the cited document); the reference documents are divided into two categories, namely "relevant documents" (documents containing the question answer) and "distracting documents" (documents not containing the question answer); in the entire dataset, of the data contains both "relevant documents" and "distracting documents", while of the data only contains "distracting documents";
[0042] (2) Use the method of supervised fine-tuning to train the large language model LLM on the training dataset. The model is trained to answer questions in the presence of distracting documents, enabling it to ignore the retrieved documents that are not helpful for answering the given question, which helps to improve the robustness of the model to inaccurate retrieval results during generation, and finally obtain a generation model that can accurately answer relevant questions based on the retrieved information.
[0043] Further, the specific method for constructing the verification module of S6 is as follows:
[0044] Construct a validator through prompt engineering. During the reasoning process, take the original sub-answer generated by the CoT-LLM module and the candidate sub-answer generated by the generation module as inputs, and then, through the prompt instruction, guide the validator to select one of the two answers as the preferred answer. If neither of the two answers is selected, it is determined that the correct answer cannot be obtained.
[0045] The beneficial effects of the present invention are:
[0046] (1) The CoT-LLM reasoning module selects appropriate demonstrations from the complete set of CoTs as contextual learning examples for LLM. This method enables LLM to better understand the task and generate more accurate reasoning chains. By interweaving retrieval with the chain of thought (CoT), the present invention realizes a two-way interaction between retrieval and reasoning. Even if unsolvable problems are encountered during the reasoning process, the retrieval results can be used to dynamically improve the reasoning trajectory in the chain of thought, thereby improving the chain of thought and enhancing its flexibility and accuracy.
[0047] (2) The knowledge base retrieval module adopts a two-layer retriever, which takes into account the lexical information and deeper semantic information of the text paragraph at the same time, so as to search for sub-questions in the reasoning chain and retrieve information that is highly relevant to the question; on this basis, the retrieval information is further evaluated and matched through the retrieval evaluation module to ensure that only high-quality retrieval information is used to improve the thinking chain. At the same time, skipping the modification of the sub-chain according to the matching degree can also improve the reasoning efficiency of the entire framework to a certain extent; the generation module trains the model through supervised fine-tuning so that the generation model acquires the ability to distinguish interference information, which helps to improve the robustness of the model to inaccurate retrieval results during generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 This is an overall framework diagram of a knowledge-intensive problem reasoning and generation method based on LLM.
[0049] Figure 2 The core flow chart for dynamically improving the CoT reasoning chain. DETAILED DESCRIPTION
[0050] The present invention will be further explained below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the following specific embodiments are only used to illustrate the present invention and are not used to limit the scope of the present invention.
[0051] like Figure 1 As shown, the present invention proposes a knowledge-intensive problem reasoning and generation method based on LLM, which includes the following steps:
[0052] S1: For user questions to be answered , processed by the knowledge assessment module to determine the problem Can the problem be solved using the internal knowledge of the large language model? If so, the large language model will directly generate the answer. Otherwise, the problem will be solved by Incoming knowledge base retrieval module and CoT-LLM reasoning module;
[0053] Specifically, building a knowledge assessment module can be divided into the following steps:
[0054] (1) Collect question-answer pairs D that meet the characteristics of multi-hop questions (i.e., questions that require two or more steps of reasoning to complete the answer), where D contains the question and its corresponding correct answer Multiple question-answer pairs;
[0055] (2) Constructing a question-answer pair dataset for training the knowledge evaluation model ; Specifically, first extract the questions in D The input is given to the large language model LLM, which can generate answers for each question through few sample prompts and context learning. , the answer generated at this time is completely dependent on the internal knowledge of the model; then, according to With the correct answer The comparison results will be Divided into two groups, if and The same, then these questions belong to , that is, problems that the model can solve by itself, otherwise it belongs to , that is, problems that the model cannot solve by itself; finally, the final training data set is formed , among which, for The answers are: Yes, The answers are: I don’t know;
[0056] (3) Using the standard conditional language modeling objective on the dataset The large language model LLM is trained to obtain a knowledge evaluation model that is used to determine whether a problem can be solved by the internal knowledge of the model.
[0057] S2: Knowledge base retrieval module targets questions Retrieve relevant factual information, CoT-LLM reasoning module combines questions and retrieved information to generate a structured dynamic reasoning chain ;
[0058] Specifically, building a knowledge base retrieval module can be divided into the following steps:
[0059] (1) Use bge-large-zh as a dense retriever to capture deeper semantic information of text paragraphs to retrieve relevant text. Specifically, dense vectors are used to represent text, and the similarity scores between vectors are calculated using cosine similarity, which is calculated as follows:
[0060] ;
[0061] in is the vectorized representation of the query statement. is the vectorized representation of the document;
[0062] (2) Use BM25 as a sparse retriever to capture vocabulary information in text paragraphs. Specifically, relevant text is retrieved by calculating the similarity score between the document and the query condition. The calculation formula is as follows:
[0063] ;
[0064] in, Indicates the problem, Represents a document, Represents the i-th word in the query statement, is the number of words in the query, is the inverse document frequency, is the number of occurrences of the i-th word in the document, and To adjust the parameters, is the length of the document, is the average length of documents in the document collection;
[0065] (3) In order to consider both vocabulary and semantic information, a hybrid method is used to combine the sparse retriever and the dense retriever, that is, the implementation of a two-layer retriever. The combined similarity score calculation formula is as follows:
[0066] ;
[0067] in, and It is to balance the weights of the two retrievers and adjust them according to actual needs and experimental results;
[0068] Based on the above combined similarity scores, the top-3 text fragments are selected as the retrieved relevant texts, thereby obtaining a knowledge base retrieval module. Compared with a retriever that only relies on vocabulary or semantic information, the content retrieved by the double-layer retriever will be more closely matched with the user's question.
[0069] Building the CoT-LLM reasoning module can be divided into the following steps:
[0070] (1)Construct a CoT demonstration set for context learning of large language models. Specifically, first, manually write several accurate CoT demonstrations as a benchmark set, and use these demonstrations as the starting point for constructing the complete set; then, use the multi-hop questions collected in S1 as the training set; then, use an iterative algorithm to gradually expand the benchmark set and finally complete the construction of the CoT complete set. Specifically, in each iteration, select the demonstration with the highest cosine similarity to the question in the training set from the benchmark set as the context prompt, and use ChatGPT to generate a structured CoT reasoning chain, and append the question and the generated reasoning chain to the benchmark set until each question in the training set has completed the iteration; finally, the CoT complete set is presented in the format of <Q, CoT reasoning chain>;
[0071] (2)For each question proposed by the user , filter out the demonstration with the highest cosine similarity to the question from the above-mentioned completed CoT complete set (the role of the demonstration is to help the large language model LLM understand how to generate a suitable CoT reasoning chain); the large language model LLM performs reasoning and generates a reasoning chain according to the complete instruction combining the question , the demonstration and the retrieved information. An example of the complete instruction is as follows:
[0072] Complete command example: <Task>Please refer to the "Demonstration" and combine it with the "Reference Document", and use the alternating "Sub-question" and "Sub-answer" steps to think about how to answer the "Original Question". Then, based on the thinking, obtain the "Final Answer". Among them, "Sub-question": Propose a sub-question with a unique answer to help solve the original question; "Sub-answer": The answer to the sub-question.< / Task><Demonstration><Original Question>…< / Original Question><Sub-question1>…<Sub-question1><Sub-answer1>…<Sub-answer1><Sub-question2>…<Sub-question2><Sub-answer2>…<Sub-answer2><Final Answer>…< / Final Answer>< / Demonstration><Reference Document>…< / Reference Document><Original Question>Who is the author of the novel "Life and Death Are Wearing Me Out"?< / Original Question>
[0073] S3: The knowledge base retrieval module uses a two-layer retriever to retrieve in the knowledge base for the sub-questions in the reasoning chain, and obtain relevant information beneficial to answering the sub-question ;
[0074] S4: The retrieval evaluation module re-evaluates the retrieved information. If the matching degree of the retrieved information to the sub-question is higher than the threshold, it enters the generation module, otherwise it skips the modification of the sub-question , returns to the knowledge base retrieval stage, and retrieves relevant information;
[0075] Specifically, constructing the retrieval evaluation module can be divided into the following steps:
[0076] (1)Select bge-raranker-large as the base model of the retrieval evaluation module, which has good text matching and evaluation capabilities;
[0077] (2)Set the matching degree threshold threshold: used to determine whether the retrieved information meets the requirements, ensuring that only high-quality matching results are selected. This threshold can be optimized and adjusted through experiments and verification to meet the needs of specific application scenarios;
[0078] (3)Preprocessing of input information: Standardize the retrieved information, including preprocessing steps such as removing extra spaces and punctuation handling, to ensure the consistency of the input information format;
[0079] (4)Calculation of matching score: Input the preprocessed retrieved information into the bge-reranker-large model to calculate the matching score for each piece of information;
[0080] (5)Filtering of retrieved information: Filter the retrieved information according to the matching score. Only the retrieved information with a score higher than threshold will be selected as the reference document for modifying the CoT sub-chain. If the matching scores of all retrieved information are lower than threshold, the modification of the current sub-chain will be skipped.
[0081] S5: The generation module generates candidate answers based on the retrieved relevant information and sub-questions ; ;
[0082] Specifically, building the generation module can be divided into the following steps:
[0083] (1)Construct the training dataset. In the training data, each data point contains a question, a set of reference documents, and an answer. Among them, the answer contains two parts: one is the cited document (marked with <cite>< / cite> tags), and the other is the question answer (marked with <answer>< / answer> tags), and there needs to be a certain reasoning process between these two parts (that is: the explanation of obtaining the answer based on the cited document); The reference documents are divided into two categories, namely "relevant documents" (documents containing the question answer) and "distracting documents" (documents not containing the question answer); In the entire dataset, the data contains both "relevant documents" and "distracting documents", while the data only contains "distracting documents";
[0084] (2)Use the method of supervised fine-tuning to train the large language model LLM on the training dataset. The model is trained to answer questions in the presence of distracting documents, enabling it to ignore the retrieved documents that are not helpful for answering the given question, which helps to improve the robustness of the model to inaccurate retrieval results during generation, and finally obtain a generation model that can accurately answer relevant questions based on the retrieved information.
[0085] S6: The verification module selects from the original answer and the candidate answer Select a more appropriate answer from the options as an improvement to the CoT reasoning chain. If a sub-chain in the reasoning chain is modified, enter the CoT-LLM reasoning module to adjust the subsequent sub-chains accordingly based on this modification to obtain a new reasoning chain, and then process the next sub-question in the current reasoning chain. ;
[0086] Specifically, constructing the verification module can be divided into the following steps:
[0087] Construct a validator through prompting techniques. During the reasoning process, take the original sub-answer generated by the CoT-LLM module and the candidate sub-answer generated by the generation module as inputs. Then, through prompting instructions, guide the validator to select one of the two answers as the preferred answer. If neither answer is selected, it is determined that the correct answer cannot be obtained. Specific examples of prompting instructions are as follows:
[0088] Example of prompt word command: <Task>Please select a better answer from the original answer and the candidate answer in combination with the reference document to answer the question. When choosing an answer, consider the logical consistency, information integrity, and clarity of language expression of the answer.< / Task><Reference Document>…< / Reference Document><Question>Who is the author of the full-length novel "Life and Death Are Wearing Me Out"?< / Question><Original Answer>Zhang San< / Original Answer><Candidate Answer>Mou Yan< / Candidate Answer>
[0089] S7: Repeat steps S2 - S6 in a loop until the CoT reasoning chain is completed. Then, determine whether the final answer can be obtained through the <final answer>< / final answer> tag. If this tag exists, output the answer in the tag; otherwise, it means the question cannot be answered.
Claims
1. A method for reasoning and generating knowledge-intensive problems based on LLM, characterized in that: The following steps are involved: S1: For the user question Q to be answered, the knowledge evaluation module processes it to determine whether the question Q can be solved using the internal knowledge of the large language model. If it can be solved, the large language model directly generates the answer. Otherwise, the question Q is passed to the knowledge base retrieval module and the CoT-LLM reasoning module. S2: The knowledge base retrieval module retrieves relevant factual information for question Q. The CoT-LLM reasoning module combines question Q and the retrieved information to generate a structured dynamic reasoning chain {{Q1, A1}, {Q2, A2}, ..., {Q n , A n }}; The specific method of constructing the knowledge base retrieval module is as follows: (1) Use bge-large-zh as a dense retriever to capture deeper semantic information of text paragraphs to retrieve relevant text. Specifically, dense vectors are used to represent text, and the similarity scores between vectors are calculated using cosine similarity, which is calculated as follows: where υ Q is the vectorized representation of the query statement, and UD is the vectorized representation of the document; (2) Use BM25 as a sparse retriever to capture the vocabulary information in the text paragraph. Specifically, the relevant text is retrieved by calculating the similarity score between the document and the query condition. The calculation formula is as follows: Among them, Q represents the question, D represents the document, and q i represents the i-th word in the query, n is the number of words in the query, and IDF(q i ) is the inverse document frequency, f(q i , D) is the number of occurrences of the i-th word in the document, k1 and b are adjustment parameters, |D| is the length of the document, and avgdl is the average length of the documents in the document collection; (3) In order to consider both vocabulary and semantic information, a hybrid method is used to combine sparse retrievers and dense retrievers, that is, the implementation of a two-layer retriever. The calculation formula for the combined similarity score is as follows: F(Q,D)=α·similarity(Q,D)+β·score(Q,D) Among them, α and β are the weights to balance the two retrievers, which are adjusted according to actual needs and experimental results; Based on the above combined similarity scores, the top-3 text fragments are selected as the retrieved relevant texts, thereby obtaining the knowledge base retrieval module; S3: The knowledge base retrieval module uses a two-layer retriever to target the sub-question Q in the reasoning chain. i Search the knowledge base to obtain information that is helpful in answering the sub-question Q i relevant information; S4: The retrieval evaluation module re-evaluates the retrieved information. If the retrieved information is consistent with the sub-question Q i If the matching degree of is higher than the threshold, it will enter the generation module, otherwise it will skip the sub-question Q i Modification, return to the knowledge base search stage, search Q i+1 relevant information; The specific method of constructing the retrieval evaluation module is as follows: (1) bge-raranker-large is selected as the basic model of the retrieval evaluation module, which has good text matching and evaluation capabilities; (2) Setting the matching threshold: This is used to determine whether the retrieved information meets the requirements and ensure that only high-quality matching results are selected. The threshold is optimized and adjusted through experiments and verification to meet the needs of specific application scenarios. (3) Preprocessing of input information: Standardizing the retrieved information, including removing extra spaces and punctuation marks, to ensure the consistency of the input information format; (4) Calculation of matching scores: Input the preprocessed search information into the bge-reranker-large model to calculate the matching score of each piece of information; (5) Filtering of search information: The search information is filtered according to the matching score. Only the search information with a score higher than the threshold will be selected as the reference document for modifying the CoT subchain. If the matching scores of all the search information are lower than the threshold, the modification of the current subchain will be skipped. S5: The generation module generates a i , generate candidate answer CA i ; The specific method of constructing the generation module is as follows: (1) Construct a training dataset: In the training data, each data point contains a question, a set of reference documents, and an answer. The answer consists of two parts: one is the cited document, and the other is the answer to the question. Moreover, an inference process needs to be included between these two parts, that is, an explanation of how the answer is derived based on the cited document. The reference documents are divided into two categories, namely "relevant documents" and "distracting documents". Among them, "relevant documents" are the documents that contain the answer to the question, and "distracting documents" are the documents that do not contain the answer to the question. In the entire dataset, p% of the data contains both "relevant documents" and "distracting documents", while (1 - p%) of the data contains only "distracting documents". (2) Use the method of supervised fine-tuning to train the large language model LLM on the training dataset: The model is trained to answer questions in the presence of distracting documents, enabling it to ignore retrieval documents that are not helpful for answering the given question. This helps improve the robustness of the model to inaccurate retrieval results during generation, and finally a generation model that can accurately answer relevant questions based on retrieved information is obtained. S6: Verification module from the original answer A i and candidate answer CA i Select a more appropriate answer as an improvement to the CoT reasoning chain. If a subchain in the reasoning chain is modified, the CoT-LLM reasoning module is entered to adjust the subsequent subchains according to this modification to obtain a new reasoning chain, and then process the next subquestion Q in the current reasoning chain. i+1 ; S7: Repeat steps S2 - S6 in a loop until the CoT inference chain is completed. Then, determine whether the final answer can be obtained through the <final answer>< / final answer> tag. If this tag exists, output the answer in the tag; otherwise, it means the question cannot be answered.
2. The method for reasoning and generating knowledge-intensive problems based on LLM according to claim 1, characterized in that: The specific method for constructing the knowledge evaluation module in S1 is as follows: (1) Collect question-answer pair data D that meet the characteristics of multi-hop questions, where D contains question Q i And its corresponding correct answer A i Multiple question-answer pairs; (2) Construct a question-answer pair dataset D for training the knowledge evaluation model * Specifically, first extract the question Q in D i The input is given to the large language model LLM, which can generate the answer A for each question through few sample prompts and context learning. m , the answer generated at this time is completely dependent on the internal knowledge of the model; then, according to A m The correct answer is A i The comparison result of question Q i Divided into two groups, if A m With A i Same, then these questions belong to Q known , that is, problems that the model can solve by itself, otherwise they belong to Q unknown , that is, the problem that the model cannot solve by itself; finally, the final training data set D is formed * = {Q known , Q unknown }, where for Q known The answers are all: Yes, for Q unknown The answers are: I don’t know; (3) Using the standard conditional language modeling objective on dataset D * The large language model LLM is trained to obtain a knowledge evaluation model that is used to determine whether a problem can be solved by the internal knowledge of the model.
3. The method for reasoning and generating knowledge-intensive problems based on LLM according to claim 1, characterized in that: The specific method for constructing the CoT-LLM inference module in S2 is as follows: (1) Construct a CoT demonstration set for the in-context learning of the large language model: Specifically, first, manually write several accurate CoT demonstrations as the benchmark set, and use these demonstrations as the starting point for constructing the complete set. Then, use the multi-hop questions collected in S1 as the training set. Then, use an iterative algorithm to gradually expand the benchmark set until the construction of the complete CoT set is finally completed. Specifically, in each iteration, select the demonstration with the highest cosine similarity to the question in the training set from the benchmark set as the context prompt, and use ChatGPT to generate a structured CoT inference chain. Append the question and the generated inference chain to the benchmark set until each question in the training set has completed the iteration. Finally, the complete CoT set is presented in the format of <Q, CoT inference chain>. (2) For each question Q proposed by the user, screen out the demonstration with the highest cosine similarity to question Q from the constructed complete CoT set. The large language model LLM performs inference and generates an inference chain according to the complete instruction combined with question Q, the demonstration, and the retrieved information.
4. The method for reasoning and generating knowledge-intensive problems based on LLM according to claim 1, characterized in that: The specific method for constructing the verification module in S6 is as follows: Construct a validator through prompting techniques. During the inference process, use the original sub-answer generated by the CoT-LLM module and the candidate sub-answer generated by the generation module as inputs. Then, through the prompting instruction, guide the validator to select one of the two answers as the preferred answer. If neither answer is selected, it is determined that the correct answer cannot be obtained.
