A task processing method, device and electronic device based on intelligent agent

By using the target knowledge graph and task description in the agent system to determine and call appropriate tools, the model input space occupation problem caused by the increase in the length of the prompt word is solved, and the ability to flexibly and accurately call tools to perform tasks without increasing the length of the prompt word is realized.

CN119166834BActive Publication Date: 2025-05-02ZHUO SHI ZHI XING (QINGTIAN) YUAN UNIVERSE TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411671886.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-05-02
Estimated Expiration
2044-11-21

AI Technical Summary

Technical Problem

As the number of tools that need to be called increases, the length of the prompt word increases, resulting in the input space of the model being occupied, exceeding the maximum length limit of the model input, increasing the difficulty of understanding the model, and thus affecting the ability of the agent to call the tool to perform tasks.

Method used

By obtaining the target knowledge graph and the task description of the pending task, entity extraction is carried out, tool entities that are associated with the task entity information, and target tool entities are determined from candidate tool entities based on the function function description and tool attributes of the task function, and the target tool is called to execute the pending task.

Benefits of technology

Without increasing the length of the prompt word, the tool can be called flexibly and accurately to perform tasks, reducing the difficulty of the model's understanding of the prompt word and improving the ability of the agent to call the tool.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166834B_ABST
    Figure CN119166834B_ABST
Patent Text Reader

Abstract

The present invention provides an agent-based task processing method, device and electronic device, and relates to the field of artificial intelligence technology. The method comprises: obtaining a target knowledge graph and a task description of a task to be processed; performing entity extraction processing on the task description to obtain task entity information; determining a tool entity that has an association relationship with the task entity information from the target knowledge graph to obtain a plurality of candidate tool entities; determining a target tool entity from a plurality of candidate tool entities according to a function description corresponding to the task function and a tool attribute corresponding to the candidate tool entity; calling the target tool to execute the task to be processed to obtain the execution result of the task to be processed. When executing a task, the present invention realizes the calling of the tool by searching the target knowledge graph, without adding a large amount of tool information in the prompt word, and can flexibly and accurately call the tool to execute the task according to the task description without increasing the length of the prompt word.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to an agent-based task processing method, device and electronic equipment. Background Art

[0002] An agent is a system that can autonomously perceive the environment, make decisions, and execute actions. Currently, most agents are based on large language models. After reasoning about user input, the agent analyzes the user input and breaks down the task into subtasks. The model then automatically calls and selects the appropriate tool to complete the user task.

[0003] At present, the tool information related to the defined tools can be sent to the model input in the form of prompt words. The prompt words can also include the overall task description, thinking and reasoning steps, etc., so that the model can call the corresponding tool to complete the user task. However, as the number of tools that need to be called increases, the length of the prompt words will become longer and longer, resulting in a large amount of input space of the model being occupied by the prompt words, constantly squeezing out other input information of the model, and even exceeding the maximum length limit of the model input. In addition, the longer and longer prompt words also increase the difficulty of understanding the model, which is prone to misunderstanding, resulting in the inability to correctly call the tool to perform the task, affecting the ability of the intelligent agent to call the tool to perform the task. Summary of the invention

[0004] In view of the above problems, the object of the present invention is to provide an agent-based task processing method, device and electronic device, which can call tools to perform tasks without increasing the length of prompt words.

[0005] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0006] In one aspect, the present invention provides an agent-based task processing method, comprising:

[0007] Obtain a target knowledge graph and a task description of a task to be processed, wherein the target knowledge graph includes a tool entity, a domain entity, and an association relationship between the tool entity and the domain entity;

[0008] Performing entity extraction processing on the task description to obtain task entity information;

[0009] Determine a tool entity associated with the task entity information from the target knowledge graph to obtain a plurality of candidate tool entities;

[0010] Determine a target tool entity from the plurality of candidate tool entities according to a function description corresponding to a task function and a tool attribute corresponding to the candidate tool entity, wherein the task function is a function function required to execute the task to be processed;

[0011] A target tool is called to execute the task to be processed, and an execution result of the task to be processed is obtained. The target tool is a tool represented by the target tool entity.

[0012] Optionally, the task entity information includes a task entity name and a task entity type, and the tool entity associated with the task entity information is determined from the target knowledge graph to obtain multiple candidate tool entities, including:

[0013] Calling a search function to search the target knowledge graph for entities that match the task entity name and entities that match the task entity type, and obtaining matching entities;

[0014] Obtaining a tool entity in the target knowledge graph that has an association relationship with the matching entity, and obtaining a plurality of associated tool entities;

[0015] Based on the task description and the tool attributes corresponding to each of the associated tool entities, a candidate tool entity is determined from the multiple associated tool entities.

[0016] Optionally, the tool attribute includes a tool function description, and determining a candidate tool entity from the plurality of associated tool entities based on the task description and the tool attribute corresponding to each of the associated tool entities includes:

[0017] For each of the associated tool entities, calculating a first similarity between the tool function description of the associated tool entity and the task description;

[0018] Sorting all the associated tool entities in descending order of the first similarity to obtain an associated tool sequence;

[0019] Based on the associated tool sequence, a candidate tool entity is determined from the plurality of associated tool entities.

[0020] Optionally, the tool attributes include a tool function description, and determining a target tool entity from the plurality of candidate tool entities according to the function description corresponding to the task function and the tool attributes corresponding to the candidate tool entities comprises:

[0021] Obtaining a function description corresponding to the task function according to the task description;

[0022] For each of the candidate tool entities, calculating a second similarity between the tool function description corresponding to the candidate tool entity and the function description;

[0023] The candidate tool entity corresponding to the maximum value in the second similarity is taken as the target tool.

[0024] Optionally, acquiring a function description corresponding to the task function according to the task description includes:

[0025] Analyze and process the task description to obtain the task requirements corresponding to the task to be processed;

[0026] Generate a function input and an expected output of a task function according to the task requirements;

[0027] The function input and the expected output are combined to obtain a function description corresponding to the task function.

[0028] Optionally, the calling of the target tool to execute the task to be processed and obtaining the execution result of the task to be processed includes:

[0029] Acquire tool attributes corresponding to the target tool from the target knowledge graph, wherein the tool attributes include calling parameters and tool output restrictions of the target tool;

[0030] Based on the calling parameters and the task description, generating calling information of the target tool;

[0031] Using the calling information to call the target tool, so as to control the target tool to execute the task to be processed and obtain the target tool output;

[0032] The target tool output is adjusted according to the tool output restriction to obtain the execution result of the task to be processed.

[0033] Optionally, before obtaining the target knowledge graph and the task description of the task to be processed, the method further includes:

[0034] Acquire a domain knowledge graph, wherein the domain knowledge graph includes different types of domain entities and associations between domain entities;

[0035] Acquire multiple preset tools and attribute information corresponding to each of the preset tools;

[0036] Taking each of the preset tools as a tool entity, and taking the attribute information corresponding to the preset tool as a tool attribute of the tool entity;

[0037] For each of the tool entities, the tool entity is embedded into the domain knowledge graph according to the tool attributes to obtain a target knowledge graph.

[0038] Optionally, for each of the tool entities, embedding the tool entity into the domain knowledge graph according to the tool attribute to obtain a target knowledge graph includes:

[0039] For each of the tool entities, using the tool attributes to generate a specified description corresponding to the tool entity, the specified description including a tool action and a tool operation object;

[0040] Retrieving domain entities matching the tool operation object in the domain knowledge graph to obtain operation entities;

[0041] Using the tool action, an association relationship between the tool entity and the operation entity is established to obtain a target knowledge graph.

[0042] In another aspect, the present invention provides an agent-based task processing device for implementing any of the above methods, the device comprising:

[0043] An acquisition module, used to acquire a target knowledge graph and a task description of a task to be processed, wherein the target knowledge graph includes a tool entity, a domain entity, and an association relationship between the tool entity and the domain entity;

[0044] An extraction module, used to perform entity extraction processing on the task description to obtain task entity information;

[0045] A candidate module is used to determine a tool entity that has an association relationship with the task entity information from the target knowledge graph to obtain a plurality of candidate tool entities;

[0046] A determination module, configured to determine a target tool entity from the plurality of candidate tool entities according to a function description corresponding to a task function and a tool attribute corresponding to the candidate tool entity, wherein the task function is a function function required to execute the task to be processed;

[0047] The processing module is used to call a target tool to execute the task to be processed and obtain an execution result of the task to be processed. The target tool is a tool represented by the target tool entity.

[0048] On the other hand, the present invention also provides an electronic device, including a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in any agent-based task processing method provided by the present invention.

[0049] On the other hand, the present invention also provides a computer-readable storage medium, which stores a plurality of instructions, and the instructions are suitable for a processor to load to execute the steps in any one of the agent-based task processing methods provided by the present invention.

[0050] On the other hand, the present invention also provides a computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of any agent-based task processing method provided by the present invention.

[0051] The beneficial effects brought about by the technical solution provided by the present invention include at least:

[0052] In the embodiment of the present invention, an association relationship is established between the tool to be called and the data entity in the domain as the target knowledge graph. When the task description is obtained, the task description is subjected to entity analysis to obtain the task entity information. The task entity information is used to search for the candidate tool entity from the target knowledge graph. The function description of the task function and the tool attribute of the candidate tool entity are then used to determine the target tool entity from the candidate tool entity. Finally, the target tool is called to execute the task to be processed to obtain the execution result. The tool information and the knowledge graph in the domain are integrated into the target knowledge graph. When executing the task, the tool can be called directly by searching the target knowledge graph. There is no need to add a large amount of tool information in the prompt word in advance. The tool can be called flexibly and accurately according to the task description to execute the task without increasing the length of the prompt word. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0054] Figure 1 is a schematic diagram of an application scenario of the agent-based task processing method provided by an embodiment of the present invention;

[0055] Figure 2 is a flowchart of an agent-based task processing method provided by an embodiment of the present invention;

[0056] Figure 3 is a schematic diagram of a target knowledge graph provided by an embodiment of the present invention;

[0057] Figure 4 It is a schematic diagram of determining a target tool entity from a target knowledge graph provided by an embodiment of the present invention;

[0058] Figure 5 is a schematic diagram of the structure of an agent-based task processing device provided by an embodiment of the present invention;

[0059] Figure 6 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0060] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0061] It is understandable that in the specific implementation of the present invention, data related to user information, etc., needs to obtain user permission or consent, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0062] The present invention proposes a task processing method, device and electronic device based on an intelligent agent. Figure 1 , shows a schematic diagram of an application scenario of an agent-based task processing method. The application scenario may include a terminal 101 and a server 102, and data may be exchanged between the terminal 101 and the server 102 via a network, and a corresponding application may be installed on the terminal 101. The terminal 101 may be a mobile phone, a tablet computer, a smart Bluetooth device, a computer, a large screen, a robot, and the like; the server 102 may be a single server or a server cluster consisting of multiple servers.

[0063] The user can send the task description of the task to be processed to the server 102 through the application on the terminal 101. The server 102 can obtain the task description and the target knowledge graph; perform entity extraction processing on the task description to obtain task entity information; determine the tool entity that has an association relationship with the task entity information in the target knowledge graph to obtain multiple candidate tool entities; determine the target tool entity from multiple candidate tool entities based on the function description corresponding to the task function and the tool attributes corresponding to the candidate tool entity, and then call the target tool to execute the task to be processed to obtain the execution result of the task to be processed, which can be fed back to the terminal 101 by the server 102 to display the execution result to the user.

[0064] In this embodiment, a task processing method based on an agent is provided, such as Figure 2 As shown, the specific process of the agent-based task processing method can be as follows:

[0065] S110, obtaining the target knowledge graph and the task description of the task to be processed.

[0066] The task description of the task to be processed is data input by the user, and the task description contains the content of the task to be processed. For example, if the task description is "What are the symptoms of a cold", then the corresponding task to be processed is to give the symptoms of a cold; for another example, if the task description is "Please buy cold medicine", then the task to be processed is to buy cold medicine. Among them, there are many ways to input the task description, such as voice input, text input, image input or multimodal input, etc., which are not specifically limited here. The task description in the embodiment of the present invention can be in text form, and no matter how it is input, it can be converted into text form for subsequent processing.

[0067] The target knowledge graph is the knowledge graph needed to be used in executing the task to be processed. The target knowledge graph can be acquired in advance and stored in a specified location, and can be acquired from the specified location when needed.

[0068] The target knowledge graph may include multiple nodes and edges. Nodes can be used to represent different types of entities, such as tool entities, domain entities, etc. Tool entities represent a tool that can be called by an intelligent agent, such as a tool for purchasing items, which means that the tool can realize the function of purchasing items, and another example is a chart analysis tool, which can analyze charts and output analysis results. Domain entities refer to data entities in a specific field or scenario. For example, in the field of medical health, domain entities can include symptoms, diseases, drugs, etc.

[0069] Edges can be used to represent the association between entities. Edges in the target knowledge graph can be used to represent the association between tool entities and domain entities. Of course, there are also associations between different domain entities. Each entity in the target knowledge graph has its corresponding entity attribute, which is used to supplement the description of the entity to provide detailed information about the entity.

[0070] Domain entities and the relationships between domain entities can be regarded as domain knowledge graphs, and the target knowledge graph can embed tool entities based on the domain knowledge graph. As an implementation method, the target knowledge graph can be pre-built before obtaining the target knowledge graph. When building the target knowledge graph, it can be to obtain a domain knowledge graph, the domain knowledge graph includes different types of domain entities and the relationships between domain entities; obtain multiple preset tools and attribute information corresponding to each preset tool; regard each preset tool as a tool entity, and regard the attribute information corresponding to the preset tool as the tool attribute of the tool entity; for each tool entity, embed the tool entity into the domain knowledge graph according to the tool attribute to obtain the target knowledge graph.

[0071] The domain knowledge graph is a knowledge graph composed of specific domain entities. The meanings of nodes and edges in knowledge graphs in different domains are different. For example, see Figure 3 , shows a schematic diagram of the target knowledge graph, where the dotted box is the domain knowledge graph in the medical and health field. In the domain knowledge graph, domain entities may include symptom types, disease types, and drug types. Among them, there may be an association relationship between the domain entity of the symptom type and the domain entity of the disease type, and the association relationship may be that a certain disease may contain a certain symptom, and the association relationship between the domain entity of the drug type and the domain entity of the disease type is treatment, that is, a certain drug can treat a certain disease.

[0072] Preset tools are tools that can be called in the agent system. These preset tools usually have corresponding tool functions, which can contain information such as name, call parameters, function description, and function implementation. Among them, the name refers to the identifier of the tool function; the call parameters refer to the parameters that need to be provided when calling the tool function; the function description is a description of the function implemented by the function; and the function implementation refers to the specific code implementation of the tool function.

[0073] The tool function can be used as the attribute information corresponding to the preset tool. Of course, the attribute information can also include auxiliary prompt words, which can be used to further restrict the output of the tool function, that is, it can include tool output restrictions. The auxiliary prompt word is a piece of text and can be set according to actual needs. For example, the "Disease Information Query" tool can return the information corresponding to a certain disease. The auxiliary prompt word can be set as follows: When the tool returns a lot of information, it may be necessary to summarize and extract content that is more relevant to the user input. For another example, the auxiliary prompt word can be: Please combine the information returned by the tool, and be careful not to include these contents in the final answer.

[0074] Each preset tool is taken as a tool entity, and the attribute information of the preset tool is taken as the tool attribute of the tool entity. Then, the tool entity can be embedded in the domain knowledge graph to obtain the target knowledge graph. Multiple preset tools and the attribute information corresponding to the preset tools can be stored in the tool library. When adding, deleting or modifying the definition and function of the tool, the tool library can be adjusted directly without changing the prompt word or agent code.

[0075] As an implementation method, when embedding a tool entity into a domain knowledge graph, for each tool entity, the tool attributes are used to generate a specified description corresponding to the tool entity, wherein the specified description includes a tool action and a tool operation object; the domain entity matching the tool operation object is retrieved in the domain knowledge graph to obtain the operation entity; and the association relationship between the tool entity and the operation entity is established using the tool action to obtain the target knowledge graph.

[0076] Among them, the specified description is a description related to the tool entity generated in a specific way. The specified description can be a short sentence composed of tool actions and tool operation objects. Tool action refers to the action performed by the tool entity when it is called, and tool operation object refers to the object acted upon by the tool action.

[0077] Optionally, a large language model may be used to generate a specified description based on the tool attributes. For example, a specified prompt word may be pre-set, and the specified prompt word may include guidance information and relevant examples of the specified description. The specified prompt word and the tool attributes are input into the large language model together, and the large language model may analyze and understand the tool attributes, and then summarize to obtain the specified description.

[0078] For example, a tool entity used to purchase medicines may have a corresponding designated description of "Purchase medicines", where "Purchase" is the tool action and "Medicines" is the tool operation object. Another example is a tool entity used to query disease information, where the designated description may be "Query disease information", where "Query" is the tool action and "Disease information" is the tool operation object.

[0079] Then, the domain entities matching the tool operation object can be retrieved in the domain knowledge graph. The domain entities matching the tool operation object may include domain entities whose entity types are consistent with the tool operation object, and may also include domain entities whose entity names contain the tool operation object. The matching domain entities may be used as operation entities for subsequent use.

[0080] For each operation entity, an edge between the tool entity and the operation entity can be established in the domain knowledge graph, and the association relationship represented by the edge is related to the tool action of the tool entity. For example, if the tool action is purchase, then the association relationship between the tool entity and the operation entity is purchase.

[0081] According to the above method, each tool entity can be embedded into the domain knowledge graph to obtain Figure 3 In order to ensure the accuracy of the target knowledge graph, some data can be randomly extracted from the target knowledge graph for manual verification, and then used after passing the manual verification.

[0082] By integrating the tools that can be called by the intelligent agent with the original knowledge graph, there is no need to declare and define these tools in the prompt words. The target knowledge graph can be used directly to call the tools later, which can effectively reduce the length of the prompt words and reduce the difficulty of the model's understanding of the prompt words.

[0083] S120: Perform entity extraction processing on the task description to obtain task entity information.

[0084] The task description is data in the form of text, and entity extraction can be performed on the task description to identify the entities in the task description and obtain task entity information. There are many ways to extract entities, which can be selected according to actual needs. For example, prompt words can be constructed in advance, relevant examples of entity recognition can be given, and the prompt words and task descriptions can be input into the large language model together. After the large language model understands the examples in the prompt words, the task entity information can be extracted from the task description.

[0085] The task entity information may include a task entity name and a task entity type. The task entity name is the entity name directly extracted from the task description, and the task entity type refers to the type corresponding to the extracted task entity.

[0086] S130. Determine, from the target knowledge graph, a tool entity that has an association relationship with the task entity information, and obtain a plurality of candidate tool entities.

[0087] After extracting the task entity information, the tool entity associated with the task entity information can be determined from the target knowledge graph to obtain multiple candidate tool entities. That is, the task entity name and task entity type can be used to search in the target knowledge graph, and the tool entity associated with the searched entity is used as a candidate tool entity.

[0088] As an implementation mode, when determining multiple candidate tool entities from a target knowledge graph, a search function may be called to search the target knowledge graph for entities that match the task entity name and entities that match the task entity type to obtain matching entities; obtain tool entities in the target knowledge graph that have an association relationship with the matching entities to obtain multiple associated tool entities; and determine candidate tool entities from the multiple associated tool entities based on the tool attributes corresponding to each of the associated tool entities and the task description.

[0089] See also Figure 4 , showing a schematic diagram of determining a target tool entity from a target knowledge graph, a search function is a function that can execute a knowledge graph engine search action and return a corresponding search result, and the use of the search function and the form of the returned result can be defined according to actual needs. In an embodiment of the present invention, the search function can search for entities that match the task entity name and entities that match the task entity type in the target knowledge graph to obtain matching entities.

[0090] Among them, the entity that matches the task entity name may refer to an entity whose entity name in the target knowledge graph includes the task entity name. Specifically, the task entity name can be used as a matching word, and the matching word is matched with the entity name corresponding to each entity in the target knowledge graph. If the matching word is included in the entity name, it can be determined that the match is successful.

[0091] When searching for entities that match the task entity type, the entity type of each entity in the target knowledge graph can be obtained. If the entity type of the entity is consistent with the task entity type, it can be determined that the entity and the task entity type match. In the above manner, matching entities can be searched from the target knowledge graph based on the task entity name and task entity type. For example, Figure 4 The gray nodes in the target knowledge graph represent the searched matching entities.

[0092] If a matching entity is searched in the target knowledge graph, the tool entity in the target knowledge graph that has an association relationship with the matching entity can be used as the associated tool entity, that is, the search function returns the associated tool entity that has an association relationship with the matching entity.

[0093] It should be noted that the matching entity may include matching domain entities and matching tool entities. For the matching domain entity, the tool entity that has an edge with the matching domain entity can be used as an intermediate tool entity, the matching tool entity itself can be used as an intermediate tool entity, and the tool entity that has an edge with the matching tool entity can be used as an intermediate tool entity; then, after deduplicating all the intermediate tool entities, multiple associated tool entities can be obtained.

[0094] Each entity in the target knowledge graph has corresponding entity attributes, among which the entity attributes corresponding to the tool entity can be recorded as tool attributes. Based on the functions corresponding to each associated tool entity and the attribute and task description, a candidate tool entity can be determined from multiple associated tool entities.

[0095] Optionally, when determining a candidate tool entity from a plurality of associated tool entities, the first similarity between the tool function description of the associated tool entity and the task description may be calculated for each of the associated tool entities; all the associated tool entities are sorted in descending order according to the first similarity to obtain an associated tool sequence; and based on the associated tool sequence, a candidate tool entity is determined from the plurality of associated tool entities.

[0096] The tool attributes may include a tool function description, which refers to a description of the tool's purpose. For each associated tool entity, the first similarity between the tool function description and the task description of the associated tool entity can be calculated. For example, the tool function description can be converted into a description vector, and the task description can be converted into a task vector. The first similarity can be obtained by calculating the cosine similarity between the description vector and the task vector. The larger the first similarity, the more similar the tool function description is to the task description. By sorting multiple associated tool entities in order from large to small according to the first similarity, an associated tool sequence can be obtained. Then, the first number of associated tool entities ranked high in the associated tool sequence are intercepted as candidate tool entities, wherein the first number is a positive integer and can be set according to actual needs.

[0097] If no matching entity is retrieved from the target knowledge graph, or the candidate tool cannot be determined, multiple rounds of dialogue can be triggered to obtain a more detailed task description.

[0098] S140. Determine a target tool entity from the plurality of candidate tool entities according to a function description corresponding to the task function and a tool attribute corresponding to the candidate tool entity.

[0099] The task function is a functional function required to perform the task to be processed. The function description corresponding to the task function may include function input and expected output. The task function may be obtained after analyzing the task description. The function input is recorded as the content required to input when calling the task function, and the expected output is the output after the task function executes the task. Based on the function description and the tool attributes corresponding to the candidate tool entity, the target tool can be determined from multiple candidate tool entities.

[0100] Optionally, when determining a target tool from multiple candidate tools, the function description corresponding to the task function can be obtained based on the task description; for each candidate tool entity, the second similarity between the tool function description corresponding to the candidate tool entity and the function description is calculated; and the candidate tool entity corresponding to the maximum value in the second similarity is taken as the target tool.

[0101] In some embodiments, a function library may be pre-set, and the function library includes a plurality of preset task functions, and each preset task function is provided with a corresponding preset function description. When obtaining the function function description, the similarity between the task description and each preset function description may be calculated; if the maximum similarity is greater than the similarity threshold, the preset function description corresponding to the maximum similarity is used as the function function description; if the maximum similarity is not greater than the similarity threshold, a function function description of the task function matching the task description is generated.

[0102] In some embodiments, a function description can be generated directly based on a task description. For example, the task description can be analyzed and processed to obtain task requirements corresponding to the task to be processed; function input and expected output of the task function can be generated according to the task requirements; and the function input and expected output can be combined to obtain a function description corresponding to the task function.

[0103] Among them, a prompt word can be pre-set, which is used to guide the large language model to generate a function description that matches the task description. For example, the prompt word can be "According to the user's question, extract the user's needs. Assuming that you are a code developer, please package the user's needs into corresponding function functions, and just reply with the function description of the function." Of course, some examples can be added to the prompt word according to actual needs to improve the accuracy of the function description generated by the large language model.

[0104] The prompt words and task description are input into the large language model together. The large language model can analyze and process the task description to extract the task requirements from the task description, and then generate the function input and expected output of the task function based on the task requirements. Finally, the function input and expected output are combined to obtain the function description corresponding to the task function. For example, if the task description is "where to buy cold medicine", the function description output by the large language model can be "the function accepts the user's current location information or the input city name, and returns the recommended nearby pharmacy or online platform for purchasing cold medicine location information".

[0105] It should be noted that the aforementioned need to extract task entity information from the task description can combine the generation of function description and the extraction of task entity information into one step. For example, the prompt word may include the definition of the role, the need to analyze and decompose user requirements, and return the function description and entity information in a specified format. The prompt word and task description are input into the large language model so that the large language model can output the task entity information and function description at the same time.

[0106] For each candidate tool entity, the second similarity between the tool function description and the function function description of the candidate tool entity can be calculated. The higher the second similarity, the higher the possibility that the candidate tool entity can complete the task to be processed. When calculating the second similarity, the tool function description can be converted into a tool function description vector, the function function description can be converted into a function function description vector, and then the cosine similarity between the tool function description vector and the function function description vector is calculated to obtain the second similarity.

[0107] A second similarity can be calculated for each candidate tool entity, and the maximum second similarity can be determined from multiple second similarities. The candidate tool entity corresponding to the maximum second similarity is taken as the target tool entity, and the tool represented by the target tool entity is taken as the target tool.

[0108] When determining the target tool entity from the target knowledge graph, the search function is called with the task entity name and task entity type to retrieve the associated tool entity in the target knowledge graph, and the first similarity is calculated using the task description and the tool function description of the associated tool entity. The first stage of screening is performed with the first similarity to obtain the candidate tool entity. The second similarity is then calculated using the function description generated by the task description, and the candidate tool entity is screened in the second stage to obtain the target tool entity, which can ensure the accuracy of the determined target tool entity.

[0109] S150: Calling a target tool to execute the task to be processed, and obtaining an execution result of the task to be processed.

[0110] After the target tool is determined, the target tool can be automatically called to execute the task to be processed. In some embodiments, when the target tool is called to execute the task to be processed and the automatic result of the task to be processed is obtained, the tool attributes corresponding to the target tool can be obtained from the target knowledge graph, and the tool attributes include the calling parameters and tool output restrictions of the target tool; based on the calling parameters and the task description, the calling information of the target tool is generated; the target tool is called using the calling information to control the target tool to execute the task to be processed and obtain the target tool output; the target tool output is adjusted according to the tool output restrictions to obtain the execution result of the task to be processed.

[0111] Each entity in the target knowledge graph has corresponding attributes, and the tool attributes corresponding to the target tool can be obtained from the target knowledge graph. As mentioned above, the tool attributes can include information such as name, call parameters, function description, function implementation, and auxiliary prompt words, and the call parameters and tool output restrictions of the target tool can be directly obtained, among which the tool output restrictions can be pre-set in the auxiliary prompt words.

[0112] The calling information of the target tool can be generated based on the calling parameters and the task description. Usually, the task entity name extracted from the task description can be combined with the calling parameters into the calling information, and the target tool can be called using the calling information, so that the target tool specifies the task to be processed and obtains the processing result of the target tool, that is, the output of the target tool.

[0113] After adjusting the target tool output according to the tool output restriction, the final execution result can be obtained. For example, in the disease information query tool, a large amount of information related to a certain disease is returned. The tool output restriction of the disease information query tool is that the queried information needs to be summarized and a concise and clear answer is given. It is necessary to summarize the queried information according to the output restriction and output the final answer, which is the execution result output to the user.

[0114] For another example, the output of the drug purchase tool is limited to feedback of the delivery time if the purchase is successful, and feedback of the failure reason if the purchase fails. After successfully purchasing the drug, the drug purchase tool can obtain the delivery time and feedback the purchase success and delivery time to the user as the execution result. If the drug purchase tool fails to purchase the drug due to out-of-stock, the purchase failure and out-of-stock of the drug can be fed back to the user as the execution result.

[0115] It should be noted that in this intelligent agent system, multiple agents may need to work together to execute a task. In order to avoid infinite interaction among multiple agents and their inability to stop, environment variables can be set in the intelligent agent system to record the number of communication rounds between agents. When the number of communication rounds reaches the maximum, a fallback mechanism is triggered. For example, communication between agents may be directly stopped, fixed content may be output to end the task, etc. The specific settings can be made according to actual needs.

[0116] The agent-based task processing method provided by the embodiment of the present invention can be applied to a variety of scenarios where the agent needs to automatically call tools. By adopting the solution provided by the embodiment of the present invention, the tools called by the agent can be integrated into the knowledge graph. Compared with the method of adding tool information to the prompt word, the prompt word in the embodiment of the present invention only needs to include the part of outputting action instructions in a format, and there is no need to add tool information to the prompt word. The tool can be called to perform tasks while reducing the length of the prompt word. In addition, in the method of adding tool information to the prompt word, the definition of the tool is pre-declared, and the tool cannot be adjusted dynamically in real time during the operation of the agent. When the definition and function of the tool need to be added, deleted or modified, the embodiment of the present invention can dynamically modify the tool library, which is more flexible.

[0117] From the above, it can be seen that the embodiments of the present invention can integrate information such as tools into the domain knowledge graph. If the information related to the tool needs to be modified, it is only necessary to modify the content related to the tool in the target knowledge graph, which will not affect the already implemented intelligent agent code, which is convenient and fast. When used in combination with the domain knowledge graph, it can adapt to the business scenarios of the existing knowledge graph, such as medical and financial scenarios. In actual use, there is no need to introduce a large amount of tool information in the prompt words. The target tool can be accurately determined directly from the target knowledge graph based on the task description, and the information related to the target tool in the target graph can be used to call the tool to perform the task.

[0118] In order to better implement the above method, the embodiment of the present invention also provides an agent-based task processing device, which can be integrated in an electronic device, which can be a terminal, a server, etc. Among them, the terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop, a personal computer, etc.; the server can be a single server or a server cluster composed of multiple servers.

[0119] For example, in this embodiment, the method of the embodiment of the present invention will be described in detail by taking the agent-based task processing device specifically integrated in the server as an example.

[0120] For example, Figure 5 As shown, the agent-based task processing device 200 may include an acquisition module 210 , an extraction module 220 , a candidate module 230 , a determination module 240 and a processing module 250 .

[0121] An acquisition module 210 is used to acquire a target knowledge graph and a task description of a task to be processed, wherein the target knowledge graph includes a tool entity, a domain entity, and an association relationship between the tool entity and the domain entity;

[0122] An extraction module 220 is used to perform entity extraction processing on the task description to obtain task entity information;

[0123] A candidate module 230 is used to determine a tool entity that has an association relationship with the task entity information from the target knowledge graph to obtain a plurality of candidate tool entities;

[0124] A determination module 240, configured to determine a target tool entity from the plurality of candidate tool entities according to a function description corresponding to a task function and a tool attribute corresponding to the candidate tool entity, wherein the task function is a function function required to execute the task to be processed;

[0125] The processing module 250 is used to call a target tool to execute the task to be processed and obtain an execution result of the task to be processed. The target tool is a tool represented by the target tool entity.

[0126] In some embodiments, the task entity information includes the task entity name and the task entity type, and the candidate module 230 is specifically used to:

[0127] Calling a search function to search the target knowledge graph for entities that match the task entity name and entities that match the task entity type, and obtaining matching entities;

[0128] Obtaining a tool entity in the target knowledge graph that has an association relationship with the matching entity, and obtaining a plurality of associated tool entities;

[0129] Based on the task description and the tool attributes corresponding to each of the associated tool entities, a candidate tool entity is determined from the multiple associated tool entities.

[0130] In some embodiments, the tool attributes include a tool function description, and the candidate module 230 is specifically used to:

[0131] For each of the associated tool entities, calculating a first similarity between the tool function description of the associated tool entity and the task description;

[0132] Sorting all the associated tool entities in descending order of the first similarity to obtain an associated tool sequence;

[0133] Based on the associated tool sequence, a candidate tool entity is determined from the plurality of associated tool entities.

[0134] In some embodiments, the tool attributes include a tool function description, and the determination module 240 is specifically used to:

[0135] Obtaining a function description corresponding to the task function according to the task description;

[0136] For each of the candidate tool entities, calculating a second similarity between the tool function description corresponding to the candidate tool entity and the function description;

[0137] The candidate tool entity corresponding to the maximum value in the second similarity is taken as the target tool.

[0138] In some embodiments, the determination module 240 is specifically configured to:

[0139] Analyze and process the task description to obtain the task requirements corresponding to the task to be processed;

[0140] Generate a function input and an expected output of a task function according to the task requirements;

[0141] The function input and the expected output are combined to obtain a function description corresponding to the task function.

[0142] In some embodiments, the processing module 250 is specifically configured to:

[0143] Acquire tool attributes corresponding to the target tool from the target knowledge graph, wherein the tool attributes include calling parameters and tool output restrictions of the target tool;

[0144] Based on the calling parameters and the task description, generating calling information of the target tool;

[0145] Using the calling information to call the target tool, so as to control the target tool to execute the task to be processed and obtain the target tool output;

[0146] The target tool output is adjusted according to the tool output restriction to obtain the execution result of the task to be processed.

[0147] In some embodiments, the agent-based task processing device 200 may further include a graph building module. Before obtaining the target knowledge graph and the task description of the task to be processed, the graph building module is specifically used to:

[0148] Acquire a domain knowledge graph, wherein the domain knowledge graph includes different types of domain entities and associations between domain entities;

[0149] Acquire multiple preset tools and attribute information corresponding to each of the preset tools;

[0150] Taking each of the preset tools as a tool entity, and taking the attribute information corresponding to the preset tool as a tool attribute of the tool entity;

[0151] For each of the tool entities, the tool entity is embedded into the domain knowledge graph according to the tool attributes to obtain a target knowledge graph.

[0152] In some embodiments, the graph creation module is specifically used to:

[0153] For each of the tool entities, using the tool attributes to generate a specified description corresponding to the tool entity, the specified description including a tool action and a tool operation object;

[0154] Retrieving domain entities matching the tool operation object in the domain knowledge graph to obtain operation entities;

[0155] Using the tool action, an association relationship between the tool entity and the operation entity is established to obtain a target knowledge graph.

[0156] In specific implementation, the above modules can be implemented as independent entities, or can be arbitrarily combined and implemented as the same or several entities. The specific implementation of the above modules can be found in the previous method embodiments, which will not be repeated here.

[0157] As can be seen from the above, the agent-based task processing device of this embodiment can establish an association relationship between the tool to be called and the data entity in the field as the target knowledge graph. When the task description is obtained, the task description is analyzed and processed by the entity to obtain the task entity information. The candidate tool entity is searched from the target knowledge graph using the task entity information. The target tool entity is determined from the candidate tool entity using the function description of the task function and the tool attribute of the candidate tool entity. Finally, the target tool is called to execute the task to be processed to obtain the execution result. The tool information and the knowledge graph in the field are integrated into the target knowledge graph. When executing the task, the tool can be called directly by searching the target knowledge graph. There is no need to add a large amount of tool information in the prompt word in advance. The tool can be called flexibly and accurately according to the task description to execute the task without increasing the length of the prompt word.

[0158] The embodiment of the present invention further provides an electronic device, which may be a terminal, a server, or the like. The terminal may be a mobile phone, a tablet computer, a smart Bluetooth device, a notebook computer, a personal computer, or the like; the server may be a single server or a server cluster composed of multiple servers, or the like.

[0159] In some embodiments, the agent-based task processing device can also be integrated into multiple electronic devices. For example, the agent-based task processing device can be integrated into multiple servers, and the agent-based task processing method of the present invention can be implemented by multiple servers.

[0160] In this embodiment, the electronic device of this embodiment is a server as an example for detailed description, for example, Figure 6 As shown, it shows a schematic diagram of the structure of an electronic device involved in an embodiment of the present invention, specifically:

[0161] The electronic device may include components such as a processor 310 with one or more processing cores, a memory 320 with one or more computer-readable storage media, a power supply 330, an input module 340, and a communication module 350. Those skilled in the art will appreciate that Figure 6 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0162] The processor 310 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 320, and calling data stored in the memory 320. In some embodiments, the processor 310 may include one or more processing cores; in some embodiments, the processor 310 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 310.

[0163] The memory 320 can be used to store software programs and modules. The processor 310 executes various functional applications and data processing by running the software programs and modules stored in the memory 320. The memory 320 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 320 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 320 may also include a memory controller to provide the processor 310 with access to the memory 320.

[0164] The electronic device also includes a power supply 330 for supplying power to various components. In some embodiments, the power supply 330 can be logically connected to the processor 310 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 330 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.

[0165] The electronic device may further include an input module 340, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls.

[0166] The electronic device may further include a communication module 350. In some embodiments, the communication module 350 may include a wireless module. The electronic device may perform short-range wireless transmission through the wireless module of the communication module 350, thereby providing the user with wireless broadband Internet access. For example, the communication module 350 may be used to help the user send and receive emails, browse web pages, and access streaming media.

[0167] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 310 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 320 according to the following instructions, and the processor 310 will run the application programs stored in the memory 320, thereby implementing the steps in the methods of the embodiments of the present invention.

[0168] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0169] As can be seen from the above, the electronic device provided by the embodiment of the present invention can establish an association relationship between the tool to be called and the data entity in the field as the target knowledge graph. When the task description is obtained, the task entity information is obtained by performing entity analysis on the task description, and the candidate tool entity is searched from the target knowledge graph using the task entity information. Then, the target tool entity is determined from the candidate tool entity using the function description of the task function and the tool attribute of the candidate tool entity, and finally the target tool is called to execute the task to be processed to obtain the execution result. The tool information and the knowledge graph in the field are integrated into the target knowledge graph. When executing the task, the tool can be called directly by searching the target knowledge graph, without adding a large amount of tool information in the prompt word in advance. The tool can be called flexibly and accurately according to the task description to execute the task without increasing the length of the prompt word.

[0170] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0171] To this end, an embodiment of the present invention provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any one of the agent-based task processing methods provided by the embodiments of the present invention.

[0172] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0173] According to one aspect of the present invention, a computer program product or computer program is provided, the computer program product or computer program including a computer program / instruction, the computer program / instruction being stored in a computer-readable storage medium. A processor of an electronic device reads the computer program / instruction from the computer-readable storage medium, and the processor executes the computer program / instruction, so that the electronic device executes the method provided in various optional implementations of the target knowledge graph construction aspect or the agent-based task processing aspect provided in the above-mentioned embodiments.

[0174] Since the instructions stored in the storage medium can execute the steps in any one of the agent-based task processing methods provided in the embodiments of the present invention, the beneficial effects that can be achieved by any one of the agent-based task processing methods provided in the embodiments of the present invention can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0175] The above is a detailed introduction to an agent-based task processing method, device and electronic device provided in an embodiment of the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. An agent-based task processing method, characterized in that: The method comprises: Obtain a target knowledge graph and a task description of a task to be processed, wherein the target knowledge graph includes a tool entity, a domain entity, and an association relationship between the tool entity and the domain entity; Performing entity extraction processing on the task description to obtain task entity information; Determine a tool entity associated with the task entity information from the target knowledge graph to obtain a plurality of candidate tool entities; Determine a target tool entity from the plurality of candidate tool entities according to a function description corresponding to a task function and a tool attribute corresponding to the candidate tool entity, wherein the task function is a function function required to execute the task to be processed; Calling a target tool to execute the task to be processed and obtaining an execution result of the task to be processed, wherein the target tool is a tool represented by the target tool entity; Before obtaining the target knowledge graph and the task description of the task to be processed, the method further includes: Acquire a domain knowledge graph, wherein the domain knowledge graph includes different types of domain entities and associations between domain entities; acquire multiple preset tools and attribute information corresponding to each of the preset tools; take each of the preset tools as a tool entity, and take the attribute information corresponding to the preset tool as the tool attribute of the tool entity; for each of the tool entities, embed the tool entity into the domain knowledge graph according to the tool attributes to obtain a target knowledge graph.

2. The method according to claim 1, characterized in that The task entity information includes a task entity name and a task entity type. The tool entity associated with the task entity information is determined from the target knowledge graph to obtain multiple candidate tool entities, including: Calling a search function to search the target knowledge graph for entities that match the task entity name and entities that match the task entity type, and obtaining matching entities; Obtaining a tool entity in the target knowledge graph that has an association relationship with the matching entity, and obtaining a plurality of associated tool entities; Based on the task description and the tool attributes corresponding to each of the associated tool entities, a candidate tool entity is determined from the multiple associated tool entities.

3. The method according to claim 2, characterized in that The tool attributes include a tool function description, and determining a candidate tool entity from the plurality of associated tool entities based on the task description and the tool attributes corresponding to each of the associated tool entities includes: For each of the associated tool entities, calculating a first similarity between the tool function description of the associated tool entity and the task description; Sorting all the associated tool entities in descending order of the first similarity to obtain an associated tool sequence; Based on the associated tool sequence, a candidate tool entity is determined from the plurality of associated tool entities.

4. The method according to claim 1, characterized in that: The tool attributes include a tool function description, and determining a target tool entity from the plurality of candidate tool entities according to the function description corresponding to the task function and the tool attributes corresponding to the candidate tool entities includes: Obtaining a function description corresponding to the task function according to the task description; For each of the candidate tool entities, calculating a second similarity between the tool function description corresponding to the candidate tool entity and the function description; The candidate tool entity corresponding to the maximum value in the second similarity is taken as the target tool.

5. The method according to claim 4, characterized in that The step of obtaining a function description corresponding to the task function according to the task description includes: Analyze and process the task description to obtain the task requirements corresponding to the task to be processed; Generate a function input and an expected output of a task function according to the task requirements; The function input and the expected output are combined to obtain a function description corresponding to the task function.

6. The method according to claim 1, characterized in that The calling of the target tool to execute the task to be processed and obtaining the execution result of the task to be processed includes: Acquire tool attributes corresponding to the target tool from the target knowledge graph, wherein the tool attributes include calling parameters and tool output restrictions of the target tool; Based on the calling parameters and the task description, generating calling information of the target tool; Using the calling information to call the target tool, so as to control the target tool to execute the task to be processed and obtain the target tool output; The target tool output is adjusted according to the tool output restriction to obtain the execution result of the task to be processed.

7. The method according to claim 1, characterized in that For each of the tool entities, embedding the tool entity into the domain knowledge graph according to the tool attribute to obtain a target knowledge graph includes: For each of the tool entities, using the tool attributes to generate a specified description corresponding to the tool entity, the specified description including a tool action and a tool operation object; Retrieving domain entities matching the tool operation object in the domain knowledge graph to obtain operation entities; Using the tool action, an association relationship between the tool entity and the operation entity is established to obtain a target knowledge graph.

8. An agent-based task processing device, the device being used to implement the method according to any one of claims 1 to 7, characterized in that: The device comprises: An acquisition module, used to acquire a target knowledge graph and a task description of a task to be processed, wherein the target knowledge graph includes a tool entity, a domain entity, and an association relationship between the tool entity and the domain entity; An extraction module, used to perform entity extraction processing on the task description to obtain task entity information; A candidate module is used to determine a tool entity that has an association relationship with the task entity information from the target knowledge graph to obtain a plurality of candidate tool entities; A determination module, configured to determine a target tool entity from the plurality of candidate tool entities according to a function description corresponding to a task function and a tool attribute corresponding to the candidate tool entity, wherein the task function is a function function required to execute the task to be processed; A processing module, used for calling a target tool to execute the task to be processed and obtaining an execution result of the task to be processed, wherein the target tool is a tool represented by the target tool entity; Among them, the device also includes a graph establishment module. Before obtaining the target knowledge graph and the task description of the task to be processed, the graph establishment module is used to: obtain a domain knowledge graph, the domain knowledge graph includes different types of domain entities and the association relationships between domain entities; obtain multiple preset tools and attribute information corresponding to each of the preset tools; take each of the preset tools as a tool entity, and take the attribute information corresponding to the preset tool as the tool attribute of the tool entity; for each of the tool entities, embed the tool entity into the domain knowledge graph according to the tool attributes to obtain the target knowledge graph.

9. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the steps in the agent-based task processing method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Task execution method and device, equipment, medium and program product

    CN118193754A