Agent-based problem solving method, device, storage medium and product
By generating tool diagrams and sub-graph sampling to form a reference knowledge base, the problem of low accuracy and efficiency of agents when solving complex problems is solved, and the agents can quickly and accurately solve actual user problems.
Patent Information
- Application Number
- CN202410924417.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-07-10
AI Technical Summary
When solving complex problems, agents based on large language models lack background knowledge tips, the accuracy of the solution steps is low and the exploration time is long.
By generating tool diagrams, sub-graph sampling is performed to obtain multiple tool sub-graphs, determine the reference user problems and reference solution steps corresponding to the tool sub-graph, form a reference knowledge base, and improve the accuracy and efficiency of the agent when solving actual user problems. .
It significantly improves the accuracy and speed of the agent when solving complex problems, and quickly matches similar user problems through a pre-generated reference knowledge base to achieve efficient and accurate solutions.
Smart Images

Figure CN118469023B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an agent-based problem-solving method, device, storage medium and product. Background Art
[0002] With the development of large language model technology, AI agents based on large language models have become a hot topic of research. The AI agent relies on the large language model as its core decision-making and processing unit, and can use the logical reasoning ability of the large language model to decompose the solution steps of user problems, call tools, and summarize the solution results of multiple steps.
[0003] However, due to the limitations of the current large language model capabilities, especially for complex problems, without background knowledge prompts, the accuracy of the intelligent agent's decomposition of the solution steps for user problems is low, and the exploration time of the solution steps is long. Summary of the invention
[0004] Embodiments of the present invention provide an agent-based problem-solving method, device, storage medium, and product to improve the speed and accuracy of solving user problems.
[0005] In a first aspect, an embodiment of the present invention provides an agent-based problem solving method, the method comprising:
[0006] Obtaining a toolset included in an agent, wherein the agent includes a first language model;
[0007] generating a tool graph corresponding to the toolset by using a second language model, wherein the tool graph describes dependencies between multiple tools in the toolset;
[0008] Performing sub-graph sampling on the tool graph to obtain a plurality of tool sub-graphs, wherein the plurality of tool sub-graphs are used to reflect a plurality of application scenarios to which the plurality of tools are applicable;
[0009] Determine, according to the second largest language model, reference user questions corresponding to each of the plurality of tool subgraphs and reference solution steps for the reference user questions, wherein the reference solution steps call tools included in the corresponding tool subgraphs;
[0010] In response to input of an actual user problem, the actual user problem is solved based on a reference knowledge base and the agent, wherein the reference knowledge base contains reference user problems corresponding to each of the multiple tool subgraphs and reference solution steps for the reference user problems.
[0011] In a second aspect, an embodiment of the present invention provides an agent-based problem solving device, the device comprising:
[0012] An acquisition module, used to acquire a tool set included in an intelligent agent, wherein the intelligent agent includes a first language model;
[0013] A generating module, configured to generate a tool graph corresponding to the tool set by using a second language model, wherein the tool graph describes a dependency relationship between multiple tools in the tool set;
[0014] A sampling module, used for performing sub-graph sampling on the tool graph to obtain a plurality of tool sub-graphs, wherein the plurality of tool sub-graphs are used to reflect a plurality of application scenarios to which the plurality of tools are applicable;
[0015] a determination module, configured to determine, according to the second largest language model, reference user questions corresponding to each of the plurality of tool subgraphs and reference solution steps for the reference user questions, wherein the tools included in the corresponding tool subgraphs are called in the reference solution steps;
[0016] A solution module is used to respond to the input of an actual user problem and complete the solution of the actual user problem based on a reference knowledge base and the intelligent agent, wherein the reference knowledge base contains reference user problems corresponding to each of the multiple tool subgraphs and reference solution steps for the reference user problems.
[0017] In a third aspect, an embodiment of the present invention provides a method for generating a reference knowledge base, the method comprising:
[0018] Obtaining a toolset included in an agent, wherein the agent includes a first language model;
[0019] Generate a tool graph corresponding to the toolset by using a second language model, wherein the tool graph describes dependencies between multiple tools in the toolset;
[0020] Performing sub-graph sampling on the tool graph to obtain a plurality of tool sub-graphs, wherein the plurality of tool sub-graphs are used to reflect a plurality of application scenarios to which the plurality of tools are applicable;
[0021] Determine, according to the second largest language model, reference user questions corresponding to each of the plurality of tool subgraphs and reference solution steps for the reference user questions, wherein the reference solution steps call tools included in the corresponding tool subgraphs;
[0022] A reference knowledge base is generated, which includes reference user problems corresponding to each of the plurality of tool subgraphs and reference solution steps for the reference user problems.
[0023] In a fourth aspect, an embodiment of the present invention provides a reference knowledge base generation device, the device comprising:
[0024] An acquisition module, used to acquire a toolset included in an intelligent agent, wherein the intelligent agent includes a first language model;
[0025] A generating module, configured to generate a tool graph corresponding to the tool set by using a second language model, wherein the tool graph describes a dependency relationship between multiple tools in the tool set;
[0026] A sampling module, used for performing sub-graph sampling on the tool graph to obtain a plurality of tool sub-graphs, wherein the plurality of tool sub-graphs are used to reflect a plurality of application scenarios to which the plurality of tools are applicable;
[0027] a determination module, configured to determine, according to the second largest language model, reference user questions corresponding to each of the plurality of tool subgraphs and reference solution steps for the reference user questions, wherein the tools included in the corresponding tool subgraphs are called in the reference solution steps;
[0028] A creation module is used to generate a reference knowledge base including reference user problems corresponding to each of the plurality of tool subgraphs and reference solution steps for the reference user problems.
[0029] In a fifth aspect, an embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the method described in the first aspect or the third aspect.
[0030] In the sixth aspect, an embodiment of the present invention provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor executes the method described in the first aspect or the third aspect.
[0031] In a seventh aspect, an embodiment of the present invention provides a computer program product, comprising: a computer program, which, when executed by a processor of an electronic device, enables the processor to execute the method described in the first aspect or the third aspect.
[0032] The agent-based problem solving method provided by the embodiment of the present invention automatically generates a reference knowledge base before the actual user problem arrives, obtains multiple reference user problems that can be solved by the tool set contained in the agent, and the reference solution steps for each reference user problem, thereby obtaining rich prior knowledge. After the actual user problem arrives, the reference user problem corresponding to the actual user problem can be directly searched in the reference knowledge base, and the actual user problem can be solved based on the reference solution steps of the reference user problem, so that the solution steps of the actual user problem can be quickly obtained and the actual user problem can be quickly solved. In the process of generating the reference knowledge base, a tool graph corresponding to the toolset in the agent is generated through the second largest language model, and sub-graph sampling is performed on the tool graph to obtain multiple tool sub-graphs reflecting multiple application scenarios applicable to multiple tools. The second largest language model in the agent is then used to determine the reference user problems corresponding to each of the multiple tool sub-graphs and the reference solution steps for the reference user problems. That is, the prior knowledge of all possible reference user problems and the solution steps corresponding to the reference user problems under the toolset is obtained. Since the prior knowledge has a wider coverage, the hit rate of reference user problems similar to actual user problems can be improved, so that the actual user problems can be efficiently and accurately solved with the help of this prior knowledge. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0034] Figure 1 A schematic diagram of a hardware execution environment of an agent-based problem-solving method provided by an embodiment of the present invention;
[0035] Figure 2 A schematic diagram of a cloud computing environment for an agent-based problem-solving method provided by an embodiment of the present invention;
[0036] Figure 3 A flow chart of an agent-based problem-solving method provided by an embodiment of the present invention;
[0037] Figure 4 A specific example diagram of sub-graph sampling provided by an embodiment of the present invention;
[0038] Figure 5 A flowchart of determining reference user problems corresponding to each of a plurality of tool subgraphs and reference solution steps for the reference user problems provided by an embodiment of the present invention;
[0039] Figure 6 A flowchart of a reference knowledge base generation method provided by an embodiment of the present invention;
[0040] Figure 7 A schematic diagram of the structure of an agent-based problem-solving device provided by an embodiment of the present invention;
[0041] Figure 8 A schematic diagram of the structure of a reference knowledge base generating device provided by an embodiment of the present invention;
[0042] Fig. 9 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0044] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0045] Some embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the case where there is no conflict between the embodiments, the following embodiments and the features in the embodiments can be combined with each other. In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.
[0046] First, the terms or concepts involved in the embodiments of the present invention are explained:
[0047] AI Agent: It is an intelligent agent system with a large language model as the core controller. Its essence is an agent system that controls the large language model to solve user problems. It relies on the large language model as its core decision-making and processing unit, and can use the logical reasoning ability of the large language model to realize the decomposition of the solution steps of user problems, tool calls and summary of the solution results of multiple steps.
[0048] Big language model: refers to a deep learning model trained based on massive text data, which has strong expressive and generalization capabilities. It can not only generate natural language text, but also deeply understand the meaning of the text and handle various natural language tasks such as text summarization, question answering, translation, etc.
[0049] Tools: refers to the components or software used by the intelligent agent to perform its tasks, make decisions, or interact with the environment. For example, these tools can be pre-programmed algorithms, models, knowledge bases, or some specific software applications.
[0050] Currently, there are two main ways to obtain the solution steps of user problems through intelligent agents:
[0051] 1. In the absence of a reference knowledge base (i.e., prior knowledge), based on the input of user questions, tree search algorithms (such as Tree of Thoughts, abbreviated as ToT) and mind maps (such as Graph of Thoughts, abbreviated as GoT) are generally used to guide the agent to better explore during problem planning, so that the agent can find the solution steps of the user problem in real time during repeated error correction and exploration, which takes a long time. Among them, the reference knowledge base refers to a database containing reference user problems that the toolset in the agent can be used to solve and the reference solution steps of the reference user problems. These multiple application scenarios correspond to different application scenarios to which the toolset contained in the agent can be applied.
[0052] Second, establish a reference knowledge base by manual input, and then enable the intelligent agent to obtain the solution steps of the actual user problem input based on the reference knowledge base. However, this manual input method is difficult to cover various reference user problems that the tool set in the intelligent agent can apply, so based on the input of the actual user problem, it is impossible to accurately match similar reference user problems in the reference knowledge base, and thus it is impossible to use the reference knowledge base to achieve a fast and accurate solution to the actual user problem. In actual applications, if the actual user problem does not hit the reference user problem that already exists in the reference knowledge base, then the intelligent agent will use the first solution method mentioned above to explore the solution steps of the actual user problem in real time, which is time-consuming.
[0053] In view of this, the embodiment of the present invention provides the following ideas to solve the problems existing in the above two methods: before the actual user problem is input, by automatically mining various application scenarios that may be applicable to the tool set in the intelligent agent, that is, the reference user problems that can be solved and the reference solution steps of each reference user problem, a reference knowledge base is generated to improve the richness of its prior knowledge. After the actual user problem is input, the reference user problem corresponding to the actual user problem in the reference knowledge base can be hit with a higher probability, and the actual user problem can be solved based on the reference solution steps of the reference user problem, so that the solution steps of the actual user problem can be quickly obtained, and the actual user problem can be quickly and accurately solved.
[0054] The following is an introduction to the agent-based problem-solving solution provided by an embodiment of the present invention.
[0055] Figure 1 A schematic diagram of a hardware execution environment of an intelligent agent problem solving method provided by an embodiment of the present invention, such as Figure 1 As shown, the hardware execution environment of the problem-solving method of the intelligent agent can be composed of a client device 101 and a server device 102, and the client device 101 is in communication connection with the server device 102. The server device 102 can be a cloud server of a cloud service provider. The client device 101 can be a laptop, a tablet computer, a PC, a robot, etc.
[0056] In an optional embodiment, the agent including the first language model provided in the embodiment of the present invention can be set in the server device 102. At this time, the execution process of the above-mentioned agent-based problem solving method can be: the server device 102 (also called the cloud) generates a tool graph corresponding to the tool set through the second language model (the same as or different from the first language model), and performs subgraph sampling on the tool graph to obtain multiple tool subgraphs, and then determines the reference user problems and reference solution steps of the reference user problems corresponding to the multiple tool subgraphs according to the second language model in the agent, so as to generate a reference knowledge base including the reference user problems and reference solution steps of the reference user problems corresponding to the multiple tool subgraphs. Afterwards, the client device 101 receives the actual user problem and sends the actual user problem to the server device 102, and the server device 102 completes the solution of the above-mentioned actual user problem in response to the input of the actual user problem based on the reference user problems and reference solution steps of the reference user problems corresponding to the multiple tool subgraphs contained in the reference knowledge base and the above-mentioned agent deployed locally.
[0057] In actual applications, the server device 102 may be a cloud server maintained by a cloud service provider, which is called a computing node. Figure 2 In the cloud computing environment shown in the figure, several distributed deployments may be included ( Figure 2 In the diagram, there are computing nodes (201-1, 201-2, ...), each of which has computing, storage and other processing resources. In a cloud computing environment, multiple computing nodes can be organized to provide a certain service. Of course, a computing node can also provide one or more services, such as Figure 2 The service A, service B, service C, and service D are shown in the figure. The way to provide the service in the cloud computing environment is to provide a service interface to the outside world, and the client device calls the service interface to use the corresponding service. The service interface includes software development kit (SDK), application programming interface (API), etc.
[0058] The above services are deployed based on various virtualization technologies supported by the cloud computing environment, such as virtualization technologies based on virtual machines and containers. Taking container-based virtualization technology as an example, several containers corresponding to a service can be assembled into a container group (pod). For example Figure 2 The service B shown in the figure can be configured with one or more pods, each of which can include a proxy and one or more containers. The one or more containers in the pod are used to process requests related to one or more corresponding functions of the service, and the proxy in the pod is used to control network functions related to the service, such as routing, load balancing, etc.
[0059] During operation, executing a request from a client device may require calling one or more services in the cloud computing environment, and executing one or more functions of a service may require calling one or more functions of another service. Figure 2 As shown, after service A receives a request from a client device, it can call service B, and service B can request service D to perform one or more functions.
[0060] In an embodiment of the present invention, a cloud service for solving user problems can be deployed in one or more computing nodes. The cloud service integrates the intelligent agent containing the first language model mentioned above and may also include the second language model mentioned above.
[0061] The following describes in detail the execution process of the intelligent agent problem solving method provided by the embodiment of the present invention in conjunction with the accompanying drawings. The intelligent agent problem solving method can be executed by the computing nodes in the above cloud computing environment.
[0062] Figure 3 A flowchart of an agent-based problem solving method provided by an embodiment of the present invention, such as Figure 3 As shown, the method comprises the following steps:
[0063] 301. Obtain a toolset included in an agent, wherein the agent includes a first language model.
[0064] 302. Generate a tool graph corresponding to the toolset through the second largest language model, where the tool graph describes the dependency relationship between multiple tools in the toolset.
[0065] 303. Sub-graph sampling is performed on the tool graph to obtain a plurality of tool sub-graphs, where the plurality of tool sub-graphs are used to reflect a plurality of application scenarios applicable to a plurality of tools.
[0066] 304. Determine reference user questions and reference solution steps for the reference user questions corresponding to each of the plurality of tool subgraphs according to the second largest language model, wherein the tools included in the corresponding tool subgraphs are called in the reference solution steps.
[0067] 305. In response to input of an actual user problem, the actual user problem is solved based on a reference knowledge base and an intelligent agent, wherein the reference knowledge base contains reference user problems corresponding to a plurality of tool subgraphs and reference solution steps for the reference user problems.
[0068] It should be noted that the first largest language model and the second largest language model in the embodiment of the present invention may be the same or different. When the first largest language model and the second largest language model are different, the weight parameter amount of the second largest language model is greater than that of the first largest language model. The embodiment of the present invention does not limit the specific implementation of the first largest language model and the second largest language model, and various existing large language models may be applicable.
[0069] In order to generate a reference knowledge base corresponding to the toolset included in the agent offline in advance, it is first necessary to generate a tool graph corresponding to the toolset included in the agent through the second language model. The tool graph describes the dependency relationship between multiple tools in the toolset. It can be seen that the tool graph, as a graph structure, is a directed acyclic graph, in which the nodes are the tools, and the directed edges between the nodes represent the dependency relationship between the corresponding different tools. For example, if the use of tool a depends on the output of tool b, then the node of tool b can have a directed edge pointing to the node of tool a. Among them, "offline" here means before the agent is used to solve actual user problems.
[0070] The specific process of the second largest language model generation tool diagram is as follows:
[0071] S1, obtaining a toolset contained in the agent, the toolset containing multiple tools;
[0072] S2, adding definition information of a first tool and definition information of a second tool in the tool set to a first prompt word template to generate a first prompt word, wherein the first tool and the second tool are any two tools in the tool set;
[0073] S3. Input the first prompt word into the second largest language model to obtain a dependency determination result between the first tool and the second tool output by the second largest language model, and determine the corresponding connection edge between the first tool and the second tool in the tool graph according to the dependency determination result.
[0074] The definition information of the first tool and the second tool may include a functional description of the tool (e.g., a tool is used to perform road statistics in a region. Given a region, the tool returns the road network distribution in the region, the names of the main roads, and the lengths of roads of different levels), input parameters of the tool (e.g., the city where the region to be counted is located and the name of the region), output parameters of the tool (e.g., the road network distribution in the region, including the names of the main roads and the lengths of roads of different levels), and the type of input / output parameters of the tool (e.g., string type).
[0075] In the specific implementation, multiple tools in the tool set are randomly traversed in pairs, assuming that the two tools currently obtained are the first tool and the second tool. Then, after obtaining the definition information of the first tool and the second tool, the definition information of the first tool and the definition information of the second tool are added to the first prompt word template corresponding to the second largest language model. Among them, the first prompt word template includes: dependency feature prompt information and task requirement prompt information. The task requirement prompt information is used to prompt the second largest language model to complete the dependency determination task of the two input tools, and the dependency feature prompt information is used to prompt the feature requirements that the two tools with dependencies need to meet.
[0076] For ease of understanding, the following examples illustrate the dependency feature prompt information and task requirement prompt information:
[0077] Dependency feature hints may include:
[0078] 1. Through the tool function description content of Tool 1 and Tool 2, it is found that the use of Tool 2 depends on Tool 1, so Tool 1 is the prerequisite tool of Tool 2, that is, Tool 2 depends on Tool 1.
[0079] 2. The output parameter type (output.type) of tool 1 is the same as the type (type) of a parameter in the input parameters (parameters) of tool 2.
[0080] 3. The meaning of the output parameter of tool 1 is the same as the meaning of a parameter in the input parameter of tool 2.
[0081] The above-mentioned tool 1 and tool 2 generally refer to any two different tools.
[0082] The meaning of a parameter of the above two tools is the same. Often, the names of the parameters with the same meaning in the two tools may be different, but the essential meaning is the same. For example, the parameter with the meaning of "city name" in tool 1 is named a, and the parameter with the same meaning in tool 2 is named b.
[0083] Through the above dependency feature prompt information, the second largest language model can be prompted with the feature requirements that the two tools with a dependency relationship need to meet, so that the second largest language model can make dependency judgments between the two tools.
[0084] The task requirement prompt information may include: "Now there are the first tool and the second tool. Please determine the dependency relationship between the first tool and the second tool based on the tool's functional description, input parameters, and output parameters. If there is no dependency between the two, output "no". If there is a dependency between the two, output a specific dependency description. Each tool is defined by json, where id is the name of the tool, description is the tool's functional description, parameters are the tool's input parameters, and output is the tool's output parameters", and "Please determine whether the first tool and the second tool have a dependency relationship."
[0085] The task requirement prompt information is equivalent to issuing a task for the second largest language model, and can prompt the second largest language model to perform the task of determining the dependency relationship between the first tool and the second tool.
[0086] The above two parts of prompt information are equivalent to the fixed content in the first prompt word template, and the variable content in the first prompt word template is the definition information of the two tools input. Therefore, after the definition information of the first tool and the definition information of the second tool that need to be input are added to the corresponding positions in the above first prompt word template, the first prompt word (including the tool function description, input parameters, output parameters and other definition information of the first tool and the second tool, as well as the dependency feature prompt information and task requirement prompt information) will be generated. After that, the first prompt word is input into the second largest language model to obtain the dependency determination result of the first tool and the second tool output by the second largest language model, and then the corresponding connection edges of the first tool and the second tool in the tool graph are determined according to the dependency determination result. According to the multiple connection edges generated after traversing multiple tools in pairs, a complete tool graph can be generated.
[0087] It should be noted that the initial tool graph may only contain nodes corresponding to several tools in the tool set, and the node attributes are the definition information of the tools. By determining the dependency relationship between the two tools mentioned above, directed connection edges between different nodes can be gradually added to the tool graph.
[0088] After the tool graph is generated, it can be manually reviewed by visual means, and the connection edges in the tool graph can be added or deleted according to the manual review results to further ensure the accuracy of the tool graph. For example, if a loop appears between two tools in the tool graph generated by the second largest language model, one of the connection edges can be manually removed according to the actual dependency relationship between the two tools. Alternatively, if there is actually a dependency relationship between the two tools but the second largest language model does not recognize it, the corresponding directed connection edge can be manually added.
[0089] Afterwards, the tool graph is sampled as a subgraph to obtain multiple tool subgraphs, which are directed acyclic graphs that also include multiple nodes and connecting lines for connecting two nodes. For tool graphs of different complexity, the sampling method is also different, which will not be described in detail here. For details, please refer to the subsequent embodiments.
[0090] The purpose of sub-graph sampling of the tool graph is to explore various application scenarios in which the toolset in the agent can be applied. One application scenario corresponds to one tool sub-graph, that is, in one application scenario, different tools in the toolset may need to be used.
[0091] Afterwards, the description information of multiple tool subgraphs (including the definition information of each tool in the tool subgraph and the directed connection information between different tools) is input into the second largest language model in the intelligent agent to obtain the reference user problems corresponding to the multiple tool subgraphs and the reference solution steps of the reference user problems, that is, the reference user problems and the reference solution steps of the reference user problems in multiple application scenarios are obtained.
[0092] In this way, a reference knowledge base can be generated that includes reference user problems corresponding to multiple tool subgraphs and reference solution steps for the reference user problems.
[0093] In summary, the second largest language model corresponds to a second prompt word template. The description information of a tool subgraph is added to the second prompt word template to obtain the second prompt word, and then input into the second largest language model to obtain the reference user problem output by the second largest language model for the tool subgraph and the reference solution steps for the reference user problem.
[0094] After creating a reference knowledge base, in response to input of an actual user problem, a target reference user problem matching the actual user problem is determined from the reference knowledge base, and the target reference user problem, the reference solution steps corresponding to the target reference user problem, and the actual user problem are input into the intelligent agent, so that the intelligent agent outputs the actual solution steps corresponding to the actual user problem through the first language model, and completes the solution of the actual user problem based on the actual solution steps, wherein the tools used in the corresponding reference solution steps are called in the actual solution steps.
[0095] In specific implementation, after obtaining the actual user question, you can search in the reference knowledge base to find the target reference user question whose similarity with the actual user question exceeds a set threshold. For example, if a target reference user question with a similarity with the actual user question exceeding 80% is found in the reference knowledge base, the actual user question is considered to match the target reference user question.
[0096] In practical applications, optionally, the similarity calculation may be: inputting the actual user question and any reference user question included in the reference knowledge base into a pre-trained neural network model for determining the semantic similarity of two input sentences, and determining the semantic similarity between the actual user question and the reference user question through the neural network model. Calculate the semantic similarity between each reference user question in the reference knowledge base and the actual user question one by one, and determine the reference user question that meets the threshold condition as the target reference user question.
[0097] Alternatively, optionally, the calculation of the above-mentioned similarity may also be: extracting the keywords contained in the actual user question and the keywords contained in each reference user question, determining the similarity between the actual user question and the reference user question based on the degree of matching between the keywords in the actual user question and the keywords in a reference user question, and determining the reference user question that meets the threshold condition as the target reference user question.
[0098] After that, the target reference user problem, the reference solution steps corresponding to the target reference user problem, and the actual user problem are input into the intelligent agent, so that the intelligent agent outputs the actual solution steps corresponding to the actual user problem through the first language model, thereby completing the solution of the actual user problem. It can be understood that the actual solution steps corresponding to the actual user problem and the reference solution steps corresponding to the target reference user problem are essentially the same (that is, the tools called in each step are corresponding), but the input and output parameters of the tools will change. For example, the target reference user problem is: statistics on the traffic flow in area x1 of city A, and the actual user problem is: statistics on the traffic flow in area x2 of city A. Assuming that the reference solution step of the target reference user problem includes a step of calling tool y, the input parameter is: area x1 of city A, then the input parameter of the step of calling tool y in the actual solution step of the actual user problem will become: area x2 of city A. The first language model will complete the adaptive adjustment of the parameter.
[0099] The agent-based problem solving method provided by the embodiment of the present invention can form a reference knowledge base rich in prior knowledge by fully mining the reference user problems and corresponding reference solution steps in various application scenarios where the tool set in the agent can be used. In this way, after the actual user problem is generated, it is possible to hit similar reference user problems in the reference knowledge base with a higher probability, and combine the reference solution steps of the reference user problem to efficiently determine the actual solution steps of the actual user problem, thereby completing the efficient and accurate solution of the actual user problem.
[0100] Following the above embodiment, the process of sub-graph sampling for the tool graph is specifically introduced below:
[0101] In the embodiment of the present invention, Figure 4 As shown, subgraph sampling is performed on the tool graph to obtain multiple tool subgraphs, including: determining the target subgraph sampling method to be adopted according to the total number of multiple tools in the tool set; and performing subgraph sampling on the tool graph according to the target subgraph sampling method to obtain multiple tool subgraphs. Specifically, the total number of multiple tools in the tool set is obtained, and it is determined whether the total number of multiple tools in the tool set is less than the set threshold. If the total number of multiple tools is less than the set threshold, the target subgraph sampling method to be adopted is determined to be the subgraph traversal method; if the total number of multiple tools is greater than or equal to the set threshold, the target subgraph sampling method to be adopted is determined to be the random walk method. In fact, for tool graphs of the same scale, the computational cost of using the subgraph traversal method is often higher than that of the random walk method. Therefore, from the perspective of computational cost, the subgraph traversal method can be used for small-scale tool graphs, and the random walk method can be used for large-scale tool graphs. The subgraph traversal method and the random walk method are described in detail below.
[0102] For the subgraph traversal method, the sampling process of multiple tool subgraphs may include:
[0103] Determine multiple weakly connected subgraphs corresponding to the tool graph;
[0104] For the target weakly connected subgraph, if there is a target tool that meets the set conditions in the target weakly connected subgraph, the target weakly connected subgraph is filtered out. The set conditions include: the in-degree of the tool is less than the number of its input parameters, and the target weakly connected subgraph is any one of the multiple weakly connected subgraphs;
[0105] The weakly connected subgraphs remaining after filtering are determined as a plurality of tool subgraphs.
[0106] Among them, the process of determining multiple weakly connected subgraphs corresponding to the tool graph can be: first traverse each (initial) tool subgraph (directed graph) that may exist in the tool graph, and convert each traversed tool subgraph into an undirected graph to obtain a base graph of each tool subgraph. If the base graph of a tool subgraph is a connected graph, then the tool subgraph is a weakly connected graph (called a weakly connected subgraph).
[0107] Afterwards, the multiple weakly connected subgraphs are filtered: for any target weakly connected subgraph, if there is a target tool whose "in-degree is less than the number of its input parameters" in the target weakly connected subgraph, the target weakly connected subgraph is filtered.
[0108] It should be understood that the number of input parameters of the target tool here can be the number of necessary input parameters required by it. For example, if the target tool has 3 input parameters, but 1 of them is optional and 2 are required, then the number of necessary input parameters is 2. The in-degree of the target tool is actually the number of other tools it depends on, that is, the number of directed connection edges pointing to the target tool, and each directed connection edge actually corresponds to the output result of another tool, which will be used as the input parameter of the target tool. Therefore, if the in-degree of the target tool is less than the number of its input parameters, it means that the target tool has not obtained all the necessary input parameters, and the target tool cannot work properly. Then the target weakly connected subgraph containing the target tool does not meet the requirements and needs to be filtered out.
[0109] The weakly connected subgraphs remaining after the above filtering process correspond to the available multiple tool subgraphs.
[0110] For the random walk method, the sampling process of multiple tool subgraphs can be implemented as follows. The following steps are performed in each iteration process to obtain multiple tool subgraphs through multiple iteration processes;
[0111] Randomly select a tool in the tool graph as a seed tool, and generate a tool subgraph corresponding to the seed tool;
[0112] Each time, a tool is randomly selected from the tool subgraph corresponding to the seed tool as the extended tool, and the neighbor tools of the extended tool are added to the tool subgraph until the number of tools in the tool subgraph reaches the total number of tools contained in the tool subgraph set during this iteration, so as to obtain the tool subgraph corresponding to the seed tool.
[0113] In the specific implementation, during each iteration, a tool is randomly selected in the tool map as a seed tool, and the maximum number of tools N corresponding to the tool submap corresponding to the current seed tool is randomly determined (that is, the tool submap can contain at most N tools), and a tool submap containing the seed tool is generated based on the seed tool and the maximum number of tools N.
[0114] Specifically, a sub-tool is represented as a seed tool a, and the tool sub-graph g1 corresponding to the seed tool a generated initially only contains the seed tool. Afterwards, the neighbor tool b of the seed tool a (i.e., the tool having a connection edge with the seed tool) is determined in the tool graph, and the neighbor tool b and its connection edge with the seed tool a are added to the tool sub-graph g1 corresponding to the seed tool, thereby obtaining an updated tool sub-graph g2. Afterwards, a tool is randomly selected from the tool sub-graph g2 as an extended tool. Assuming that the tool b is selected at this time, the neighbor tools of the tool b are determined in the tool graph: assuming that they are tool c and tool d, and the tool c and tool d and their respective connection edges with tool b are added to the tool sub-graph g2 corresponding to the seed tool, thereby obtaining an updated tool sub-graph g3. And so on, until the number of tools in the updated tool sub-graph gi reaches the total number of tools N set in this iteration corresponding to the seed tool a. Or, before the total number of tools N is reached, it is no longer possible to add new tools to the tool sub-graph gi (for example, the neighbor tools of all tools in the tool sub-graph gi have been added to the tool sub-graph gi). The tool subgraph that meets the above iteration cutoff condition is finally determined as the tool subgraph sampling result corresponding to the seed tool a.
[0115] It should be noted that in the above-mentioned tool subgraph expansion process, a tool with no out-degree or in-degree (i.e., an isolated tool node that is not connected to other tools in the tool graph) can only be added once, that is, there will only be one tool subgraph for the isolated tool node, namely, a tool subgraph that uses it as a seed tool and only contains the seed tool.
[0116] Furthermore, if there is a target tool that meets the set conditions in the tool subgraph corresponding to a certain sub-tool, the tool subgraph corresponding to the seed tool is filtered out, and the set conditions include: the in-degree of the tool is less than the number of its input parameters. The meaning of the filtering condition and the filtering process can refer to the relevant description in the above embodiment, which will not be repeated here.
[0117] The following specifically describes the process of determining the reference user problems corresponding to each of the multiple tool subgraphs and the reference solution steps for the reference user problems based on the second largest language model in the intelligent agent.
[0118] Figure 5 A flowchart for determining the reference user problems corresponding to the multiple tool subgraphs and the reference solution steps for the reference user problems, such as Figure 5 As shown, the reference user questions corresponding to the plurality of tool subgraphs and the reference solution steps for the reference user questions are determined according to the second largest language model, including:
[0119] 501. Generate sub-graph description information corresponding to a target tool sub-graph, where the target tool sub-graph is any one of a plurality of tool sub-graphs.
[0120] 502. Add the sub-image description information corresponding to the target tool sub-image to the second prompt word template to generate a second prompt word.
[0121] 503. Input the second prompt word into the second largest language model to obtain a reference user question corresponding to the target tool subgraph output by the second largest language model and a reference solution step for the reference user question.
[0122] For step 501, for ease of understanding, the expression form of the subgraph description information corresponding to the target tool subgraph is illustrated by way of example. The subgraph description information may include: {"id":......,"tool desc":......},"tool input":{......},"tool output":{......}, where "id" is the identification information of a tool contained in the target tool subgraph, "tool desc" is the functional description information of the tool, "tool input" is the input parameter of the tool, and "tool output" is the output parameter of the tool, that is, the subgraph description information corresponding to the target tool subgraph at least includes the identification information, functional description information, input parameters and output parameters of each tool in the target tool subgraph. In addition, the subgraph description information corresponding to the target tool subgraph also needs to include the description information of the connection relationship (i.e., dependency relationship) between different tools therein. Thus, the second largest language model can learn the composition of the target tool subgraph, the tool usage method, and the tool calling relationship.
[0123] For step 502, after the subgraph description information corresponding to the target tool subgraph is generated in step 501, the subgraph description information can be added to the second prompt word template to generate the second prompt word, and the second prompt word template includes: task requirement prompt information and output content prompt information. The task requirement prompt information is used to prompt the second largest language model of the use requirements of the target tool subgraph in the process of generating the reference user question corresponding to the target tool subgraph and the reference solution step of the reference user question.
[0124] The prompt information required for this task is simply used to prompt the second largest language model on how to use the target tool subgraph to generate reference user problems and reference solution steps for the reference user problems. For example, the second largest language model is required to generate reference user problems that can be solved based on the tools provided in the target tool subgraph, and in the multi-step solution steps of the reference user problem, the tool call chain presented by the tools called in sequence must match the dependency relationship of the corresponding tools in the target tool subgraph. Another example is that the use of a tool in the target tool subgraph must meet the requirements of the input and output parameters of the tool (such as data type and meaning requirements). Another example is to inform the second largest language model that the same tool can be reused in the process of determining the reference solution steps for the generated user reference problem.
[0125] The output content prompt information is used to prompt the output content and the corresponding output format that the second language model needs to output, wherein the output format is, for example, json format. The output content prompt information includes a first output content prompt word, a second output content prompt word, a third output content prompt word, and a fourth output content prompt word.
[0126] Among them, the first output content prompt word is used to prompt the output of the reference user problem corresponding to the target tool subgraph, the second output content prompt word is used to prompt the output of the reference solution steps corresponding to the reference user problem, the third output content prompt word is used to prompt the output of the tool call graph corresponding to the tool called in the reference solution step, and the fourth output content prompt word is used to prompt the output of the verification result of the rationality check of the tool call graph and the reference user problem corresponding to the target tool subgraph, so that the reference user problem and reference solution steps that meet the verification results are added to the reference knowledge base.
[0127] By performing rationality checks on the reference user questions corresponding to the tool call graph and the target tool subgraph based on the second prompt word template, the feasibility of the user reference questions output by the second language model and their reference solution steps is ensured, thereby improving the quality of the reference knowledge base.
[0128] In the second prompt word template, the above four output content prompt words can have corresponding string identifiers and corresponding prompt contents respectively. For example, the string identifier corresponding to the first output content prompt word is "user_request", and the prompt content is, for example: please generate a reference user problem that gives detailed parameter information and can be solved by yourself; the string identifier corresponding to the second output content prompt word is "task_step", and the prompt content is, for example: give a specific list of solution steps, the format is step i: call a certain (assuming it is represented as ***) tool, the input parameters are: ###; the string identifier corresponding to the third output content prompt word is "invoking_graph", and the prompt content is, for example: the description information of tool node a "links" the description information of tool node b. Among them, links represents the dependency relationship between tool a and tool b, and the description information of each tool includes information such as the tool name, input and output parameters; the string identifier corresponding to the fourth output content prompt word is "check_by_teacher", and the prompt content is, for example: the inspection task is "to evaluate the generated reference user questions and tool call graphs here, to determine whether the reference user questions are appropriate, and whether the tool call graphs are available, with special attention to whether the prerequisites of the input parameters in the tool are met, and whether there are any omissions in the upstream tools that have not been called. Generate a short text to represent the verification results", and give the verification results: rationality of reference user questions: yes / no, availability of tool call graphs: yes / no.
[0129] Among them, the tool call graph is a graph structure reflecting the actual tool call relationship generated based on the tools used in each step of the reference solution steps corresponding to the reference user problem given by the second language model. The second language model will generate corresponding four parts of output content based on the above prompt content, including a paragraph of text generated to evaluate the rationality of the reference user problem and the tool call graph. If the evaluation content indicates that the reference user problem and the tool call graph are both reasonable (that is, the verification results are all yes), then the reference user problem and the corresponding reference solution steps are added to the reference knowledge base.
[0130] For ease of understanding, the following is a detailed description of the above four parts that the second largest language model needs to output:
[0131] 1. Reference user questions: reasonable questions generated based on the target tool subgraph.
[0132] 2. Reference solution steps: Give the tools that need to be called at each step when solving the reference user problem and the input parameters of the tools. The specific format is: "Step 1: ......; Step 2: ......; Step 3: ......".
[0133] 3. Tool call graph: List the nodes in the tool call graph and the edges between every two nodes in JSON format. The nodes in the tool call graph are the tools called in each step and the related parameters of the tools.
[0134] 4. Verify results: Evaluate the rationality of the reference user questions and tool call graphs corresponding to the target tool subgraphs to determine whether the reference user questions are appropriate and whether the tool call graphs are truly usable.
[0135] Based on the above, after the sub-image description information corresponding to the target tool sub-image is added to the second prompt word template, the second prompt word can be generated.
[0136] For step 503, in step 502, the sub-graph description information corresponding to the target tool sub-graph is added to the second prompt word template. After the second prompt word is generated, the second prompt word is input into the second largest language model to obtain the reference user problem corresponding to the target tool sub-graph output by the second largest language model and the reference solution steps for the reference user problem.
[0137] Figure 6 A flowchart of a method for generating a reference knowledge base provided by an embodiment of the present invention is shown in FIG. Figure 6 As shown, the method comprises the following steps:
[0138] 601. Obtain a toolset included in an intelligent agent, wherein the intelligent agent includes a first language model.
[0139] 602. Generate a tool graph corresponding to the toolset through the second largest language model, where the tool graph describes dependencies between multiple tools in the toolset.
[0140] 603. Perform sub-graph sampling on the tool graph to obtain multiple tool sub-graphs, where the multiple tool sub-graphs are used to reflect multiple application scenarios applicable to multiple tools.
[0141] 604. Determine reference user questions and reference solution steps of the reference user questions corresponding to each of the plurality of tool subgraphs according to the second largest language model, wherein the tools included in the corresponding tool subgraphs are called in the reference solution steps.
[0142] 605. Generate a reference knowledge base including reference user problems corresponding to each of the plurality of tool subgraphs and reference solution steps for the reference user problems.
[0143] The specific implementation process of steps 601-604 can be found in the above embodiment and will not be described again here.
[0144] Compared with the traditional solution of manually entering the reference knowledge base, the embodiment of the present invention can automatically generate a reference knowledge base consisting of reference user questions covering more scenarios and reference solution steps of reference user questions based on the mining of tool graphs and tool subgraphs and the learning of large language models. The automation is significantly improved and the application scenarios covered are more comprehensive.
[0145] Based on the above-mentioned reference knowledge base construction method, the constructed reference knowledge base can be used to process the user problems actually input by the user that need to be solved.
[0146] Specifically, in response to the input of the actual user question, a target reference user question matching the actual user question is determined from the constructed reference knowledge base. Afterwards, the target reference user question, the reference solution steps corresponding to the target reference user question stored in the reference knowledge base, and the actual user question are input into the intelligent agent, so that the intelligent agent outputs the actual solution steps corresponding to the actual user question through the first language model contained in itself, and completes the solution of the actual user question based on the actual solution steps. Among them, the actual solution step calls the tool used in the corresponding reference solution step.
[0147] As described above, the reference knowledge base includes reference user problems and reference solution steps of the reference user problems corresponding to multiple tool subgraphs determined based on the second largest language model. The reference solution step of a reference user problem calls the tools contained in the corresponding tool subgraph. The multiple tool subgraphs are obtained by collecting subgraphs of the tool graph generated by the second largest language model. The tool graph corresponds to the tool set contained in the intelligent agent, and is used to describe the dependency relationship between multiple tools in the tool set.
[0148] The following will describe in detail the agent-based problem solving device of one or more embodiments of the present invention. Those skilled in the art will appreciate that these devices can be configured using commercially available hardware components through the steps taught in this solution.
[0149] Figure 7 A schematic diagram of a problem-solving device based on an agent provided in an embodiment of the present invention is shown in FIG. Figure 7 As shown, the device includes: an acquisition module 11, a generation module 12, a sampling module 13, a determination module 14 and a solution module 15.
[0150] The acquisition module 11 is used to acquire a tool set included in an intelligent agent, wherein the intelligent agent includes a first language model.
[0151] The generating module 12 is used to generate a tool graph corresponding to the tool set by using the second largest language model, wherein the tool graph describes the dependency relationship between multiple tools in the tool set.
[0152] The sampling module 13 is used to perform sub-graph sampling on the tool graph to obtain a plurality of tool sub-graphs, where the plurality of tool sub-graphs are used to reflect a plurality of application scenarios to which the plurality of tools are applicable.
[0153] The determination module 14 is used to determine the reference user questions corresponding to each of the multiple tool subgraphs and the reference solution steps of the reference user questions according to the second largest language model, wherein the tools included in the corresponding tool subgraph are called in the reference solution steps.
[0154] The solution module 15 is used to respond to the input of the actual user problem and complete the solution of the actual user problem based on the reference knowledge base and the intelligent agent, wherein the reference knowledge base contains the reference user problems corresponding to each of the multiple tool subgraphs and the reference solution steps of the reference user problems.
[0155] Among them, optionally, the generation module 12 is specifically used to: add the definition information of the first tool and the definition information of the second tool in the toolset to the first prompt word template to generate a first prompt word, the first tool and the second tool are any two tools in the toolset; input the first prompt word into the second largest language model to obtain the dependency determination result of the first tool and the second tool output by the second largest language model; determine the corresponding connection edges between the first tool and the second tool in the tool graph according to the dependency determination result, wherein the nodes in the tool graph are the multiple tools in the toolset.
[0156] Among them, the first prompt word template includes: dependency feature prompt information and task requirement prompt information; the task requirement prompt information is used to prompt the second largest language model to complete the dependency determination task of the two input tools; the dependency feature prompt information is used to prompt the feature requirements that need to be met by two tools with a dependency relationship.
[0157] Optionally, the sampling module 13 is specifically used to: determine a target subgraph sampling method to be adopted according to the total number of the multiple tools in the tool set; and perform subgraph sampling on the tool graph according to the target subgraph sampling method to obtain multiple tool subgraphs.
[0158] Optionally, the sampling module 13 is specifically used to: if the total number of the multiple tools is less than a set threshold, determine that the target subgraph sampling method to be adopted is a subgraph traversal method; if the total number of the multiple tools is greater than or equal to the set threshold, determine that the target subgraph sampling method to be adopted is a random walk method.
[0159] Among them, optionally, the target subgraph sampling method is a subgraph traversal method, and the sampling module 13 is specifically used to: determine multiple weakly connected subgraphs corresponding to the tool graph; for the target weakly connected subgraph, if there is a target tool that meets the set conditions in the target weakly connected subgraph, filter out the target weakly connected subgraph, and the set conditions include: the in-degree of the tool is less than the number of its input parameters, and the target weakly connected subgraph is any one of the multiple weakly connected subgraphs; determine the weakly connected subgraphs remaining after filtering as the multiple tool subgraphs.
[0160] Optionally, the target subgraph sampling method is a random walk method, and the sampling module 13 is specifically used to: perform the following steps in each iterative process to obtain the multiple tool subgraphs through multiple iterative processes: randomly select a tool as a seed tool in the tool graph to generate a tool subgraph corresponding to the seed tool; randomly select a tool as an extended tool from the tool subgraph corresponding to the seed tool each time, and add the neighbor tools of the extended tool to the tool subgraph until the number of tools in the tool subgraph reaches the total number of tools contained in the tool subgraph set in this iterative process, so as to obtain the tool subgraph corresponding to the seed tool.
[0161] Optionally, the device further includes: a filtering module for filtering out the tool subgraph corresponding to the seed tool if there is a target tool that meets set conditions in the tool subgraph corresponding to the seed tool, and the set conditions include: the in-degree of the tool is less than the number of its input parameters.
[0162] Among them, optionally, the determination module 14 is specifically used to: generate sub-graph description information corresponding to the target tool sub-graph, the target tool sub-graph being any one of the multiple tool sub-graphs; adding the sub-graph description information corresponding to the target tool sub-graph to a second prompt word template to generate a second prompt word; inputting the second prompt word into the second largest language model to obtain a reference user problem corresponding to the target tool sub-graph output by the second largest language model and a reference solution step for the reference user problem.
[0163] Among them, the second prompt word template includes: task requirement prompt information and output content prompt information; the task requirement prompt information is used to prompt the second large language model of the use requirements of the target tool subgraph in the process of generating the reference user problem corresponding to the target tool subgraph and the reference solution steps of the reference user problem; the output content prompt information is used to prompt the output content and the corresponding output format that the second large language model needs to output, wherein the output content prompt information includes a first output content prompt word and a second output content prompt word; the first output content prompt word is used to prompt the output of the reference user problem corresponding to the target tool subgraph, and the second output content prompt word is used to prompt the output of the reference solution steps corresponding to the reference user problem.
[0164] In addition, the output content prompt information includes a third output content prompt word and a fourth output content prompt word; the third output content prompt word is used to prompt the output of a tool call graph corresponding to the tool called in the reference solution step, and the fourth output content prompt word is used to prompt the output of a verification result of a rationality check on the tool call graph and the reference user problem corresponding to the target tool subgraph.
[0165] Wherein, optionally, the solution module 15 is specifically used to: in response to the input of the actual user problem, determine the target reference user problem matching the actual user problem from the reference knowledge base; input the target reference user problem, the reference solution step corresponding to the target reference user problem and the actual user problem into the intelligent agent, so that the intelligent agent outputs the actual solution step corresponding to the actual user problem through the first large language model, and completes the solution of the actual user problem based on the actual solution step; wherein the tool used in the corresponding reference solution step is called in the actual solution step
[0166] Figure 8 A schematic diagram of a reference knowledge base generation device provided by an embodiment of the present invention is shown in FIG. Figure 8 As shown, the device includes: an acquisition module 21, a generation module 22, a sampling module 23, a determination module 24 and a creation module 25.
[0167] The acquisition module 21 is used to acquire the tool set included in the intelligent agent, and the intelligent agent includes the first language model.
[0168] The generating module 22 is used to generate a tool graph corresponding to the tool set by using the second largest language model, wherein the tool graph describes the dependency relationship between multiple tools in the tool set.
[0169] The sampling module 23 is used to perform sub-graph sampling on the tool graph to obtain multiple tool sub-graphs, where the multiple tool sub-graphs are used to reflect multiple application scenarios applicable to multiple tools.
[0170] The determination module 24 is used to determine the reference user questions corresponding to each of the plurality of tool subgraphs and the reference solution steps of the reference user questions according to the second largest language model, wherein the tools included in the corresponding tool subgraphs are called in the reference solution steps.
[0171] The creation module 25 is used to generate a reference knowledge base including reference user questions corresponding to each of the plurality of tool subgraphs and reference solution steps for the reference user questions.
[0172] Figure 7 and Figure 8 The device shown can execute the steps provided in the aforementioned embodiments. For detailed execution process and technical effects, please refer to the description in the aforementioned embodiments, which will not be repeated here.
[0173] In one possible design, the above Figure 7 or Figure 8 The structure of the device shown can be implemented as an electronic device. Fig. 9 As shown, the electronic device may include: a processor 31, a memory 32, and a communication interface 33. The memory 32 stores executable codes, and when the executable codes are executed by the processor 31, the processor 31 can at least implement the agent-based problem solving method or reference knowledge base generation method provided in the aforementioned embodiments.
[0174] In addition, an embodiment of the present invention provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor can at least implement the agent-based problem-solving method or reference knowledge base generation method provided in the aforementioned embodiments.
[0175] In addition, an embodiment of the present invention provides a computer program product, which includes: a computer program, which, when executed by a processor of an electronic device, enables the processor to at least implement the agent-based problem-solving method or reference knowledge base generation method provided in the aforementioned embodiments.
[0176] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. Those of ordinary skill in the art may understand and implement the present invention without creative effort.
[0177] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and software. Based on such an understanding, the above technical solution can essentially or in other words be embodied in the form of a computer product, and the present invention can be implemented in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0178] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. An agent-based problem solving method, characterized in that: include: Obtaining a toolset included in an agent, wherein the agent includes a first language model; Generate a tool graph corresponding to the toolset by using a second language model, wherein the tool graph describes dependencies between multiple tools in the toolset; Performing sub-graph sampling on the tool graph to obtain a plurality of tool sub-graphs, wherein the plurality of tool sub-graphs are used to reflect a plurality of application scenarios to which the plurality of tools are applicable; Determine, according to the second largest language model, reference user questions corresponding to each of the plurality of tool subgraphs and reference solution steps for the reference user questions, wherein the reference solution steps call tools included in the corresponding tool subgraphs; In response to input of an actual user problem, solving the actual user problem based on a reference knowledge base and the agent, wherein the reference knowledge base contains reference user problems corresponding to each of the plurality of tool subgraphs and reference solution steps for the reference user problems; The generating a tool graph corresponding to the tool set by using the second largest language model includes: Adding definition information of a first tool and definition information of a second tool in the tool set to a first prompt word template to generate a first prompt word, wherein the first tool and the second tool are any two tools in the tool set; Inputting the first prompt word into the second largest language model to obtain a result of determining the dependency relationship between the first tool and the second tool output by the second largest language model; Determine the corresponding connection edges between the first tool and the second tool in the tool graph according to the dependency determination result, wherein the nodes in the tool graph are the multiple tools in the tool set, and the first prompt word template includes: dependency feature prompt information and task requirement prompt information; the task requirement prompt information is used to prompt the second largest language model to complete the dependency determination task of the two input tools; the dependency feature prompt information is used to prompt the feature requirements that need to be met by the two tools with a dependency relationship.
2. The method according to claim 1, characterized in that The performing sub-graph sampling on the tool graph to obtain a plurality of tool sub-graphs includes: Determining a target subgraph sampling method to be used according to the total number of the plurality of tools in the tool set; According to the target subgraph sampling method, subgraph sampling is performed on the tool graph to obtain a plurality of tool subgraphs.
3. The method according to claim 2, characterized in that The step of determining the target subgraph sampling method to be used according to the total number of the plurality of tools in the tool set includes: If the total number of the plurality of tools is less than a set threshold, determining that the adopted target subgraph sampling method is a subgraph traversal method; If the total number of the plurality of tools is greater than or equal to a set threshold, it is determined that the adopted target subgraph sampling method is a random walk method.
4. The method according to claim 3, characterized in that: The target subgraph sampling method is a subgraph traversal method; The step of performing sub-graph sampling on the tool graph according to the target sub-graph sampling method to obtain a plurality of tool sub-graphs includes: Determine a plurality of weakly connected subgraphs corresponding to the tool graph; For a target weakly connected subgraph, if there is a target tool that meets a set condition in the target weakly connected subgraph, the target weakly connected subgraph is filtered out, and the set condition includes: the in-degree of the tool is less than the number of its input parameters, and the target weakly connected subgraph is any one of the multiple weakly connected subgraphs; The weakly connected subgraphs remaining after filtering are determined as the multiple tool subgraphs.
5. The method according to claim 3, characterized in that: The target subgraph sampling method is a random walk method; The step of performing sub-graph sampling on the tool graph according to the target sub-graph sampling method to obtain a plurality of tool sub-graphs includes: The following steps are performed in each iteration process to obtain the multiple tool subgraphs through multiple iteration processes: Randomly select a tool in the tool graph as a seed tool, and generate a tool subgraph corresponding to the seed tool; Each time, a tool is randomly selected from the tool subgraph corresponding to the seed tool as an extended tool, and the neighbor tools of the extended tool are added to the tool subgraph until the number of tools in the tool subgraph reaches the total number of tools contained in the tool subgraph set during this iteration, so as to obtain the tool subgraph corresponding to the seed tool.
6. The method according to claim 5, characterized in that The method further comprises: If there is a target tool that meets the set conditions in the tool subgraph corresponding to the seed tool, the tool subgraph corresponding to the seed tool is filtered out, and the set conditions include: the in-degree of the tool is less than the number of its input parameters.
7. The method according to claim 1, characterized in that The step of determining reference user questions corresponding to each of the plurality of tool subgraphs and reference solutions to the reference user questions according to the second largest language model includes: Generate subgraph description information corresponding to a target tool subgraph, where the target tool subgraph is any one of the multiple tool subgraphs; Adding the sub-image description information corresponding to the target tool sub-image to the second prompt word template to generate a second prompt word; The second prompt word is input into the second large language model to obtain a reference user question corresponding to the target tool subgraph output by the second large language model and a reference solution step for the reference user question.
8. The method according to claim 7, characterized in that The second prompt word template includes: task requirement prompt information and output content prompt information; The task requirement prompt information is used to prompt the second largest language model for the use requirement of the target tool subgraph in the process of generating the reference user question corresponding to the target tool subgraph and the reference solution step of the reference user question; The output content prompt information is used to prompt the output content and the corresponding output format that the second large language model needs to output, wherein the output content prompt information includes a first output content prompt word and a second output content prompt word; the first output content prompt word is used to prompt the output of a reference user problem corresponding to the target tool subgraph, and the second output content prompt word is used to prompt the output of a reference solution step corresponding to the reference user problem.
9. The method according to claim 8, characterized in that The output content prompt information includes a third output content prompt word and a fourth output content prompt word; the third output content prompt word is used to prompt the output of a tool call graph corresponding to the tool called in the reference solution step, and the fourth output content prompt word is used to prompt the output of a verification result of a rationality check on the tool call graph and the reference user problem corresponding to the target tool subgraph.
10. The method according to any one of claims 1 to 9, characterized in that: The step of responding to the input of the actual user problem and solving the actual user problem based on the reference knowledge base and the intelligent agent comprises: In response to input of an actual user question, determining a target reference user question matching the actual user question from the reference knowledge base; The target reference user problem, the reference solution steps corresponding to the target reference user problem and the actual user problem are input into the intelligent agent, so that the intelligent agent outputs the actual solution steps corresponding to the actual user problem through the first large language model, and completes the solution of the actual user problem based on the actual solution steps; wherein the tools used in the corresponding reference solution steps are called in the actual solution steps.
11. A method for generating a reference knowledge base, characterized in that: include: Obtaining a toolset included in an agent, wherein the agent includes a first language model; Generate a tool graph corresponding to the toolset by using a second language model, wherein the tool graph describes dependencies between multiple tools in the toolset; Performing sub-graph sampling on the tool graph to obtain a plurality of tool sub-graphs, wherein the plurality of tool sub-graphs are used to reflect a plurality of application scenarios to which the plurality of tools are applicable; Determine, according to the second largest language model, reference user questions corresponding to each of the plurality of tool subgraphs and reference solution steps for the reference user questions, wherein the reference solution steps call tools included in the corresponding tool subgraphs; Generate a reference knowledge base including reference user problems corresponding to each of the plurality of tool subgraphs and reference solution steps for the reference user problems; The generating a tool graph corresponding to the tool set by using the second largest language model includes: Adding definition information of a first tool and definition information of a second tool in the tool set to a first prompt word template to generate a first prompt word, wherein the first tool and the second tool are any two tools in the tool set; Inputting the first prompt word into the second largest language model to obtain a result of determining the dependency relationship between the first tool and the second tool output by the second largest language model; Determine the corresponding connection edges between the first tool and the second tool in the tool graph according to the dependency determination result, wherein the nodes in the tool graph are the multiple tools in the tool set, and the first prompt word template includes: dependency feature prompt information and task requirement prompt information; the task requirement prompt information is used to prompt the second largest language model to complete the dependency determination task of the two input tools; the dependency feature prompt information is used to prompt the feature requirements that need to be met by the two tools with a dependency relationship.
12. An agent-based problem solving method, characterized in that: include: In response to input of an actual user question, determining a target reference user question matching the actual user question from a constructed reference knowledge base; The target reference user problem, the reference solution steps corresponding to the target reference user problem stored in the reference knowledge base, and the actual user problem are input into the intelligent agent, so that the intelligent agent outputs the actual solution steps corresponding to the actual user problem through the first language model contained in the intelligent agent, and completes the solution of the actual user problem based on the actual solution steps; wherein the actual solution steps call the tools used in the corresponding reference solution steps; The reference knowledge base includes reference user problems corresponding to multiple tool subgraphs determined based on the second largest language model and reference solution steps for the reference user problems, wherein the reference solution steps for the reference user problems call tools included in the corresponding tool subgraphs; the multiple tool subgraphs are obtained by collecting subgraphs of the tool graph generated by the second largest language model; the tool graph corresponds to a toolset included in the agent, and is used to describe the dependency relationship between multiple tools in the toolset; The steps to generate a tool graph using the second largest language model are as follows: Adding definition information of a first tool and definition information of a second tool in the tool set to a first prompt word template to generate a first prompt word, wherein the first tool and the second tool are any two tools in the tool set; Inputting the first prompt word into the second largest language model to obtain a result of determining the dependency relationship between the first tool and the second tool output by the second largest language model; Determine the corresponding connection edges between the first tool and the second tool in the tool graph according to the dependency determination result, wherein the nodes in the tool graph are the multiple tools in the tool set, and the first prompt word template includes: dependency feature prompt information and task requirement prompt information; the task requirement prompt information is used to prompt the second largest language model to complete the dependency determination task of the two input tools; the dependency feature prompt information is used to prompt the feature requirements that need to be met by the two tools with a dependency relationship.
13. An electronic device, characterized in that: include: A memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the method as claimed in any one of claims 1 to 10 or claim 11 or claim 12.
14. A non-transitory machine-readable storage medium, characterized in that: The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor executes the method according to any one of claims 1 to 10 or claim 11 or claim 12.
15. A computer program product, characterized in that include: A computer program, when executed by a processor of an electronic device, causes the processor to perform the method according to any one of claims 1 to 10 or claim 11 or claim 12.
