Prompt word generation method and device and intelligent agent
By generating prompt words, the collaborative efficiency and processing capabilities of the agent are improved, the collaboration problem of the agent is solved, the writing and collaboration costs are reduced, and the efficient processing of the agent in complex scenarios is achieved.
Patent Information
- Application Number
- CN202411355436.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-09-26
AI Technical Summary
It is difficult to collaborate among agents to solve scenario problems. It is only suitable for simple scenarios. It requires careful writing by professionals, which is inefficient and costly.
By obtaining agent information matching the problem description, an agent configuration part is generated, and a prompt word is generated based on the information and problem description, which is used by the agent to handle problems and improve the cooperative efficiency and processing capabilities of the agent.
It improves the agent's ability and processing efficiency for problems, and reduces the cost of agent writing and collaboration.
Smart Images

Figure CN119294518A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence, and in particular to technical fields such as deep learning and NLP. Background Art
[0002] Intelligent agents can complete some creative tasks, and there are many types. However, it is difficult to solve the problem of a certain scene through the collaboration between intelligent agents. On the one hand, it is only applicable to simple scenes, and on the other hand, it requires professionals to carefully write the intelligent agents, which is not only inefficient but also costly. Summary of the invention
[0003] The present invention provides a prompt word generation method, device and intelligent agent.
[0004] According to one aspect of the present disclosure, a method for generating a prompt word is provided, comprising:
[0005] Get information about agents that partially match the problem description;
[0006] Generate an agent configuration part based on the information of the agent;
[0007] Generate prompt words based on the problem description part and the agent configuration part;
[0008] The prompt word is used as an input to the agent configured in the agent configuration part so as to process the problem in the problem description part through the agent.
[0009] According to another aspect of the present disclosure, there is provided an agent-based problem processing method, comprising:
[0010] Based on the agent configuration part in the prompt word, input the prompt word to the agent configured by the agent configuration part, wherein the prompt word is generated by the prompt word generation method;
[0011] The problem in the prompt word is processed by the intelligent agent to obtain a processing result.
[0012] According to another aspect of the present disclosure, there is provided a prompt word generating device, comprising:
[0013] The acquisition module is used to obtain the information of the agent that partially matches the problem description;
[0014] A generating module, used for generating an agent configuration part based on the information of the agent;
[0015] The generation module is also used to generate prompt words based on the problem description part and the agent configuration part;
[0016] The prompt word is used as an input to the agent configured in the agent configuration part so as to process the problem in the problem description part through the agent.
[0017] According to another aspect of the present disclosure, there is provided an agent-based problem processing device, comprising:
[0018] An input module, for inputting the prompt word to the agent configured by the agent configuration part based on the agent configuration part in the prompt word, wherein the prompt word is generated by using the prompt word generation method;
[0019] The processing module is used to process the problem in the prompt word through the intelligent agent to obtain a processing result.
[0020] According to another aspect of the present disclosure, there is provided an intelligent agent comprising:
[0021] An input module, used to receive input information, where the input information is generated based on any prompt word generation method in the embodiments of the present disclosure;
[0022] A processing module, used for determining a target task based on the input information received by the input module, and executing the target task to obtain output information;
[0023] The output module is used to output the output information obtained by the processing module.
[0024] According to another aspect of the present disclosure, there is provided an electronic device, comprising:
[0025] at least one processor; and
[0026] a memory communicatively connected to the at least one processor; wherein,
[0027] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute any method in the embodiments of the present disclosure.
[0028] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute any method according to the embodiments of the present disclosure.
[0029] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, which implements any method according to the embodiments of the present disclosure when executed by a processor.
[0030] According to the present disclosure, the problem-solving capability of the intelligent agent can be improved, and the problem-solving efficiency can be improved.
[0031] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0033] Figure 1 is a flowchart of a method for generating prompt words according to an embodiment of the present disclosure;
[0034] Figure 2 is a flowchart of a method for generating prompt words according to another embodiment of the present disclosure;
[0035] Figure 3 is a flow chart of an agent-based problem-solving method according to an embodiment of the present disclosure;
[0036] Figure 4 is a flow chart of an agent-based problem-solving method according to another embodiment of the present disclosure;
[0037] Figure 5 This is an example diagram of the prompt system architecture diagram;
[0038] Figure 6a It is an example graph of knowledge expressed by the knowledge graph;
[0039] Figure 6b is an example diagram of a collaborative agent setting;
[0040] Figure 7 is a structural schematic diagram of a prompt word generating device according to an embodiment of the present disclosure;
[0041] Figure 8 is a structural schematic diagram of a prompt word generating device according to another embodiment of the present disclosure;
[0042] Fig. 9 is a schematic diagram of the structure of an agent-based problem processing device according to an embodiment of the present disclosure;
[0043] Fig.10 is a structural schematic diagram of an agent-based problem processing device according to another embodiment of the present disclosure;
[0044] Fig.11 It is a schematic diagram of the structure of an intelligent agent according to an embodiment of the present disclosure.
[0045] Fig.12 It is a block diagram of an electronic device used to implement the prompt word generation method and the agent-based problem processing method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0046] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0047] Figure 1 FIG. 1 is a flow chart of a prompt word generating method 100 according to an embodiment of the present disclosure. The method may include:
[0048] S110, obtaining information of an agent that partially matches the problem description;
[0049] S120, generating an agent configuration part based on the information of the agent;
[0050] S130, generating prompt words based on the problem description part and the agent configuration part;
[0051] The prompt word is used as an input to the agent configured in the agent configuration part so as to process the problem in the problem description part through the agent.
[0052] In the disclosed embodiment, a prompt may include input information provided to an agent. The prompt may guide the agent to process a problem and generate an output of a specific type or style. The prompt may include a problem description part, an agent configuration part, and the like. The problem description part of the prompt may be generated first according to the problem input by the user. The problem description part may include the input problem itself, or may include the understanding content obtained after natural language understanding and other processing of the input problem. The correspondence between the agent and the problem type is preset. One problem may correspond to one agent or multiple agents. The corresponding relationship may be searched according to the problem description part to obtain the information of the matching agent. For example, the information of the agent may include the number, function, name, and number of agents that can process this problem. For example, the problem description part includes "Please process problem A", and the information of the agent is: "According to the matching, the number of agents that can process this problem is 3, and the names are A1, A2, and A3 respectively". Agents may also be called agents or artificial intelligence agents. Different agents may process certain task relationships in parallel, or perform certain tasks in series, and agents may interact with each other. For example, a problem needs to be solved by agents A1, A2, and A3. Agent A1 sends the result of the problem to agent A2 for processing, and then sends the result to agent A3 for further processing.
[0053] In the disclosed embodiment, an agent configuration part can be generated based on the information of the agent that matches the problem description part. The agent configuration part can include information of one or more agents required to process the problem in the problem description part, and can also include information such as the interaction relationship between multiple agents. In one way, the names of the collaborative agents required to process the problem can be configured through the configuration center, for example, agent A1 and agent A2 can collaborate to process the problem. In another way, the description of the agent function can be configured through the configuration center, for example, the function description of agent A1 is: "You are responsible for searching all types of A on the search website", and the description of agent A2 is configured as: "You are responsible for searching all types of A on the shopping website". When configuring the agent, multiple groups of agents that process different types of problems can be configured in the agent set, and the corresponding one or more groups of agents can be matched according to the problem description part, thereby generating the agent configuration part.
[0054] In the embodiment of the present disclosure, based on the problem description part and the agent configuration part, prompt words for solving the problems in the problem description part can be generated. The prompt words can also be called prompt word templates, prompt word modules, etc.
[0055] According to the embodiment of the present disclosure, prompt words that can be used by the intelligent agent can be automatically generated through the problem description part and the intelligent agent configuration part. The use of prompt words can improve the intelligent agent's ability to handle problems, improve problem handling efficiency, and reduce the intelligent agent's writing cost and collaboration cost.
[0056] In one embodiment, step S110 obtains information of an agent that partially matches the problem description, including: searching an agent set according to the type of problem in the problem description to obtain information of an agent that matches the type of problem; wherein the agent set includes multiple groups of agents, and a group of agents can collaborate to handle one or more problems; the information of the agent that partially matches the problem description includes information of a group of agents that can collaborate to handle the problem in the problem description.
[0057] In the disclosed embodiment, an agent set can be pre-set, and the agent set can be grouped according to the type of problem. A certain type of problem corresponds to one or more groups of agents. If a group of agents includes multiple agents, the specific problem can be solved collaboratively by multiple agents. The type of problem can be determined first based on the input problem or problem description part, a matching agent set can be selected based on the type of problem, and information of one or more groups of collaborative agents in the agent set that match the type of problem can be obtained. The problem can be divided into multiple steps and then handled by different agents in a group of agents corresponding to the problem. For example, the problem is divided into steps S1, S2 and S3, agent A1 is called to execute step S1, agent A2 is called to execute step S2, and agent A3 is called to execute step S3 based on the execution results of S1 and S2.
[0058] According to the embodiments of the present disclosure, by using the type of question in the question description part of the prompt words, an agent in the agent set that matches the type of question can be selected, and the problem can be processed collaboratively through the agents, which can not only reduce the cost of agent collaboration through the prompt words, but also improve the efficiency of agent collaboration.
[0059] In one embodiment, the agent configuration portion includes one or more of agent responsibilities, interaction format descriptions, and interaction examples.
[0060] In the disclosed embodiment, the specific responsibilities of the agents can be configured through the configuration center. For example, in agent set 1, the agents in group G1 are responsible for collecting image information, the agents in group G2 are responsible for collecting voice information, and the agents in group G3 are responsible for downloading text information, etc. The data interaction format between agents can be configured through the configuration center, for example, in Json (JavaScript Object Notation) format. The configuration center can also configure some interaction examples for the agents to use as a reference. For example, the execution result of agent A1 in group G1 is sent to agent A2, and the execution result of agent A2 is returned to agent A1; until a certain condition is met, the execution result of agent A2 is sent to agent A3.
[0061] According to the embodiments of the present disclosure, by configuring the responsibilities, interaction formats, interaction examples, etc. of the intelligent agent, the probability of errors of the intelligent agent can be reduced and the quality of the intelligent agent can be improved.
[0062] In one implementation, the prompt word further includes: one or more of: a task description part, a processing step description part, a related knowledge part, and a Chain of Thought (CoT) part.
[0063] In an embodiment of the present disclosure, the task description part may describe the functions of the agent. The task description part may include the functions of the agent for certain application scenarios, such as service governance scenarios of search systems. For example, a description of the required services. The service governance scenario may include the analysis requirements of certain abnormal services of the search system, and the task description part may include the entry services, intermediate services, end services corresponding to these requirements, and the interaction methods between these services, etc. The problem description part may include content related to the input problem. The processing step description part can be described in natural language. For example, the language that business personnel are most familiar with can be used. These languages can subsequently be added with the relevant knowledge part of the prompt words in the form of terminology explanation. The CoT part can be generated based on the processing step description, the problem description part, the relevant knowledge part, the analysis strategy (task description part), etc.
[0064] According to the embodiment of the present disclosure, prompt words for the intelligent agent are generated based on the task description part, the problem description part, the processing step description part, the relevant knowledge part and the COT part, which can reduce the probability of errors of the intelligent agent and improve the quality of the intelligent agent.
[0065] In one embodiment, the relevant knowledge portion is updated based on the problem description portion; and / or the CoT portion is updated based on the processing result of the problem description portion and / or the prompt word in the agent.
[0066] In the disclosed embodiment, first, the relevant knowledge part of the prompt word may include explanations of some terms in other parts of the prompt word, such as the task description part, the processing step description part, and the COT part. Secondly, after receiving the input question or generating the problem description part, the relevant knowledge part and / or the COT part of the prompt word may be updated according to the problem to be processed. In the process of the intelligent agent processing the problem, the intelligent agent may generate some execution results. If the execution result of one intelligent agent needs to be used as input information for another intelligent agent, the execution result included in the problem description part or the COT part of the prompt word can be updated. Then the updated prompt word is input to the new intelligent agent for continued execution. Until the steps required for the problem are processed or the termination condition is met.
[0067] According to the embodiments of the present disclosure, by updating the relevant knowledge part and / or CoT part of the agent according to the processing results, collaboration between agents can be achieved, the stability of the agent execution process can be improved, and the execution efficiency of the agent can be improved.
[0068] Figure 2 2 is a flow chart of a keyword generation method 200 according to another embodiment of the present disclosure. The method 200 may include one or more steps in the keyword generation method 100. In one implementation, the method 200 further includes:
[0069] S210, extracting terms from the problem description part;
[0070] S220, obtaining the explanation content of the terms in the problem description part;
[0071] S230. Add the explanation of the term to the relevant knowledge section.
[0072] In the disclosed embodiments, terms may also be referred to as keywords, key words, etc. Terms may include words that conform to the specific writing habits of the agent. Explanations of terms may be pre-stored in the knowledge graph. When it is detected that there are terms in the problem description that need to be explained, the explanation corresponding to the term may be obtained from the knowledge graph. For example, if the problem description is "How to indent the first line of a paragraph", the term "first line indent" may be extracted. The term "first line indent" is used to represent the operation of indenting the first line of text in a paragraph.
[0073] In the disclosed embodiment, after extracting the terms in the problem description part, the explanation content of the terms can be searched through the knowledge base, and the explanation content of the terms can include the introduction corresponding to the terms, the concept description corresponding to the terms, the static attributes of the entities corresponding to the terms, and other aliases corresponding to the terms. The explanation content of the terms can also include the corresponding relationships between multiple terms, such as inclusion relationships, subordinate relationships, dependency relationships, and upstream and downstream relationships. The knowledge base can include a knowledge graph, a vector database, etc. The storage form of the terms in the knowledge graph can be stored in the form of nodes, and can also be connected through edges through different node homes.
[0074] In the disclosed embodiment, the extraction and interpretation process of the terms in other parts of the prompt word is similar to that of the problem description part. The interpretation content of each part of the prompt word found can be added to the relevant knowledge part of the prompt word.
[0075] According to the embodiment of the present disclosure, terms are extracted from the problem description part and explained, and the explanation content is added to the relevant knowledge part, so that the intelligent agent can understand the problem accurately and improve the execution efficiency of the intelligent agent.
[0076] In one implementation, step S210 extracts terms from the problem description portion, including one or more of the following:
[0077] The problem description part is embedded to obtain a problem feature, and multiple terms are matched from a vector database based on the problem feature;
[0078] The problem description part is segmented based on the segmentation algorithm to obtain multiple terms;
[0079] Based on the large language model, the problem description part is segmented to obtain multiple terms;
[0080] Based on the enumeration method, the terms in the knowledge graph are substring matched with the problem description to obtain multiple terms.
[0081] For example, the vector database stores embedded vectors of various terms. The problem description part can be embedded first, and the problem description can be converted into problem features in vector form. Then, the corresponding terms can be matched and searched in the vector database according to the problem features.
[0082] For another example, you can use a segmentation algorithm to segment the problem description, and then extract the terms that need to be explained from the segmented terms. The segmentation algorithm can also be called a word segmentation algorithm. Through semantic recognition, semantic understanding, etc., the text of the problem description can be segmented into multiple words or short sentences.
[0083] For another example, a large language model (LLM) can be used to extract terms from the problem description. The large language model can be used to perform natural language understanding and other processing on the text of the problem description to obtain the terms that need to be explained in the problem description.
[0084] For example, the knowledge graph can be used to perform substring matching operations on the text entered in the problem description part. By traversing all the terms and aliases in the knowledge graph, the text entered in the problem description part is matched one by one. The matched terms can be considered as terms that need to be explained.
[0085] According to the embodiments of the present disclosure, the terms in the problem description part can be extracted in a variety of ways and explained, so that the intelligent agent can accurately understand the problem and improve the accuracy and efficiency of the intelligent agent's processing.
[0086] In one embodiment, step S220 obtains the explanation content of the terms in the question description part, including: searching for the explanation content of the multiple terms from the knowledge graph based on the multiple terms.
[0087] In one embodiment, step S230 adds the explanation content of the term to the relevant knowledge part, including: filling the extracted terms into the knowledge part of the prompt word in the order of the number of terms on which they depend.
[0088] In the disclosed embodiment, the knowledge graph is a structured semantic knowledge base, and the explanation content corresponding to the term can be extracted from the problem description part in the knowledge graph.
[0089] In the embodiment of the present disclosure, the association relationship between different terms, such as dependency relationship, can be obtained, and the terms can be sorted in order from small to large in terms of the number of dependency relationships. For example, term 1, term 2, and term 3 are sorted according to the dependency relationship. If the explanation of term 3 mentions term 1 and term 2, term 2 and term 1 can be sorted before term 3. If the explanation of term 2 mentions term 1, term 1 can be sorted before term 2. In the related knowledge section, an example of the sorting relationship of term 1, term 2, and term 3 can be:
[0090] Term 1;
[0091] Term 2, associated with term 1;
[0092] Term 3, associated with term 1 and term 2.
[0093] After sorting the terms that need to be explained in the prompt words, the explanation content of the terms can be filled into the relevant knowledge part of the prompt words according to the sorting results.
[0094] According to the embodiments of the present disclosure, the terms are explained through the knowledge graph and sorted by the dependency quantity, so that the intelligent agent can understand the problem accurately, improve the understanding speed of the intelligent agent, and improve the processing efficiency of the intelligent agent.
[0095] In one implementation, searching for explanations of the multiple terms from the knowledge graph based on the multiple terms includes at least one of the following:
[0096] For a target term among the multiple terms, find explanation content from a target node corresponding to the target term in the knowledge graph;
[0097] Through a recursive algorithm, the knowledge graph is traversed based on the edges starting from the target node, and the explanation content of the terms found during the traversal process is extracted.
[0098] In the disclosed embodiment, a term node identical or similar to a target term can be searched in the knowledge graph according to a target term, and the explanation of the target term in the term node can be extracted. After the target node is found, the target node can be used as a starting point in the knowledge graph, and the associated node can be found based on the edge of the target node, and the explanation of the target term in the associated node can be extracted. The traversal of the edge can use a recursive algorithm to extract more explanations of the target term.
[0099] In the disclosed embodiment, each part of the prompt word may include many terms that need to be explained. The terms in the parts including static configuration content, such as the task description part, the processing step description part, the agent configuration part, and the COT part may be explained first, and then the explanations in the related knowledge part may be updated each time according to the terms in the dynamically generated problem description part. Some content in the COT part may be updated according to the processing results, and the explanations in the related knowledge part may also be updated based on the terms of the updated processing results.
[0100] According to the embodiments of the present disclosure, using the knowledge graph to search for the explanation content of a term can improve the accuracy of the term explanation, thereby improving the accuracy of the execution of the intelligent agent.
[0101] Figure 3 FIG. 3 is a flow chart of an agent-based problem processing method 300 according to an embodiment of the present disclosure, the method comprising:
[0102] S310, based on the agent configuration part in the prompt word, input the prompt word to the agent configured by the agent configuration part, wherein the prompt word is generated by using any prompt word generation method in any one of the above method embodiments;
[0103] S320: Process the problem in the prompt word through the intelligent agent to obtain a processing result.
[0104] In the disclosed embodiment, the prompt words generated by the above prompt word generation method are input into the agent involved in the agent configuration part, which will not be repeated here. If multiple agents are involved in the agent configuration part, the initial prompt words can be sent to one of the agents first. For example, the prompt words are sent to the agent corresponding to the first step of the prompt words. For another example, the prompt words are sent to the first agent in the matching group. After an agent executes the steps it is responsible for, it can generate a processing result (or execution result), and the CoT and other parts of the prompt words can be updated according to the execution results. Then the new prompt words can be sent to the agents required to process the subsequent steps.
[0105] In the disclosed embodiment, after the agent receives the prompt word, it analyzes the problem in the prompt word and processes the problem according to the CoT part of the prompt word. In this process, the framework can be called as needed, and other agents can be requested to cooperate. In addition, the agent can understand the terms involved in the prompt word according to the relevant knowledge part. If the agent can independently process the problem in the prompt word, the agent cooperation may not be performed; if the agent cannot independently process the problem in the prompt word, a cooperation request can be sent to other agents to cooperate in processing the problem.
[0106] According to the embodiment of the present disclosure, inputting prompt words into a preconfigured intelligent agent to automatically process the problem step by step can improve processing efficiency.
[0107] Figure 4 4 is a flow chart of an agent-based problem processing method 400 according to another embodiment of the present disclosure, which can be used to implement step S320 in the agent-based problem processing method 300. In one embodiment, the method 400 includes processing the problem in the prompt word by the agent to obtain a processing result, and further includes:
[0108] S410, executing the problem processing steps in the CoT part of the prompt word by the first agent to obtain a processing result;
[0109] S420, updating the CoT part based on the processing result;
[0110] S430. When it is determined based on the configuration part of the agent that a second agent needs to collaborate in processing the updated CoT, the updated CoT part is input to the second agent for processing.
[0111] In an embodiment of the present disclosure, after an agent required to solve a problem, such as a first agent, receives an input prompt word, the problem is processed according to the prompt word. The processing method of the first agent may include obtaining a processing instruction according to the CoT part in the prompt word. The processing instruction can be generated based on the problem processing steps in the CoT part, for example, step 1 corresponds to the first agent performing image recognition, and step 2 corresponds to the second agent rendering after image processing. Among them, after executing step 1, the image recognition result can be added to the CoT part to generate a new prompt word, and the new prompt word can be input into the second agent for rendering.
[0112] In the disclosed embodiment, if the processing result of the first agent is not the final processing result of the problem, the problem can continue to be processed. If the second agent is required to cooperate, the first agent can re-input the processing result to the configuration center, and the configuration center updates one or more of the agent configuration part, the relevant knowledge part, the CoT part, etc. of the prompt word according to the processing result, and then inputs the updated CoT part into the second agent, and regards the second agent as the first agent, and executes steps S410, S420 and S430 in a loop.
[0113] In the disclosed embodiment, there may be one or more second agents. When multiple second agents need to collaborate, the configuration information of the second agents may be updated and determined according to the characteristics of different second agents, and the updated CoT part may be input to the second agents for processing. Each agent that receives the prompt word may execute steps S410 to S430 until the keyword processing is completed.
[0114] According to the embodiments of the present disclosure, the processing results between intelligent agents can be interactively transmitted through prompt words, so that the processing of the problem can be completed through the collaboration of the intelligent agents, which can improve the processing efficiency of the intelligent agents and reduce the collaboration cost of the intelligent agents.
[0115] The agent-based problem-solving method of the disclosed embodiment can be applied to an agent structure that can precipitate business experience using natural language terms, can collaborate stably with each other, and can effectively derive solutions.
[0116] The disclosed embodiments can generate intelligent agents and prompt patterns, can introduce concept explanations based on knowledge graphs, perform deductions based on CoT patterns, and perform collaboration based on setting the scope of interaction of intelligent agents. Figure 5 This is an example of a prompt system architecture diagram. The prompt structure can include the following parts:
[0117] 1. Task Description
[0118] 2. Related knowledge
[0119] 3. Description of current problem
[0120] 4. Description of processing steps
[0121] 5. Collaborative agent configuration: agent responsibilities, interaction format description, and interaction examples;
[0122] 6. CoT model.
[0123] 1. Task description part (can be statically configured)
[0124] In the configuration center description, the function of the agent can be described in detail. For example, in the case analysis scenario of "a URL is not recalled under a specific query", the task description of the agent corresponding to a service X may include:
[0125]
[0126] 2. Related knowledge part (partially statically configured and partially dynamically generated.)
[0127] This section is a detailed explanation of all the internal terms involved in the current problem and task description. This part is critical and is also the innovation of this solution. This part of knowledge is extracted through the collaboration of knowledge graph and vector database.
[0128] The vector database stores the embedding vectors of various internal terms, which is used to directly find the relevant term set from the input question of the intelligent agent.
[0129] The knowledge graph stores detailed knowledge about various terms and is the ultimate source of the content of the prompt-related knowledge part. It expresses two types of knowledge in a graphical way, such as Figure 6a shown.
[0130] Single node: Introduction to a single term, including the conceptual description of the term, static properties of the entity corresponding to the term, other aliases of the term, etc.
[0131] Edge: The relationships between terms include belongs to, depends on, upstream and downstream, etc.
[0132] The following are examples of term extraction algorithms, and you can choose any one of them.
[0133] Algorithm 1: Screening based on vector database
[0134] Step 1: Embed the agent’s input question.
[0135] Step 2: Based on the embedding of the input question, match N relevant terms from the vector database.
[0136] Step 3: For each of the N terms above, find a detailed introduction from the corresponding node in the knowledge graph, and use a recursive algorithm to traverse the graph based on the edges starting from this node, and extract the detailed introductions of all terms in the traversal process. Ensure that the terms that are finally filled in the prompt appear from small to large according to the number of dependencies on other terms. An example is as follows:
[0137]
[0138] Algorithm 2: Based on word segmentation algorithm
[0139] Step 1: Based on the word segmentation algorithm, the agent’s input question is segmented into N terms.
[0140] Step 2: For each of the N terms above, find a detailed description from the corresponding node in the knowledge graph, and use a recursive algorithm to traverse the graph based on the edges starting from this node, and extract the detailed descriptions of all terms in the traversal process. Ensure that the terms that are finally filled in the prompt appear in order of the number of dependencies on other terms from small to large.
[0141] Algorithm 3: LLM-based word segmentation
[0142] Step 1: Request the agent’s input question to LLM once to perform word segmentation and divide it into N terms.
[0143] Step 2: For each of the N terms above, find a detailed description from the corresponding node in the knowledge graph, and use a recursive algorithm to traverse the graph based on the edges starting from this node, and extract the detailed descriptions of all terms in the traversal process. Ensure that the terms that are finally filled in the prompt appear in order of the number of dependencies on other terms from small to large.
[0144] Algorithm 4: Brute Force Enumeration
[0145] All the terms and aliases in the knowledge graph are substring matched in the input question of the intelligent agent. If a match is found, it is considered to be a term that needs to be explained.
[0146] 3. Description of the current problem (can be dynamically generated based on the input question)
[0147] The agent input problem is described in this section.
[0148] 4. Description of problem handling steps
[0149] It can be described in pure natural language. This part can be described in the language that business personnel (or writers) are most familiar with. It can be described through the configuration center. The following is an example:
[0150]
[0151]
[0152] 5. Collaborative Agent Settings
[0153] Directly configure the name of the agent that can be collaborated in the configuration center, or associate the agent that needs to be collaborated with the current agent by dragging and dropping. When generating the prompt of the current agent, the framework extracts the three parts of the description of the agent that needs to be collaborated, the description of the interaction format, and the interaction example, and assembles them in the description part of the collaborative agent in the prompt. The description of the responsibilities, interaction format, and interaction examples of each agent are also expressed in the configuration center, such as Figure 6b shown.
[0154] The interaction format is a description of the natural language input format that the agent expects to see, which minimizes the richness of the input and improves the stability of the agent's execution. For example, if the X service does not recall the URL, the corresponding agent can be required to accept the following input: "X service does not recall Y URL".
[0155] Interaction examples are given to make the agent's execution more stable and further reduce hallucinations.
[0156] 6. An example of CoT writing is as follows. After the agent executes the prompt word, it can update the historical steps, execution results, etc.
[0157]
[0158]
[0159] This description method needs to bring about the following effect: after each step, the agent generates a structured answer, which can be understood by the framework and dispatched to other agents to obtain the execution results, append the results to the prompt of this agent, form a new prompt, and perform further execution.
[0160] The use of knowledge graphs and vector databases allows business personnel to directly accumulate their experience in natural language, and they can use internal terms that they are familiar with in the process, which reduces costs.
[0161] Intelligent agents interact entirely with natural language, and based on formatted interaction instructions, the stability of collaboration is further improved.
[0162] Based on the explanation of terms, manually accumulated experience step descriptions and the CoT model, the intelligent agent can understand the received input problems very well, complete the derivation of the solution steps, and execute them step by step based on the framework capabilities to finally solve the problem.
[0163] This solution can save a lot of manpower when applied to search problem tracing, service management, etc.
[0164] Figure 7 is a schematic diagram of a prompt word generating device 700 according to an embodiment of the present disclosure. The device 700 may include:
[0165] An acquisition module 710 is used to acquire information of an agent that partially matches the problem description;
[0166] A generating module 720, for generating an agent configuration part based on the information of the agent;
[0167] The generating module 720 is also used to generate prompt words based on the problem description part and the agent configuration part;
[0168] The prompt word is used as an input to the agent configured in the agent configuration part so as to process the problem in the problem description part through the agent.
[0169] In one embodiment, the acquisition module 710 is used to search for an agent set according to the type of problem in the problem description portion, and obtain information of an agent that matches the problem description portion of the type of problem; wherein the agent set includes multiple groups of agents, and a group of agents can collaborate to handle one or more problems; the information of the agent that matches the problem description portion includes information of a group of agents that can collaborate to handle the problem in the problem description portion.
[0170] In one embodiment, the agent configuration portion includes one or more of agent responsibilities, interaction format instructions, and interaction examples.
[0171] In one implementation, the prompt word further includes: one or more of: a task description part, a processing step description part, a related knowledge part, and a chain of thought CoT part.
[0172] In one embodiment, the relevant knowledge portion is updated based on the problem description portion; and / or the CoT portion is updated based on the processing result of the problem description portion and / or the prompt word in the agent.
[0173] Figure 88 is a schematic diagram of a prompt word generating device 800 according to another embodiment of the present disclosure, the device 800 includes: an acquisition module 810 and a generation module 820, the functions of the above modules can refer to the functions of the modules of the prompt word generating device in the above embodiment. In one embodiment, the prompt word generating device also includes:
[0174] An extraction module 830, for extracting terms from the problem description part;
[0175] The acquisition module 810 is also used to obtain the explanation content of the terms in the problem description part;
[0176] The processing module 840 is used to add the explanation content of the term to the relevant knowledge part.
[0177] In one embodiment, the extraction module 830 is used for one or more of the following:
[0178] The problem description part is embedded to obtain a problem feature, and multiple terms are matched from a vector database based on the problem feature;
[0179] The problem description part is segmented based on the segmentation algorithm to obtain multiple terms;
[0180] Based on the large language model, the problem description part is segmented to obtain multiple terms;
[0181] Based on the enumeration method, the terms in the knowledge graph are substring matched with the problem description to obtain multiple terms.
[0182] In one implementation, the acquisition module 810 is used to search for explanations of the multiple terms from the knowledge graph based on the multiple terms;
[0183] The processing module is used to fill the extracted terms into the knowledge part of the prompt word in the order of the number of terms on which they depend.
[0184] In one implementation, the acquisition module 810 is used for at least one of the following:
[0185] For a target term among the multiple terms, find explanation content from a target node corresponding to the target term in the knowledge graph;
[0186] Through a recursive algorithm, the knowledge graph is traversed based on the edges starting from the target node, and the explanation content of the terms found during the traversal process is extracted.
[0187] Fig. 9 is a schematic diagram of a structure of an agent-based problem processing device 900 according to an embodiment of the present disclosure. The device 900 may include:
[0188] An input module 910 is used to input the prompt word to the agent configured by the agent configuration part based on the agent configuration part in the prompt word, wherein the prompt word is generated by using the prompt word generation method described above;
[0189] The processing module 920 is used to process the problem in the prompt word through the intelligent agent to obtain a processing result.
[0190] Fig.10 1 is a schematic diagram of a structure of an agent-based problem processing device 1000 according to another embodiment of the present disclosure, the device 1000 includes: an input module 1010 and a processing module 1020. The functions of the above modules can refer to the functions of the modules of the agent-based problem processing device in the above embodiment. In one implementation, the processing module 1020 also includes:
[0191] An execution submodule 1021 is used to execute the problem processing steps in the CoT part of the prompt word through the first agent to obtain a processing result;
[0192] An updating submodule 1022, configured to update the CoT part based on the processing result;
[0193] The processing submodule 1023 is used to input the updated CoT part to the second agent for processing when it is determined based on the agent configuration part that the second agent needs to cooperate in processing the updated CoT.
[0194] In the technical solution disclosed herein, the acquisition, storage and application of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0195] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0196] Fig.11 1 is a schematic diagram of a structure of an agent 1100 according to another embodiment of the present disclosure, and the agent 1100 includes:
[0197] An input module 1110, configured to receive input information, the input information being generated based on any prompt word generation method in the embodiments of the present disclosure;
[0198] A processing module 1120 is used to determine a target task based on the input information received by the input module, and execute the target task to obtain output information;
[0199] The output module 1130 is used to output the output information obtained by the processing module.
[0200] Fig.12A schematic block diagram of an example electronic device 1200 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0201] like Fig.12 As shown, the device 1200 includes a computing unit 1201, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 1202 or a computer program loaded from a storage unit 1208 into a random access memory (RAM) 1203. In the RAM 1203, various programs and data required for the operation of the device 1200 can also be stored. The computing unit 1201, the ROM 1202, and the RAM 1203 are connected to each other via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.
[0202] A number of components in the device 1200 are connected to the I / O interface 1205, including: an input unit 1206, such as a keyboard, a mouse, etc.; an output unit 1207, such as various types of displays, speakers, etc.; a storage unit 1208, such as a disk, an optical disk, etc.; and a communication unit 1209, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 1209 allows the device 1200 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0203] The computing unit 1201 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 1201 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 1201 executes the various methods described above, such as the prompt word generation method and the agent-based problem processing method. For example, in some embodiments, the prompt word generation method and the agent-based problem processing method may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 1208. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 1200 via the ROM 1202 and / or the communication unit 1209. When the computer program is loaded into the RAM 1203 and executed by the computing unit 1201, one or more steps of the prompt word generation method and the agent-based problem processing method described above may be executed. Alternatively, in other embodiments, the computing unit 1201 may be configured to execute the prompt word generation method and the agent-based problem processing method in any other appropriate manner (eg, by means of firmware).
[0204] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations may include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, at least one input device, and at least one output device.
[0205] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0206] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0207] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0208] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0209] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0210] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0211] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the principles of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for generating a prompt word, comprising: Get information about agents that partially match the problem description; Generate an agent configuration part based on the information of the agent; Generate prompt words based on the problem description part and the agent configuration part; The prompt words are used as inputs of the agent configured in the agent configuration part so as to process the problems in the problem description part through the agent.
2. The method according to claim 1, wherein: Get information about agents that partially match the problem description, including: Search the agent set according to the type of problem in the problem description part to obtain the information of the agent matching the type of the problem; wherein the agent set includes multiple groups of agents, and a group of agents can collaborate to handle one or more problems; the information of the agent matching the problem description part includes the information of a group of agents that can collaborate to handle the problem in the problem description part.
3. The method according to claim 1, wherein: The agent configuration part includes one or more of agent responsibilities, interaction format descriptions and interaction examples.
4. The method according to claim 1, wherein: The prompt words also include: one or more of: a task description part, a processing step description part, a related knowledge part and a thinking chain CoT part.
5. The method according to claim 4, wherein: The relevant knowledge part is updated based on the problem description part; and / or, the CoT part is updated based on the processing result of the problem description part and / or the prompt word in the agent.
6. The method according to claim 1, further comprising: Extracting terms from the problem description; Obtain explanations of terms in the problem description; Add explanations of the terms to the relevant knowledge section.
7. The method according to claim 6, wherein: Extract terms from the problem description, including one or more of the following: Embedding the problem description part to obtain problem features, and matching multiple terms from a vector database based on the problem features; Segmenting the problem description part based on a segmentation algorithm to obtain multiple terms; Based on the large language model, the problem description part is segmented to obtain multiple terms; Based on the enumeration method, substring matching is performed on the terms in the knowledge graph and the problem description part to obtain multiple terms.
8. The method according to claim 6 or 7, wherein: Obtaining explanation contents of the terms in the problem description part, including: searching for explanation contents of the multiple terms from a knowledge graph based on the multiple terms; Adding the explanation content of the term to the relevant knowledge part includes: filling the extracted term into the knowledge part of the prompt word in the order of the number of terms on which it depends.
9. The method according to claim 8, wherein: Searching for explanations of the multiple terms from a knowledge graph based on the multiple terms includes at least one of the following: For a target term among the multiple terms, finding explanation content from a target node corresponding to the target term in the knowledge graph; Through a recursive algorithm, the knowledge graph is traversed based on the edges starting from the target node, and the explanation content of the terms found during the traversal process is extracted.
10. An agent-based problem solving method, comprising: Based on the agent configuration part in the prompt word, input the prompt word to the agent configured by the agent configuration part, wherein the prompt word is generated by the prompt word generation method according to any one of claims 1 to 9; The intelligent agent processes the problem in the prompt word to obtain a processing result.
11. The method according to claim 10, wherein: The intelligent agent processes the problem in the prompt word to obtain a processing result, and further comprises: The first agent executes the problem processing steps in the CoT part of the prompt word to obtain a processing result; updating the CoT portion based on the processing result; When it is determined based on the agent configuration part that a second agent is required to cooperate in processing the updated CoT, the updated CoT part is input to the second agent for processing.
12. A prompt word generating device, comprising: The acquisition module is used to obtain the information of the agent that partially matches the problem description; A generating module, used for generating an agent configuration part based on the information of the agent; The generating module is also used to generate prompt words based on the problem description part and the agent configuration part; The prompt words are used as inputs of the agent configured in the agent configuration part so as to process the problems in the problem description part through the agent.
13. The prompt word generating device according to claim 12, wherein: The acquisition module is used to search for an agent set according to the type of problem in the problem description part, and obtain information of agents that match the problem description part of the type of problem; wherein the agent set includes multiple groups of agents, and a group of agents can collaborate to handle one or more problems; the information of agents that match the problem description part includes information of a group of agents that can collaborate to handle the problem in the problem description part.
14. The prompt word generating device according to claim 12, wherein: The agent configuration part includes one or more of agent responsibilities, interaction format descriptions and interaction examples.
15. The prompt word generating device according to claim 12, wherein: The prompt words also include: one or more of: a task description part, a processing step description part, a related knowledge part and a thinking chain CoT part.
16. The prompt word generating device according to claim 15, wherein: The relevant knowledge part is updated based on the problem description part; and / or, the CoT part is updated based on the processing result of the problem description part and / or the prompt word in the agent.
17. The prompt word generating device according to claim 12, further comprising: An extraction module, for extracting terms from the problem description part; The acquisition module is also used to acquire the explanation content of the terms in the problem description part; The processing module is used to add the explanation content of the term into the relevant knowledge part.
18. The prompt word generating device according to claim 17, wherein: The extraction module is used for one or more of the following: Embedding the problem description part to obtain problem features, and matching multiple terms from a vector database based on the problem features; Segmenting the problem description part based on a segmentation algorithm to obtain multiple terms; Based on the large language model, the problem description part is segmented to obtain multiple terms; Based on the enumeration method, substring matching is performed on the terms in the knowledge graph and the problem description part to obtain multiple terms.
19. The prompt word generating device according to claim 17 or 18, wherein: The acquisition module is used to search for explanation contents of the multiple terms from the knowledge graph based on the multiple terms; The processing module is used to fill the extracted terms into the knowledge part of the prompt word in the order of the number of terms on which they depend.
20. The prompt word generating device according to claim 19, wherein: The acquisition module is used for at least one of the following: For a target term among the multiple terms, finding explanation content from a target node corresponding to the target term in the knowledge graph; Through a recursive algorithm, the knowledge graph is traversed based on the edges starting from the target node, and the explanation content of the terms found during the traversal process is extracted.
21. A problem-solving device based on an intelligent agent, comprising: An input module, for inputting the prompt word to the agent configured by the agent configuration part based on the agent configuration part in the prompt word, wherein the prompt word is generated by the prompt word generation method according to any one of claims 1 to 9; The processing module is used to process the problem in the prompt word through the intelligent agent to obtain a processing result.
22. The problem handling device according to claim 21, wherein: The processing module also includes: An execution submodule, configured to execute the problem processing steps in the CoT part of the prompt word through the first agent to obtain a processing result; An updating submodule, configured to update the CoT part based on the processing result; A processing submodule is used to input the updated CoT part to the second agent for processing when it is determined based on the agent configuration part that the second agent needs to cooperate in processing the updated CoT.
23. An intelligent agent comprises: An input module, used for receiving input information, wherein the input information is generated based on the prompt word generation method according to any one of claims 1 to 9; A processing module, configured to determine a target task based on the input information received by the input module, and execute the target task to obtain output information; An output module is used to output the output information obtained by the processing module.
24. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 11.
25. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-11.
26. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Solution plan generation method and device, equipment and storage medium
CN117407514A
Multi-agent task processing method and device, computer equipment and storage medium
CN117992231A
Prompt word evaluation method and device, electronic equipment and storage medium
CN118410141A
Task processing method and device, equipment and computer readable storage medium
CN118626690A
Live agent recommendation for a human-robot symbiosis conversation system
US20200099790A1
Cited By
Education data analysis method and device and electronic equipment
CN122550331A