Autonomous retrieval enhancement generation method and device based on large language model
By guiding the large language model to generate search strategies and fine-tune it in iterative search, the problems of large inference overhead and inefficiency in the existing technology are solved, and a more efficient and flexible iterative search process is achieved.
Patent Information
- Application Number
- CN202411890644.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-15
AI Technical Summary
Existing iterative search techniques rely on manual design rules and examples, resulting in high inference overhead and inability to make full use of the inference decision-making capabilities of large language models, which are inefficient.
Through a few samples, the large language model is guided to generate search strategies based on inference in iterative search, build training data and perform supervised fine-tuning to realize the independent decision-making of the large language model in iterative search.
The efficiency and effectiveness of iterative search is improved, the inference decision-making ability of large language models is fully utilized, and the number of searches can be adjusted adaptively according to the difficulty of the problem and the usefulness of external knowledge.
Smart Images

Figure CN119831041A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of retrieval enhancement generation of large language models, and in particular to an autonomous retrieval enhancement generation method and device based on a large language model, a storage medium and an electronic device. Background Art
[0002] Retrieval-Augmented Generation (RAG) of large language models is one of the important technologies to alleviate the hallucination phenomenon of large language models. The usual practice is to use the user's input as a query to retrieve external knowledge, and splice this knowledge into the model's input to assist the model in text generation. For complex problems, it is difficult for the retriever to provide sufficient external knowledge at one time; in addition, the external knowledge returned by the retriever may be noisy. For this reason, iterative retrieval was proposed. It accesses the retriever multiple times to obtain more relevant, richer, and more valuable information. The core of iterative retrieval is to decide when to retrieve and what to retrieve. However, existing technologies often implement iterative retrieval through manually designed rules and examples, which not only introduces additional reasoning overhead, but also wastes the reasoning and decision-making capabilities of the large language model itself.
[0003] Existing iterative retrieval techniques often use manually designed rules and sample input (Few-shot) to achieve iterative retrieval. Although this method has achieved certain results, it wastes the reasoning and decision-making capabilities of the large language model itself.
[0004] For example, Shao et al. proposed a simple iterative retrieval rule in 2023. First, a normal retrieval enhancement is performed, using the user's input as a query to retrieve external knowledge, and then the retrieved external knowledge is spliced into the input to guide the large language model to generate text. Subsequently, the iteration is corrected multiple times: each iteration uses the previous output as a query, and after obtaining the retrieved external knowledge, the existing documents are refreshed to regenerate the answer. Although this method improves the effect of retrieval enhancement, the retrieval strategy is not flexible enough, because it is not necessary to perform the same number of retrievals for all questions; in addition, the content of each retrieval depends on the previous output of the large language model, there may be error accumulation, and it is difficult to deal with the phenomenon of topic shifting during generation.
[0005] Jiang et al. proposed the FLARE (Fast and Lightweight Adaptation through Retrieval-enhanced generation) method in 2023. Specifically, this method also performs a normal retrieval enhancement generation first. In each subsequent iteration, if there is a position with low confidence in the output, a query for that position is constructed to retrieve new documents (for example, "XX's undergraduate school is YY University", and the confidence of "YY University" is low, so "YY University" is deleted and "XX's undergraduate school is" is used as a new query), and the previous output is corrected based on the new knowledge; if the confidence in the output is high, no retrieval is required. Although this method uses the confidence (probability) of the output to make decisions on the timing of retrieval, it relies on manually set thresholds and does not give full play to the subjective initiative of the large language model, resulting in low efficiency.
[0006] Asai et al. proposed the Self-RAG (Self-Reflective Retrieval-Augmented Generation) method in 2023. This method makes decisions by letting the large language model predict the reflection token. That is, every time an answer is to be generated, the special token [retrieve] is first predicted to determine whether retrieval is needed. After retrieval, the special token [is_relavant] is used to judge the relevance of each retrieved document, and an answer is generated for each document, and the usefulness of the answer is evaluated by the special token [is_useful]. Finally, based on the probabilities of these special tokens, the confidence of each path is calculated (question->document->answer is counted as one path, and there are multiple paths because there are multiple documents), and the answer of the path with the highest confidence is selected and returned to the user. Although this approach allows the large language model to make decisions through special tokens, the large language model only mechanically predicts special tokens, but it is unclear why. In addition, the timing of retrieval is limited by the length of the generated answer. For short-form question-answering tasks, the large language model only has one retrieval opportunity. If the retrieved documents are not relevant, the large language model is still forced to generate an answer, resulting in hallucinatory output.
[0007] In summary, the prior art obviously has inconveniences and defects in practical use, so it is necessary to improve it. Summary of the invention
[0008] In view of the above-mentioned defects, the purpose of the present invention is to provide an autonomous retrieval enhancement generation method and device based on a large language model, a storage medium and an electronic device, which can make full use of the reasoning and decision-making capabilities of the large language model itself, realize autonomous decision-making in iterative retrieval, and not only have better retrieval effects but also have higher efficiency.
[0009] In order to solve the above-mentioned technical problems, the present invention is achieved as follows:
[0010] In a first aspect, an embodiment of the present invention provides an autonomous retrieval enhancement generation method based on a large language model, comprising:
[0011] A data construction step, guiding the large language model to generate a retrieval strategy based on reasoning in iterative retrieval through a small number of sample examples, and generating training data according to the retrieval strategy;
[0012] A model training step, using the training data to train the large language model;
[0013] In the step of applying reasoning, after receiving the user's question, the large language model generates the corresponding retrieval strategy based on reasoning, and autonomously performs iterative retrieval on the user's question according to the retrieval strategy.
[0014] According to the autonomous retrieval enhancement generation method based on a large language model of the present invention, the few sample examples include interactive samples in the form of multi-round dialogues;
[0015] The data construction step includes:
[0016] The interaction between the large language model and the retriever is constructed in the form of multiple rounds of dialogue, and the large language model is guided to generate the retrieval strategy based on reasoning in iterative retrieval, and the retrieval strategy includes retrieval time and / or retrieval content.
[0017] According to the autonomous retrieval enhancement generation method based on a large language model of the present invention, the model training step includes:
[0018] The large language model is fine-tuned in a supervised manner using the training data to train the large language model.
[0019] According to the autonomous retrieval enhancement generation method based on a large language model of the present invention, the model training step includes:
[0020] The large language model is fine-tuned in a supervised manner using a cross entropy loss function, where the calculation formula of the cross entropy loss function is:
[0021]
[0022] Among them, for the inclusion of (x t ,yt ) Samples for 0 ≤ t ≤ T, y t represents the output of the t-th iteration, x≤t represents all inputs before the current iteration, and y<t represents all previous outputs.
[0023] According to the self-retrieval enhanced generation method based on a large language model of the present invention, the inference application steps include:
[0024] In each round of iterative retrieval process, the input of the large language model is the user's question or external knowledge provided by the retriever, and the output of the large language model is the inference on the existing knowledge, the retrieval strategy, the next query information, and the final answer provided when the knowledge is sufficient.
[0025] According to the self-retrieval enhanced generation method based on a large language model of the present invention, in the inference application steps, the large language model adjusts the number of iterations according to the difficulty of the user's question and the usefulness of the external knowledge.
[0026] According to the self-retrieval enhanced generation method based on a large language model of the present invention, the inference application steps include:
[0027] The inference application steps include:
[0028] In the 0th iteration, receive the user's question from the user side as the first-round input;
[0029] Generate the corresponding retrieval strategy as the output according to the user's question, and generate the initial query information;
[0030] Send the query information to the retriever for retrieval;
[0031] In the t-th iteration, use the retrieved external knowledge as the input for this round;
[0032] Judge whether the existing external knowledge is sufficient;
[0033] If the existing external knowledge is sufficient, generate the final answer in combination with the existing external knowledge, and return the final answer to the user side;
[0034] If the existing external knowledge is not sufficient, identify the information requirements, rewrite the query information according to the information requirements, and send the rewritten query information to the retriever for retrieval.
[0035] In a second aspect, an embodiment of the present invention provides a self-retrieval enhanced generation device based on a large language model constructed according to any of the above methods, including:
[0036] A data construction module, used to guide the large language model to generate a retrieval strategy based on reasoning in iterative retrieval through a small number of sample examples, and to generate training data according to the retrieval strategy;
[0037] A model training module, used to train the large language model using the training data;
[0038] The reasoning application module is used to generate the corresponding search strategy based on reasoning after the large language model receives the user's question, and autonomously perform iterative search on the user's question according to the search strategy.
[0039] In a third aspect, an embodiment of the present invention provides a storage medium for storing a computer program for executing any one of the autonomous retrieval enhancement generation methods based on a large language model.
[0040] In a fourth aspect, an embodiment of the present invention provides an electronic device, comprising a storage medium, a processor, and a computer program stored on the storage and executable on the processor, wherein when the processor executes the computer program, any one of the autonomous retrieval enhancement generation methods based on a large language model is implemented.
[0041] The present invention provides an autonomous retrieval enhancement generation technology based on a large language model, including: guiding the large language model to generate a retrieval strategy based on reasoning in iterative retrieval through a small number of sample examples, generating training data according to the retrieval strategy; using the training data to train the large language model; after the large language model receives a user's question, generating a corresponding retrieval strategy based on reasoning, and autonomously performing iterative retrieval on the user's question according to the retrieval strategy. In this way, the present invention can make full use of the reasoning and decision-making ability of the large language model itself, realize autonomous decision-making in iterative retrieval, and not only has better retrieval effect, but also has higher efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is a flowchart of the autonomous retrieval enhancement generation method based on a large language model provided in the first embodiment of the present invention;
[0043] Figure 2 It is a flowchart of the reasoning application steps of the autonomous retrieval enhancement generation method based on a large language model provided in the second embodiment of the present invention;
[0044] Figure 3 It is a structural schematic diagram of an autonomous retrieval enhancement generation device based on a large language model provided in the first embodiment of the present invention;
[0045] Figure 4 It is a structural diagram of an autonomous retrieval enhancement generation device based on a large language model provided in the second embodiment of the present invention;
[0046] Figure 5 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. Figure 5 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0048] It should be noted that references to "one embodiment", "embodiment", "example embodiment", etc. in this specification refer to the embodiment described, which may include specific features, structures or characteristics, but not every embodiment must include these specific features, structures or characteristics. In addition, such expressions do not refer to the same embodiment. Furthermore, when describing specific features, structures or characteristics in conjunction with an embodiment, whether or not there is an explicit description, it has been shown that it is within the knowledge of those skilled in the art to combine such features, structures or characteristics into other embodiments.
[0049] In addition, certain words are used in the specification and subsequent claims to refer to specific components or parts. Those with ordinary knowledge in the relevant field should understand that manufacturers can use different nouns or terms to refer to the same component or part. This specification and subsequent claims do not use differences in names as a way to distinguish components or parts, but use differences in the functions of components or parts as the criteria for distinction. "Including" and "including" mentioned throughout the specification and subsequent claims are open-ended terms and should be interpreted as "including but not limited to". In addition, the word "connected" here includes any direct and indirect electrical connection means. Indirect electrical connection means include connection through other devices.
[0050] The following describes in detail the autonomous retrieval enhancement generation method based on a large language model provided by the embodiment of the present invention through specific embodiments and application scenarios in conjunction with the accompanying drawings.
[0051] For a user input, the large language model should request the retriever multiple times until it obtains all the knowledge required to answer the user input. However, how to make the large language model learn such decisions is challenging. In addition, if the large language model is allowed to perform iterative retrieval through sample input (Few-shot), it will bring additional reasoning overhead and is not suitable for practical applications. To this end, the present invention constructs instruction data for autonomous decision-making in iterative retrieval to fine-tune the large language model, so that the large language model can learn to make autonomous decisions in iterative retrieval.
[0052] The inventors tried to model the interaction process between the large language model and the retriever in the form of multiple rounds of dialogue, hoping to construct a sequence of "given user input, the large language model continues to search until sufficient information is available and returns the answer to the user" to train the large language model, hoping to guide the large language model to learn such a process by providing examples in the input to generate training data. However, experiments have shown that the large language model will only continuously modify the query and will not converge on the answer, which means that the large language model will only blindly imitate the examples and is not clear that the reason for the search is insufficient information and the reason for generating the answer is sufficient information, and it is unable to complete the iterative search.
[0053] In this regard, the present invention proposes the Auto-RAG model (Auto-Retrieval-Augmented Generation), an autonomous iterative retrieval model with the powerful decision-making ability of a large language model (LLM) as its core, so as to make full use of the knowledge and reasoning ability of the large language model itself. The present invention adds a reasoning process to the input example, that is, adds processes such as "retrieval planning, extracting external knowledge, and indicating information needs" to the output of each round of the large language model, and can successfully guide the large language model to complete the iterative retrieval process and construct training data. After training, the large language model demonstrates the ability of iterative retrieval with autonomous decision-making, and can autonomously adjust the number of iterations according to the difficulty of the problem and the usefulness of external knowledge, giving full play to the reasoning and decision-making ability of the large language model.
[0054] In the iterative retrieval process, the autonomous retrieval enhancement generation method uses reasoning to perform retrieval planning, extract valuable external knowledge, identify information needs, rewrite queries, and continuously query the retriever for new information until sufficient information is available, terminating the iteration and returning the answer to the user. In order to give the large language model the ability to use reasoning to make autonomous decisions in iterative retrieval and to more accurately decide the timing and content of retrieval, a method for automatically building and filtering training data was designed, and the latest open source model was fine-tuned.
[0055] Figure 1 : is a flow chart of an autonomous retrieval enhancement generation method based on a large language model provided in the first embodiment of the present invention. The method is implemented by an Auto-RAG model and applied to the retrieval enhancement generation technology of a large language model, and includes the following steps:
[0056] Step S101, data construction step, guides the large language model to generate a retrieval strategy based on reasoning in iterative retrieval through few-shot prompting, and generates training data according to the retrieval strategy.
[0057] Preferably, the few-shot examples include interactive examples in the form of multi-turn conversations.
[0058] Preferably, the data construction step includes:
[0059] Preferably, based on an open-source large language model, the present invention uses the few-shot example method to guide the large language model to make decisions on when to retrieve and what to retrieve through reasoning in iterative retrieval, so as to construct training data.
[0060] Preferably, the present invention constructs the interaction between the large language model and the retriever in the form of multi-turn conversations, guiding the large language model to generate a retrieval strategy based on reasoning in iterative retrieval. The retrieval strategy includes retrieval time and / or retrieval content. Therefore, in each round of iteration, the input of the large language model is the user's question or the knowledge provided by the retriever, and the output of the large language model is the reasoning about the existing knowledge, the plan for retrieval, the next query to be used, and the answer to be provided when the knowledge is sufficient.
[0061] Step S102, the model training step, uses the training data to train the large language model.
[0062] Preferably, the model training step includes:
[0063] In order to enable any large language model to have the ability to make autonomous decisions in iterative retrieval, the present invention adopts a standard supervised fine-tuning method. That is to say, the large language model is trained using the training data.
[0064] More preferably, the model training step includes:
[0065] Perform supervised fine-tuning on the large language model through the cross-entropy loss function. The calculation formula of the cross-entropy loss function is:
[0066]
[0067] where, for samples containing (x t , y t ) 0 ≤ t ≤ T, y t represents the output of the t-th iteration, x≤t represents all the inputs before the current iteration, and y<t represents all the previous outputs.
[0068] Step S103, the inference application step, after the large language model receives the user's question, generates a corresponding retrieval strategy based on reasoning, and autonomously performs iterative retrieval on the user's question according to the retrieval strategy.
[0069] After training, the Auto-RAG model has the ability to make autonomous decisions based on reasoning in iterative retrieval, and can effectively identify when to retrieve and what to retrieve. In each iteration, you only need to provide input to the Auto-RAG model (whether it is a user question or a retrieved document) and extract the plan that the Auto-RAG model has made for the next step.
[0070] Preferably, the reasoning application step comprises:
[0071] In each round of iterative retrieval, the input of the large language model is the user's questions or the external knowledge provided by the retriever, and the output of the large language model is the reasoning based on the existing knowledge, the retrieval strategy, the next query information, and the final answer provided when the knowledge is sufficient.
[0072] Preferably, in the reasoning application step, the large language model adjusts the number of iterations according to the difficulty of the user's question and the usefulness of the external knowledge.
[0073] The purpose of the present invention is to solve the problem that the retrieval strategy in the iterative retrieval in the prior art is inflexible and does not fully utilize the reasoning and decision-making capabilities of the large language model itself, and proposes a large language model that can perform iterative retrieval with autonomous decision-making. In order to give the large language model such capabilities, the present invention designs a method for automatically constructing and filtering training data and fine-tunes the latest open source model.
[0074] The key technical points of the present invention include the following:
[0075] (1) The present invention proposes a large language model that can autonomously perform iterative retrieval. The number and timing of retrieval are completely autonomously determined by the large language model without human intervention. The large language model makes full use of its own reasoning and decision-making capabilities, and exhibits a certain degree of robustness in the face of questions of different difficulty and knowledge of different relevance.
[0076] (2) Modeling the interaction between the large language model and the retriever in the form of multi-round dialogues not only improves the interpretability of the method but also provides a more intuitive user experience.
[0077] Compared with the baseline model, the present invention has achieved better results in multiple QA (question and answer) data sets. Compared with other iterative retrieval methods, this method is not only less time-consuming, but also more effective. This is due to the full use of the reasoning and decision-making capabilities of the large language model itself, which can adaptively adjust the number of retrievals according to the difficulty of user input and the availability of external knowledge to make accurate decisions. In summary, the present invention has achieved good results in the overall effect and efficiency of retrieval enhancement technology, and is an advanced and practical retrieval enhancement method.
[0078] Figure 2: is a flowchart of the reasoning application steps of the autonomous retrieval enhancement generation method based on a large language model provided in the second embodiment of the present invention. The method is implemented by the Auto-RAG model and applied to the retrieval enhancement generation technology of the large language model, and includes the following steps:
[0079] Step S201, in the 0th iteration, receiving a user question from the user end as the first round of input.
[0080] Step S202: Generate a corresponding search strategy as output according to the user's question, and generate initial query information.
[0081] Step S203, sending the query information to the search engine for retrieval.
[0082] Step S204: In the tth iteration, the retrieved external knowledge is used as input for this round.
[0083] Step S205, determine whether the existing external knowledge is sufficient, if so, execute step S206, otherwise execute step S207.
[0084] Step S206: If the existing external knowledge is sufficient, a final answer is generated by combining the existing external knowledge, and the final answer is returned to the user end, and the iterative search ends.
[0085] Step S207, if the existing external knowledge is insufficient, the information needs are identified, the query information is rewritten according to the information needs, and the rewritten query information is sent to the searcher for retrieval, that is, returning to step S203.
[0086] It should be noted that the autonomous retrieval enhancement generation method based on a large language model provided in the embodiment of the present invention can be executed by an electronic device, a device, or a control module in the device for executing the autonomous retrieval enhancement generation method based on a large language model. In the embodiment of the present invention, the autonomous retrieval enhancement generation method based on a large language model is executed by an autonomous retrieval enhancement generation device based on a large language model as an example to illustrate the autonomous retrieval enhancement generation device based on a large language model provided in the embodiment of the present invention.
[0087] Figure 3 1 is a schematic diagram of the structure of an autonomous retrieval enhancement generation device based on a large language model provided in Embodiment 1 of the present invention. The autonomous retrieval enhancement generation device based on a large language model 100 includes a data construction module 10, a model training module 20 and a reasoning application module 30, wherein:
[0088] The data construction module 10 is used to guide the large language model to generate a retrieval strategy based on reasoning in iterative retrieval through a small number of sample examples, and to generate training data according to the retrieval strategy.
[0089] The model training module 20 is used to train the large language model using the training data.
[0090] The reasoning application module 30 is used to generate a corresponding search strategy based on reasoning after the large language model receives the user's question, and autonomously perform iterative search on the user's question according to the search strategy.
[0091] The autonomous retrieval enhancement generation device based on a large language model provided by the embodiment of the present invention can achieve Figures 1-2 To avoid repetition, the various processes implemented in the embodiment of the autonomous retrieval enhancement generation method based on a large language model are not described here.
[0092] The autonomous retrieval enhancement generation device based on the large language model provided by the embodiment of the present invention includes a data construction module, a model training module and a reasoning application module. The data construction module is used to guide the large language model to generate a retrieval strategy based on reasoning in iterative retrieval through a small number of sample examples, and generate training data according to the retrieval strategy; the model training module is used to train the large prediction model using the training data; the reasoning application module is used to generate a corresponding retrieval strategy based on reasoning after the large language model receives the user's question, and autonomously perform iterative retrieval on the user's question according to the retrieval strategy. In this way, the present invention can make full use of the reasoning decision-making ability of the large language model itself, realize autonomous decision-making in iterative retrieval, and not only has better retrieval effect, but also has higher efficiency.
[0093] Figure 4 1 is a schematic diagram of the structure of an autonomous retrieval enhancement generation device based on a large language model provided in Embodiment 2 of the present invention. The autonomous retrieval enhancement generation device based on a large language model 100 includes a data construction module 10, a model training module 20 and a reasoning application module 30, wherein:
[0094] The data construction module 10 is used to guide the large language model to generate a retrieval strategy based on reasoning in iterative retrieval through a small number of sample examples, and to generate training data according to the retrieval strategy.
[0095] Preferably, the few sample examples include interaction samples in the form of multi-round dialogues. The data construction module 10 is used to construct the interaction between the large language model and the retriever in the form of multi-round dialogues, and guide the large language model to generate a retrieval strategy based on reasoning in iterative retrieval, and the retrieval strategy includes retrieval time and / or retrieval content.
[0096] The model training module 20 is used to train a large language model.
[0097] Preferably, the model training module 20 is used to perform supervised fine-tuning on the large language model using the training data to train the large language model.
[0098] Preferably, the model training module 20 is used to perform supervised fine-tuning on the large language model through the cross-entropy loss function. The calculation formula of the cross-entropy loss function is as follows:
[0099]
[0100] where, for samples containing (x t , y t ) 0 ≤ t ≤ T, y t represents the output of the t-th iteration, x≤t represents all inputs before the current iteration, and y<t represents all previous outputs.
[0101] The inference application module 30 is used to generate a corresponding retrieval strategy based on inference after the large language model receives a user question, and iteratively retrieve the user question autonomously according to the retrieval strategy.
[0102] Preferably, in the process of each round of iterative retrieval, the input of the large language model for the inference application module 30 is the user question or the external knowledge provided by the retriever, and the output of the large language model is the inference for the existing knowledge, the retrieval strategy, the next query information, and the final answer provided when the knowledge is sufficient.
[0103] Preferably, the inference application module 30 is used to enable the large language model to adjust the number of iterations according to the difficulty of the user question and the usefulness of the external knowledge.
[0104] Preferably, the inference application module 30 further includes:
[0105] A generation sub-module 31, which is used to receive the user question from the user side as the first-round input in the 0th iteration, generate a corresponding retrieval strategy as the output according to the user question, and generate initial query information.
[0106] A retrieval sub-module 32, which is used to send the query information to the retriever for retrieval, and use the retrieved external knowledge as the input for this round in the t-th iteration.
[0107] A judgment sub-module 33, which is used to judge whether the existing external knowledge is sufficient.
[0108] A rewrite sub-module 34, which is used to identify the information requirements if the existing external knowledge is not sufficient, rewrite the query information according to the information requirements, and send the rewritten query information to the retriever for retrieval, that is, hand it over to the retrieval sub-module 31 for processing again.
[0109] A reply sub-module 35, which is used to generate a final answer in combination with the existing external knowledge if the existing external knowledge is sufficient, and return the final answer to the user side, and the iterative retrieval ends.
[0110] The present invention also provides a storage medium for storing Figure 1-2 A computer program of any of the autonomous retrieval enhancement generation methods based on a large language model. For example, a computer program instruction, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer, and can achieve the same technical effect. To avoid repetition, it will not be repeated here. The program instructions for calling the method of the present invention may be stored in a fixed or removable storage medium, and / or transmitted through a data stream in a broadcast or other signal-bearing medium and / or stored in a storage medium of a computer device that runs according to the program instructions.
[0111] According to one embodiment of the present invention, the present invention also provides a Figure 5 The electronic device 400 shown, the electronic device 400 optionally includes a storage medium 200 for storing a computer program and a processor 300 for executing the computer program, wherein when the computer program is executed by the processor 300, any of the above-mentioned autonomous retrieval enhancement generation methods based on a large language model is implemented, triggering the electronic device 400 to execute the methods and / or technical solutions based on the aforementioned multiple embodiments, and can achieve the same technical effect, to avoid repetition, it is not repeated here. It should be noted that the electronic devices in the embodiments of the present invention include mobile electronic devices and non-mobile electronic devices. Exemplarily, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, a super mobile personal computer, a netbook or a personal digital assistant, etc., and the non-mobile electronic device can be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiments of the present invention.
[0112] It should be noted that the present invention can be implemented in software and / or a combination of software and hardware, for example, can be implemented using an application specific integrated circuit (ASIC), a general purpose computer or any other similar hardware device. In one embodiment, the software program of the present invention can be executed by a processor to implement the above steps or functions. Similarly, the software program of the present invention (including related data structures) can be stored in a computer-readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and the like. In addition, some steps or functions of the present invention can be implemented using hardware, for example, as a circuit that cooperates with a processor to perform each step or function.
[0113] The present invention can be implemented on a computer as a computer-implemented method, or implemented in dedicated hardware, or implemented in a combination of the two. The executable code or part thereof for the method according to the present invention can be stored on a computer program product. Examples of computer program products include memory devices, optical storage devices, integrated circuits, servers, online software, etc. Optionally, the computer program product includes a non-temporary program code component stored on a computer-readable medium so as to perform the method according to the present invention when the program product is executed on a computer.
[0114] In an alternative embodiment, the computer program comprises computer program code means adapted to perform all the steps of the method according to the invention when the computer program is run on a computer. Optionally, the computer program is embodied on a computer readable medium.
[0115] It should be noted that, in this article, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the method and device in the embodiment of the present invention is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0116] Of course, the present invention may have many other embodiments. Without departing from the spirit and essence of the present invention, those skilled in the art may make various corresponding changes and modifications based on the present invention, but these corresponding changes and modifications should all fall within the scope of protection of the claims attached to the present invention.
Claims
1. A method for autonomous retrieval enhancement generation based on a large language model, characterized in that: include: A data construction step, guiding the large language model to generate a retrieval strategy based on reasoning in iterative retrieval through a small number of sample examples, and generating training data according to the retrieval strategy; A model training step, using the training data to train the large language model; In the step of applying reasoning, after receiving the user's question, the large language model generates the corresponding retrieval strategy based on reasoning, and autonomously performs iterative retrieval on the user's question according to the retrieval strategy.
2. The autonomous retrieval enhancement generation method based on a large language model according to claim 1 is characterized in that: The few sample examples include interaction samples in the form of multi-round dialogues; The data construction step includes: The interaction between the large language model and the retriever is constructed in the form of multiple rounds of dialogue, and the large language model is guided to generate the retrieval strategy based on reasoning in iterative retrieval, and the retrieval strategy includes retrieval time and / or retrieval content.
3. The autonomous retrieval enhancement generation method based on a large language model according to claim 1, characterized in that: The model training step includes: The large language model is fine-tuned in a supervised manner using the training data to train the large language model.
4. The autonomous retrieval enhancement generation method based on a large language model according to claim 1, characterized in that: The model training step includes: The large language model is fine-tuned in a supervised manner using a cross entropy loss function, where the calculation formula of the cross entropy loss function is: Among them, for samples containing (x t , y t ) where \(0\leq t\leq T\), \(y t represents the output of the \(t\)-th iteration, \(x\leq t\) represents all the inputs before the current iteration, and \(y < t\) represents all the previous outputs.
5. The autonomous retrieval enhancement generation method based on a large language model according to claim 1, characterized in that: The reasoning application step comprises: In each round of iterative retrieval, the input of the large language model is the user's question or the external knowledge provided by the retriever, and the output of the large language model is the reasoning based on the existing knowledge, the retrieval strategy, the next query information and the final answer provided when the knowledge is sufficient.
6. The autonomous retrieval enhancement generation method based on a large language model according to claim 5 is characterized in that: In the reasoning application step, the large language model adjusts the number of iterations according to the difficulty of the user's question and the usefulness of external knowledge.
7. The autonomous retrieval enhancement generation method based on a large language model according to claim 5 is characterized in that: The reasoning application step comprises: In the 0th iteration, receiving the user question from the user end as the first round of input; Generate the corresponding search strategy as output according to the user's question, and generate initial query information; Sending the query information to a retriever for retrieval; In the tth iteration, the retrieved external knowledge is used as the input of this round; Determine whether the existing external knowledge is sufficient; If the existing external knowledge is sufficient, generate a final answer by combining the existing external knowledge, and return the final answer to the user end; If the existing external knowledge is insufficient, information needs are identified, query information is rewritten according to the information needs, and the rewritten query information is sent to the retriever for retrieval.
8. An autonomous retrieval enhancement generation device based on a large language model constructed based on the method described in any one of claims 1 to 7, characterized in that: include: A data construction module, used to guide the large language model to generate a retrieval strategy based on reasoning in iterative retrieval through a small number of sample examples, and to generate training data according to the retrieval strategy; A model training module, used to train the large language model using the training data; The reasoning application module is used to generate the corresponding search strategy based on reasoning after the large language model receives the user's question, and autonomously perform iterative search on the user's question according to the search strategy.
9. A storage medium, characterized in that: A computer program for storing a computer program for executing the autonomous retrieval enhancement generation method based on a large language model according to any one of claims 1 to 7.
10. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the autonomous retrieval enhancement generation method based on a large language model according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Retrieval enhancement generation method and device based on large language model and electronic equipment
CN121542392A