CN-121980057-A - Large model multi-hop tool calling training data construction method based on subgraph backtracking
Abstract
The invention belongs to the technical field of artificial intelligence and natural language processing, and particularly relates to a large model multi-hop tool calling training data construction method based on subgraph backtracking, which comprises the steps of obtaining a large model callable tool to obtain a tool name, tool description, input and output parameter information; the method comprises the steps of constructing a tool graph which takes tools as nodes and has a dependency relationship between tool input and output as directed edges, sampling tool subgraphs which are different in tool quantity and have directed and loop-free functions from the constructed tool graph, traversing all the dependent edges in the tool subgraph according to the topological order of the subgraphs, generating subtask data corresponding to the dependency relationship by using a first large language model based on tool information connected with each edge, synthesizing all the generated subtasks into a complete natural language query by using a second large language model, and verifying the synthesized data and corresponding tool execution tracks to produce high-quality multi-hop tool learning data.
Inventors
- ZHANG XIAOYU
- WANG YI
- WU KEFENG
- SUN FUJUN
- LIU CHENGXIANG
Assignees
- 航天科工智能运筹与信息安全研究院(武汉)有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20251230
Claims (10)
- 1. The method for constructing the training data by calling the large model multi-hop tool based on subgraph backtracking is characterized by comprising the following steps of: step 1, acquiring a large model callable tool to obtain a tool name, tool description, input and output parameter information, constructing a tool graph with the tool as a node and the dependency relationship between the input and the output of the tool as a directed edge; step 2, sampling tool subgraphs with different tool numbers and directed acyclic from the constructed tool graph; traversing all dependent edges in the tool subgraph according to the subgraph topology sequence, and generating subtask data corresponding to the dependent relationship by using a first large language model based on tool information connected with each edge; step 4, synthesizing all the generated subtasks into a complete natural language query by using a second large language model; And 5, verifying the synthesized data and the corresponding tool execution track to produce high-quality multi-jump tool learning data.
- 2. The method for constructing training data for invoking large model multi-hop tools based on subgraph backtracking according to claim 1, wherein in step 1, tools available for invoking large model tools are collected, each available tool is abstracted to a node in the graph, and node information includes a tool name, a tool function description, input parameters and output parameters. If the output of the tool A is the input necessary for the execution of the tool B or the execution logic of the tool B depends on the result of the tool A, a directed edge A-B is established between the node A and the node B, the attribute information of the edge is the output parameter name of the tool A and the input parameter name of the tool B with dependence, and the directed edges existing in all the tools are judged according to the function description and the input-output description of each tool to construct a tool graph G.
- 3. The method for constructing training data by using the large model multi-hop tool call based on sub-graph backtracking as claimed in claim 1, wherein in the tool sub-graph sampling step of the step 2, when multi-hop sub-graphs including three or more nodes are sampled, a breadth-first search strategy based on topological ordering is adopted to traverse the tool graph, firstly, the number of tool nodes sampled this time is set, the nodes with zero degree are selected from the tool graph, namely, the tool nodes without prepositive dependence are gradually expanded outwards, the property of the sub-graph is ensured to keep the directed acyclic graph in each step until the preset number of tool nodes is reached, so that a tool sub-graph is obtained, the number of initial node tools is changed, and the process is repeated to obtain diversified tool sub-graphs.
- 4. The method for constructing training data by using large model multi-hop tool call based on sub-graph backtracking as claimed in claim 3, wherein the step2 samples different scale and directed acyclic tool sub-graphs from the constructed tool graph G, the sub-graphs are divided into two classes of one-hop sub-graph and multi-hop sub-graph according to the difference of hop count, and the method comprises the following steps: Step 2.1, a jump sub-graph is obtained by directly traversing all edges in the tool graph, namely each edge and nodes at two ends of each edge form a sub-graph comprising two tools; Step 2.2, traversing the tool graph by adopting a breadth-first search strategy based on topological sorting for multi-jump subgraphs comprising three or more nodes, firstly setting the number of tool nodes sampled at this time, selecting the node with zero degree from the tool graph, namely, the tool node without front dependency, expanding outwards gradually, ensuring that the subgraphs keep the property of the directed acyclic graph in each step until reaching the preset number of tool nodes, obtaining a tool subgraph up to the moment, changing the tool number of the initial nodes, repeating the process, and obtaining diversified tool subgraphs; and 2.3, inputting the generated tool description of each tool subgraph, the input and output parameter names of the dependent edges, the description thereof and the topological relation of the tool graph into a large language model, and judging whether the tool graph accords with the tool calling logic in actual use or not by the large language model, so that an effective multi-hop tool calling chain can be formed.
- 5. The method for constructing training data for a large model multi-hop tool call based on subgraph backtracking according to claim 4, wherein in the step 3 of generating subtask data, the process of generating subtasks is an inverse process of the simulated multi-hop tool call execution flow.
- 6. The method for constructing training data by invoking the large model multi-hop tool based on subgraph backtracking according to claim 5, wherein the step 3 includes the steps of: Step 3.1, for each sub-graph, extracting each directed edge in the sub-graph in turn according to the topological ordering order of the sub-graph, and marking as Each node in the subgraph is noted as ; Step 3.2 for the currently traversed edge Obtaining the tool nodes at the two ends of the edge And The method comprises the steps of establishing subtask tool call data based on the dependency relationship between two tools; step 3.3, inputting the collected tool information and the dependency relationship into a large language model, and providing a subtask generation prompt template The model is instructed to generate a subtask query corresponding to the current one of the dependent edges The subtask inquiry simulates conditions and observed intermediate results which need to be met for calling a subsequent tool after the precursor tool is executed in the multi-hop calling process, and the process is formally expressed as: a first language model for subtask generation is represented.
- 7. The method for constructing training data according to claim 6, wherein in the step of synthesizing and verifying the data in step 4 and step 5, when the complete query is synthesized, the prompt information provided to the second language model includes a dependency perception prompt for ensuring that parameters of the synthesized query maintain consistency and consistency in the multi-hop reasoning process.
- 8. The method for constructing training data by invoking the large model multi-hop tool based on subgraph backtracking as set forth in claim 6, wherein the multi-hop data of step 4 is synthesized by generating sub-task data for all edges of a subgraph and then sequencing the sub-tasks Edge dependency E, tool node set F and a data synthesis hint template Inputting the data into a large language model together, wherein the model is responsible for synthesizing all subtasks into complete, natural and smooth end user query data Q, the data synthesis prompt template is integrated with prompt of dependency relationship so as to ensure that parameters of synthesized query keep consistency and logic consistency in the whole multi-hop reasoning process, and the process is formally expressed as follows: A second language model for multi-hop data synthesis is represented. The final output multi-hop tool call data is a structured execution trace in the form of inference action generation (ReAct) that contains the composition of the natural language query question, subtask decomposition results, a "thinking-action-observation" sequence, and the final answer.
- 9. The method for constructing training data by using the large model multi-hop tool based on subgraph backtracking according to claim 8, wherein in the step 5 of generating data verification, the generated data is verified systematically, and the method comprises the steps of LLM auxiliary verification, automatic checking whether the tool is used correctly, whether the data flow follows the dependency edge or not and whether the reasoning process accords with tool operation logic or not by using a large language model, manual verification, and final generation of a named high-quality multi-hop tool learning data set by using the verification flow, wherein part or all of the generated data is subjected to manual verification to ensure high quality.
- 10. The method for constructing training data by invoking the large model multi-hop tool based on subgraph backtracking according to claim 9 is characterized in that the method ensures that the generated data has clear logic chains and accurate tool dependency relationship by starting from a real tool graph and adopting a reverse backtracking generation strategy, which is significantly superior to the traditional reverse instruction generation method.
Description
Large model multi-hop tool calling training data construction method based on subgraph backtracking Technical Field The invention belongs to the technical field of artificial intelligence and natural language processing, and particularly relates to a method for constructing training data by calling a large model multi-hop tool based on subgraph backtracking. Background With the development of Large Language Models (LLMs), their ability to use external tools (e.g., various types of databases, application Programming Interfaces (APIs), etc.) to accomplish complex tasks, i.e., tool learning, has become increasingly important. The multi-jump tool calling requirement model can decompose a complex problem into a plurality of subtasks, and sequentially call a plurality of tools according to a logical dependency relationship among the tools, and finally integrate results to solve the problem. Constructing a high-quality multi-hop tool call data set is a key for training an intelligent body model capable of conducting complex reasoning and having an autonomous solution to the problem. This requires that the query itself be multi-hop, i.e., the answer cannot be obtained directly through a single tool call. The model is required to make multi-step tool calls, information integration and logical reasoning. The data set should contain samples of different types, different numbers of tools to be called upon, and be able to perform tasks of different types, complexities. Therefore, how to quickly and accurately construct a high-quality multi-hop tool call training data set has higher practical value for improving the calling capability of the large-model multi-hop tool. The tool calling training data construction method commonly used at present adopts a reverse instruction strategy, namely, directly provides description information about calling tools for a large language model, and constructs and prompts the large language model to generate corresponding query data. Using this approach tends to cause problems in two ways: (1) Complicated dependency relations among tools in a multi-hop scene are difficult to capture fully, so that generated data are limited in quality, a logic chain is incoherent, and a model cannot be trained effectively to perform complicated multi-step reasoning. (2) Constructing data is costly and it is difficult to cover all possible tool combination dependent paths. Disclosure of Invention First, the technical problem to be solved The invention aims to solve the technical problem of providing a method for constructing large-model multi-jump tool call training data based on subgraph backtracking, which can systematically generate multi-jump tool call data with high quality and strong logic association by constructing a tool graph, sampling a directed acyclic tool subgraph, reversely generating subtask data by a large model and synthesizing the subtask data and verifying the subtask data, thereby effectively solving the problems of low quality and dependency loss of the generated data of the existing method. (II) technical scheme In order to solve the technical problems, the invention provides a large model multi-hop tool call training data construction method based on subgraph backtracking, which comprises the following steps: step 1, acquiring a large model callable tool to obtain a tool name, tool description, input and output parameter information, constructing a tool graph with the tool as a node and the dependency relationship between the input and the output of the tool as a directed edge; step 2, sampling tool subgraphs with different tool numbers and directed acyclic from the constructed tool graph; traversing all dependent edges in the tool subgraph according to the subgraph topology sequence, and generating subtask data corresponding to the dependent relationship by using a first large language model based on tool information connected with each edge; step 4, synthesizing all the generated subtasks into a complete natural language query by using a second large language model; And 5, verifying the synthesized data and the corresponding tool execution track to produce high-quality multi-jump tool learning data. In step 1, tools available for large model tool call are collected, each available tool is abstracted into a node in the graph, and node information includes a tool name, a tool function description, input parameters and output parameters. If the output of the tool A is the input necessary for the execution of the tool B or the execution logic of the tool B depends on the result of the tool A, a directed edge A-B is established between the node A and the node B, the attribute information of the edge is the output parameter name of the tool A and the input parameter name of the tool B with dependence, and the directed edges existing in all the tools are judged according to the function description and the input-output description of each tool to construct a tool graph G. In the tool sub