Data generation method, electronic device, readable storage medium and program product
By constructing a tool dependency graph and performing path enhancement operations, combined with large-scale model simulation of tool calls, the difficulty of generating training data for intelligent agents in complex scenarios is solved, enabling efficient batch generation of diverse tool call data and reducing manual costs.
Patent Information
- Application Number
- CN202511807529.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-03
- Publication Date
- 2026-01-09
AI Technical Summary
Existing technologies face difficulties in generating training data for intelligent agents in complex scenarios, rely on manual annotation which is costly, and struggle to generate data in batches for multi-round, multi-task tool calls.
Construct a tool dependency graph, enhance tool paths through merging, splitting, and insertion operations, generate task configuration information, and utilize large model simulation tools to generate dialogue trajectory data.
It enables efficient batch generation of training data for intelligent agents in complex scenarios, reduces manual costs, and improves the diversity and adaptability of data, making it suitable for various complex scenarios such as single-round single-task and independent multi-task.
Smart Images

Figure CN121303271A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, specifically to a data generation method, electronic device, readable storage medium, and program product. Background Technology
[0002] An agent is an agent that can perceive its environment and use tools to take actions to achieve specific goals. In mobile devices and other terminal devices, various agents can receive user commands and automatically execute them through tool invocation, helping users complete a wide variety of tasks. Training large-scale agent models requires a large amount of labeled data as a foundation.
[0003] Current data generation solutions focus on the execution of a single task in simple, single-turn scenarios, where the user issues only one instruction containing only one independent task. However, for complex scenarios, continuous dialogues, and continuous tasks, there is a lack of methods for batch data generation, and data generation relies too heavily on manual annotation, which is costly. This makes it very difficult to obtain training data for intelligent agents in complex scenarios, such as through tool calls, and the cost of building complex intelligent agents also increases accordingly. Summary of the Invention
[0004] This application provides a data generation method, electronic device, readable storage medium, and program product that can automatically generate tool call data such as dialogue trajectory data in complex scenarios without requiring manual task design or dialogue writing, thus significantly improving the efficiency and cost of batch production of complex scenario data.
[0005] In a first aspect, this application provides a data generation method, which includes: constructing a tool dependency graph corresponding to n tools, wherein the tool dependency graph is used to indicate the dependency relationship between each tool among the n tools, and the n tools are related to a task model; determining m tool paths according to the tool dependency graph; performing enhancement operations on the tool paths among the m tool paths to obtain p enhanced tool paths, wherein the enhancement operations include at least one of the following: merging operation, splitting operation, or insertion operation; obtaining s task configuration information corresponding to the p enhanced tool paths, where p is greater than or equal to s; obtaining s sets of dialogue trajectory data corresponding to the s task configuration information, and using the s sets of dialogue trajectory data as tool call data of the task model, wherein each set of dialogue trajectory data is generated based on the corresponding task configuration information through simulated task interaction, and n, p, and s are all positive integers.
[0006] As an example, the above task model can be implemented using an intelligent agent. Each task configuration corresponds to a tool path, and different task configurations correspond to different tool paths. For example, a single-round task could be to query the weather in city A. A complex task could be to query the weather in both city A and city B, and then query the navigation route to location B1 in city B.
[0007] Thus, the tool dependency graph constructed in this application can cover various scenarios such as single tool calls and multi-tool collaborative calls, avoiding data limitation to a single tool's usage scenario. Furthermore, by enhancing the selected tool paths, the diversity of tool paths can be further expanded, adapting to various complex scenarios such as single-turn single-task, independent multi-task, nested tasks, multi-turn dependencies, tool inheritance, and parameter inheritance. In addition, this application can simulate task interactions to generate corresponding dialogue trajectory data for each task configuration information, reducing the implementation cost of tool execution and improving scalability. In this way, tool call data such as dialogue trajectory data for complex scenarios can be automatically generated without manual task design and dialogue writing, significantly improving the efficiency and cost of batch production of complex scenario data.
[0008] In one possible implementation of the first aspect above, the enhancement operation includes a merging operation. The tool path enhancement operation includes: selecting the tool at step h and the tool at step h+1 from the tool path, merging the tool at step h and the tool at step h+1 into one tool, and obtaining the enhanced tool path, where h is a positive integer.
[0009] It can be understood that when an electronic device performs a tool path merging operation, it merges tools from two adjacent steps and moves subsequent tools forward one step at a time, reducing the path length by 1. In this case, p equals m minus 1. For example, it merges the tool at step h (randomly selected) and step h+1 (randomly selected) into a new tool at step h, and moves the tools at each step after step h forward one step. Thus, more complex and diverse tool paths can be obtained through merging operations.
[0010] In one possible implementation of the first aspect above, the enhancement operation includes a splitting operation. The tool path enhancement operation includes: selecting the tool at step h from the tool path, inserting the same tool as the tool at step h after the tool at step h, and obtaining the enhanced tool path, where h is a positive integer.
[0011] It's understandable that when electronic devices split tool paths, they can copy the target tool and insert it into the next step, shifting subsequent tools one step forward, and increasing the path length by 1 (i.e., p equals m plus 1). For example, a tool randomly selected at step h in the tool path can be inserted into the next step, and all tools after step h before the split can be shifted one step forward. Splitting operations are suitable for scenarios requiring repeated data verification. Therefore, splitting operations can yield more complex and diverse tool paths.
[0012] In one possible implementation of the first aspect above, the enhancement operation includes an insertion operation. The tool path is enhanced by: selecting the tool at step h from the tool path, selecting the tool associated with the tool at step h from the tool dependency graph, and inserting the tool associated with the tool at step h after the tool at step h to obtain the enhanced tool path, where h is a positive integer.
[0013] It is understandable that when electronic devices perform a tool path insertion operation, they can insert associated tools after the target tool based on the tool dependency graph, and increment the path length by 1. Thus, more complex and diverse tool paths can be obtained through insertion operations.
[0014] In one possible implementation of the first aspect described above, the first tool in the tool dependency graph has a dependency relationship with the second tool, and the first tool and the second tool satisfy at least one of the following conditions: the first tool is executed before the second tool is executed; the output information of the first tool is the same as the input information required by the second tool; the output information of the first tool is a subset of the input information required by the second tool. For example, the tool dependency graph includes a set of nodes and a set of directed edges, where each node represents a tool, and a directed edge is an edge from one tool to another (such as a line segment with an arrow), in which case the tool has a dependency relationship with the other tool.
[0015] In one possible implementation of the first aspect above, determining m tool paths based on the tool dependency graph includes: determining the m tool paths using a random walk strategy based on the tool dependency graph; wherein the walk strategy includes a maximum number of walks and / or a maximum number of paths, and in each of the m tool paths, the preceding tool has a dependency relationship with the following tool, the number of tools in each tool path is less than or equal to the maximum number of walks, and the value of m is less than or equal to the maximum number of paths. Thus, a relatively complex tool dependency graph can be generated using the random walk strategy.
[0016] In one possible implementation of the first aspect described above, obtaining the enhanced p tool paths and corresponding s task configuration information includes: obtaining p task configuration information corresponding to the p tool paths, wherein each task configuration information includes: task objective, tool invocation scope, and external information required by the task; performing a verification operation on the p task configuration information to obtain s task configuration information that meets the verification conditions, wherein the verification operation includes at least one of the following: format verification, executability verification, large model judge scoring verification, or summary feedback verification, and the verification conditions include: the task objective, tool invocation information, and external information required by the task configuration information are consistent. This improves the accuracy of the verified s task configuration information.
[0017] In one possible implementation of the first aspect described above, the dialogue trajectory data corresponding to the task configuration information is obtained through the following method: based on the task objective in the task configuration information, the task model is controlled to generate dialogue content based on dialogue prompts; the task model is controlled to generate tool call content corresponding to the dialogue content; based on execution prompts, the task model is controlled to generate simulated tool call results corresponding to the tool call data; and based on the dialogue content, tool call content, and simulated tool call results, the dialogue trajectory data corresponding to the task configuration information is obtained. Thus, this application can perform large-scale model simulation execution of tasks and simulate tool calls using a large model, reducing the implementation cost of tool execution and improving scalability. Furthermore, by simulating dialogue and the tool call process and results using a large model, the authenticity of the dialogue content is ensured, solving the problem of difficulty in batch generating multi-turn, multi-task tool call data.
[0018] In one possible implementation of the first aspect described above, the execution prompt is related to the corresponding tool documentation and tool call content of the task model.
[0019] In a second aspect, this application provides an electronic device, including: one or more processors; one or more memories; the one or more memories storing one or more programs, which, when executed by one or more processors, cause the electronic device to perform the methods described in the first aspect and any possible implementation thereof.
[0020] Thirdly, this application provides a computer-readable storage medium storing instructions that, when executed on a computer, cause the computer to perform the methods described in the first aspect and any possible implementation thereof.
[0021] Fourthly, this application provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the code detection method described in the first aspect above and any possible implementation thereof.
[0022] The beneficial effects of the second to fourth aspects mentioned above can be referred to the relevant descriptions in the first aspect and various possible implementations of the first aspect, which will not be repeated here. Attached Figure Description
[0023] Figure 1 The diagram shown is a structural schematic of a data generation device 10 provided in an embodiment of this application.
[0024] Figure 2 The diagram shown is a flowchart illustrating a data generation process provided in an embodiment of this application.
[0025] Figure 3 The diagram shown is a flowchart of a data generation method provided in an embodiment of this application.
[0026] Figure 4 The diagram shown is a schematic of a tool path generation process provided in an embodiment of this application.
[0027] Figure 5A The diagram shown is a scenario illustration of a tool path merging operation provided in an embodiment of this application.
[0028] Figure 5B The diagram shown is a scenario illustration of a tool path splitting operation provided in an embodiment of this application.
[0029] Figure 5C The diagram shown is a scenario illustration of a tool path insertion operation provided in an embodiment of this application.
[0030] Figure 6 The diagram shown is an interactive scenario of a user intelligent agent, an assistant intelligent agent, and a tool intelligent agent provided in an embodiment of this application.
[0031] Figure 7 The figure shown is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0032] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions in the embodiments of this application will be described in detail below with reference to the accompanying drawings and specific implementation methods.
[0033] It should also be stated that the steps in the methods and processes in this application are numbered for ease of reference, not to limit the order of steps. If there is an order between the steps, the textual description shall prevail.
[0034] To facilitate understanding of the solutions in the embodiments of this application by those skilled in the art, some concepts and terms involved in the embodiments of this application will be explained below.
[0035] 1. An intelligent agent is an agent that can perceive its environment and use tools to take action to achieve a specific goal. In the field of artificial intelligence (AI), an intelligent agent can also be called an AI intelligent agent, which is a closed-loop AI system that integrates perception, memory, reasoning, and action capabilities.
[0036] Key components of an intelligent agent include: Large Language Model (LLM), Tools, Memory, and Planning.
[0037] Large language models, acting as the brain of intelligent agents, are used to understand, reason, and generate content, and are the core of decision-making capabilities.
[0038] Tools are used to extend the capabilities of intelligent agents, such as calling calculators, online search tools, and application programming interfaces (APIs), to help intelligent agents complete specific tasks.
[0039] Memory includes short-term memory and long-term memory. Short-term memory is used to store the context of the current session, while long-term memory is used to store key information for future use, enabling agents to conduct coherent multi-turn interactions.
[0040] For complex tasks, intelligent agents can break them down into multiple sub-steps and execute them sequentially or in parallel to achieve the final goal.
[0041] 2. Tool documentation is a standardized document that describes the tool's functions, calling methods, parameter requirements, return results, and other information. Common formats include Markdown, PDF, API documentation, etc.
[0042] As an example, the tool documentation includes: tool name and function description, calling interface (such as API endpoint), parameter list (including required / optional parameters, data type, and example value), return result structure and interpretation method, and exception handling rules (such as rules for handling parameter errors and call failures).
[0043] As mentioned earlier, current data generation solutions focus on single tasks in simple, single-round scenarios, while acquiring training data for agents in complex scenarios is difficult and costly.
[0044] To address this, this application provides a data generation method that efficiently produces high-quality, comprehensive tool call data for intelligent agents adapted to complex scenarios, while reducing manual costs and supporting the training of intelligent agents in complex scenarios. Specifically, the method constructs a tool dependency graph corresponding to multiple tools in a tool library. This tool dependency graph indicates the dependencies between various tools, and the tool library is associated with a task model. Then, based on the tool dependency graph, one or more tool paths are determined, and enhancement operations are performed on these tool paths to obtain one or more enhanced tool paths. For example, the enhancement operations include at least one of merging, splitting, or inserting operations. Subsequently, task configuration information corresponding to each enhanced tool path can be obtained, followed by a set of dialogue trajectory data corresponding to each task configuration information. Finally, each set of dialogue trajectory data is used as tool call data for the task model, wherein each set of dialogue trajectory data is generated based on simulated task interaction using the corresponding task configuration information.
[0045] As an example, the above task model can be implemented using an intelligent agent. Each task configuration corresponds to a tool path, and different task configurations correspond to different tool paths.
[0046] For example, a single-round task could be to query the weather in city A. A complex task could be to query the weather in both city A and city B, and then query the navigation route to location B1 in city B.
[0047] Thus, the tool dependency graph constructed in this application can cover various scenarios such as single tool calls and multi-tool collaborative calls, avoiding data limitation to a single tool's usage scenario. Furthermore, by enhancing the selected tool paths, the diversity of tool paths can be further expanded, adapting to various complex scenarios such as single-turn single-task, independent multi-task, nested tasks, multi-turn dependencies, tool inheritance, and parameter inheritance. In addition, this application can simulate task interactions to generate corresponding dialogue trajectory data for each task configuration information, reducing the implementation cost of tool execution and improving scalability. In this way, tool call data such as dialogue trajectory data for complex scenarios can be automatically generated without manual task design and dialogue writing, significantly improving the efficiency and cost of batch production of complex scenario data.
[0048] In some embodiments, the task model provided in this application includes an intelligent agent, which can be implemented by an independent third-party application, or deployed in a system application such as a voice assistant or system interaction application (such as Xiaoyi See the World), or implemented by a cloud service, without specific limitations.
[0049] In other embodiments, the task model provided in this application includes an interaction service and an intelligent agent. The intelligent agent can be implemented by a separate third-party application, or deployed in a system application such as a voice assistant or system interaction application (e.g., Xiaoyi's World), or implemented by a cloud service; no specific limitation is made. As an example, the interaction service and the intelligent agent can be deployed in the same application, such as both being deployed in a system interaction application. As another example, the interaction service and the intelligent agent can be deployed in different applications, such as the interaction service being deployed in a voice assistant, while the intelligent agent is deployed in a separate third-party application.
[0050] In some embodiments, the electronic devices applicable to this application may be mobile phones, smart screens, tablets, wearable devices, in-vehicle devices (also known as vehicle-mounted systems), drone devices, augmented reality (AR) devices, virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), interactive robots, servers, etc. This application does not impose any restrictions on the specific type of electronic device.
[0051] In some embodiments, the above-mentioned electronic device may provide an interaction entry point for the intelligent agent represented by the task model. For example, the terminal device may have a third-party application or system application that supports the task model installed. This application embodiment does not specifically limit this.
[0052] It is understood that the entity executing the data generation method in the embodiments of this application can be an electronic device or a device (denoted as a data generation device) or module in the electronic device for executing the data generation method. As an example, the electronic device in the embodiments of this application may be equipped with an intelligent agent represented by the task model described above.
[0053] Reference Figure 1 This is a data generation apparatus 10 provided in an embodiment of this application. For example... Figure 1 As shown, the data generation device 10 includes a relationship generation module 11, a path generation module 12, a path enhancement module 13, a configuration generation module 14, a configuration verification module 15, and a dialogue trajectory collection module 16.
[0054] The relationship generation module 11 is used to generate a tool dependency graph corresponding to multiple tools, which indicates the dependency relationships between these tools. For example, the relationship generation module 11 can generate a tool dependency graph between multiple tools contained in a tool document library corresponding to a task model. For example, the tool document library corresponding to the task model includes tools called by the agent to perform a single task or multiple tasks.
[0055] The tool documentation library is a collection of documentation related to tools that can be called by intelligent agents. It covers the tool calling methods, parameter configurations, function introductions, etc., so that developers can integrate tools or users can understand the purpose of the tools.
[0056] The path generation module 12 is used to generate multiple tool paths from the tool dependency graph, for example, by generating multiple tool paths corresponding to the tool dependency graph according to a random walk strategy. Here, a tool path refers to one or more paths that call tools.
[0057] The path enhancement module 13 is used to perform enhancement operations such as merging, splitting, or enhancing on the generated multiple tool paths to obtain enhanced tool paths.
[0058] The configuration generation module 14 is used to generate corresponding task configuration information for each of the generated tool paths, such as the enhanced tool paths. It can be understood that in the intelligent agent development framework, the task configuration information for a tool path can be specified through configuration files or code parameters to define the tool's storage path, invocation path, and bind the task's execution rules, collaboration logic, and other content.
[0059] The configuration verification module 15 is used to verify the task configuration information of each tool path, so as to verify whether the task target, tool call information and external information required by the task in the task configuration information are consistent.
[0060] The dialogue trajectory collection module 16 is used to simulate task interaction on the task configuration information of each tool path (such as the verified task configuration information) to generate dialogue trajectory data corresponding to each task configuration information.
[0061] In some embodiments, the dialogue trajectory collection module 16 described above can be implemented based on an agent in the task model, for example by employing agents with different roles.
[0062] Among them, the roles of intelligent agents can be mainly categorized as follows: user intelligent agents, assistant intelligent agents, and tool intelligent agents.
[0063] The user agent simulates a real user, organizing its discourse according to the intent in the task configuration, proposing task requests, providing necessary information, and engaging in multi-turn dialogues with the assistant agent. The user agent can provide interaction objects for the assistant agent, simulating the user request initiator in a real scenario, and driving the generation of the dialogue trajectory.
[0064] The assistant agent interacts with the user agent to determine whether a tool needs to be invoked. If a tool is needed, it outputs the tool invocation command and interacts with the tool agent to obtain the result. If the user's needs are unclear or information is missing, it asks follow-up questions to clarify the situation. Specifically, the assistant agent acts as a bridge between the user and the tool, performing task planning, tool scheduling, and information integration. It is a core player in the logical progression of the dialogue.
[0065] The tool agent receives tool invocation instructions from the assistant agent and simulates the tool invocation result based on the tool documentation, invocation content, and parameters. Specifically, the tool agent can simulate the function of a real tool, providing feedback to the assistant agent on task execution, thus creating a complete closed loop from requirement to result in the dialogue.
[0066] As an example, for a single-round task "Check the weather," the data exchanged between the user agent and the assistant agent includes data in the following format (e.g., JSON format): [{"role": "user","content": "Check the weather in city A for me"},{"role": "assistant","content": "[{"name": "Get Weather", "parameter": {"location": "city A"}}]"}]. In the above data, the user agent's input text is "Check the weather in city A for me," and the assistant agent's input content is the name of the "Get Weather" tool, with the input parameter being the location information "city A." Therefore, the assistant agent can use the "Get Weather" tool to query the weather in city A and return the query results.
[0067] As an example, for the multi-turn task "Check the weather and navigate", the data exchanged between the user agent and the assistant agent includes data in the following format (such as JSON format): "[{"role": "user","content": "Check the weather for city A and city B for me"},{"role": "assistant","content": "[{"name":'Get Weather', 'parameter': {'location': 'city A'}}, {"name": 'Get Weather', 'parameter': {'location': 'city B'}}]"},{"role":"user","content": "Navigate to location A1 for me"},{"role": "assistant","content": "[{"name": 'navigation', 'parameter': {'departure point': '', 'destination': 'location A1'}}]"}]". In the first round of tasks, the user agent's input text was "Check the weather in cities A and B," while the assistant agent's input was the name of the "Get Weather" tool, along with the location information "City A" and "City B." The assistant agent could then use the "Get Weather" tool to check the weather in cities A and B and return the results. In the second round of tasks, the user agent's input text was "Navigate me to location A1," while the assistant agent's input was the name of the "Navigation" tool, along with the location information "Starting Point" and "Destination A1." The assistant agent could then use the "Navigation" tool to find a navigation route from the starting point to location A1 and return the results.
[0068] In some other embodiments, the data generation device 10 may not include the configuration verification module 15, or the data generation device 10 may not include the path enhancement module 13, etc. The embodiments of this application do not make specific limitations in this regard.
[0069] Furthermore, in Figure 1 Based on the data generation apparatus 10 shown, the data generation process provided in the embodiments of this application will be described. For example... Figure 2 The diagram shown is a flowchart illustrating a data generation process provided in an embodiment of this application. Specifically, the process first generates a tool dependency graph based on a tool document library. This dependency graph includes tools for "querying user information," "querying order information," "querying logistics information," "exchanging goods," "querying product information," and "placing an order." At this point, the tool document library contains... Figure 2The tool-related content is shown. Then, a random walk approach is used to generate one or more tool paths between tools in the tool dependency graph. These tool paths can be enhanced to obtain enhanced tool paths. Next, a large model is used to generate task configurations for each enhanced tool path, and the generated task configuration information is validated to obtain validated task configuration information. Finally, based on the task configuration information, the large model acts as both user and assistant, simulating multi-party interactions during tool calls and collecting dialogue trajectories. Here, the aforementioned large model refers to the large model used by the intelligent agent, such as... .
[0070] Next, refer to Figure 3 The flow of the data generation method provided in this application embodiment will be described, taking an electronic device equipped with the aforementioned data generation device 10 as an example. Specifically, the flow includes the following steps:
[0071] S301: The electronic device constructs a tool dependency graph corresponding to n tools, wherein the tool dependency graph is used to indicate the dependency relationship between each tool among the n tools, and the n tools are related to the task model.
[0072] Where n is a positive integer. For example, the tool dependency graph above can be: Figure 2 The tool dependency graph shown represents the various tools in the scenario.
[0073] In some embodiments, a first tool in the tool dependency graph has a dependency relationship with a second tool. For example, the first tool and the second tool can be two tools that are called sequentially. Furthermore, the first tool and the second tool satisfy at least one of the following conditions: the first tool is executed before the second tool; the output information of the first tool is the same as the input information required by the second tool; or the output information of the first tool is a subset of the input information required by the second tool.
[0074] As an example, for the tool library All tools Based on whether a dependency relationship exists between any two tools, a tool dependency graph is constructed. This tool dependency graph is a directed graph. The definition of a tool dependency relationship is: if tools... tools For a dependency relationship to exist, one of the following conditions must be met: 1) Tools It is a tool Prerequisites for execution (i.e., tools) In the execution tool (Previously executed); 2) Tools The output information, and the tool The required input information is exactly the same; 3) Tools The output information is the tool A subset of the required input information. For example, refer to Figure 2 The scene shown, tools This is a tool for "querying user information". When querying order information, the tool and tools (1) The above conditions must be met.
[0075] For example, a successfully constructed tool dependency graph is represented by the following formula (1).
[0076] (1) (2) (3)
[0077] Among them, in formula (1) This represents the set of nodes in a tool dependency graph, where each node represents a tool. For example, This can be expressed by the above formula (2), Each represents a tool. Furthermore, in formula (1)... This represents the set of all directed edges in the tool dependency graph. For example, This can be expressed by the above formula (3), Representation tools From the node to the tool The directed edge of the node.
[0078] Understandable. The directed edges are represented as tools. To tools The edge (such as a line segment with an arrow), at this time the tool tools There is a dependency relationship.
[0079] As an example, combined Figure 2 The tool dependency graph in the scene shown, tools and tools These can be two tools: one for "Querying Order Information" and the other for "Querying User Information." In this case, the directed edge (the line segment with the arrow) pointing from the node containing the "Querying User Information" tool to the node containing the "Querying Order Information" tool is the tool. From the node to the tool The directed edge of the node.
[0080] S302: The electronic device determines m tool paths based on the tool dependency graph.
[0081] Where m is less than or equal to n, and m is a positive integer.
[0082] In some embodiments, the electronic device can determine m tool paths using a random walk strategy based on a tool dependency graph. The walk strategy includes a maximum number of walks and / or a maximum number of paths. Furthermore, in each of the m tool paths, the preceding tool has a dependency relationship with the following tool, the number of tools in each tool path is less than or equal to the maximum number of walks, and the value of m is less than or equal to the maximum number of paths.
[0083] For a tool dependency graph, a tool execution path can be obtained by starting from any initial node and using a random walk strategy. Assume that for the tool... The tool of the node is represented by the following formula (4) among all its neighboring nodes.
[0084] (4)
[0085] In formula (4), k is a positive integer, and in formula (4)... For tools Tools in the neighboring nodes.
[0086] As an example, combined Figure 2 The tool dependency graph in the scene shown is referenced. Figure 4 The diagram illustrates a tool path generation process. Figure 4 As shown, assuming tools The node in question is the same as the node containing the "Query User Information" tool. If the node is the initial node, then its neighboring nodes include the node where the "Query Order Information" tool is located and the node where the "Query Product Information" tool is located. If the node where the "Query Order Information" tool is located is the initial node, then its neighboring nodes include the node where the "Query Logistics Information" tool is located and the node where the "Exchange" tool is located.
[0087] So, from the tools The random walk performed by the current node involves randomly selecting a node from all its neighbors as the next node to move to. At this point, the tool... The next node after the current node is represented by the following formula (5).
[0088] (5)
[0089] Furthermore, regarding tools The node that starts the random walk can be combined with all the nodes visited by limiting the maximum number of walks H. This can be used to obtain a walk path that starts from the initial node, which is the tool path (or tool execution path). .in, Each represents a node.
[0090] As an example, refer to Figure 4 As shown, a tool path can be constructed from the node containing the "Query User Information" tool, through the "Query Order Information" tool, to the node containing the "Exchange" tool. These three nodes can then be denoted as nodes. ,node and nodes The path to this tool can be remembered as follows: .
[0091] In some embodiments, the content of a tool includes its name, description, and parameters. In this case, the tool path can be represented according to a set data format (such as JSON data format), and the tool path includes the content of each tool. The tool name clearly defines the tool's function, such as "query user information," "query order information," or "exchange goods," allowing the agent to quickly identify the tool's purpose. The tool description information supplements the description of the tool's applicable scenarios and boundaries, helping the agent determine when to invoke the tool. The tool parameter configuration defines the parameters that need to be passed when the tool is invoked (such as user ID, order number, reason for exchange, etc.), ensuring that the tool can accurately execute tasks.
[0092] As an example, the above tool path It can be represented by the following data format: [{"name":"Query User Information","description": "……","parameters": "……"},{"name": "Query Order Information","description": "……","parameters": "……"},{"name": "Exchange","description": "……","parameters": "……"}].
[0093] S303: The electronic device performs enhancement operations on the tool paths among the m tool paths to obtain p enhanced tool paths.
[0094] The enhancement operations include at least one of the following: merge, split, or insert operations. Therefore, by enhancing the toolpath, more complex and diverse toolpaths can be obtained.
[0095] In some embodiments, the electronic device can select the tool at step h and the tool at step h+1 from the tool path, and merge the tool at step h and the tool at step h+1 into one tool to obtain an enhanced tool path, where h is a positive integer. In this case, the electronic device performs a merging operation on the tools in the tool path. Here, h+1 is less than or equal to p.
[0096] It can be understood that when an electronic device performs a tool path merging operation, it merges tools from two adjacent steps and moves subsequent tools forward one step at a time, reducing the path length by 1. In this case, p equals m minus 1. For example, it merges the tool at step h (randomly selected) and the tool at step h+1 (randomly selected) into a new tool at step h, and moves the tools at each step after step h forward one step.
[0097] As an example, for a merge operation, a tool at a certain step (such as step h) in the tool path is randomly selected and merged with the tool at the next step (such as step h+1) into the same step. Then, the tool at step h after the merge operation can be represented by formula (6), and the tools at each step after step h after the merge operation can be represented by formula (7).
[0098] (6) (7)
[0099] In formulas (6) and (7), h and y are both positive integers, and in formula (7) This represents the tool at step y after the tool path has undergone the merge operation. At this point, step y is the step after step h.
[0100] As an example, with Figure 4 toolpath shown For example, refer to Figure 5A As shown, for nodes Perform a merge operation to obtain the merged node. At this point, the node after the merge operation... Simultaneously invoke two tools: the "Query User Information" tool and the "Query Order Information" tool, and also include nodes. This is the second step in the new path. At this point, m is 3 and p is 2. The tool for step h is the node. Tools.
[0101] In some embodiments, the tool at step h is selected from the tool path, and an identical tool is inserted after the tool at step h, resulting in an enhanced tool path. At this point, the electronic device performs a splitting operation on the tools in the tool path.
[0102] It's understandable that when an electronic device splits a tool path, it can copy the target tool and insert it into the next step, moving subsequent tools one step forward, and increasing the path length by 1 (i.e., p equals m plus 1). For example, it can randomly select the tool at step h in the tool path and insert it into the next step, while moving all tools after step h before the split one step forward. This splitting operation is suitable for scenarios where data needs to be repeatedly validated.
[0103] As an example, for a split operation, a tool for a certain step (such as step h) is randomly selected in the tool path and inserted into the next step. Then, the tool for step h+1 after the split operation can be represented by formula (8), and the tools for each subsequent step after the split operation can be represented by formula (9).
[0104] (8) (9)
[0105] As an example, with Figure 4 toolpath shown For example, refer to Figure 5B As shown, for nodes Perform an insertion operation to obtain the node after the insertion operation. At this point, the node after the insertion operation... and nodes It contains the same tools (such as tools for querying user information). Furthermore, the nodes after the insertion operation... Including the "Query Order Information" tool, node This includes the "exchange" tool. At this point, m is 3, p is 4, and the tool in step h is the same as the node in step one. Tools.
[0106] In some embodiments, after selecting the tool at step h from the tool path, a tool associated with the tool at step h is selected from the tool dependency graph, and a tool associated with the tool at step h is inserted after the tool at step h, resulting in an enhanced tool path. At this point, the electronic device performs the tool insertion operation in the tool path.
[0107] It is understandable that when an electronic device inserts a tool path, it can insert a related tool after the target tool based on the tool dependency graph, and the path length is increased by 1.
[0108] As an example, for a splitting operation, select a step in the tool path, and for that step, the tool... (i.e., the tool in step h), randomly select an associated tool from the tool dependency graph. Insert it after the tool in this step. Then, the tool in the h-th step after the insertion operation can be represented by formula (10).
[0109] (10)
[0110] As an example, with Figure 4 toolpath shown For example, refer to Figure 5C As shown, for nodes Perform the split operation, select Figure 2 The "Query Product Information" tool is shown, and this "Query Product Information" tool is inserted into the node. In the middle. So, the nodes after the split operation... Simultaneously calling two tools, namely the "Query User Information" tool and the "Query Product Information" tool. At this point, both m and p are 2, and the tools... and tools They are nodes The tools in the system include the "Query User Information" tool and the "Query Product Information" tool.
[0111] S304: The electronic device obtains the configuration information of s tasks corresponding to the enhanced p tool paths.
[0112] Where s is less than or equal to p, and s is a positive integer.
[0113] In some embodiments, the electronic device obtains p task configuration information corresponding to p tool paths; then, it performs a verification operation on the p task configuration information to obtain s task configuration information that meets the verification conditions. This improves the accuracy of the verified s task configuration information.
[0114] Each task configuration includes: task objective, tool invocation scope, and external information required by the task.
[0115] As an example, an electronic device can generate prompts using configuration based on tool path information, and a large model can generate task configuration information. The task configuration information is represented by the following formula (11).
[0116] (11)
[0117] The task configuration information includes three parts. An Intent, or task objective, describes the goal that the task needs to achieve. It can contain one or more objectives and provides any other possible requirements and limitations. Actions, or tool invocations, are a set of tool calls that need to be executed to achieve the Intent's objective. Each tool call includes the tool name and tool parameters. Outputs represent the external information required by the task. They are a set of information containing all the external information needed by the task, including query results, parameter values required by tool calls, etc.
[0118] In some embodiments, the task configuration information of the tool path in this application can be represented by a set data format (such as JSON format).
[0119] As an example, the above tool path The corresponding task configuration information can be represented in the following data format, such as JSON: {"Intent": "You purchased a mobile phone on a shopping platform and want to exchange it","Operation": [{"Name": "Query User Information","Parameters": {...}},{"Name": "Query Order Information","Parameters": {...}},{"Name": "Exchange","Parameters": {...}}],"Output": [...]}. Here, the task objective is "You purchased a mobile phone on a shopping platform and want to exchange it," the tool invocation scope represents actions including the "Query User Information" tool and the "Exchange" tool, and the external information required by the task is the output content, such as the queried user information and the exchange address.
[0120] In some embodiments, the above verification operations include at least one of the following: format verification, executability verification, large model judge scoring verification or summary feedback verification, and the verification conditions include: the task objectives, tool call information and external information required by the task in the task configuration information are consistent.
[0121] In some embodiments, the format validation of task configuration information for tool paths by electronic devices includes the following process: ① Define format specifications, determining the format requirements for each field in the task configuration information (such as task objective, tool invocation scope, and external information required by the task). For example, the task objective may require starting with a specific statement structure or keyword; the tool invocation scope may stipulate that the tool name and version number must be presented in list form; the external information required by the task may require a specific file format (such as JSON, XML) or data encoding method. ② Write a validation program, specifically using a programming language (such as Python) according to the defined format specifications. This program reads the task configuration information line by line and checks the format of each field. For example, for string type fields, it checks whether their length is within the specified range; for list type fields, it checks whether their elements meet specific type requirements. ③ Execute the validation, specifically inputting the obtained p task configuration information into the validation program, which sequentially checks the format of each field of each task configuration information. If the format of a certain field does not conform to the specification, the program will record it and mark the task configuration information as formatting failure. ④ Output results: After the verification program finishes running, output the format verification results, including the number of task configuration information that passed the format verification and the task configuration information that failed the verification and the specific fields that do not conform to the format specifications.
[0122] Thus, format validation ensures that all task configuration information is consistent and standardized in form, facilitating subsequent processing and storage. For example, when storing task configuration information in a database, a standardized format can improve the efficiency of data insertion and retrieval. Furthermore, correctly formatted task configuration information can reduce errors and anomalies caused by format issues during subsequent processing, improving system stability and reliability. For instance, during task scheduling, if the task configuration information is incorrectly formatted, the scheduling system may be unable to correctly parse and execute the task.
[0123] In some embodiments, the executable verification of task configuration information for a tool path by an electronic device includes the following process: ① Determine the various dependencies required to complete the task, including hardware resources (such as CPU, memory, disk space), software environment (such as operating system version, dependency library version), network connection, etc. Simultaneously, analyze whether the tools specified in the tool call scope can run normally in the current environment, and whether the external information required by the task can be correctly obtained and used. ② Simulate the execution environment: Specifically, build a simulated environment similar to the actual execution environment. This environment should have the same hardware configuration, software installation, and network settings as the actual environment. In the simulated environment, attempt to load and run the tools specified in the task configuration information, and attempt to obtain the external information required by the task. ③ Execute the simulated task: Specifically, according to the task objectives in the task configuration information, perform the corresponding operations in the simulated environment. Observe the tool's operation, the acquisition of external information, and the task execution results. If the tool can run normally, the external information can be correctly acquired, and the task can be completed as expected, then the task configuration information is considered executable; otherwise, it is considered not executable. ④ Record the results: Record the executable verification results for each task configuration information, including the reasons for whether it is executable or not. For example, if a tool cannot run in the current environment, record the specific error message and the reason; if the external information required by the task cannot be obtained, record the reason for the failure to obtain it.
[0124] Thus, executability verification can identify potential problems in the task configuration information before actual task execution, such as insufficient hardware resources, software version incompatibility, or unavailable external information. This avoids failures during actual task execution, saving time and resources. Based on the results of the executability verification, the task configuration information can be optimized and adjusted. For example, if a tool is found to be unable to run in the current environment, consider replacing the tool or upgrading the software environment; if the external information required by the task cannot be obtained, try finding other data sources or modifying the task objective.
[0125] In some embodiments, the electronic device's scoring and verification of task configuration information for tool paths by a large model includes the following steps: ① Preparing training data: Specifically, a large number of task configuration information samples are collected, and each sample is labeled with a reasonable score. These scores can be evaluated based on the completeness, rationality, and innovativeness of the task configuration information. The labeled data is used to train the large model, enabling it to learn how to score task configuration information. ② Inputting task configuration information: The obtained p task configuration information pieces can be input into the trained large model. The large model will evaluate each task configuration information piece based on its learned knowledge and patterns and give a corresponding score. ③ Setting a score threshold: A score threshold can be set according to actual needs. When the score of the task configuration information is higher than the threshold, it is considered to meet the verification conditions; otherwise, it is considered not to meet the verification conditions.
[0126] In other embodiments, the electronic device's verification of the task configuration information of the tool path through a large-scale model and judge scoring process also includes the following steps: ① Assembling a judging panel: Experts or experienced personnel in relevant fields can be invited to form the judging panel. Panel members should possess the professional knowledge and ability to evaluate task configuration information. ② Developing scoring criteria: Detailed scoring criteria can be developed, clearly defining the definition and weight of each scoring dimension. For example, the clarity of the task objective, the rationality of tool invocation, and the relevance of external information can be used as scoring dimensions, and a corresponding score range can be set for each dimension. ③ Independent scoring by judges: P task configuration information pieces can be provided to the judging panel members, who are required to independently score each piece of task configuration information according to the scoring criteria. Judges can evaluate various aspects of the task configuration information based on their professional judgment and experience, and give corresponding scores. ④ Comprehensive scoring results: Specifically, the scoring results of the judging panel members are comprehensively processed. Methods such as average score and weighted average score can be used to calculate the final score of each task configuration information. Similarly, a score threshold is set; only task configuration information with a final score higher than this threshold is considered to meet the verification conditions.
[0127] Thus, large-scale model-based evaluation by judges allows for a comprehensive assessment of task configuration information from multiple dimensions, focusing not only on format and executability but also on its rationality, innovation, and practicality. This provides a more holistic evaluation of the quality of task configuration information, ensuring that the selected configurations better meet actual needs. Furthermore, judge scoring incorporates the subjective judgment of human experts, taking into account subtle factors and practical situations that large-scale models might miss. For example, judges can use their experience to determine whether task objectives align with actual business requirements and whether tool usage conforms to industry standards. Large-scale model scoring, on the other hand, leverages its powerful data processing and analysis capabilities to quickly evaluate large amounts of task configuration information, improving verification efficiency. Combining these two approaches fully utilizes their respective strengths, enhancing the accuracy and reliability of the verification process.
[0128] In some embodiments, the electronic device's summary feedback verification of the task configuration information of the tool path includes the following process: ① Collecting historical task feedback, specifically collecting relevant feedback information of similar tasks previously executed, including problems during task execution, user feedback, task result evaluation, etc. This feedback information can come from system logs, user surveys, project reports, etc. ② Analyzing feedback information, specifically conducting in-depth analysis of the collected historical task feedback information to summarize potential problems and improvement directions in the task configuration information. For example, if it is found that tool invocation errors frequently lead to task failures in previous tasks, then in this verification, the accuracy of the tool invocation scope in the task configuration information needs to be emphasized. ③ Formulating verification rules, specifically formulating corresponding verification rules based on the analysis results. These rules may include checking requirements for specific fields in the task configuration information, judgment criteria for the consistency between the task objective and the tool invocation scope, etc. For example, stipulating that the functions mentioned in the task objective must match the tool functions specified in the tool invocation scope. ④ Performing verification, specifically comparing the obtained p task configuration information with the formulated verification rules to check whether each task configuration information meets the rule requirements. If a task configuration violates the verification rules, it is considered to fail the verification. ⑤ Record and provide feedback on the results: Specifically, record the verification results and provide feedback on the task configuration information that fails the verification and its specific issues to the relevant personnel for modification and improvement.
[0129] In this way, by summarizing feedback and verification, we can learn from the lessons of past tasks and avoid similar problems in the current task configuration. For example, if inaccurate external information required by the task led to unsatisfactory results in the past, then the accuracy and completeness of the required external information can be strengthened in this verification. Furthermore, based on the verification results and feedback information, the process and methods for formulating task configuration information can be continuously improved. For example, if unreasonable aspects are found in the verification rules, they can be adjusted and optimized in a timely manner; if problems are found in the method of collecting task configuration information, the collection method can be improved to enhance the quality and accuracy of the information. This can continuously improve the quality of task configuration information, thereby increasing the execution efficiency and success rate of the task.
[0130] In some embodiments, the configuration generation prompts described above are used to indicate the task objectives, tool invocation scope, and external information required for the task in the large model output tool path. It is understood that configuration generation prompts can set work requirements and specifications for a task configuration generation assistant (such as an agent).
[0131] As an example, the above configuration generates the following prompt words:
[0132] "You are a professional task configuration generation assistant. You will be given... You need to generate a task configuration based on...."
[0133] Task configuration consists of three parts:
[0134] Intent: In this part, you should...
[0135] Action: In this part, you should...
[0136] Output: In the output, you should...
[0137] Precautions:
[0138] Step by step, think through and generate task configurations.
[0139] Generate according to the following format...
[0140] Output only the task configuration; do not output any additional information.
[0141] enter
[0142] ...
[0143] Now generate your answer:
[0144] It is understandable that the aforementioned configuration generation prompts can be used to define the agent's role, explicitly designating the recipient of the instructions as the task configuration generation assistant. Furthermore, these prompts can be used to design task requirements, specifying that the task configuration generation assistant needs to generate a task configuration in a specific format based on given content, and detailing the three necessary parts of the task configuration (intent (i.e., task objective), action (i.e., tool invocation scope), and output (external information required by the task)) and the content that each part needs to complete. Additionally, the prompts can provide precautions, such as specifying requirements for the process and output of generating the task configuration, including the thinking method (e.g., step-by-step thinking), the generation format (e.g., according to a specific format), and output limitations (only outputting the task configuration, without additional information). Moreover, the prompts can also guide input and output, such as providing input hints and explicitly requiring the assistant to generate an answer.
[0145] S305: The electronic device acquires s sets of dialogue trajectory data corresponding to s task configuration information, and uses the s sets of dialogue trajectory data as tool call data for the task model. Each set of dialogue trajectory data is generated based on the corresponding task configuration information to simulate task interaction.
[0146] In some embodiments, the electronic device controls the task model to generate dialogue content based on dialogue prompts according to the task objectives in the task configuration information; controls the task model to generate tool call content corresponding to the dialogue data; controls the task model to generate simulated tool call results corresponding to the tool call data based on execution prompts; and obtains dialogue trajectory data corresponding to the task configuration information based on the dialogue content, tool call content, and simulated tool call results.
[0147] Among them, the execution prompts mentioned above are related to the tool documentation and tool call content corresponding to the task model.
[0148] It is understandable that the dialogue trajectory collection module 16 can be composed of three roles: a user agent, an assistant agent, and a tool agent, all of which are played by a large model. (Refer to...) Figure 6 The scenario shown illustrates how, guided by task configuration information, three roles—the user agent, the assistant agent, and the tool agent—interact with each other, collecting dialogue content and tool call details to form a dialogue trajectory. For example... Figure 6As shown, the user agent, assistant agent, and tool agent can interact in multiple rounds. For example, in the first round, the user agent and assistant agent have a conversation such as "Hello! I bought a mobile phone on a shopping platform and now I want to apply for after-sales service." In the second round, the assistant agent instructs the tool agent to call the tool. In the third round, the tool agent simulates the execution through a large model to obtain the tool call result and feeds it back to the assistant agent. In the fourth round, the assistant agent can provide feedback on the tool call result (such as the tool call content) to the user agent.
[0149] In some embodiments, the task model described above may include a large model, which may include three roles: user agent, assistant agent, and tool agent.
[0150] In some embodiments, the above-mentioned electronic device generates dialogue content based on the task objectives in the task configuration information and the dialogue prompts to control the task model. This can be achieved through the following process: The user agent in the task model organizes speech according to the task objectives (i.e., Intent) in the task configuration information and conducts multi-round dialogues with the assistant agent through the control of system prompts such as the above-mentioned dialogue prompts, making task requests and providing necessary information, thereby generating dialogue content.
[0151] As an example, the above dialogue prompts, using a data format such as JSON, are shown below: "You are a user interacting with a smart assistant, and you want to complete the following tasks:"
[0152] {intention}
[0153] rule:
[0154] Only one line of content is generated at a time to simulate user information.
[0155] Try to make the conversation as natural and fluent as possible.
[0156] If the expected goal has been achieved, generate "###Stop###" to end the conversation.
[0157] ......".
[0158] It's understandable that the "{intent}" in the above dialogue prompts clearly identifies the user and indicates that the user has a specific intention to complete a task using the intelligent assistant. Here, "{intent}" is a placeholder; in actual use, it will be replaced with the specific task intent, such as checking the weather or ordering goods. Furthermore, the "rules" included in the dialogue prompts, such as "generate only one line of content each time to simulate user information," indicate that during the interaction with the intelligent assistant, the user can only input or generate one line at a time, simulating the gradual input of information in a real-world scenario. "Make the dialogue as natural and fluent as possible" requires that the generated dialogue content conform to everyday communication habits, avoiding stiff and disjointed expressions, making the interaction process closer to real human-computer dialogue. "If the expected goal has been achieved, generate '###Stop###' to end the dialogue" means that when the user completes the predetermined task and achieves the expected goal through interaction with the intelligent assistant, a specific "###Stop###" marker needs to be generated to end the entire dialogue process.
[0159] In some embodiments, the electronic device control task model generates tool call content corresponding to the generated dialogue content, including the following process: the assistant agent in the task model engages in dialogue with the user agent to generate tool call content corresponding to the dialogue content. It is understood that the aforementioned dialogue content implicitly includes a need to "obtain external information" or "trigger tool calls." The task model can identify the tools and parameters to be called based on the dialogue content and simulated user responses, and generate standardized tool call content. For example, if the dialogue content guides the user to provide information, the assistant agent in the task model will automatically generate a reasonable response, such as the user replying "order number is 123456." The assistant agent in the task model can parse the key information in the above reply (such as order number 123456), combine it with the "tool call scope" of the task configuration information (such as "logistics query tool"), and identify the matching tool. Thus, tool call content (usually in JSON format, including tool name, parameters, and call order) is generated.
[0160] As an example, the strategy for the assistant agent to converse with the user agent includes the following: On the one hand, if the user agent's request can be fulfilled by calling a tool, the assistant agent needs to output the corresponding tool call and interact with the tool agent to obtain the tool call content. For example, if the user agent requests to check the weather in a certain city, and a weather query tool exists, the assistant agent should output the instruction to call the weather query tool and interact with the weather query tool agent to obtain the weather information. On the other hand, if the user agent's request is unclear or lacks necessary information, the assistant agent needs to follow up and clarify the user agent's ambiguous intent, and ask for follow-up questions about the missing information to determine the tool call content. For example, if the user agent says "Help me find something," but does not specify what, the assistant agent needs to ask the user what specific item they want to find.
[0161] In some embodiments, the tool agent can receive tool call content programmed by the agent, and simulate the result of the tool call by prompting words such as execution prompts on the tool document, tool call content and parameters.
[0162] In some embodiments, the large model in the task model can integrate dialogue content, tool call content, and simulated tool call results in chronological order to form complete dialogue trajectory data, which covers the entire process of interaction, call, and feedback.
[0163] For example, the task model can sort the data of each stage by timestamp (dialogue content, user simulation response, tool call content, simulation results, and agent's final feedback). Then, the task model supplements the trajectory metadata (such as task ID, configuration information ID, and generation time) and outputs structured dialogue trajectory data.
[0164] As an example, the execution prompt above, using a data format such as JSON, would look like this: "Imagine you are an API server running within a dedicated tool that contains a set of different APIs. Your responsibility is to thoroughly understand the functionality of each API based on the descriptions in the API documentation. ...
[0165] Your response must follow a specific JSON structure, as shown below: ......
[0167] Notice:
[0168] Your response should be around 100 to 200 words, containing a wealth of information based on the API input parameters. Keep your answer brief and concise.
[0169] Your response must be valid and contain actual content. ......
[0171] You will also receive examples of successful API calls and their expected outputs, which you will use to generate responses for a given input.
[0172] enter: ......
[0174] Now generate your output:
[0175] As can be understood, the execution prompts in the above example describe the operational requirements and response specifications of the API server (within a specific tool environment), providing role and responsibility settings, response specification requirements, reference example instructions, and input / output guidance. The role explicitly defines the object as an API server running within a dedicated tool. The responsibility requires the API server to have a deep understanding of the specific functionality of each API based on the descriptions in the API documentation. This emphasizes the importance of the server's accurate grasp of API functionality, which is the foundation for subsequent correct responses. The structure requirement specifies that the response must follow a specific JSON structure, and the structure content is indicated later (using "..."), ensuring the uniformity and standardization of the response data format, facilitating subsequent parsing and processing. The content and length requirements stipulate that the response should be approximately 100 to 200 characters long and should include rich information based on the API input parameters. It mentions providing successful API call examples and their expected outputs, requiring the generation of responses for given inputs based on these examples. The reference example instructions provide a reference standard for the API server, helping it generate correct responses according to the expected format and content. The input / output guidance information provides prompts such as "Input" and "Generate your output now," clearly indicating the location of information input and response output, making the entire interaction process clear and concise.
[0176] In some embodiments, dialogue trajectories are aggregated into dialogue trajectory data by collecting the dialogue between the user agent and the assistant agent, the tool calls orchestrated by the assistant agent, and the tool call results simulated by the tool agent. Dialogue trajectory data simulates the interactions between multiple roles in a real-world scenario and can be used as training data for large-scale model agents.
[0177] As an example, the above dialogue trajectory data uses a data format such as JSON as shown below: "[
[0178] {"Role": "User", "Content": "Hello! I purchased a mobile phone on a shopping platform and now want to apply for after-sales service."}
[0179] {"Role": "Assistant", "Content": "Okay, I need to verify your identity first. Please provide your user information."}
[0180] {"Role": "User", "Content": "Okay, my name is Xiaoming, and my postal code is 12345"},
[0181] {"Role": "Tool Call", "Content": "[{"Name": "find_user_by_name", "Parameters":{...}]}"},
[0182] {"Role": "Tool", "Content": "xiaoming_1831"},
[0183] {"Role": "Assistant", "Content": "Your identity has been verified. How can I help you?"}, ......
[0185] {"Role": "User", "Content": "Okay, my request has been fulfilled, thank you. ###Stop###"},
[0186] ]".
[0187] Thus, the data generation method provided in this application can construct relatively complex tool dependency graphs and enhance tool paths, adapting to various complex scenarios such as single-turn single-task, independent multi-task, nested tasks, multi-turn dependencies, tool inheritance, and parameter inheritance. Furthermore, this application can simulate task execution using a large model, simulating tool calls, reducing the implementation cost of tool execution and improving scalability. Moreover, by simulating dialogue and tool call processes and results using a large model, the authenticity of the dialogue content is ensured, solving the problem of difficulty in batch generating multi-turn, multi-task tool call data.
[0188] Next, the hardware structure of the electronic device for executing code detection in the embodiments of this application will be described.
[0189] like Figure 7 As shown, the electronic device 100 includes a processor 1001 and a memory 1002, used to store instructions executed by the processor 1001, or input data required by the processor 1001 to execute instructions, or data generated after the processor 1001 executes instructions. Furthermore, the electronic device 100 also includes an interface circuit 1003. The processor 1001 and the interface circuit 1003 are coupled to each other. It can be understood that the interface circuit 1003 can be a transceiver, an input / output interface, or a communication module.
[0190] The aforementioned electronic device 100 can be used to perform Figure 3 The method is illustrated. For example, the processor 1001 described above is used to support an electronic device in executing the data generation method described above.
[0191] This application also provides an electronic device, including: one or more processors; one or more memories; the one or more memories storing one or more programs, which, when executed by the one or more processors, cause the electronic device to perform the data generation method described above.
[0192] This application also provides a computer-readable storage medium (also referred to as a readable storage medium) storing a program or instructions that, when executed on an electronic device (e.g., a server or computer), cause the electronic device (e.g., a server or computer) to perform the data generation method described above.
[0193] This application also provides a computer program product (also called a program product), including a program or instructions, which, when executed by a processor, implement the data generation method described above in the various embodiments.
[0194] Various embodiments of the mechanisms disclosed in this application can be implemented in hardware, software, firmware, or combinations of these implementation methods. Embodiments of this application can be implemented as computer program modules or module code executable on a programmable system, the programmable system including at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.
[0195] Computer program modules or module code can be applied to input instructions to perform the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, the processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application-specific integrated circuit (ASIC), or a microprocessor.
[0196] Module code can be implemented using a high-level modular language or an object-oriented programming language to communicate with the processing system. Assembly language or machine language can also be used to implement module code when needed. In fact, the mechanisms described in this application are not limited to any particular programming language. In either case, the language can be a compiled language or an interpreted language.
[0197] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored thereon on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, the instructions may be distributed via a network or via other computer-readable storage media. Therefore, machine-readable storage media may include any mechanism for storing or transmitting information in a machine-readable (e.g., computer-readable) form, including but not limited to floppy disks, optical disks, optical discs, magneto-optical disks, read-only memory (ROM), random access memory (RAM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic cards or optical cards, flash memory, or tangible machine-readable storage for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in the form of electrical, optical, acoustic, or other forms of propagated signals. Therefore, machine-readable storage media include any type of machine-readable storage media suitable for storing or transmitting electronic instructions or information in a machine-readable (e.g., computer-readable) form.
[0198] In this specification, the reference to "an embodiment" or "an embodiment" means that a specific feature, structure, or characteristic described in connection with the embodiment is included in at least one exemplary implementation or technology disclosed according to an embodiment of this application. The appearance of the phrase "in an embodiment" in various places in the specification does not necessarily refer to the same embodiment.
[0199] The disclosure of embodiments of this application also relates to means for performing operations in text. This means may be specifically constructed for the claimed purpose or may include a general-purpose computer selectively activated or reconfigured by a computer program stored in a computer. Such a computer program may be stored in a computer-readable storage medium, such as, but not limited to, any type of disk, including floppy disks, optical disks, CD-ROMs, magneto-optical disks, read-only memory (ROM), random access memory (RAM), EPROM, EEPROM, magnetic or optical cards, application-specific integrated circuits (ASICs), or any type of medium suitable for storing electronic instructions, and each may be coupled to a computer system bus. Furthermore, the computer mentioned in the specification may include a single processor or may be an architecture employing multiple processors for increased computing power.
[0200] Furthermore, the language used in this specification has been primarily chosen for readability and instructional purposes and may not have been chosen to depict or limit the disclosed subject matter. Therefore, the embodiments disclosed herein are intended to illustrate, and not limit, the scope of the concepts discussed herein.
Claims
1. A data generation method, characterized in that, The method includes: Construct a tool dependency graph corresponding to n tools, wherein the tool dependency graph is used to indicate the dependency relationship between each of the n tools, and the n tools are related to the task model; Based on the tool dependency graph, determine m tool paths; Enhancement operations are performed on the tool paths among the m tool paths to obtain p enhanced tool paths, wherein the enhancement operations include at least one of the following: merging operation, splitting operation, or insertion operation; Obtain the configuration information of s tasks corresponding to the enhanced p tool paths, where p is greater than or equal to s; Obtain s sets of dialogue trajectory data corresponding to the s task configuration information, and use the s sets of dialogue trajectory data as tool call data for the task model. Each set of dialogue trajectory data is generated by simulating task interaction based on the corresponding task configuration information, and n, p and s are all positive integers.
2. The method according to claim 1, characterized in that, The enhancement operations include a merging operation, and the toolpath performs enhancement operations, including: Select the tool at step h and the tool at step h+1 from the tool path, and merge the tool at step h and the tool at step h+1 into one tool to obtain the enhanced tool path, where h is a positive integer.
3. The method according to claim 1, characterized in that, The enhancement operations include splitting operations, and the toolpath undergoes enhancement operations, including: Select the tool at step h from the tool path, and insert the same tool as the tool at step h after the tool at step h to obtain the enhanced tool path, where h is a positive integer.
4. The method according to claim 1, characterized in that, The enhancement operations include insertion operations, and the toolpath performs enhancement operations, including: Select the tool at step h from the tool path, select the tool associated with the tool at step h from the tool dependency graph, and insert the tool associated with the tool at step h after the tool at step h to obtain the enhanced tool path, where h is a positive integer.
5. The method according to claim 1, characterized in that, The first tool in the tool dependency graph has a dependency relationship with the second tool, and the first tool and the second tool satisfy at least one of the following conditions: The first tool is executed before the second tool is executed; The output information of the first tool is the same as the input information required by the second tool; The output information of the first tool is a subset of the input information required by the second tool.
6. The method according to any one of claims 1 to 5, characterized in that, The step of determining m tool paths based on the tool dependency graph includes: Based on the tool dependency graph, m tool paths are determined using a random walk strategy; The walking strategy includes a maximum number of walks and / or a maximum number of paths, and... In each of the m tool paths, the preceding tool has a dependency relationship with the following tool. The number of tools in each tool path is less than or equal to the maximum number of traversals, and the value of m is less than or equal to the maximum number of paths.
7. The method according to claim 6, characterized in that, The step of obtaining the s task configuration information corresponding to the enhanced p tool paths includes: Obtain the configuration information of p tasks corresponding to the p tool paths, wherein each task configuration information includes: task objective, tool call scope, and external information required by the task; A verification operation is performed on the p task configuration information to obtain the s task configuration information that meets the verification conditions. The verification operation includes at least one of the following: format verification, executability verification, large model judge scoring verification or summary feedback verification, and the verification conditions include: the task objectives, tool call information and external information required by the task in the task configuration information are consistent.
8. The method according to claim 7, characterized in that, The dialogue trajectory data corresponding to the task configuration information is obtained through the following methods: Based on the task objectives in the task configuration information, the task model is controlled to generate dialogue content based on dialogue prompts. The task model is controlled to generate tool call content corresponding to the dialogue content; Based on the execution prompt words, the task model is controlled to generate simulated tool call results corresponding to the tool call data; Based on the dialogue content, the tool call content, and the simulated tool call results, the dialogue trajectory data corresponding to the task configuration information is obtained.
9. The method according to claim 8, characterized in that, The execution prompts are related to the tool documentation corresponding to the task model and the tool call content.
10. An electronic device, characterized in that, include: One or more processors; One or more memories; the one or more memories storing one or more programs that, when executed by the one or more processors, cause the electronic device to perform the method of any one of claims 1 to 9.
11. A computer-readable storage medium, characterized in that, The readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the method of any one of claims 1 to 9.
12. A computer program product, characterized in that, Includes a computer program / instruction that, when executed by a processor, implements the method of any one of claims 1 to 9.
Citation Information
Cited By
Tool calling method based on routine task
CN121722530A