Task answering method and device, equipment and medium
Through the combination of action generator and reasoning tools, tasks are gradually decomposed and executed, and the problem of LLMs insufficient inference ability in multi-step, improving the accuracy of task answers and complex task processing capabilities.
Patent Information
- Application Number
- CN202411382790.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-01-10
AI Technical Summary
Large language models (LLMs) have limitations when facing long-term reasoning or multi-step problem solving, and cannot achieve general multi-step reasoning capabilities, and the accuracy of generated content and mathematical calculation and symbolic reasoning capabilities are insufficient.
By obtaining task instructions and answer history, use the pre-generated action generator to predict the next reasoning action and corresponding reasoning tools, including search tools, mathematical tools, code tools and common sense reasoning tools, gradually decompose the task and execute the reasoning action until it reaches its termination state.
It significantly improves the general multi-step reasoning ability of large language models, reduces the problem of inaccurate tool calls, and realizes effective solutions to complex tasks.
Smart Images

Figure CN119293211A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a task answering method, device, equipment and medium. Background Art
[0002] Large Language Models (LLMs) play a significant role in promoting the advancement of natural language processing technology. They can perform complex tasks such as text generation and machine translation, and are used in search engines, intelligent customer service and other fields. However, LLMs have limitations in certain complex tasks such as long-term reasoning or multi-step problem solving, and require deep understanding and reasoning capabilities. In addition, LLMs lack the accuracy of generated content and the ability to perform mathematical calculations and symbolic reasoning.
[0003] At present, in order to improve the reasoning ability of LLMs, external tools can be combined to form intelligent agents, and the reasoning ability can be improved through methods such as task decomposition or thought chain. For example, Chain of Thought (CoT), Self-consistency, Tree of Thought (ToT), Reasoning and Action (ReAct) and Reflexion are adopted. Although these methods are effective in specific tasks, they are not universal and lack cross-domain generalization.
[0004] In view of the above problems, how to solve the problem that current LLMs cannot achieve general multi-step reasoning capabilities is an urgent problem to be solved by technicians in this field. Summary of the invention
[0005] The purpose of the present invention is to provide a task solving method, device, equipment and medium to solve the problem that current LLMs cannot achieve general multi-step reasoning capabilities.
[0006] In order to solve the above technical problems, the present invention provides a task solving method, comprising:
[0007] Obtaining a task instruction and obtaining a solution history corresponding to the task instruction; wherein the solution history includes a historical solution process and a historical output result of the task instruction;
[0008] Based on the task instruction and the solution history, the next reasoning action and the corresponding reasoning tool are predicted by a pre-generated action generator; wherein the reasoning tool includes a pre-generated search tool, a mathematical tool, a code tool and a common sense reasoning tool, and each of the reasoning tools has a corresponding expert model;
[0009] Inputting the task instruction, the solution history and the reasoning action into the reasoning tool to obtain an output result;
[0010] Determine whether the final answer is determined in the entire solution history through the action generator; if not, generate a new solution history based on the solution history, the reasoning action and the output result, and return to the step of predicting the next reasoning action and the corresponding reasoning tool based on the task instruction and the solution history through the pre-generated action generator. If so, end.
[0011] On the one hand, the specific process of generating the action generator and the reasoning tool includes:
[0012] generating a solution trajectory dataset integrating the reasoning tool according to the teacher model;
[0013] Generating a training data set for the action generator and a training data set for the reasoning tool respectively according to the solution trajectory data set;
[0014] Training is performed according to the training data set of the action generator and the training data set of the reasoning tool respectively to generate the action generator and the reasoning tool.
[0015] On the other hand, generating a solution trajectory dataset integrating the reasoning tool according to the teacher model includes:
[0016] Acquire an input question based on the teacher model, and determine an operation step containing content to be executed according to the input question;
[0017] Determining the corresponding reasoning tool according to the operation steps;
[0018] A solution based on the reasoning tool is generated to obtain the solution trajectory dataset.
[0019] On the other hand, determining the corresponding reasoning tool according to the operation steps includes:
[0020] Determine the content to be executed in the operation steps;
[0021] When the content to be executed and the historical solution provide necessary information for mathematical calculation, determining that the reasoning tool is the mathematical tool;
[0022] When there is unknown information in the content to be executed and it cannot be solved based on the existing information, determining that the reasoning tool is the search tool;
[0023] When the to-be-executed content representation performs data processing, determining that the reasoning tool is the code tool;
[0024] When the to-be-executed content represents processing of a general reasoning task, determining that the reasoning tool is the common sense reasoning tool;
[0025] Correspondingly, generating a solution based on the reasoning tool includes:
[0026] When the reasoning tool is the mathematical tool and the content to be executed involves equation construction, defining data parameter variables of the equation and outputting the final result of the operation step in a preset format;
[0027] When the reasoning tool is the search tool, the search query result of the search tool is set between the row where the search engine information is located and the row where the separator is located;
[0028] When the reasoning tool is the code tool, controlling the code tool to generate only one code snippet each time, and setting the code snippet between the line where the programming language information is located and the line where the separator is located;
[0029] When the reasoning tool is the common sense reasoning tool, the common sense reasoning tool is controlled to set the answer to the operation step in the first label, and set the final answer to the input question in the second label.
[0030] On the other hand, after generating a solution trajectory dataset integrating the reasoning tool according to the teacher model, the method further includes:
[0031] Based on the teacher model, wrong answers in the solution trajectory data are deleted by regular expressions.
[0032] On the other hand, the generating of the training data set of the action generator and the training data set of the reasoning tool respectively according to the solution trajectory data set includes:
[0033] Based on the solution trajectory dataset, data related to action generation is filtered through regular expressions and reorganized to obtain a training dataset for the action generator;
[0034] Based on the solution trajectory dataset, data related to the reasoning process is screened through regular expressions and reorganized to obtain a training dataset for the reasoning tool.
[0035] On the other hand, it also includes:
[0036] Determining whether the final answer corresponding to the task instruction is correct;
[0037] If it is confirmed that the final answer corresponding to the task instruction is correct, then the task ends;
[0038] If it is confirmed that the final answer corresponding to the task instruction is incorrect, the task instruction is re-edited, and the answer is performed again based on the re-edited task instruction.
[0039] In order to solve the above technical problems, the present invention further provides a task solving device, comprising:
[0040] An acquisition module, used to acquire a task instruction and acquire a solution history corresponding to the task instruction; wherein the solution history includes a historical solution process and a historical output result of the task instruction;
[0041] A prediction module, used to predict the next reasoning action and the corresponding reasoning tool based on the task instruction and the solution history through a pre-generated action generator; wherein the reasoning tool includes a pre-generated search tool, a mathematical tool, a code tool and a common sense reasoning tool, and each of the reasoning tools has a corresponding expert model;
[0042] A reasoning module, used for inputting the task instruction, the solution history and the reasoning action into the reasoning tool to obtain an output result;
[0043] A judgment module is used to judge whether the final answer is determined in the entire solution history through the action generator; if not, a new solution history is generated according to the solution history, the reasoning action and the output result, and returns to the step of predicting the next reasoning action and the corresponding reasoning tool based on the task instruction and the solution history through the pre-generated action generator. If so, the process ends.
[0044] In order to solve the above technical problems, the present invention further provides a task answering device, comprising:
[0045] Memory for storing computer programs;
[0046] A processor is used to implement the steps of the above-mentioned task solving method when executing the computer program.
[0047] In order to solve the above technical problem, the present invention also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above task solving method are implemented.
[0048] The task answering method provided by the present invention obtains task instructions and the answering history corresponding to the task instructions; wherein the answering history includes the historical answering process and the historical output results of the task instructions; based on the task instructions and the answering history, the next reasoning action and the corresponding reasoning tool are predicted by a pre-generated action generator; wherein the reasoning tool includes a pre-generated search tool, a mathematical tool, a code tool and a common sense reasoning tool, and each reasoning tool has a corresponding expert model; the task instructions, the answering history and the reasoning action are input into the reasoning tool to obtain the output result; it is determined whether the final answer is determined in the entire answering history by the action generator; if not, a new answering history is generated according to the answering history, the reasoning action and the output result, and the method returns to the step of predicting the next reasoning action and the corresponding reasoning tool by a pre-generated action generator based on the task instructions and the answering history, and if so, the method ends.
[0049] The beneficial effect of the present invention lies in that a unified large language agent framework is proposed. Based on task instructions and solution history, the task instructions are decomposed into a series of executable reasoning actions through a pre-generated action generator, and the reasoning tools corresponding to the reasoning actions are determined. Specifically, the task answers are abstracted into four reasoning tools, including search tools, mathematical tools, code tools and common sense reasoning tools. Each tool corresponds to an expert model, which can reduce the problem of inaccurate tool calls due to too many tools when a large language model calls the tool; further, each reasoning action is executed by the reasoning tool until the termination state is reached to obtain the final answer, thereby solving complex multi-step reasoning tasks and significantly improving the general multi-step reasoning ability of the large language model.
[0050] On the other hand, the present invention specifically generates a solution trajectory data set of an integrated reasoning tool based on a teacher model; generates a training data set of an action generator and a training data set of a reasoning tool based on the solution trajectory data set; trains based on the training data set of the action generator and the training data set of the reasoning tool to generate an action generator and a reasoning tool, respectively, and implements the training generation of the action generator and the reasoning tool to facilitate the answering of task instructions. Based on the teacher model, an input problem is obtained, and the operation steps containing the content to be executed are determined based on the input problem; the corresponding reasoning tool is determined based on the operation steps; a solution based on the reasoning tool is generated, and finally a solution trajectory data set is obtained, so that the training data set of the action generator and the training data set of the reasoning tool are generated respectively through the solution trajectory data set.
[0051] In addition, the present invention also provides a task answering device, equipment and medium, which have the same effects as above. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0053] Figure 1 A flowchart of a task solving method provided by an embodiment of the present invention;
[0054] Figure 2 A schematic diagram of a large language agent framework provided by an embodiment of the present invention;
[0055] Figure 3 A schematic diagram of a task solving device provided by an embodiment of the present invention;
[0056] Figure 4 A structural diagram of a task answering device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0057] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0058] The core of the present invention is to provide a task solving method, device, equipment and medium to solve the problem that current LLMs cannot achieve general multi-step reasoning capabilities.
[0059] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0060] At present, in order to improve the reasoning ability of LLMs, external tools can be combined to form intelligent agents, and the reasoning ability can be improved through methods such as task decomposition or thought chain. For example, techniques such as thought chain, self-consistency, thought tree, reasoning and action, and reflection are adopted. Although these methods are effective in specific tasks, they are not universal and lack cross-domain generalization. Therefore, in order to solve the above problems, the present invention provides a task solving method.
[0061] Figure 1 Flow chart of a task solving method provided by an embodiment of the present invention. Figure 1 As shown, the method includes:
[0062] S10: Obtain task instructions, and obtain the answer history corresponding to the task instructions.
[0063] The answer history includes the historical answer process and historical output results of the task instructions.
[0064] In the specific implementation, a complex task instruction that requires multi-step reasoning is obtained, which can be understood as a question or command (for example, help me generate a Python code for calculating the stock mean). At the same time, the solution history corresponding to the task instruction is obtained.
[0065] It should be noted that the answer history (h) includes the historical answer process and historical output results of the task instructions. Since this solution specifically answers the task instructions step by step, the output result of the previous step will be taken as part of the answer history at each step.
[0066] S11: Based on the task instructions and solution history, the next reasoning action and the corresponding reasoning tool are predicted by the pre-generated action generator.
[0067] Among them, reasoning tools include pre-generated search tools, mathematical tools, code tools and common sense reasoning tools, and each reasoning tool has a corresponding expert model.
[0068] S12: Input the task instructions, solution history and reasoning actions into the reasoning tool to obtain output results.
[0069] Figure 2 A schematic diagram of a large language agent framework provided by an embodiment of the present invention. Figure 2 As shown, the present invention provides a large language agent framework, which is specifically divided into two steps for processing complex tasks that require multi-step reasoning: first, the action generator (Action generator, denoted as A) predicts the next action (step, denoted as s) based on the task instruction x and the solution history h, and allocates a corresponding reasoning tool (tool, denoted as t) from a preset reasoning tool set; further, according to the specified reasoning tool, the corresponding expert model is called to perform the operation, and the output result is obtained specifically according to the task instruction x, the solution history h and the reasoning action s, so as to obtain a specific output at each step (rewrite the tool output in natural language as required), and update the solution status.
[0070] It should be noted that, considering the demand for real-time data, mathematical computing capabilities and code capabilities in actual situations, the reasoning tools in this embodiment specifically include pre-generated search tools Q, mathematical tools M, and code tools C; in addition, considering the basic knowledge and basic reasoning capabilities required in basic tasks, the reasoning tools also include common sense reasoning tools R, and each reasoning tool has a corresponding expert model. Among them, for the two tools, search tool Q and code tool C, their outputs are respectively the "questions" used for searching and the codes that can be executed by the code interpreter, and then the common sense reasoning tool R rewrites the results of the search engine and the results of the code execution, specifically rewriting them into natural language.
[0071] In this embodiment, there is no restriction on the generation and training process of the action generator and the reasoning tool, which depends on the specific implementation situation.
[0072] S13: Determine whether the final answer is determined in the entire solution history through the action generator; if not, generate a new solution history based on the solution history, reasoning actions and output results, and return to step S11; if yes, end.
[0073] After obtaining the output result corresponding to the previous step, it is necessary to further generate a new answer history based on the answer history, reasoning action and output result of the previous step, return to step S11, and predict the next reasoning action and the corresponding reasoning tool based on the task instruction and the answer history again through the pre-generated action generator, so as to obtain the next reasoning action and the corresponding reasoning tool. This process is repeated until the action generator A finds the final answer to the task instruction x from the entire answer history. In this way, the task instruction is solved.
[0074] In this embodiment, a unified large language agent framework is proposed. Based on task instructions and solution history, the task instructions are decomposed into a series of executable reasoning actions through a pre-generated action generator, and the reasoning tools corresponding to the reasoning actions are determined. Specifically, the task answers are abstracted into four reasoning tools, including search tools, mathematical tools, code tools, and common sense reasoning tools. Each tool corresponds to an expert model, which can reduce the problem of inaccurate tool calls due to too many tools when a large language model calls the tool; further, each reasoning action is executed by the reasoning tool until the termination state is reached to obtain the final answer, which solves complex multi-step reasoning tasks and significantly improves the general multi-step reasoning ability of the large language model.
[0075] Based on the above embodiments, in some embodiments, the specific process of generating the action generator and the reasoning tool includes:
[0076] S101: Generate a solution trajectory dataset for the integrated reasoning tool based on the teacher model;
[0077] S102: Generate a training data set for the action generator and a training data set for the reasoning tool according to the solution trajectory data set;
[0078] S103: Perform training according to the training data set of the action generator and the training data set of the reasoning tool respectively to generate the action generator and the reasoning tool.
[0079] In order to generate the action generator and the reasoning tool, in this embodiment, a solution trajectory dataset of the integrated reasoning tool is generated according to the teacher language model (Teacher LM). It should be noted that Teacher LM is an artificial intelligence model based on a large language model, which aims to provide education and guidance by simulating the role of a teacher. Teacher LM usually has the following characteristics: Teacher LM can understand and generate natural language, which enables them to interact with students, answer questions, provide feedback, etc.; Teacher LM usually contains a lot of knowledge and information, which enables them to provide accurate answers and guidance; Teacher LM can provide personalized learning content and suggestions according to students' needs and abilities; Teacher LM can support multiple languages, which enables them to provide services for students with different language backgrounds. In addition, the solution trajectory dataset contains intermediate processes, specifically including reasoning tool calls, output rewriting, etc. In this embodiment, there is no restriction on the type of teacher model specifically selected, and there is no restriction on the specific generation process of the solution trajectory dataset, which depends on the specific implementation situation.
[0080] After obtaining the solution trajectory dataset, the training dataset of the action generator and the training dataset of the reasoning tool are generated according to the solution trajectory dataset. Finally, the training is performed according to the training dataset of the action generator and the training dataset of the reasoning tool to generate the action generator and the reasoning tool. It can be understood that the training process is simplified and general, ensuring that the framework can handle a wide range of tasks rather than specific tasks. In addition, the training set of the open source dataset can be selected as the source of the training dataset, and the test set of the open source dataset can be used as the final test dataset to improve the test results.
[0081] In this embodiment, a solution trajectory dataset of an integrated reasoning tool is generated based on a teacher model; a training dataset of an action generator and a training dataset of a reasoning tool are generated respectively based on the solution trajectory dataset; training is performed based on the training dataset of the action generator and the training dataset of the reasoning tool respectively to generate an action generator and a reasoning tool, thereby realizing the training generation of the action generator and the reasoning tool to facilitate the answering of task instructions.
[0082] Based on the above embodiments, in some embodiments, generating a solution trajectory dataset of an integrated reasoning tool according to a teacher model includes:
[0083] S111: obtaining an input question based on the teacher model, and determining an operation step containing content to be executed according to the input question;
[0084] S112: Determine a corresponding reasoning tool according to the operation steps;
[0085] S113: Generate a solution based on a reasoning tool to obtain a solution trajectory dataset.
[0086] In order to generate a solution trajectory dataset, in this embodiment, the input problem is first obtained based on the teacher model. It should be noted that for the obtained input problem, it is necessary to combine step-by-step reasoning, mathematical problem solving, code, and search queries to obtain a solution to ensure that the next operation to be performed, the reasoning tool to be used, and the corresponding mathematical, code, search, or common sense reasoning solution are generated.
[0087] Therefore, the operation steps containing the content to be executed are determined based on the input question. It should be noted that for the operation steps containing the content to be executed, the first sentence in the operation steps should be a high-level abstract overview of what to do in this step, that is, the content to be executed, and it should start with a verb. For example, "search", "calculate", "derive", "determine", "find" or "identify", and end with a line break.
[0088] Further, the corresponding reasoning tool is determined according to the operation steps, and one of the search tool Q, the mathematical tool M, the code tool C, and the common sense reasoning tool R is specifically selected to generate a solution based on the reasoning tool, that is, a solution based on mathematics, a solution based on search, a solution based on code, or a solution based on common sense reasoning is returned, and finally a solution trajectory data set is obtained. In this embodiment, the specific process of determining the corresponding reasoning tool according to the operation steps is not limited.
[0089] In this embodiment, an input problem is obtained based on a teacher model, and the operation steps containing the content to be executed are determined according to the input problem; the corresponding reasoning tool is determined according to the operation steps; a solution based on the reasoning tool is generated, and finally a solution trajectory data set is obtained, so that a training data set of the action generator and a training data set of the reasoning tool are generated respectively through the solution trajectory data set.
[0090] Based on the above embodiments, in some embodiments, determining the corresponding reasoning tool according to the operation steps includes:
[0091] S121: Determine the content to be executed in the operation steps;
[0092] S122: When necessary information for mathematical calculation is provided in the content to be executed and the historical solution, determining that the reasoning tool is a mathematical tool;
[0093] S123: When unknown information exists in the content to be executed and cannot be answered based on existing information, determining that the reasoning tool is a search tool;
[0094] S124: When the to-be-executed content representation performs data processing, determining that the reasoning tool is a code tool;
[0095] S125: When the content to be executed represents processing of a general reasoning task, determining that the reasoning tool is a common sense reasoning tool.
[0096] In a specific implementation, in order to determine the reasoning tool, the content to be executed in the operation steps is first determined. When the content to be executed and the historical solution provide the necessary information for mathematical calculations, the reasoning tool is determined to be the mathematical tool M, and the mathematical tool M will be used for mathematical calculations in the future. When there is unknown information in the content to be executed and it cannot be solved based on the existing information, the reasoning tool is determined to be the search tool Q, so that the search tool Q is used to retrieve the unknown information. When the content to be executed represents data processing, such as performing precise numerical calculations, processing large numbers or decimals, and calculating long lists of numbers or performing operations between two different dates, the reasoning tool is determined to be the code tool C, and the code tool C is used to perform data processing. When the content to be executed represents the processing of general reasoning tasks, such as comparing the size of two numbers, the reasoning tool is determined to be the common sense reasoning tool R, and this task does not require the use of mathematical tools M, search tools Q or code tools C.
[0097] Accordingly, solutions based on reasoning tools are generated, including:
[0098] S131: When the reasoning tool is a mathematical tool and the content to be executed involves equation construction, define data parameter variables of the equation and output the final result of the operation step in a preset format;
[0099] S132: When the reasoning tool is a search tool, the search query result of the search tool is set between the row where the search engine information is located and the row where the separator is located;
[0100] S133: When the reasoning tool is a code tool, control the code tool to generate only one code snippet each time, and set the code snippet between the line where the programming language information is located and the line where the separator is located;
[0101] S134: When the reasoning tool is a common sense reasoning tool, control the common sense reasoning tool to set the answer to the operation step in the first label, and set the final answer to the input question in the second label.
[0102] Specifically, when the reasoning tool is a math tool M, and the content to be executed involves equation construction, define the data parameter variables of the equation. For example, do not write "Write an equation for the problem." Instead, write "Write an equation for the problem, using $x$ to represent the number of apples and $y$ to represent the number of oranges." At the same time, output the final result of the operation steps through a preset format. For example, use LaTeX's '\\boxed{}' format to present the final result of the step without adding any units. Use the 'pi' symbol and 'Rational' in sympy to represent $\pi$ and fractions, and simplify all fractions and square roots, and do not convert them to decimal values.
[0103] When the reasoning tool is the search tool Q, the search query result of the search tool Q is set between the line where the search engine information is located and the line where the separator is located, for example, written in the line between '```search engine information' and '```'.
[0104] When the reasoning tool is code tool C, control code tool C to generate only one code snippet each time, and set the code snippet between the line where the programming language information is located and the line where the separator is located. For example, when using python, write the code snippet in the line between '```python' and '```'. It should be noted that for code-based solutions, do not try to predict the execution output of the code, just write out the code; do not use undefined variables in the code snippet; if the variable is mentioned in an earlier code snippet, copy the value of the variable to the current code snippet.
[0105] When the reasoning tool is a common sense reasoning tool R, the common sense reasoning tool R is controlled to set the answer to the operation step in the first label and the final answer to the input question in the second label. <output> 'and'< / output> ' tag, if the final answer ANS has been obtained in the output of the previous step, simply return "The answer is: <answer> ANS< / answer> ” and place the final answer in <answer> and< / answer> Do not write units between tags.
[0106] In summary, the solution trajectory dataset of the integrated reasoning tool contains step si (i∈[1...]), as well as the tool ti of this step and its output oi. The dataset example and specific format are as follows. Step si is preceded by "Stepi", and tool ti is preceded by "Tool:ti", where ti∈{Q,M,C,R}. When ti∈{Q,C}, a search question qi and a code snippet ci containing the labels "search engine information" and "programming language information" are generated at the same time. The search question qi and the code snippet ci will be further executed by the search engine and the code interpreter, and the final output will be rewritten into natural language by the common sense reasoning tool. For ti∈{M,R}, the result does not need to be rewritten, so the output of the teacher model T is directly after ti. This step iteratively guides the teacher model to find the answer to the input x and labels it. <answer>The following example illustrates:
[0107] Question: If a map is designed with 1 square centimeter representing 100 square kilometers, then on this map of City 1 and City 2, how many square centimeters larger is City 1 than City 2? Round to the nearest integer.
[0108] Solution:
[0109] Step 1: Determine the area of city 1 (in square kilometers).
[0110] Tool: Search Tool Q
[0111] ```Search engine information
[0112] City 1 Area
[0113] ```
[0114] ```output
[0115] 16,410
[0116] ```
[0117] The area of City 1 is 16,410 square kilometers.
[0118] Step 2: Determine the area of City 2 (in square kilometers).
[0119] Tool: Search Tool Q
[0120] ```Search engine information
[0121] City 2 Area
[0122] ```
[0123] ```output
[0124] 6,341
[0125] ```
[0126] The area of City 2 is 6,341 square kilometers.
[0127] Step 3: Calculate the difference in area between city 1 and city 2 on the map.
[0128] Tool: Code Tool C
[0129] ```Python
[0130] #Define the area of the two cities
[0131] #Calculate the area of city 1 and city 2 on the map
[0132] # Calculate the difference in area on the map
[0133] ```output 10079
[0135] ```
[0136] The area of City 1 on the map is 10,079 square centimeters larger than that of City 2.
[0137] The answer is: <answer> 10079< / answer> .
[0138] Based on the above embodiments, in some embodiments, after generating a solution trajectory dataset of an integrated reasoning tool according to a teacher model, the method further includes:
[0139] S14: Based on the teacher model, the wrong answers in the solution trajectory data are deleted through regular expressions.
[0140] In specific implementations, the solution trajectory data of the integrated reasoning tool may contain incorrect final answers. Therefore, it is necessary to extract the final answers generated by the large model through regular expressions and compare them with the labels in the original data set to filter out the correct set of answers and remove the incorrect answers.
[0141] Based on the above embodiments, in some embodiments, a training data set for an action generator and a training data set for a reasoning tool are generated respectively according to a solution trajectory data set, including:
[0142] S141: Based on the solution trajectory dataset, data related to action generation is filtered through regular expressions and reorganized to obtain a training dataset for the action generator;
[0143] S142: Based on the solution trajectory dataset, data related to the reasoning process is filtered through regular expressions and reorganized to obtain a training dataset for the reasoning tool.
[0144] In the specific implementation, for the action generator A, the input of the i-th step includes the formatted task instruction x and the solution history hi-1, that is, {x}\n{hi-1}, and the output of the action generator A is [ti]si. The training dataset of the action generator A can be obtained by filtering and reorganizing the solution trajectory dataset of the integrated reasoning tool using regular expression matching. A simple example is shown below:
[0145] Question: Who was the first writer in country X to win the N Literature Award, and in which year did he win it?
[0146] Solution: Search tool Q to determine the first winner of N literature award in country X.
[0147] Furthermore, the inputs of the expert models of the search tool Q, the math tool M, and the code tool C are formatted task instructions x, history records hi, and actions si, and the outputs are search questions q, math solutions m, or code snippets c. In the above example, the output of search Q should be qi="Determine the first winner of the N literature award in country X." Similarly, the solution trajectory dataset of the integrated reasoning tool can be screened and reorganized using regular expression matching to obtain the training dataset of the search Q, math M, and code C expert models.
[0148] Finally, the four models of action generator A, search tool Q, math tool M, and code tool C are trained independently. The basic models can all choose the teacher model, or the code model can choose the open source model that has been fine-tuned on the code dataset. The original common sense reasoning ability of the model is good enough, so the common sense reasoning tool R can directly use the teacher model without fine-tuning. In order to save computing resources and video memory resources, the large language model low-rank adapter (Low-Rank Adaptation, LoRA) can be selected to fine-tune some parameters.
[0149] Based on the above embodiments, in some embodiments, the following further includes:
[0150] S15: Determine whether the final answer corresponding to the task instruction is correct; if it is confirmed that the final answer corresponding to the task instruction is correct, then end; if it is confirmed that the final answer corresponding to the task instruction is incorrect, then re-edit the task instruction, and perform the solution again based on the re-edited task execution.
[0151] In a specific implementation, after completing the solution to the task instruction, it can be determined whether the final answer corresponding to the task instruction is correct; if it is confirmed that the final answer corresponding to the task instruction is correct, the process ends. If it is confirmed that the final answer corresponding to the task instruction is incorrect, the task instruction is re-edited, and the solution is performed again based on the re-edited task execution, thereby eliminating the influence of incorrect task instruction input on the solution process.
[0152] In addition, the answers to different task instructions can be continuously monitored to obtain the answer accuracy of the large language model. When the answer accuracy is lower than a threshold, it is considered that the accuracy of the current large language model is low and the large language model needs to be retrained to ensure its accuracy.
[0153] In the above embodiments, the task solving method is described in detail. The present invention also provides a corresponding embodiment of the task solving device.
[0154] Figure 3 Schematic diagram of a task solving device provided by an embodiment of the present invention. Figure 3 As shown, the device comprises:
[0155] The acquisition module 10 is used to acquire the task instruction and the solution history corresponding to the task instruction; wherein the solution history includes the historical solution process and historical output results of the task instruction.
[0156] The prediction module 11 is used to predict the next reasoning action and the corresponding reasoning tool based on the task instructions and the solution history through a pre-generated action generator; wherein the reasoning tool includes a pre-generated search tool, a mathematical tool, a code tool and a common sense reasoning tool, and each reasoning tool has a corresponding expert model.
[0157] The reasoning module 12 is used to input task instructions, solution history and reasoning actions into the reasoning tool to obtain output results.
[0158] The judgment module 13 is used to judge whether the final answer is determined in the entire solution history through the action generator; if not, a new solution history is generated according to the solution history, reasoning actions and output results, triggering the prediction module 11, and if so, ending.
[0159] In some embodiments, the specific process of generating an action generator and a reasoning tool includes:
[0160] A solution trajectory dataset of an integrated reasoning tool is generated according to the teacher model; a training dataset of an action generator and a training dataset of a reasoning tool are generated according to the solution trajectory dataset; and training is performed according to the training dataset of the action generator and the training dataset of the reasoning tool to generate an action generator and a reasoning tool.
[0161] In some embodiments, a solution trajectory dataset of an integrated reasoning tool is generated based on a teacher model. Specifically, an input problem is obtained based on the teacher model, and the operation steps containing the content to be executed are determined based on the input problem; the corresponding reasoning tool is determined based on the operation steps; and a solution based on the reasoning tool is generated to obtain a solution trajectory dataset.
[0162] In some embodiments, the corresponding reasoning tool is determined according to the operation steps, and the content to be executed in the operation steps is specifically determined; when the content to be executed and the historical solution provide necessary information for mathematical calculations, the reasoning tool is determined to be a mathematical tool; when there is unknown information in the content to be executed and it cannot be solved based on the existing information, the reasoning tool is determined to be a search tool; when the content to be executed represents data processing, the reasoning tool is determined to be a code tool; when the content to be executed represents the processing of a general reasoning task, the reasoning tool is determined to be a common sense reasoning tool;
[0163] Correspondingly, a solution based on the reasoning tool is generated. Specifically, when the reasoning tool is a mathematical tool and the content to be executed involves equation construction, the data parameter variables of the equation are defined, and the final results of the operation steps are output in a preset format; when the reasoning tool is a search tool, the search query results of the search tool are set between the row where the search engine information is located and the row where the separator is located; when the reasoning tool is a code tool, the code tool is controlled to generate only one code snippet each time, and the code snippet is set between the row where the programming language information is located and the row where the separator is located; when the reasoning tool is a common sense reasoning tool, the common sense reasoning tool is controlled to set the answer to the operation step in the first label, and the final answer to the input question is set in the second label.
[0164] In some embodiments, it also includes:
[0165] The deletion submodule is used to delete the wrong answers in the solution trajectory data through regular expressions based on the teacher model.
[0166] In some embodiments, a training data set for an action generator and a training data set for a reasoning tool are generated respectively based on the solution trajectory data set. Specifically, based on the solution trajectory data set, data related to action generation is filtered through regular expressions and reorganized in format to obtain the training data set for the action generator; based on the solution trajectory data set, data related to the reasoning process is filtered through regular expressions and reorganized in format to obtain the training data set for the reasoning tool.
[0167] In some embodiments, it also includes:
[0168] The judgment submodule is used to judge whether the final answer corresponding to the task instruction is correct; if it is confirmed that the final answer corresponding to the task instruction is correct, the process ends; if it is confirmed that the final answer corresponding to the task instruction is incorrect, the task instruction is re-edited, and the solution is performed again based on the re-edited task execution.
[0169] Since the embodiments of the apparatus part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the apparatus part, which will not be repeated here.
[0170] Figure 4 FIG. 1 is a structural diagram of a task answering device provided by an embodiment of the present invention. Figure 4 As shown, the task solving device includes:
[0171] A memory 20, used for storing computer programs;
[0172] The processor 21 is used to implement the steps of the task solving method mentioned in the above embodiment when executing the computer program.
[0173] The task answering device provided in this embodiment may include but is not limited to a smart phone, a tablet computer, a laptop computer, or a desktop computer.
[0174] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of a digital signal processor (DSP), a field programmable gate array (FPGA), and a programmable logic array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in an awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 21 may be integrated with a graphics processing unit (GPU), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0175] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 20 is at least used to store the following computer program 201, wherein, after the computer program is loaded and executed by the processor 21, it can implement the relevant steps of the task solution method disclosed in any of the aforementioned embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 202 may include Windows, Unix, Linux, etc. Data 203 may include but is not limited to data related to the task solution method.
[0176] In some embodiments, the task answering device may further include a display screen 22 , an input / output interface 23 , a communication interface 24 , a power supply 25 , and a communication bus 26 .
[0177] Those skilled in the art will understand that Figure 4 The structure shown in the figure does not constitute a limitation of the task solving device, and may include more or less components than shown in the figure.
[0178] Finally, the present invention also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps recorded in the above method embodiment are implemented.
[0179] It is understandable that if the method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc. Various media that can store program codes.
[0180] The above is a detailed introduction to a task solving method, device, equipment and medium provided by the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, several improvements and modifications can be made to the present invention, and these improvements and modifications also fall within the scope of protection of the present invention.
[0181] It should also be noted that, in this specification, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, 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 statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.< / answer>
Claims
1. A task solving method, characterized in that: include: Obtaining a task instruction and obtaining a solution history corresponding to the task instruction; wherein the solution history includes a historical solution process and a historical output result of the task instruction; Based on the task instruction and the solution history, the next reasoning action and the corresponding reasoning tool are predicted by a pre-generated action generator; wherein the reasoning tool includes a pre-generated search tool, a mathematical tool, a code tool and a common sense reasoning tool, and each of the reasoning tools has a corresponding expert model; Inputting the task instruction, the solution history and the reasoning action into the reasoning tool to obtain an output result; Determine whether the final answer is determined in the entire solution history through the action generator; if not, generate a new solution history based on the solution history, the reasoning action and the output result, and return to the step of predicting the next reasoning action and the corresponding reasoning tool based on the task instruction and the solution history through the pre-generated action generator. If so, end.
2. The task solving method according to claim 1, characterized in that: The specific process of generating the action generator and the reasoning tool includes: generating a solution trajectory dataset integrating the reasoning tool according to the teacher model; Generating a training data set for the action generator and a training data set for the reasoning tool respectively according to the solution trajectory data set; Training is performed according to the training data set of the action generator and the training data set of the reasoning tool respectively to generate the action generator and the reasoning tool.
3. The task solving method according to claim 2, characterized in that: The step of generating a solution trajectory dataset integrating the reasoning tool according to the teacher model includes: Acquire an input question based on the teacher model, and determine an operation step containing content to be executed according to the input question; Determining the corresponding reasoning tool according to the operation steps; A solution based on the reasoning tool is generated to obtain the solution trajectory dataset.
4. The task solving method according to claim 3, characterized in that: Determining the corresponding reasoning tool according to the operation steps includes: Determine the content to be executed in the operation steps; When the content to be executed and the historical solution provide necessary information for mathematical calculation, determining that the reasoning tool is the mathematical tool; When there is unknown information in the content to be executed and it cannot be solved based on the existing information, determining that the reasoning tool is the search tool; When the to-be-executed content representation performs data processing, determining that the reasoning tool is the code tool; When the to-be-executed content represents processing of a general reasoning task, determining that the reasoning tool is the common sense reasoning tool; Correspondingly, generating a solution based on the reasoning tool includes: When the reasoning tool is the mathematical tool and the content to be executed involves equation construction, defining data parameter variables of the equation and outputting the final result of the operation step in a preset format; When the reasoning tool is the search tool, the search query result of the search tool is set between the row where the search engine information is located and the row where the separator is located; When the reasoning tool is the code tool, controlling the code tool to generate only one code snippet each time, and setting the code snippet between the line where the programming language information is located and the line where the separator is located; When the reasoning tool is the common sense reasoning tool, the common sense reasoning tool is controlled to set the answer to the operation step in the first label, and set the final answer to the input question in the second label.
5. The task solving method according to claim 2, characterized in that: After generating a solution trajectory dataset integrating the reasoning tool according to the teacher model, the method further includes: Based on the teacher model, wrong answers in the solution trajectory data are deleted by regular expressions.
6. The task solving method according to claim 2, characterized in that: The generating a training data set for the action generator and a training data set for the reasoning tool respectively according to the solution trajectory data set comprises: Based on the solution trajectory dataset, data related to action generation is filtered through regular expressions and reorganized to obtain a training dataset for the action generator; Based on the solution trajectory dataset, data related to the reasoning process is screened through regular expressions and reorganized to obtain a training dataset for the reasoning tool.
7. The task solving method according to any one of claims 1 to 6, characterized in that: Also includes: Determining whether the final answer corresponding to the task instruction is correct; If it is confirmed that the final answer corresponding to the task instruction is correct, then the task ends; If it is confirmed that the final answer corresponding to the task instruction is incorrect, the task instruction is re-edited, and the answer is performed again based on the re-edited task instruction.
8. A task solving device, characterized in that: include: An acquisition module, used to acquire a task instruction and acquire a solution history corresponding to the task instruction; wherein the solution history includes a historical solution process and a historical output result of the task instruction; A prediction module, used to predict the next reasoning action and the corresponding reasoning tool based on the task instruction and the solution history through a pre-generated action generator; wherein the reasoning tool includes a pre-generated search tool, a mathematical tool, a code tool and a common sense reasoning tool, and each of the reasoning tools has a corresponding expert model; A reasoning module, used for inputting the task instruction, the solution history and the reasoning action into the reasoning tool to obtain an output result; A judgment module is used to judge whether the final answer is determined in the entire solution history through the action generator; if not, a new solution history is generated according to the solution history, the reasoning action and the output result, and returns to the step of predicting the next reasoning action and the corresponding reasoning tool based on the task instruction and the solution history through the pre-generated action generator. If so, the process ends.
9. A task solving device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the task solving method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the task solving method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Question and answer method and device, electronic equipment and medium
CN117521625A
Information processing method and device based on large language model, storage medium and equipment
CN118093813A
Intelligent question and answer method and device, related equipment and computer program product
CN118132721A
Task-based dialogue method, storage medium and computer equipment
CN118245589A
Tool routing method and device
CN118246474A