Question and answer data processing method and device based on knowledge graph
By abstracting knowledge graph operations into intelligent agents and using multi-level intelligent agents to generate answers, the problem of single and inaccurate results in knowledge graph search by large language models is solved, achieving higher diversity and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
- Filing Date
- 2026-01-13
- Publication Date
- 2026-05-12
AI Technical Summary
In knowledge graph-based tree-structured thinking chain search, large language models are limited by temperature parameters when generating sample outputs, resulting in overly similar or inaccurate results, which restricts the ability to explore diverse solutions and adaptability.
The knowledge graph operations are abstracted into multiple agents. Answers are generated by calling agents at multiple levels. Target agents are selected and scored at each level to form an agent call tree, thus eliminating the dependence on temperature coefficients and expanding the possibilities for exploration.
It improves the diversity and accuracy of answers, and enhances the adaptability and result stability of the large language model in different contexts.
Smart Images

Figure CN122021884A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to one or more embodiments in the field of computer technology, and in particular to a question-and-answer data processing method and apparatus based on knowledge graphs. Background Technology
[0002] In the era of information explosion, the knowledge accumulated by human society is growing exponentially, and the connections between knowledge are becoming increasingly complex. Knowledge graphs, as a structured knowledge representation method with entities as nodes and relationships as edges, have become an important tool for solving complex knowledge organization and retrieval problems due to their accurate modeling capabilities of semantic relationships. Knowledge graphs can connect scattered knowledge units (such as people, concepts, and events) through semantic relationships, forming a hierarchical and network-like knowledge network, thus providing a foundation for understanding the deep semantics of user queries and uncovering implicit connections between knowledge.
[0003] With the rise of Large Language Models (LLMs), the integration of knowledge graphs with extended search in problem-solving has elevated the connections between knowledge to a new level. However, in Tree of Thought (ToT) search based on knowledge graphs, the generation of sample outputs is limited by temperature parameters, resulting in overly similar or inaccurate results. When making further choices based on these similar or inaccurate results, it is often impossible to guarantee diversity or obtain the correct outcome. This limitation restricts the ability of LLMs to explore diverse solutions and also limits the adaptability of large language models in different contexts. Therefore, how to achieve diverse reasoning path exploration and high-quality result generation has become a crucial technical problem for path search in knowledge graph-based problem-solving using large language models. Summary of the Invention
[0004] This specification describes one or more embodiments of a question-answering data processing method and apparatus based on knowledge graphs, which are used to solve one or more problems mentioned in the background art.
[0005] According to a first aspect, a question-answering data processing method based on a knowledge graph is provided, comprising: obtaining a first question; determining at least one operation sequence based on the first question through multi-level calls, wherein, in a single level call, a first number of target agents are determined from a plurality of candidate agents based on the first question and the current operation sequence, a call instruction is sent to each target agent, each target agent generates its own operation result, and a target operation result is selected and added to the current operation sequence based on an evaluation score obtained by scoring each operation result; wherein the plurality of candidate agents includes a first type of agent for querying the knowledge graph; selecting a target operation sequence from the at least one operation sequence; and generating a first answer for the first question based on the target operation sequence.
[0006] In one embodiment, the first type of intelligent agent includes a first intelligent agent and a second intelligent agent, wherein the first intelligent agent is used to perform a node lookup operation on the knowledge graph, and the second intelligent agent is used to check the node type of neighboring nodes in the knowledge graph.
[0007] In one embodiment, sending the invocation instruction to each target agent includes: determining the parameter data for this invocation based on at least one operation result at the end of the current operation sequence and the target agent; including the parameter data in the instruction format corresponding to the target agent to generate the invocation instruction and sending it to the target agent.
[0008] In a further embodiment, generating the invocation instruction further includes: determining a behavioral strategy applicable to the target agent, and including the behavioral strategy in the invocation instruction.
[0009] In another further embodiment, the target agent belongs to the first type of agent, and the parameter data includes at least one of the following: the name of the node to be searched, the type of the edge to be searched, the type of the neighbor node to be searched, and the number of returned results.
[0010] In one embodiment, determining a first number of target agents from multiple candidate agents based on the first problem and the current operation sequence includes: using a large language model to predict the probability of each candidate agent being the agent that performs the next operation; and selecting a first number of agents as target agents in descending order of probability.
[0011] In one embodiment, the evaluation score corresponding to a single operation result is obtained in one of the following ways: by the target agent performing a corresponding operation on the knowledge graph to obtain the single operation result; or by a large language model scoring the operation sequence updated using the single operation result.
[0012] In one embodiment, selecting the target operation sequence from the at least one operation sequence includes: scoring each operation sequence using a large language model to obtain a score for each candidate operation path; and selecting the operation sequence with the highest score as the target operation sequence.
[0013] In one embodiment, generating a first answer to the first question based on the target operation sequence includes: determining the first answer according to the last operation result of the target operation sequence; or, generating the first answer based on information contained in the target operation sequence.
[0014] According to the second aspect, a question-answering data processing device based on a knowledge graph is provided, comprising:
[0015] The acquisition unit is configured to acquire the first question;
[0016] The determining unit is configured to determine at least one operation sequence based on the first question through multi-level calls. In a single level call, a first number of target agents are determined from multiple candidate agents based on the first question and the current operation sequence. Call instructions are sent to each target agent, and each target agent generates its own operation result. Based on evaluation scores obtained from scoring each operation result, a target operation result is selected and added to the current operation sequence. The multiple candidate agents include a first type of agent used for querying the knowledge graph.
[0017] The determination unit is configured to select the target operation sequence from each candidate operation path;
[0018] The generation unit is configured to generate a first answer to the first question based on the target operation sequence.
[0019] According to a third aspect, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of the first aspect.
[0020] According to a fourth aspect, a computing device is provided, including a memory and a processor, wherein executable code is stored in the memory, and the processor, when executing the executable code, implements the method of the first aspect.
[0021] The methods and apparatus provided in the embodiments of this specification abstract each key operation on a knowledge graph into an independent intelligent agent. For a user question, the answer can be determined through the knowledge graph. In the process of determining the answer based on operations on the knowledge graph, multi-level intelligent agent invocation is performed. In a single-level invocation, a first number of target intelligent agents are determined from multiple candidate intelligent agents based on a first question and the current operation sequence. Invocation instructions are sent to each target intelligent agent, and each target intelligent agent generates its own operation result. Based on the evaluation score obtained by scoring each operation result, a target operation result is selected and added to the current operation sequence. At least one operation sequence is determined level by level based on the evaluation score, and a target operation sequence is selected from various operation paths to generate an answer to the user question. Thus, in the process of invoking intelligent agents level by level, the agents can explore, thereby increasing the diversity of available operations and the stability of the operation sequence, and thus improving the accuracy of the generated answer. Attached Figure Description
[0022] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This document illustrates a specific application scenario.
[0024] Figure 2 This illustrates a mind tree (ToT) diagram in a conventional technology.
[0025] Figure 3 This is a schematic diagram of a knowledge graph subgraph used for question-answering processing, which is a specific example.
[0026] Figure 4 This diagram illustrates the principle of the agent call tree (ToA) based on the technical concept described in this specification.
[0027] Figure 5 A schematic flowchart of a knowledge graph-based question-answering data processing method according to an embodiment of this specification is shown.
[0028] Figure 6 This diagram illustrates the architecture of a knowledge graph-based question-answering data processing apparatus according to one embodiment of this specification. Detailed Implementation
[0029] First, let's introduce some concepts that may be used in this manual.
[0030] Large Language Models (LLMs) are deep learning-based natural language processing models, typically ranging from billions to hundreds of billions of words, possessing powerful language understanding and generation capabilities. LLMs can employ the Transformer architecture or its variants (such as GPT and BERT), which utilizes an attention mechanism to globally model sequential data, efficiently handling long-distance dependencies and thus performing exceptionally well in natural language tasks. By pre-training on large-scale corpora, LLMs learn the statistical features and semantic relationships of language, giving them strong generalization capabilities. The core capabilities of LLMs include, but are not limited to: understanding contextual semantics, generating coherent and grammatically correct text, performing logical reasoning, and handling multi-task scenarios. Their usage typically includes two modes: direct inference and fine-tuning. In direct inference mode, users design prompts to guide the LLM in generating specific outputs. Prompts can be various textual references, task descriptions, or instructions used to stimulate the LLM's semantic understanding and generation capabilities. In fine-tuning mode, large language models are further trained on small-scale datasets within a specific domain to optimize their performance on specific tasks. The powerful generalization capabilities and flexibility of large language models make them an important tool in the field of artificial intelligence, providing efficient and accurate solutions for automated text generation and understanding.
[0031] A tree-structured thought chain is a decision-making process that breaks down a problem into multiple levels. A single decision point (such as an action) can extend into multiple branches, ultimately forming a decision tree. These decision points are the nodes of the tree, representing intermediate steps in problem-solving. Nodes taken layer by layer from the root node form a coherent sequence of language, constituting a thought chain. The reasoning process of predicting actions layer by layer to form a thought chain can be represented as a tree of thought (ToT).
[0032] An intelligent agent (sometimes also translated as a proxy) is a proxy capable of perceiving its environment and taking actions to achieve a specific goal. It can be software, hardware, or a system that can perform predetermined functions. For example, an intelligent agent can be: a module encapsulated in a program, such as an agent performing addition or data merging; a machine learning model, such as a large language model; a device containing both hardware and software components, such as a robot; and so on. In short, data is passed to the intelligent agent, and the agent can provide corresponding results.
[0033] The solution provided in this specification will now be described with reference to the accompanying drawings.
[0034] Figure 1 A schematic diagram illustrating an application scenario covered in this specification is shown. For example... Figure 1 As shown, this application scenario includes a business server and at least one client. The business server can support one or more services, such as information retrieval, homework completion (e.g., student problem solving), and planning tasks (e.g., driving route planning, travel planning, experiment planning), etc. The client is typically a user terminal or an application running on a user terminal. Through the network and the user terminal, the client can interact with the business server to perform the services supported by the business server, such as searching for information, providing homework images, and proposing planning tasks. When a user sends various business requests (which can be denoted as queries, questions, etc.) to the business server through the client, the business server can use a computing platform and a pre-built knowledge graph to perform a question-and-answer path search for the user's business request. Through the search, question-and-answer knowledge (such as paths) closely related to the user's question can be discovered in the knowledge graph. Therefore, using the question-and-answer knowledge, the business server can determine the corresponding answer and provide feedback to the user.
[0035] Understandable, Figure 1 This is merely an example of a specific application scenario. In practice, it can be used in any business scenario that requires searching and generating answers based on knowledge graphs, and it is also applicable to standalone mode (as opposed to a server-client architecture). Figure 1 In the server-client architecture shown, the number of clients and the number of business servers can be arbitrary.
[0036] The improvements to this specification involve a knowledge search process based on knowledge graphs. Figure 1 The text uses bold borders to indicate key points. In the knowledge search process, one can start with a user question. By identifying nodes in the knowledge graph that match the user question and combining these nodes with multi-level action sequences on the knowledge graph, a tree-like search network, such as a search tree, is gradually formed. A concrete example is the mind tree (ToT mentioned earlier). Figure 2 This example illustrates a typical tree-structured search network (mind tree) with four levels, separated by dashed lines. Figure 2 As shown, based on a conventional technology concept, in a mind tree that includes operations on the knowledge graph, the user question (Input, i.e., the query mentioned above) is taken as the root node, and actions at each level are predicted step by step. At each level, the actions are filtered to select the action with the highest probability, and the prediction of the action sequence is completed level by level.
[0037] Figure 2 In the search process shown, a single layer selects one optimal action, such as... Figure 2 In the process, the operation nodes representing actions selected from the second layer onwards (here, tree nodes, corresponding to an operation step in the thought chain) are represented by bold ellipses, and the arrows in the formed optimal action path are also bolded. Figure 2 To demonstrate the principles of the mind tree architecture, each layer retains one operation node (i.e., a specific action). In practice, a predetermined number of operation nodes can be retained. (Reference) Figure 2 As shown, by retaining a superior operation node at each level, a thought chain described in bold can be formed: "Input → Action 1 → Action 13 → Action 131…". Those skilled in the art will understand that the final choice of thought chain can also be determined based on the final scoring results of multiple thought chains, which are not shown here.
[0038] Each action in this thought chain corresponds at least partially to an operation on a corresponding knowledge graph, yielding a result within the knowledge graph. The result of this operation corresponds to... Figure 1 The process of searching from input to path in the thought chain. When each action in the action sequence is an operation on the knowledge graph, a tree-like execution result targeting the knowledge graph can be formed.
[0039] For example Figure 2 The input to the mind tree shown is "Please provide the foundation for building 'artificial intelligence'", in Figure 3 Searching within the knowledge graph, action 1 is, for example, matching the node "Artificial Intelligence"; action 2 is, for example, matching the node "Turing"; action 3 is, for example, matching the node "Knowledge Graph"; action 11 is, for example, matching the node "Turing"; action 12 is, for example, matching the node "Knowledge Graph"; action 13 is, for example, matching the sub-topic "Deep Learning"... action 131 is, for example, finding the implementation method TensorFlow... Therefore, Figure 2 The optimal thought chain formed by the operation path in the code, "Input → Action 1 → Action 13 → Action 131…", can be mapped to the knowledge graph path "Artificial Intelligence - Deep Learning - TensorFlow…", which is in… Figure 3 The text is still represented by bold lines. Figure 2 , Figure 3 These are just examples and may not represent the actual situation.
[0040] In the process of determining the above operation path, conventional techniques often employ the Tree of Thoughts (ToT) concept. This involves a Large Language Model (LLM) generating several inference paths (i.e., operation paths) and selecting a superior one for inference. For example, in response to the user question "Please find the direct research areas of 'Artificial Intelligence' from the knowledge graph," the inference path predicted by LLM, consisting of various actions, would be: find the "Artificial Intelligence" node → check its neighbor types → confirm the "SubTopic" edge type → obtain neighbor nodes → ... Such paths are often generated by LLM based on a sampling strategy (such as a temperature parameter T). This sampling strategy can be understood as adjusting the probability distribution of each candidate operation when generating a single candidate operation (generating a specific action, such as checking the neighbor type of a node). Specifically, LLM can predict the probability of each candidate operation in a single round, selecting the candidate operation with the higher probability as the next predicted operation. After multiple iterations, the inference path can be obtained. In a single round, let thought represent a single operation, P(thought) represent the generation probability of the single operation, T be the temperature coefficient, and P model (thought) is the numerical value obtained by mapping a single operation through an activation function in the large language model; it can be called the direct probability value. Therefore: P(thought) = exp(logP model (thought) / T) / ∑exp(logP model (thought) / T). Here, exp represents the power of the natural constant e, ∑ represents the summation of the mapping values of each operation, T > 1 can compress the probability distribution, increasing the probability of generating candidate operations with lower direct probabilities, and T < 1 can amplify the probability distribution, increasing the probability of generating candidate operations with higher direct probabilities.
[0041] The above reasoning path generation process may have one or more of the following problems: lack of path diversity, with LLM-generated paths often focusing on operations corresponding to a few specific instructions; poor adaptability to graph structures, such as when the specified edge type (e.g., ...) is limited. Figure 3 When the SubTopic (implementation method, etc.) is unavailable, alternative solutions cannot be automatically generated; relying on the temperature parameter T can easily generate duplicate or invalid paths, affecting the accuracy of the final result; and so on.
[0042] In view of this, this specification provides a technical solution for question-answering data processing based on knowledge graphs. It abstracts each operation corresponding to the knowledge graph into an agent, thus forming a multi-agent search architecture based on automatic exploration. This search architecture still follows the tree-like search approach, but the difference is that instead of the large language model directly inferring subsequent operations (i.e., specific actions) to generate a thought chain, at each layer, the large language model infers the next suitable agent. These agents constitute nodes in the search tree, exploring various operations using current parameter data and providing feedback on the operation results. For each operation result, an LLM or the agent itself can provide a score, and the corresponding operation result is selected to form an operation path based on the score. It can be understood that when a single operation corresponding to the knowledge graph is abstracted into a single agent, a single call to the corresponding operation function can explore and execute multiple actions to complete the task given in the call instruction.
[0043] This approach decouples the reasoning process from the temperature coefficient, allowing the agent to explore more possibilities. It is suitable for diverse reasoning tasks and improves the overall accuracy of the results.
[0044] Figure 4 This illustrates a specific principle underlying the technical concept of this specification. For example... Figure 4 As shown, the Large Language Model (LLM) 401 can associate multiple agents, including agents for knowledge graph operations, such as the agent corresponding to node lookup operations and the agent corresponding to neighbor confirmation operations (used to check the node type of neighboring nodes). Agents related to knowledge graph operations can be pre-encapsulated according to predetermined rules and corresponding instructions. When a user inputs a question, the LLM can predict the target agent for the first level based on the user question and a candidate agent list. Each target agent then performs a corresponding operation on the knowledge graph, such as operation 1, operation 2, etc., and each operation produces a corresponding result and a score. Based on the scores of each operation result, the LLM selects the operation for the current level (e.g., ...). Figure 4 Only the highest-scoring agent's operation result is selected and marked in orange (e.g., the operation result corresponding to operation 3 generated by agent 3). In this way, after multiple cycles, the target agent is predicted layer by layer, and the better operation result is selected from the operations generated by the target agent. This layer-by-layer invocation forms an agent call tree, and the operation paths are constructed through the operations at each level. Corresponding data can be obtained from the knowledge graph through the corresponding operation results.
[0045] exist Figure 4In this process, the executing entity can be a master entity distinct from the candidate agents and the large language model 401 (such as an intelligent control module or a control program), or it can be the large language model 401 itself. First, based on the input user question, the large language model 401 can predict a list of agents at the first level. For example, the target agent list predicted at the first level includes Agent 1, Agent 2, Agent 3, etc. Each target agent is provided with the required parameters, and then performs corresponding operations based on these parameters (which may include operations targeting the knowledge graph). For example, Agent 1 performs Operation 1. Simultaneously, the target agent can score its performed operations; for example, Operation 1 receives a score of 0.1. Similarly, Agent 2 performs Operation 2 with a score of 0.3, and Agent 3 performs Operation 3 with a score of 0.9. In practice, these scores can be provided directly by the target agents or determined by the large language model 401. The large language model 401 can summarize the operation results obtained by each target agent performing its corresponding operations and select Operation 3 with the highest score and its result to update the current operation sequence. Based on the current operation sequence, and combining the user question and the candidate agent list, a second-level target agent prediction is performed to obtain the corresponding operation and its result. Through multiple iterative cycles, the operations and results at each level are obtained sequentially, forming the final operation sequence output. Based on the operation sequence, an answer to the user question can be generated using data obtained from the knowledge graph.
[0046] from Figure 4As can be seen, in the process of answering questions based on knowledge graphs, in order to find relevant knowledge for the answer within the knowledge graph, operations on the knowledge graph are treated as agent invocations. This is achieved by using a tree-like search network to form an agent-based search tree (ToA). Because the operations performed by a single agent are scalable, this is fundamentally different from the conventional tree of thought, which predicts specific actions to form search paths. Specifically, each search node in each layer of ToA corresponds to an agent encapsulated as a tool, or an agent abstracted from operations on the knowledge graph. These agents execute related operations in parallel, and based on the evaluation scores obtained from evaluating the operations, the appropriate operation result is selected, continuing the selection process for the next layer of agents. The operations of agents in each layer are sequentially connected to form the operation path. Under this technical concept, the large language model only predicts agents; the agents actively explore relevant operations, rather than the large language model predicting individual actions. Since the operations obtained through extended exploration are based on encapsulated intelligent agents or abstract intelligent agents that perform various operations according to corresponding operation instructions and rules (i.e., regarded as intelligent agents but not actually encapsulated as intelligent agents), the operations obtained are more feasible, accurate, and diverse. Therefore, the accuracy and robustness of the answers can be improved.
[0047] The technical concept of this specification will now be described in detail with reference to the embodiments shown in the accompanying drawings.
[0048] Figure 5 This diagram illustrates a knowledge graph-based question-answering data processing flow proposed in an embodiment of this specification. The execution entity of this flow can be a computer, device, or server with a certain computing power; specifically, for example… Figure 1 The computing platform shown Figure 4 The large language model 401 is shown.
[0049] like Figure 5 As shown, the question-answering data processing flow based on knowledge graphs may include: Step 501, obtaining a first question; Step 502, based on the first question, determining at least one operation sequence through multi-level calls, wherein, in a single level call, a first number of target agents are determined from multiple candidate agents based on the first question and the current operation sequence, call instructions are sent to each target agent, each target agent generates its own operation result, and target operation results are selected and added to the current operation sequence based on the evaluation scores obtained by scoring each operation result, wherein the multiple candidate agents include a first type of agent used for querying the knowledge graph; Step 503, selecting a target operation sequence from the at least one operation sequence; Step 504, generating a first answer for the first question based on the target operation sequence.
[0050] First, in step 501, the first problem is obtained.
[0051] The first question can be a user-input request (such as "Please find the direct research areas of 'artificial intelligence' from the knowledge graph"), a question (such as "Given the lengths of two sides of a right triangle, how do you find the length of the other side?"), or a search query (such as "What is a beam search?") in a question-and-answer or search scenario. These are collectively referred to as user questions. The current user's question is designated as the first question. It is understood that the current user can be any network user, and the current user question they raise can be any user question; no restrictions are imposed here.
[0052] Next, according to step 502, based on the first problem, at least one operation sequence is determined through multi-level calls.
[0053] based on Figure 4 As shown in the schematic diagram of the specific principle architecture, under the technical concept of this specification, in the process of answering the first question, various intelligent agents can be called in a tree-like hierarchical manner. The candidate intelligent agents faced by a single level of call can be all available intelligent agents. By determining and calling the target intelligent agent level by level, an operation path for the knowledge graph can be generated. A single candidate operation path can be an operation sequence composed of the operation results of each level. Candidate intelligent agents are, for example, the intelligent agent that performs the merging operation, the intelligent agent corresponding to the knowledge graph operation, etc. Here, the knowledge graph operation is usually a specific operation instruction. The intelligent agent corresponding to the knowledge graph operation can be an intelligent agent encapsulated from the corresponding operation instruction, used to complete the relevant operation based on the corresponding parameters and the specific operation instruction, or it can be an abstract intelligent agent, that is, used as an intelligent agent, but in reality, such an encapsulated real independent intelligent agent may not exist. Here, it is referred to as the intelligent agent corresponding to the knowledge graph operation, on the one hand, to maintain consistency in description, and on the other hand, to conform to the concept of the technical solution of this specification.
[0054] In a single-level call, several candidate agents most likely to be used in the next operation can be predicted from among the candidate agents based on the first problem and the current operation sequence, and these will be used as the target agents for the current level call. It is understood that the current operation sequence can initially be empty. After the first-level agent call, several candidate operation results can be obtained, and the target operation result is selected from these results and added to the current operation sequence. The current operation sequence can maintain a predetermined number, such as one or more. For a single current operation sequence, in subsequent single-level agent calls, several candidate operation results are generated, and the target operation result is selected and appended to the current operation sequence to form a new current operation sequence. Optionally, the operation sequences obtained after a single-level update can be evaluated together to maintain the total number of current operation sequences at a predetermined number.
[0055] At a single level, the target agent can be predicted using a Large Language Model (LLM). During the prediction process, a prompt can be provided to the LLM with a first question, a single current operation sequence, and a list of candidate agents (optionally including the role or operation performed by the candidate agents). In some embodiments, the prompt can also provide the LLM with a few examples (sample questions, operation sequences) for reference. This allows the LLM to select one or more candidate agents as the target agent for that single level. For example, the LLM can predict probability scores for each candidate agent and select a number (up to a predetermined number, such as 5) of candidate agents as the target agents according to their probability scores in descending order or a predetermined threshold. Specifically, this could involve selecting the top 5 candidate agents with the highest probability scores (5) or filtering out candidates at the current level based on a probability value of 0.5, eliminating those with probabilities less than 0.5, leaving only candidates with probabilities greater than or equal to 0.5 as the target agents. When a target agent is determined by a predetermined threshold, the number of selected target agents may be less than a predetermined number (e.g., there may be only one candidate agent with a probability value not less than the predetermined threshold).
[0056] For a selected target agent, the agent can be invoked by passing relevant parameters, and the target agent will then provide the corresponding operation result. For example, for the agent corresponding to a merge operation, parameters such as the data to be merged and the format of the merged data can be passed to it. The parameter data can be determined based on at least one operation result at the end of the current operation sequence and the target agent. For example, a large language model can provide configuration parameters based on the current operation sequence while predicting the target agent.
[0057] In optional embodiments, the invocation instruction may further include a behavioral policy for the target agent. This behavioral policy guides operations in various situations. For example, it may be a policy to modify an operation to another operation if an existing operation is invalid.
[0058] Under the technical concept outlined in this specification, various operation instructions targeting knowledge graphs can be abstracted into corresponding intelligent agents, which, along with other intelligent agents, serve as candidate intelligent agents. Typically, operations interacting with knowledge graphs can be implemented through various instructions. Operations targeting knowledge graphs can include, but are not limited to, the NeighbourCheck operation, the RetrieveNode operation, and so on. Among these, RetrieveNode is one of the fundamental operations in knowledge graph operations, used to locate and extract target entities (nodes) and their associated information. For example, it locates target entities based on unique identifiers (IDs) and obtains complete information about the target entity (such as entity attributes, neighbor relationships), etc. Similarly, NeighbourCheck is also one of the fundamental operations in knowledge graph operations, used to verify and analyze the relationships between target entities and their neighbors. It ensures data consistency, optimizes query efficiency, and supports complex reasoning tasks by checking the direct connected nodes (neighbor entities) of the entity. Operations targeting knowledge graphs can also include node filtering, etc., which will not be elaborated upon here.
[0059] Thus, the NeighbourCheck instruction for neighbor checking can be encapsulated as a NeighbourCheck agent with autonomous exploration capabilities, or abstractly viewed as corresponding to a NeighbourCheck agent that completes a series (not a single) neighbor checking operations when invoked according to predefined calling rules. The agent corresponding to the neighbor checking operation is denoted as the first agent. Similarly, the RetrieveNode instruction for node searching can be encapsulated as a RetrieveNode agent with autonomous exploration capabilities, or abstractly viewed as corresponding to a RetrieveNode agent that completes a series (not a single) node searching operations when invoked according to predefined calling rules, denoted as the second agent. And so on, various operations on the knowledge graph can be considered candidate agents, and so on. Here, the first agent and the second agent are agents corresponding to operations on the knowledge graph. Since they can be encapsulated agents or abstract agents (such as understood as a sub-agent embedded in the main agent), this specification refers to these agents as the first type of agent. The parameter data of the first type of agent may include, but is not limited to, at least one of the following: the name of the node to be searched, the type of edge to be searched, the type of neighbor node to be searched, the number of returned results, etc.
[0060] Invoking a corresponding intelligent agent can involve using relevant instructions to complete specific operations and generate results. The invocation instruction can include at least one of the following: configuration parameters required for the operation instruction, and a behavioral strategy. The behavioral strategy can be described by predefined rules, which can incorporate various scenarios that may occur during actual knowledge graph data operations to provide execution strategies. For example, the predefined rules might explicitly state that if an operation using the corresponding instruction is invalid, an alternative operation will be automatically generated. As a specific example, if the neighbor type of a node to be confirmed is "research field," which is an unavailable type (e.g., does not exist in the knowledge graph), it can be replaced with a corresponding available type, such as "application field" or "related technology," according to predefined rules. Here, the neighbor type can be determined through the attributes of neighbor nodes or connecting edges.
[0061] It is understandable that when a single operation instruction is encapsulated as an independent agent, a call instruction can be generated and sent to the corresponding agent, which then predicts and completes the corresponding operation based on the instruction. Alternatively, when the agent corresponding to a single operation instruction is an abstract agent, a call instruction can be directly generated according to configuration parameters and behavioral strategies to complete the operation; this is considered as utilizing the corresponding agent to perform the relevant operation.
[0062] As the target agent in the current level of invocation, it can perform relevant operations and produce specific operation results by using at least one of the parameters and behavioral strategies passed in the invocation command. Taking the agent corresponding to the RetrieveNode operation as an example, it can retrieve the knowledge graph nodes that match the user's question (such as the first question). Search operations are performed on each matched node to obtain various operation results. For example, one operation is "RetrieveNode(Artificial Intelligence) → NodeID: N1", which means retrieving the node "Artificial Intelligence" with node ID (NodeID) N1. Similarly, each target agent can produce corresponding operation results.
[0063] Each operation result can have a corresponding evaluation score, used to describe the quality of the corresponding operation result when connected to the current operation sequence. In this specification, the evaluation score of each operation result can be determined in various reasonable ways. For example: in one embodiment, the target agent can output the corresponding evaluation score while executing the response operation and obtaining the operation result; in another embodiment, the current executing agent (such as the main agent) can obtain each operation result and score it to obtain the corresponding evaluation score; in yet another embodiment, a large language model can be invoked to combine the first question and the current operation sequence to score each operation result and obtain the corresponding evaluation score; and so on.
[0064] It is understandable that the invocation of a single target agent can produce one or more operational results. Each operational result can correspond to a specific evaluation score.
[0065] In some optional implementations, for a single target agent selected for a single current operation sequence at a single level, their operation results can be filtered together by evaluation scores, and several target operation results can be selected from each operation result according to the evaluation score. The target operation results can be the first predetermined number of operation results (e.g., 3) in descending order of evaluation score, or operation results with evaluation scores greater than a predetermined threshold (e.g., 0.7), or operation results with evaluation scores greater than the predetermined threshold and in descending order of the first predetermined number of operation results; there is no limitation here.
[0066] The selected target operation result can be appended to the corresponding current operation sequence to form a new operation sequence. After a single level call is completed, a predetermined number (e.g., 3) of current operation sequences can be determined. Thus, the target agents in the candidate agents are called level by level, forming a tree-like call structure for agents, and the target operation results are obtained level by level until a stopping condition is met. Stopping conditions include, for example, the number of levels (or the depth of the tree) reaching a predetermined number (e.g., 10), no target agent with a probability value not less than a predetermined threshold being predicted at a single level, and no operation result with an evaluation score not less than a predetermined threshold being predicted as the target operation result at a single level, etc.
[0067] As a concrete example, suppose the first question is "Please find the direct research areas of 'artificial intelligence' from the knowledge graph." Based on the first question, we can use LLM to predict the target agent at the first level. Assuming we select only the candidate agent with the highest probability value as the target agent, such as the first agent corresponding to the RetrieveNode operation, we can then "distribute" the prediction task to the first agent, configure its parameters, provide behavioral strategies, and have it execute the corresponding knowledge graph operation (the node acquisition operation) to generate the corresponding result.
[0068] Assuming the first agent is an agent encapsulated based on the RetrieveNode operation command, capable of node matching and node retrieval, the calling command for this first agent is: retrieve the top 5 nodes that best match "Artificial Intelligence". The calling statement is: `node_results = self.node_retriever.search_topk("Artificial Intelligence", top_k=5, offset=0)`. Here, `search_topk` indicates the top k matched nodes, `node_retriever` indicates retrieving the top k matched nodes, and "artificial intelligence", "5", and "0" can be considered configuration parameters. `top_k` and `offset` define the behavior strategy: retrieving the top 5 nodes with an offset of 0 will retrieve the top 5 nodes that best match "artificial intelligence". Thus, the first agent can determine the top 5 (top_k) nodes with the highest matching degree to "artificial intelligence" based on the node matching results and retrieve these 5 nodes via the RetrieveNode operation command.
[0069] The following example uses four matching nodes, denoted as N1, N2, N3, and N4. The first agent executes the following RetrieveNode operation instructions: RetrieveNode (Artificial Intelligence) → NodeID: N1; RetrieveNode (Machine Learning) → NodeID: N2; RetrieveNode (Deep Learning) → NodeID: N3; RetrieveNode (Natural Language Processing) → NodeID: N4. The execution result is nodes N1, N2, N3, and N4. See Table 1 for reference.
[0070] Table 1 illustrates the return results of the agent corresponding to RetrieveNode in a specific example.
[0071] node_id (node identifier) node_name (node name) node_type (node type) N1 AI Concept N2 Machine Learning Subfield N3 Deep learning Technology N4 Natural Language Processing Application
[0072] Since the number of current operation sequences is 1 in this specific example, the result of this operation can be used as the first operation result of the current operation sequence. If the results of obtaining 4 nodes are considered as one operation result, then the results of obtaining 4 nodes together are used as the first operation result of the current operation sequence. If the results of obtaining 4 nodes are considered as 4 operation results, then the result of obtaining a single node is used as the first operation result of a single operation sequence, resulting in a total of 4 current operation sequences.
[0073] Based on the results of the first operation, and according to the first question, LLM can be further invoked to predict the target agent at the second level. Assuming the candidate agent with the highest probability is the agent corresponding to the NeighbourCheck operation instruction (i.e., the second agent), the second agent can be further invoked to perform the operation of confirming the node types of the neighboring nodes of the above nodes. The invocation instruction for the second agent can pass the configuration parameters of the NeighbourCheck operation instruction, as well as the behavioral strategy. For example, a specific invocation instruction includes:
[0074] "if action_type == 'NeighbourCheck':
[0075] NeighbourCheck(neighbor_type)
[0076] neighbor_type_array = ['Research Field', 'Application Field', 'Related Technologies']
[0077] for nt in neighbor_type_array:
[0078] if nt != neighbor_type:
[0079] generate alternative action with nt”.
[0080] Here, "NeighbourCheck(neighbor_type)" indicates a call to the NeighbourCheck function (i.e., an operation instruction), with the parameter being neighbor_type. The call instruction also includes the following behavioral strategy: During the call, the neighbor type is first expanded (neighbor_type_array represents the expansion range). For example, if the original neighbor type is research field, it is expanded to three types: "'Research Field', 'Application Field', 'Related Technology'", where nt represents the node type. If the node type is not within this range (unavailable), another node type is selected, and an alternative action is generated.
[0081] For example, the original request is NeighbourCheck(N1, Research Domain), which checks whether the neighboring entities of node N1 conform to the rule of "Research Domain". If the check finds that the "Research Domain" type is unavailable, NeighbourCheck can replace it with "Application Domain" or "Related Technology" according to predetermined rules, checking whether the neighboring entities of node N1 conform to either "Application Domain" or "Related Technology". The final operations are: NeighbourCheck(N1, Application Domain) and NeighbourCheck(N1, Related Technology). The results of NeighbourCheck(N1, Application Domain) and NeighbourCheck(N1, Related Technology) can be used as the operation results of the second agent. NeighbourCheck(N1, Application Domain) and NeighbourCheck(N1, Related Technology) can be considered as one operation result or two operation results. If considered as two operation results, they can correspond to two evaluation scores, and the higher score is selected as the current operation result.
[0082] Thus, through the above two layers of intelligent agents, a predetermined number of operation sequences can be obtained, and so on, until a predetermined stopping condition is met, such as the number of levels reaching a predetermined depth (e.g., 3, 5, etc.). In practice, a predetermined number of operation sequences can ultimately be retained.
[0083] Then, based on step 503, a target operation sequence is selected from at least one of the above operation sequences.
[0084] As described above, there can be one or more candidate operation sequences. A specific example of an operation sequence is: retrieve the "Artificial Intelligence" node → retrieve the list of neighbor nodes of the "Application Domain" type. If there is only one candidate operation sequence, it can be determined as the target operation sequence. If there are multiple candidate operation paths, one can be selected as the target operation sequence. For example, a large language model can be used to score each candidate operation sequence, and the one with the highest score can be selected as the target candidate sequence.
[0085] As a concrete example, suppose we obtain the following candidate operation sequences: RetrieveNode(N1), NeighbourCheck(N1, Research Area); RetrieveNode(N1), NeighbourCheck(N1, Application Area); RetrieveNode(N2), NeighbourCheck(N2, Subject Classification); ... A concrete example of scoring each candidate operation sequence is shown in Table 2.
[0086] Table 2. Illustration of candidate operation sequences and scoring results generated by multi-layered intelligent agents.
[0087] Path ID Action sequence Evaluation score (Score) P1 RetrieveNode(N1), NeighbourCheck(N1, Research Area) 0.85 P2 RetrieveNode(N1), NeighbourCheck(N1, application domain) 0.92 P3 RetrieveNode(N2), NeighbourCheck(N2, Subject Classification) 0.78 …… …… ……
[0088] Where P1, P2, and P3 represent each candidate operation sequence (or operation path). Assuming that the candidate operation sequence with the highest score is finally selected as the output of the target operation path, the target operation sequence P2 can be determined as: "RetrieveNode(N1), NeighbourCheck(N1, application domain)".
[0089] Further, in step 504, a first answer to the first question is generated based on the target operation sequence.
[0090] It's understandable that the answer to the first question is usually the response provided to the user, which can be referred to as the first answer. The target operation sequence corresponds to the thought process for the first question, and the first answer can be determined based on the target operation sequence.
[0091] In one embodiment, the final operation result of the target operation sequence, i.e., the last operation result in the target operation sequence, can be used as the first answer. For example, in the previous example, if the first question is "Please find the direct research areas of 'artificial intelligence' from the knowledge graph", then after performing the second-level NeighbourCheck(N1, application area) or NeighbourCheck(N1, related technology) neighbor type confirmation, nodes that match "application area" or "related technology" can be obtained as the first answer.
[0092] In another embodiment, a first answer can be generated based on the target operation sequence. For example, if a valid path for the first question is found in the knowledge graph, containing multiple knowledge graph nodes, each describing a corresponding entity, these entities may contain the answer or the materials required for the answer. Therefore, the answer for the first question can be determined based on each node on the valid path. For instance, the first answer can be determined manually based on the valid path, such as selecting the corresponding answer from each node on the valid path, or organizing the first answer based on the valid path; a generative model can be used to generate the first answer based on the valid path and the first question. A specific example of a generative model is a large language model, where the first question, the target path, and the answer generation task can be used as prompts for the large language model, which then performs the answer generation task to generate the first answer; and so on.
[0093] It is worth noting that since operations on a knowledge graph may only be a part of the operation sequence, with the aim of obtaining auxiliary information from the knowledge graph, the process of generating the first answer can be based on the knowledge obtained from the knowledge graph, using the entire target operation sequence to generate the first answer, or it can be based on the knowledge obtained from the knowledge graph, obtaining the first answer at the end of the operation sequence.
[0094] In other embodiments, the first answer can also be generated in other ways, which will not be listed here.
[0095] Reviewing the above process, the knowledge graph-based question-answering data processing method provided under the technical concept of this specification treats each key operation on the knowledge graph as an independent intelligent agent. For a user question, the corresponding answer can be obtained through appropriate operations within the knowledge graph nodes. During the operation process within the knowledge graph nodes, multi-level intelligent agent invocation is possible. In a single-level invocation, a large language model scores each intelligent agent, selects an agent to invoke, and obtains the corresponding operation result based on the scoring results of each operation. This hierarchical intelligent agent invocation forms an operation sequence, and the answer is determined according to the operation sequence. When predicting the target intelligent agent instead of the predicted action, parameter configuration and behavioral strategies can be used to provide exploration space for the intelligent agent. This increases the diversity of available actions and the stability of the operation sequence, thereby improving the accuracy and robustness of the answer.
[0096] More specifically, compared to the conventional Tree of Thought (ToT), the beneficial technical effects of the Tree of Agents (ToA) provided in this specification can be reflected in one or more of the following aspects: In terms of path generation, ToT relies on LLM. Random sampling results in limited and repetitive paths. ToA introduces a multi-agent (i.e., intelligent agent) mechanism, where each agent can generate multiple candidate operations, significantly improving path diversity. Regarding graph interaction with knowledge graphs, ToT typically fixes the type of connecting edges (i.e., the neighbor type mentioned earlier), often failing to adapt if the type is unavailable. ToA can dynamically replace edge types and provide explanations, enhancing graph structure adaptability. In path evaluation, ToT often relies on temperature parameters to control diversity, which is prone to failure. ToA, however, can generate multiple paths and then uniformly score them, ensuring the best path is selected. In terms of flexibility and scalability, ToT typically has weak support for complex graph structures, while ToA supports flexible knowledge graph interaction, suitable for diverse reasoning tasks. Regarding result accuracy, ToT may suffer from result bias due to single or incorrect paths, while ToA can improve overall result accuracy through multi-agent collaboration and professional verification. And so on.
[0097] According to another embodiment, a question-answering data processing device based on a knowledge graph is also provided. This device can be installed on any computer, device, or server with a certain computing power. Figure 6 A knowledge graph-based question-answering data processing apparatus 600 according to one embodiment of this specification is shown.
[0098] like Figure 6 As shown, device 600 may include: a question-and-answer data processing device based on a knowledge graph, comprising: an acquisition unit 601 configured to acquire a first question; an invocation unit 602 configured to determine at least one operation sequence based on the first question through multi-level invocation, wherein, in a single level invocation, a first number of target agents are determined from multiple candidate agents based on the first question and the current operation sequence, invocation instructions are sent to each target agent, each target agent generates its own operation result, and target operation results are selected and added to the current operation sequence based on evaluation scores obtained by scoring each operation result; wherein the multiple candidate agents include a first type of agent for querying the knowledge graph; a determination unit 603 configured to select a target operation sequence from the above at least one operation sequence; and a generation unit 604 configured to generate a first answer for the first question based on the target operation sequence.
[0099] It is worth noting that, Figure 6 The device 600 shown and Figure 5 The methods described correspond to, Figure 5 The corresponding descriptions in the illustrated method embodiments also apply to apparatus 600, and will not be repeated here.
[0100] According to another embodiment, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed in a computer, causes the computer to perform a combination Figure 5 The methods described above.
[0101] According to another embodiment, a computing device is also provided, including a memory and a processor, wherein the memory stores executable code, and when the processor executes the executable code, it implements a combination... Figure 5 The methods described above.
[0102] Those skilled in the art will recognize that the functions described in the embodiments of this specification in one or more of the above examples can be implemented using hardware, software, firmware, or any combination thereof. When implemented in software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium.
[0103] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the technical concept in this specification. It should be understood that the above description is only a specific embodiment of the technical concept in this specification and is not intended to limit the scope of protection of the technical concept in this specification. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solutions of the embodiments in this specification should be included within the scope of protection of the technical concept in this specification.
Claims
1. A question-answering data processing method based on knowledge graphs, comprising: Get the first question; Based on the first problem, at least one operation sequence is determined through multi-level calls. In a single level call, a first number of target agents are determined from multiple candidate agents based on the first problem and the current operation sequence. Call instructions are sent to each target agent, and each target agent generates its own operation result. Based on the evaluation scores obtained by scoring each operation result, a target operation result is selected and added to the current operation sequence. The multiple candidate agents include a first type of agent for querying the knowledge graph. Select a target operation sequence from the at least one operation sequence; Generate a first answer to the first question based on the target operation sequence.
2. The method as described in claim 1, wherein, The first type of intelligent agent includes a first intelligent agent and a second intelligent agent. The first intelligent agent is used to perform node lookup operations on the knowledge graph, and the second intelligent agent is used to check the node type of neighboring nodes in the knowledge graph.
3. The method as described in claim 1, wherein, Sending invocation instructions to each target agent includes: Based on at least one operation result at the end of the current operation sequence and the target agent, determine the parameter data for this call; The parameter data is included in the instruction format corresponding to the target intelligent agent to generate a calling instruction, which is then sent to the target intelligent agent.
4. The method of claim 3, wherein, The generated invocation instruction also includes: Determine the appropriate behavioral strategy for the target agent and include the behavioral strategy in the invocation instruction.
5. The method of claim 3, wherein, The target agent belongs to the first type of agent, and the parameter data includes at least one of the following: the name of the node to be searched, the type of the edge to be searched, the type of the neighbor node to be searched, and the number of returned results.
6. The method of claim 1, wherein, The step of determining a first number of target agents from multiple candidate agents based on the first problem and the current operation sequence includes: The probability of each candidate agent being selected to perform the next operation is predicted using a large language model. The first number of agents are selected as the target agents based on their probability from highest to lowest.
7. The method of claim 1, wherein, The evaluation score for a single operation result is obtained in one of the following ways: It is obtained by the target intelligent agent when performing corresponding operations on the knowledge graph to obtain the result of the single operation; The scores are obtained by a large language model based on the updated sequence of operations using the results of the single operation.
8. The method of claim 1, wherein, Selecting the target operation sequence from the at least one operation sequence includes: The large language model is used to score each operation sequence, and the score of each candidate operation path is obtained. Select the operation sequence with the highest score as the target operation sequence.
9. The method of claim 1, wherein, The step of generating a first answer for the first question based on the target operation sequence includes: The first answer is determined based on the result of the last operation in the target operation sequence; or, The first answer is generated based on the information contained in the target operation sequence.
10. A question-answering data processing device based on a knowledge graph, comprising: The acquisition unit is configured to acquire the first question; The invocation unit is configured to determine at least one operation sequence through multi-level invocation based on the first question. In a single level invocation, a first number of target agents are determined from multiple candidate agents based on the first question and the current operation sequence. Invocation instructions are sent to each target agent, and each target agent generates its own operation result. Based on the evaluation scores obtained from scoring each operation result, a target operation result is selected and added to the current operation sequence. The multiple candidate agents include a first type of agent used for querying the knowledge graph. The determining unit is configured to select a target operation sequence from the at least one operation sequence; The generation unit is configured to generate a first answer to the first question based on the target operation sequence.
11. A computer-readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform the method of any one of claims 1-9.
12. A computing device, comprising a memory and a processor, characterized in that, The memory stores executable code, and when the processor executes the executable code, it implements the method of any one of claims 1-9.