Prompt word generation method, device and intelligent agent
By generating prompt words and utilizing knowledge graphs and vector databases to optimize agent configuration, the problems of low efficiency and high cost of agent collaboration are solved, and efficient processing of agents in complex scenarios is achieved.
Patent Information
- Application Number
- CN202411355436.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2044-09-26
AI Technical Summary
Collaborative problem-solving between intelligent agents is inefficient and costly, requires careful programming by professionals, and is difficult to apply to complex scenarios.
By generating prompt words, the agent information matching the problem description is obtained, the agent configuration part is generated, and prompt words are generated based on the problem description and configuration part as the agent input to process the problem. The knowledge graph and vector database are used to improve the collaborative efficiency and accuracy of the agent.
It improves the problem-solving ability and efficiency of intelligent agents, reduces the cost and difficulty of intelligent agent collaboration, and enhances the applicability of intelligent agents in complex scenarios.
Smart Images

Figure CN119294518B_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 a variety of creative tasks. However, solving a specific scenario through collaboration between agents is difficult. This is not only applicable to simple scenarios, but also requires professional personnel to carefully program the agents, which is not only inefficient but also costly. Summary of the Invention
[0003] The present disclosure 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] generating 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-solving 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, configured to generate an agent configuration part based on the information of the agent;
[0015] The generation module is further configured 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 apparatus, 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, configured to receive input information generated based on any prompt word generation method in the embodiments of the present disclosure;
[0022] 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;
[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 perform 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. When the computer program is executed by a processor, the computer program implements any one of the methods according to the embodiments of the present disclosure.
[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 contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The accompanying drawings are provided to facilitate a better understanding of the present invention 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 flowchart of an agent-based problem-solving method according to an embodiment of the present disclosure;
[0036] Figure 4 is a flowchart 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 graph expressing knowledge;
[0039] Figure 6b This is an example diagram of a collaborative agent setting;
[0040] Figure 7 is a structural diagram of a prompt word generating device according to an embodiment of the present disclosure;
[0041] Figure 8 is a structural diagram of a prompt word generating device according to another embodiment of the present disclosure;
[0042] Figure 9 is a structural diagram of an agent-based problem-solving device according to an embodiment of the present disclosure;
[0043] Figure 10 is a structural diagram of an agent-based problem-solving device according to another embodiment of the present disclosure;
[0044] Figure 11 It is a structural diagram of an intelligent agent according to an embodiment of the present disclosure.
[0045] Figure 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 embodiments of the present disclosure. DETAILED DESCRIPTION
[0046] The following description of exemplary embodiments of the present disclosure is made 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 appreciated by those skilled 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, descriptions of well-known functions and structures are omitted in the following description.
[0047] Figure 1 FIG. 1 is a flow chart of a method 100 for generating a prompt word 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 embodiments, a prompt may include input information provided to an agent. The prompt can guide the agent in processing a question and generate output of a specific type or style. The prompt may include a question description portion, an agent configuration portion, and the like. The question description portion of the prompt may be generated based on the question input by the user. This description portion may include the input question itself or the understanding obtained through natural language understanding or other processing of the input question. A correspondence between agents and question types is pre-set; each question may correspond to one agent or multiple agents. Based on the question description portion, the corresponding relationship can be searched to obtain information about matching agents. For example, agent information may include the number, function, name, and number of agents capable of processing this question. For example, if the question description portion includes "Please process question A," the agent information may read: "According to the matching, there are three agents capable of processing this question, named A1, A2, and A3." Agents may also be referred to as agents or AI agents. Different agents can process certain tasks in parallel or perform certain tasks serially, and agents may interact with each other. For example, a problem needs to be solved collaboratively by agents A1, A2, and A3. Agent A1 sends the results of its processing to agent A2, which then sends the results to agent A3 for further processing.
[0053] In an embodiment of the present disclosure, an agent configuration part can be generated based on the information of the agent that matches the problem description part. The agent configuration part may include information of one or more agents required to process the problem in the problem description part, and may 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 can be: "You are responsible for searching for all types of A on the search website", and the description of agent A2 can be configured as: "You are responsible for searching for 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 to generate the agent configuration part.
[0054] In an embodiment of the present disclosure, based on the problem description part and the agent configuration part, prompt words for solving the problem 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 matches a portion of the problem description, including: searching an agent set according to the type of the problem in the problem description to obtain information of an agent that matches 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 that 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 embodiment of the present disclosure, 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. Based on the input problem or problem description part, the type of problem can be first determined, and a matching agent set can be selected according to 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 split into multiple steps and then handed over to different agents in a group of agents corresponding to the problem for processing. For example, the problem is divided into steps S1, S2 and S3, and agent A1 is called to execute step S1, and agent A2 is called to execute step S2. Based on the execution results of S1 and S2, agent A3 is called to execute step S3.
[0058] According to an embodiment of the present disclosure, by using the type of question in the question description part of the prompt word, an agent in the agent set that matches the type of question can be selected, and the problem can be collaboratively processed by the agent, which not only reduces the cost of agent collaboration through the prompt word, but also improves 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 the 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 configuration center can be used to configure the interaction format of data between agents, 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 the intelligent agent making mistakes can be reduced and the quality of the intelligent agent can be improved.
[0062] In one embodiment, the prompt word further includes one or more of: a task description portion, a processing step description portion, a related knowledge portion, and a Chain of Thought (CoT) portion.
[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 the intelligent agent making mistakes 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 problem description part or the execution result included in the COT part of the prompt word can be updated. The updated prompt word is then input into the new intelligent agent to continue execution. Until the steps required for the problem are processed or the termination condition is met.
[0067] According to the embodiment of the present disclosure, the relevant knowledge part and / or CoT part of the agent are updated accordingly according to the processing results, which can realize the collaboration between agents, improve the stability of the agent execution process, and improve the execution efficiency of the agent.
[0068] Figure 2 FIG2 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 embodiment, the method 200 further includes:
[0069] S210, extracting terms from the problem description;
[0070] S220, obtaining explanations of terms in the problem description;
[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 intelligent agent. The explanations of the terms may be pre-stored in the knowledge graph. When it is detected that there are terms that need to be explained in the problem description part, the explanation corresponding to the term can be obtained from the knowledge graph. For example, if the problem description part is "How to indent the first line of a paragraph", the term "first line indent" can 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 an embodiment of the present disclosure, after extracting the terms from the problem description, the explanatory content of the terms can be searched through the knowledge base. The explanatory content of the terms may include information such as 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 explanatory content of the terms may also include the corresponding relationships between multiple terms, such as inclusion relationships, subordination relationships, dependency relationships, and upstream and downstream relationships. The knowledge base may include a knowledge graph, a vector database, etc. The storage form of the terms in the knowledge graph may be stored in the form of nodes, or connected through edges through different node homes.
[0074] In the embodiment of the present disclosure, the extraction and interpretation process of the terms in the other parts of the prompt word is similar to that of the problem description part. The interpretation content of the terms in 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 accurately understand the problem and improve the execution efficiency of the intelligent agent.
[0076] In one embodiment, step S210 extracts terms from the problem description, including one or more of the following:
[0077] Embedding the problem description part to obtain problem features, and matching multiple terms from the vector database based on the problem features;
[0078] The problem description is segmented based on the segmentation algorithm to obtain multiple terms;
[0079] Based on the large language model, the problem description is segmented to obtain multiple terms;
[0080] Based on the enumeration method, the terms in the knowledge graph are matched with the problem description part to obtain multiple terms.
[0081] For example, the vector database stores embedded vectors of various terms. The problem description 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 based on the problem features.
[0082] For example, a word segmentation algorithm can be used to segment the problem description and then extract the terms that need to be explained from the segmented terms. A word segmentation algorithm, also known as a word segmentation algorithm, can segment the problem description into multiple words or short sentences through semantic recognition and understanding.
[0083] For example, a large language model (LLM) can be used to extract terms from the question description. Using a large language model, the text in the question description can be processed through natural language understanding and other processes to obtain the terms that need to be explained in the question 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 in turn. 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 to facilitate the intelligent agent to accurately understand the problem, which can 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 embodiment of the present disclosure, a knowledge graph is a structured semantic knowledge base, and explanation content corresponding to terms can be extracted from the problem description part in the knowledge graph.
[0089] In an embodiment of the present disclosure, the association relationships between different terms, such as dependency relationships, can be obtained, and the terms can be sorted from the smallest to the largest number of dependencies. For example, term 1, term 2, and term 3 are sorted according to their dependency relationships. If the explanation of term 3 mentions term 1 and term 2, then term 2 and term 1 can be sorted before term 3. If the explanation of term 2 mentions term 1, then 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 embodiment 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 embodiment, searching for explanations of the multiple terms from a 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 an embodiment of the present disclosure, a knowledge graph can be used to search for a term node that is identical or similar to a target term, and extract the target term's explanation from the term node. After finding the target node, the knowledge graph can be used as a starting point to find associated nodes based on the target node's edges, and extract the target term's explanation from the associated nodes. A recursive algorithm can be used to traverse the edges to extract more explanations of the target term.
[0099] In the disclosed embodiments, each section of the prompt may include numerous terms requiring explanation. The explanations in the sections containing statically configured content, such as the task description, process description, agent configuration, and COT, can be updated based on the terms in the dynamically generated problem description. Some content in the COT may be updated based on processing results, and the explanations in the related knowledge section can also be updated based on the updated terms in the processing results.
[0100] According to the embodiment of the present disclosure, using the knowledge graph to search for the explanation content of the term can improve the accuracy of the term explanation and thus improve the accuracy of the intelligent agent execution.
[0101] Figure 3 FIG. 3 is a flow chart of an agent-based problem-solving method 300 according to an embodiment of the present disclosure, the method comprising:
[0102] S310: Based on the agent configuration portion in the prompt word, input the prompt word to the agent configured by the agent configuration portion, wherein the prompt word is generated using the prompt word generation method of 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 embodiment disclosed herein, the prompt words generated by the above-mentioned prompt word generation method are input into the agent involved in the agent configuration part, which will not be described in detail 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. The new prompt words can then be sent to the agents required to process the subsequent steps.
[0105] In the disclosed embodiment, after receiving a prompt, an agent analyzes the problem contained in the prompt and addresses it according to the CoT portion of the prompt. During this process, the agent can invoke the framework as needed or request collaboration from other agents. Furthermore, the agent can interpret the terminology involved in the prompt using the relevant knowledge portion. If the agent can independently address the problem in the prompt, no agent collaboration is required. If the agent cannot independently address the problem in the prompt, it can send a collaboration request to other agents to collaborate on the issue.
[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 FIG4 is a flow chart of an agent-based question processing method 400 according to another embodiment of the present disclosure. The method 400 can be used to implement step S320 of the agent-based question processing method 300. In one embodiment, the method 400 includes processing the question 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 portion of the prompt word by the first agent to obtain a processing result;
[0109] S420: Update the CoT part based on the processing result;
[0110] S430. When it is determined based on the configuration portion of the agent that a second agent is required to collaborate in processing the updated CoT, the updated CoT portion 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, it processes the problem according to the prompt word. The processing method of the first agent may include obtaining a processing instruction based on 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. 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 result of the problem, the problem can continue to be processed. If a second agent is required to cooperate, the first agent can re-enter the processing result into the configuration center. The configuration center will update one or more of the agent configuration part, related knowledge part, and CoT part of the prompt word based on the processing result. The updated CoT part is then input into the second agent, and the second agent is treated as the first agent, and steps S410, S420, and S430 are repeated.
[0113] In the disclosed embodiment, there may be one or more second agents. If multiple second agents need to collaborate, the configuration information of each second agent can be updated based on the characteristics of each second agent, and the updated CoT portion can be input into the second agent for processing. Each agent that receives the prompt word can execute steps S410 to S430 until the keyword processing is complete.
[0114] According to the embodiment 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 embodiment of the present disclosure can be applied to an agent structure that can precipitate business experience using natural language terms, can stably collaborate with each other, and can effectively deduce solutions.
[0116] The disclosed embodiment can generate an intelligent agent and prompt word (prompt) pattern, can introduce concept explanation based on the knowledge graph, deduce based on the CoT pattern, and collaborate based on the set intelligent agent interaction range. 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 the 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, you can describe the agent's function in detail. For example, in a case analysis scenario where a URL is not retrieved under a specific query, the task description of the agent corresponding to a service X may include:
[0125]
[0126] 2. Related knowledge part (can be partially statically configured and partially dynamically generated.)
[0127] This section provides a detailed explanation of all the internal terms used in the current problem and task description. This section is crucial and represents the innovation of this solution. This knowledge is extracted through the collaborative work of the knowledge graph and vector database.
[0128] The vector database stores the embedding vectors of various internal terms and is used to directly find relevant term sets from the agent's input questions.
[0129] The knowledge graph stores detailed knowledge about various terms and is the ultimate source of the content related to prompts. 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 problem.
[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 description from the corresponding node in the knowledge graph. Then, using a recursive algorithm, traverse the graph from this node along the edges, extracting detailed descriptions of all terms along the way. Ensure that the terms that are ultimately populated in the prompt appear in ascending order based on 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 listed above, find a detailed description from the corresponding node in the knowledge graph. Using a recursive algorithm, traverse the graph from this node along the edges, extracting detailed descriptions of all terms along the way. Ensure that the terms that appear in the prompt appear in ascending order based on the number of dependencies on other terms.
[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 listed above, find a detailed description from the corresponding node in the knowledge graph. Using a recursive algorithm, traverse the graph from this node along the edges, extracting detailed descriptions of all terms along the way. Ensure that the terms that appear in the prompt appear in ascending order based on the number of dependencies on other terms.
[0144] Algorithm 4: Brute Force Enumeration
[0145] All terms and aliases in the knowledge graph are substring matched against the agent's input question. If a match is found, it is considered a term that needs to be explained.
[0146] 3. Current problem description (can be dynamically generated based on the input problem)
[0147] The agent input problem is described in this section.
[0148] 4. Description of problem handling steps
[0149] This can be a pure natural language description. This part can be written 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] In the configuration center, you can directly configure the name of the agent that can be collaborated, or you can drag and drop the agent that needs to be collaborated to the current agent. When generating the prompt for the current agent, the framework extracts the three parts of the agent's responsibilities, interaction format description, and interaction examples, and assembles them into the description of the agent that can be collaborated in the prompt. The responsibilities, interaction format description, and interaction examples of each agent are also expressed in the configuration center, such as Figure 6b shown.
[0154] The interaction format describes the natural language input format that the agent expects to see. This minimizes the richness of the input and improves the stability of the agent's execution. For example, if service X fails to retrieve a URL, the agent can be instructed to accept the following input: "Service X fails to retrieve URL Y."
[0155] Interaction examples are given to make the execution of the agent more stable and further reduce hallucinations.
[0156] 6. The following is an example of how to write CoT. After the agent executes the prompt word, it can update the historical steps, execution results, and other content.
[0157]
[0158]
[0159] This description method needs to bring about the following effect: after each step of the agent's execution, it generates a structured answer. This answer can be understood by the framework, and other agents can be dispatched 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. In the process, they can use internal terms they are familiar with to express themselves, which reduces costs.
[0161] Intelligent agents interact entirely with natural language and use formatted interaction instructions to further improve the stability of collaboration.
[0162] Based on terminology explanations, manually accumulated empirical step descriptions, and the CoT model, the intelligent agent can understand the received input problem very well, complete the derivation of the solution steps, and execute them step by step based on the framework capabilities to ultimately solve the problem.
[0163] This solution can save a lot of manpower when applied to search problem tracing, service management, etc.
[0164] Figure 7 FIG. 7 is a schematic structural 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 obtain information of an agent that partially matches the problem description;
[0166] A generating module 720, configured to generate an agent configuration part based on the agent information;
[0167] The generating module 720 is further configured to generate prompt words based on the problem description portion and the agent configuration portion;
[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 based on 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 process 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 process the problem in the problem description portion.
[0170] In one embodiment, the agent configuration portion includes one or more of agent responsibilities, interaction format descriptions, and interaction examples.
[0171] In one embodiment, the prompt word further includes: one or more of: a task description part, a processing step description part, a related knowledge part, and a thought chain 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 generation 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 these modules can be referred to the functions of the modules in the prompt word generation device of the above embodiment. In one embodiment, the prompt word generation device further includes:
[0174] An extraction module 830 is used to extract terms from the problem description portion;
[0175] The acquisition module 810 is further configured to acquire the explanation content of the terms in the problem description portion;
[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] Embedding the problem description part to obtain problem features, and matching multiple terms from the vector database based on the problem features;
[0179] The problem description is segmented based on the segmentation algorithm to obtain multiple terms;
[0180] Based on the large language model, the problem description is segmented to obtain multiple terms;
[0181] Based on the enumeration method, the terms in the knowledge graph are matched with the problem description part to obtain multiple terms.
[0182] In one embodiment, the acquisition module 810 is configured to search for explanations of the multiple terms from a 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 the terms depend.
[0184] In one embodiment, 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] Figure 9 FIG. 1 is a schematic structural diagram of an agent-based problem processing apparatus 900 according to an embodiment of the present disclosure. The apparatus 900 may include:
[0188] An input module 910 is configured 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 using the prompt word generation method described above;
[0189] The processing module 920 is used to process the question in the prompt word through the intelligent agent to obtain a processing result.
[0190] Figure 10 FIG2 is a schematic diagram of the structure of an agent-based problem-solving 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 these modules can be found in the functions of the modules of the agent-based problem-solving device in the above embodiment. In one embodiment, the processing module 1020 further includes:
[0191] An execution submodule 1021 is configured to execute the problem processing steps in the CoT portion of the prompt word through the first agent to obtain a processing result;
[0192] An updating submodule 1022, configured to update the CoT portion based on the processing result;
[0193] The processing submodule 1023 is configured to input the updated CoT portion to the second agent for processing when it is determined based on the agent configuration portion that the second agent needs to collaborate in processing the updated CoT.
[0194] In the technical solutions disclosed herein, the acquisition, storage, and application of user personal information involved comply 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] Figure 11 FIG1 is a schematic structural diagram of an agent 1100 according to another embodiment of the present disclosure, wherein the agent 1100 includes:
[0197] An input module 1110 is configured to receive input information generated based on any prompt word generation method in the embodiments of the present disclosure;
[0198] A processing module 1120 is 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;
[0199] The output module 1130 is configured to output the output information obtained by the processing module.
[0200] Figure 12A schematic block diagram of an example electronic device 1200 that can be used to implement embodiments 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, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are provided as examples only and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0201] like Figure 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. Various programs and data required for the operation of the device 1200 can also be stored in the RAM 1203. 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] Various components in device 1200 are connected to I / O interface 1205, including an input unit 1206, such as a keyboard and mouse; an output unit 1207, such as various types of displays and speakers; a storage unit 1208, such as a magnetic disk and optical disk; and a communication unit 1209, such as a network card, a modem, a wireless communication transceiver, etc. Communication unit 1209 allows device 1200 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0203] The computing unit 1201 can be any general-purpose and / or specialized processing component 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 specialized artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 1201 executes the various methods described above, such as the prompt word generation method and the agent-based question processing method. For example, in some embodiments, the prompt word generation method and the agent-based question processing method can be implemented as a computer software program that is tangibly contained in a machine-readable medium, such as the storage unit 1208. In some embodiments, part or all of the computer program can 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 question processing method described above can be performed. 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 embodiments of the systems and techniques described 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), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system comprising 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 can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0206] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can 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 can 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 can 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 having 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 can 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 server are generally remote from each other and typically interact through a communication network. The client-server relationship arises through computer programs running on the respective computers and having a client-server relationship with each other. The server may be a cloud server, a server in a distributed system, or a server integrated with a blockchain.
[0210] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not limited herein.
[0211] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the principles of this disclosure shall be included within the scope of protection of this disclosure.
Claims
1. A method for generating a prompt word, comprising: Get information about agents that partially match the problem description; generating 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; wherein the prompt word is used as an input of the agent configured in the agent configuration part, so as to process the problem in the problem description part through the agent; Obtaining information of an agent that matches a portion of the problem description, including: searching an agent set according to the type of the problem in the problem description to obtain information of agents that match the type of the problem; wherein the agent set includes multiple groups of agents, and a group of agents can collaborate to solve one or more problems; and the information of the agents that match the problem description includes information of a group of agents that can collaborate to solve the problem in the problem description; The prompt word also includes a related knowledge portion, and the method further includes: Extracting terms from the problem description; Obtain explanations of the terms in the problem description; Add the explanation of the term to the relevant knowledge section; Wherein, obtaining the explanation content of the terms in the problem description part includes: searching for the explanation content of the multiple terms from the 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 the term depends.
2. The method according to claim 1, wherein The agent configuration part includes one or more of agent responsibilities, interaction format descriptions and interaction examples.
3. 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 and a thought chain CoT part.
4. The method according to claim 3, wherein: 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.
5. The method according to claim 1, wherein Extract terms from the problem description, including one or more of the following: Embedding the problem description portion to obtain problem features, and matching multiple terms from a vector database based on the problem features; Segmenting the problem description portion based on a segmentation algorithm to obtain multiple terms; Segmenting the problem description part based on a large language model 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.
6. The method according to claim 1, 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.
7. 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 6; The intelligent agent processes the problem in the prompt word to obtain a processing result.
8. The method according to claim 7, wherein: The agent processes the question in the prompt word to obtain a processing result, further comprising: 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; In the case where 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.
9. 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, configured to generate an agent configuration part based on the information of the agent; The generating module is further configured to generate prompt words based on the problem description part and the agent configuration part; wherein the prompt word is used as an input of the agent configured in the agent configuration part, so as to process the problem in the problem description part through the agent; The acquisition module is configured to search an agent set according to the type of the problem in the problem description portion, and obtain information of agents matching the type of the problem; wherein the agent set includes multiple groups of agents, and a group of agents can collaborate to solve one or more problems; the information of agents matching the problem description portion includes information of a group of agents that can collaborate to solve the problem in the problem description portion; The prompt word also includes a related knowledge part, and the prompt word generating device also includes: An extraction module, configured to extract terms from the problem description portion; The acquisition module is further used to obtain the explanation content of the terms in the problem description part; specifically, it is used to search the explanation content of the multiple terms from the knowledge graph based on the multiple terms; The processing module is used to add the explanation content of the term to the relevant knowledge part; specifically, it is used to fill the extracted term into the knowledge part of the prompt word in the order of the number of terms on which it depends.
10. The prompt word generating device according to claim 9, wherein: The agent configuration part includes one or more of agent responsibilities, interaction format descriptions and interaction examples.
11. The prompt word generating device according to claim 9, wherein: The prompt words also include: one or more of: a task description part, a processing step description part and a thought chain CoT part.
12. The prompt word generating device according to claim 11, wherein: 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.
13. The prompt word generating device according to claim 9, wherein: The extraction module is used for one or more of the following: Embedding the problem description portion to obtain problem features, and matching multiple terms from a vector database based on the problem features; Segmenting the problem description portion based on a segmentation algorithm to obtain multiple terms; Segmenting the problem description part based on a large language model 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.
14. The prompt word generating device according to claim 9, 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.
15. An agent-based problem-solving device, 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 6; The processing module is used to process the question in the prompt word through the intelligent agent to obtain a processing result.
16. The problem handling device according to claim 15, wherein: The processing module further includes: an execution submodule, configured to execute, by the first agent, the problem processing steps in the CoT portion of the prompt word to obtain a processing result; an updating submodule, configured to update the CoT part based on the processing result; The processing submodule is used to input the updated CoT part into 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.
17. An intelligent agent comprising: An input module, configured to receive input information, wherein the input information is generated based on the prompt word generation method according to any one of claims 1 to 6; 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.
18. 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 8.
19. 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-8.
20. 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 8.
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