Question-and-answer methods, devices, electronic equipment and storage media
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-14
- Publication Date
- 2026-08-11
AI Technical Summary
[0004]本发明提供了一种问答方法、装置、电子设备及存储介质,以解决对上下文信息处理效果较差的问题
[0010] The question-answering method provided in this embodiment actively compresses and structurally assembles the context information corresponding to the agent based on a preset number of lexical units, obtaining the target context information for the agent, rather than passively and completely piling up the retrieved text fragments into the agent's context information. This allows the target context information to contain more important information, balancing the contradiction between information overload and information insufficiency. Consequently, when the agent performs reasoning based on the target context information, it does not need to crudely truncate the target context information when the preset number of lexical units is insufficient, avoiding the loss of important information and solving the problem of poor context information processing. This results in a more accurate target answer. Moreover, the structured assembly of the target context reduces the amount of lexical unit processing and computational resource consumption, saving the cost of generating the target answer and improving the efficiency of generating the target answer.
Smart Images

Figure CN122549602A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, specifically to question-answering methods, devices, electronic devices, and storage media. Background Technology
[0002] Using large language models (LLMs) as the decision-making core of artificial intelligence agents (AI agents), and equipping AI agents with the ability to use external tools such as search engines, databases, and application programming interfaces (APIs), can enable AI agents to evolve from passive answering machines into proactive actors that can perform tasks and interact with the environment.
[0003] However, providing AI agents with just the right amount of contextual information during task execution is a core challenge. For example, too much contextual information can drastically increase processing costs and overwhelm critical information; too little contextual information can lead to illusions and erroneous decisions. Current methods typically employ a passive and crude approach, such as directly truncating contextual information. This method struggles to effectively resolve the contradiction between information overload and information insufficiency. Summary of the Invention
[0004] This invention provides a question-answering method, apparatus, electronic device, and storage medium to solve the problem of poor performance in processing contextual information.
[0005] In a first aspect, the present invention provides a question-answering method, which includes: acquiring context information invoked by an agent during the processing of a question text to be answered; compressing the context information based on a preset number of lexical units corresponding to the agent to obtain a context summary corresponding to the agent; assembling the context summary corresponding to the agent in a structured manner to obtain target context information corresponding to the agent; and using the agent to process the question text to be answered based on the target context information to obtain and output the target answer corresponding to the question text to be answered.
[0006] Secondly, the present invention provides a question-answering device, comprising: a first acquisition module for acquiring context information invoked by an agent during the processing of a question text to be answered; a compression module for compressing the context information based on a preset number of lexical units corresponding to the agent to obtain a context summary corresponding to the agent; an assembly module for structurally assembling the context summary corresponding to the agent to obtain target context information corresponding to the agent; and a first reasoning module for using the agent to process the question text to be answered based on the target context information to obtain and output the target answer corresponding to the question text to be answered.
[0007] Thirdly, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the question-and-answer method of the first aspect or any corresponding embodiment described above.
[0008] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to perform the question-and-answer method of the first aspect or any corresponding embodiment thereof.
[0009] Fifthly, the present invention provides a computer program product, including computer instructions for causing a computer to execute the question-and-answer method of the first aspect or any corresponding embodiment thereof.
[0010] The question-answering method provided in this embodiment actively compresses and structurally assembles the context information corresponding to the agent based on a preset number of lexical units, obtaining the target context information for the agent, rather than passively and completely piling up the retrieved text fragments into the agent's context information. This allows the target context information to contain more important information, balancing the contradiction between information overload and information insufficiency. Consequently, when the agent performs reasoning based on the target context information, it does not need to crudely truncate the target context information when the preset number of lexical units is insufficient, avoiding the loss of important information and solving the problem of poor context information processing. This results in a more accurate target answer. Moreover, the structured assembly of the target context reduces the amount of lexical unit processing and computational resource consumption, saving the cost of generating the target answer and improving the efficiency of generating the target answer. Attached Figure Description
[0011] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0012] Figure 1 This is a schematic diagram of the architecture of a question-and-answer system provided according to an embodiment of the present invention; Figure 2 This is a schematic diagram of an application scenario according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the first type of question-and-answer method according to an embodiment of the present invention; Figure 4This is a schematic diagram of a second type of question-and-answer method according to an embodiment of the present invention; Figure 5 This is a schematic diagram of the architecture of the context management and storage layer according to an embodiment of the present invention; Figure 6 This is a schematic diagram of the third type of question-and-answer method according to an embodiment of the present invention; Figure 7 This is a flowchart illustrating the generation of task execution results based on SCF according to an embodiment of the present invention; Figure 8 This is a flowchart illustrating the generation of new associations according to an embodiment of the present invention; Figure 9 This is a schematic diagram of the architecture of a specific question-and-answer system according to an embodiment of the present invention; Figure 10 This is a timing diagram of a specific question-and-answer method according to an embodiment of the present invention; Figure 11 This is a structural block diagram of a question-and-answer device according to an embodiment of the present invention; Figure 12 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0013] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0014] It is understood that before using the technical solutions disclosed in the various embodiments of the present invention, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in the present invention and their authorization should be obtained in accordance with relevant laws and regulations through appropriate means.
[0015] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0016] In recent years, the field of artificial intelligence has witnessed a paradigm shift with the remarkable capabilities of large language models (LLMs) in natural language understanding, generation, and logical reasoning. However, LLMs are essentially static, closed knowledge bases and reasoning engines, whose capabilities are limited by the deadline of training data and cannot interact with the external world in real time to complete complex tasks.
[0017] To overcome this limitation, AI agents have emerged. By using an LLM (Limited Learning Model) as the brain of the AI agent and equipping it with the ability to use external tools such as search engines, databases, and application programming interfaces (APIs), the AI agent evolves from a passive question-and-answer machine into an actor capable of proactively performing tasks and interacting with its environment, thereby greatly expanding the application scenarios of AI agents.
[0018] As task complexity increases, a single agent struggles to simultaneously handle multiple specialized roles such as planning, execution, verification, and reflection. Consequently, multi-agent systems (MAS) have emerged. However, with the application of MAS in real-world complex scenarios, a series of technical challenges have arisen, becoming bottlenecks restricting their performance and reliability. For example, 1. A key challenge is providing each agent with just the right amount of contextual information at the precise moment it performs its specific task. Too much information, or information overload, leads to a surge in LLM processing costs and the suffocation of critical information; too little information, or insufficient information, can cause agents to experience illusions and make incorrect decisions.
[0019] 2. The internal thought process of an LLM-based agent is inherently probabilistic, unpredictable, and uncertain. In multi-agent systems, this uncertainty is amplified at each level, making the behavior of the entire system difficult to tune.
[0020] 3. Any intelligent agent can write information to the database, resulting in the database being filled with a large amount of low-quality, outdated, and even contradictory information. When an intelligent agent retrieves unreliable information, it will seriously affect the quality of its decision-making.
[0021] In response to the above problems, such as Figure 1As shown, this application provides a question-answering system. This system includes an external interaction layer for communication connectivity, a multi-agent collaboration layer, and a context management and storage layer. The external interaction layer receives user-input questions and ultimately presents the analysis results, i.e., the target answer, for the questions. The multi-agent collaboration layer includes multiple agents with clearly defined and separated responsibilities, such as a planning agent, an execution agent, an answer-generating agent, a first decision agent, and a second decision agent. These agents execute specific tasks and generate analysis results for the questions under the coordination of a coordinator. Furthermore, the agents communicate and manage task flow through a lightweight task state object, ResearchState. The context manager in the context management and storage layer proactively provides optimal context information to each agent in the multi-agent collaboration layer before task execution. The context management and storage layer also includes storage modules such as a first knowledge graph, a vector database, and a relational database. The first knowledge graph stores relevant historical cases, the vector database stores domain-specific knowledge, and the relational database stores relevant business data. The coordinator can be a management logic module or a highly automated scheduler. The behavior of the coordinator can be state-driven in the task state object, and it is responsible for managing the orderly flow and efficient collaboration of complex analysis tasks among different role agents such as planning agents, execution agents, and answer generation agents.
[0022] As an optional application scenario of this invention, such as Figure 2 As shown, application 101 is installed in terminal device 110, and user 130 can interact with application 101 through terminal device 110 and / or access device of terminal device 110.
[0023] For example, application 101 can be any application that provides question-and-answer related services. For instance, application 101 could be a question-and-answer interactive application, such as a text-to-text application, an image-to-text application, etc. Figure 1 In the application scenario shown, if application 101 is active, the terminal device 110 can display the interface 102 of application 101. The interface 102 may include various pages that application 101 can provide, such as interactive pages, settings pages, query pages, etc.
[0024] In some embodiments, terminal device 110 is communicatively connected to server 120 to provide services to application 101. Terminal device 110 may be a mobile terminal, fixed terminal, or portable terminal, etc., including but not limited to mobile phones, desktop computers, laptop computers, multimedia tablets, e-book devices, gaming devices, or any combination thereof, including accessories and peripherals of these devices or any combination thereof. In some embodiments, terminal device 110 may also support any type of interface, and server 120 may be various types of computing systems or servers capable of providing computing power, including but not limited to mainframes, edge computing nodes, computing devices in cloud environments, etc.
[0025] It should be noted that, Figure 2 This is merely an example of an application scenario and does not limit the scope of protection of this invention.
[0026] The embodiments of the present invention will now be described with reference to the accompanying drawings. It should be understood that the pages shown in the drawings are merely examples, and various page designs are possible in practice. The various graphic elements on the page may have different arrangements and different visual representations; one or more elements may be omitted or replaced, and one or more other elements may also be present, without any limitation in the embodiments of the present invention. Furthermore, the embodiments described below primarily pertain to terminal device 110. It should be understood that the actions described relative to terminal device 110 can be performed by application 101 on terminal device 110, or can be performed by application 101 in conjunction with its server (e.g., server 120).
[0027] According to an embodiment of the present invention, a question-answering method embodiment is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0028] This embodiment provides a question-and-answer method that can be used in terminal devices. Figure 3 This is a flowchart of a question-and-answer method according to an embodiment of the present invention, such as... Figure 3 As shown, the process includes the following steps: Step S301: Obtain the context information called by the agent during the process of processing the text of the question to be answered.
[0029] like Figure 2As shown, terminal device 110 deploys application 101, which is the question-and-answer system described above. The external interaction layer of this system provides a corresponding interactive page, through which users can input questions to be answered, such as "The hydraulic arm of electric shovel #3 has been shaking recently; please investigate what's wrong." Correspondingly, the terminal device can respond to the user's input and obtain the text of the question to be answered.
[0030] As a concrete example, the multi-agent collaboration layer in a question-answering system can correspond to a demand-receiving agent. The demand-receiving agent can analyze the text of the question to be answered and interact with the user based on the analysis results. It converts the unstructured and ambiguous natural language input by the user into a structured research outline (research_brief) that the demand-receiving agent can understand. This research outline includes not only the question to be answered, i.e., the analysis target, but also the corresponding scope of related data, i.e., the analysis boundary, when analyzing the text of the question to be answered.
[0031] For example, if the demand receiving agent analyzes the text of the question to be answered and determines that the answer to the question to be answered lacks a range of related data, it can further interact with the user and clarify the range of related data corresponding to the question to be answered, and generate a research outline such as "Analysis of the cause of abnormal vibration of the hydraulic arm of the No. 3 electric shovel based on the operation logs, maintenance records and GPS positioning data of the past 3 months".
[0032] As a specific example, the task status object shown above may include the initial_query field (the text field of the question to be answered), the research_brief field (the research outline field), the task_queue field (the task queue field), the review_queue field (the evaluation queue field), the new_hypotheses field (the new relationship field), the relevant_kg_node_ids field (the newly added knowledge node field), and the final_report_id field (the ID field of the target answer).
[0033] Furthermore, after obtaining the text of the question to be answered input by the user, the terminal device can update the initial_query field of the task status object with the text of the question to be answered. Also, after determining the research outline corresponding to the text of the question to be answered through interaction with the user, the terminal device can update the research outline in the research_brief field of the task status object.
[0034] Contextual information can be the set of all information that the agent relies on to generate the target answer corresponding to the text of the question to be answered, and that is directly or indirectly related to the text of the question to be answered. As a concrete example, it can be derived from... Figure 1 The context manager shown prepares the corresponding context information for the agent. For example, if there is only one agent, the context manager can analyze the text of the question to be answered and / or the research outline corresponding to the text of the question to be answered to determine the demand direction, i.e., the intent, corresponding to the text of the question to be answered; then, it searches the corresponding database based on the demand direction, i.e., the intent, thereby recalling content related to the demand direction, i.e., the intent, from the database, which is the context sub-information shown below; the recalled content, i.e., the context sub-information shown below, constitutes the context information corresponding to the agent. If there are multiple agents, taking one agent as an example, the context manager can search the corresponding database based on the demand direction corresponding to that agent, recalling content related to the demand direction, i.e., the context sub-information shown below, from the database; the recalled content, i.e., the context sub-information shown below, constitutes the context information corresponding to that agent.
[0035] Step S302: Compress the context information based on the preset number of lexical units corresponding to the agent to obtain the context summary corresponding to the agent.
[0036] A token is the smallest semantic unit that a model can process after text has been segmented. The preset number of tokens can be the number of tokens pre-set for the agent, i.e., the token budget (token_budget).
[0037] As a concrete example, different lexical budgets can be statically configured for different agents based on their roles. For instance, a planning agent, requiring a global perspective, typically receives a larger lexical budget to accommodate historical cases and domain knowledge; a first-decision agent, needing only to verify specific facts, can have a relatively compact lexical budget. Alternatively, a coordinator can dynamically allocate different lexical budgets to different agents based on task intent and complexity. For example, the coordinator can perceive whether the current task is a simple task like an API call or a complex task like complex spatiotemporal correlation analysis. For complex tasks involving multiple heterogeneous data sources (first-order knowledge graphs, vector databases, relational databases), the coordinator can allocate a higher lexical budget to the corresponding agent to allow more space for displaying the recalled contextual information.
[0038] The process of obtaining the context summary through compression can be as follows: using a pre-trained semantic model to label the semantic importance weights of each word in the context information; determining the number of words to be pruned based on the difference between the preset number of words and the target number of words; sorting each word in the context information in ascending order based on the semantic importance weights to obtain the sorting result, and removing the word with the smallest number of words to be pruned from the sorting result; finally, performing grammatical coherence repair on the undrunned words to generate the context summary corresponding to the agent.
[0039] Step S303: The context summary corresponding to the agent is structurally assembled to obtain the target context information corresponding to the agent.
[0040] As a concrete example, structured tags such as XML and JSON can be used to assemble the context summary corresponding to the agent by source (different databases correspond to different sources) to obtain the target context information. Furthermore, during the structured assembly process, the assembly strategy can be flexibly determined based on the task type. For example, if the task is a question-answering task, the context summary and its corresponding confidence level should be encapsulated first; if the task is a reasoning task, the context summary and the source information corresponding to the preceding and following summaries should be encapsulated first.
[0041] Structured assembly can transform fragmented context summaries into formats with standard labels / key-value pairs, such as XML and JSON. The agent can then directly locate core information using pre-defined parsing rules.<core_fact> The tag content and the confidence level corresponding to trust_tier in the text can be used without performing global semantic analysis on unstructured text, which can reduce the amount of word processing and computational resource consumption.
[0042] Step S304: The agent processes the text of the question to be answered based on the target context information to obtain and output the target answer corresponding to the text of the question to be answered.
[0043] As mentioned earlier, when there are multiple agents, the corresponding agents can be invoked to perform the corresponding tasks based on the dependencies between tasks, thereby generating the target answer for the text of the question to be answered. The target answer may include attribution analysis and maintenance strategies for the text of the question to be answered. As a specific example, the target answer may be an analysis report that combines graphs and text.
[0044] The question-answering method provided in this embodiment actively compresses and structurally assembles the context information corresponding to the agent based on a preset number of lexical units, obtaining the target context information for the agent, rather than passively and completely piling up the retrieved text fragments into the agent's context information. This allows the target context information to contain more important information, balancing the contradiction between information overload and information insufficiency. Consequently, when the agent performs reasoning based on the target context information, it does not need to crudely truncate the target context information when the preset number of lexical units is insufficient, avoiding the loss of important information and solving the problem of poor context information processing. This results in a more accurate target answer. Moreover, the structured assembly of the target context reduces the amount of lexical unit processing and computational resource consumption, saving the cost of generating the target answer and improving the efficiency of generating the target answer.
[0045] This embodiment provides a question-and-answer method that can be used in terminal devices. Figure 4 This is a flowchart of a question-and-answer method according to an embodiment of the present invention, such as... Figure 4 As shown, the process includes the following steps: Step S401: Obtain the context information called by the agent during the process of processing the text of the question to be answered.
[0046] As a specific example, there can be multiple agents.
[0047] Specifically, step S401 includes: Step S4011: For each agent, retrieve the task state object based on the agent's role identifier to obtain the task corresponding to the agent. The task state object is used to store the mapping relationship between the role identifier and the task. The task is generated based on the text of the question to be answered.
[0048] The role identifier for each agent here is used to uniquely identify its role and core functional boundaries within a multi-agent system. Different role identifiers can correspond to different fields in the task state object; that is, the correspondence between role identifiers and fields in the task state object is equivalent to the relationship between a role identifier and the corresponding task.
[0049] For example, the planning agent can read the research_brief field in the task status object; the execution agent can read the task_queue field; and the answer generation agent can write content to the final_report_id field in the task status object.
[0050] Step S4012: Based on the task description corresponding to the task, search each database to obtain the context sub-information retrieved from each database. The context information includes multiple context sub-information.
[0051] As a specific example, the databases can be, but are not limited to, the first knowledge graph, vector database, and relational database shown above.
[0052] As a specific example, such as Figure 1 As shown, when an agent is scheduled by the coordinator, the context manager can retrieve the task state object based on the agent's corresponding role identifier to determine the task and task description corresponding to the agent. Then, combining the task description and role identifier, it determines the agent's task demand direction, i.e., the intent mentioned earlier. Subsequently, based on the demand direction, it retrieves the first knowledge graph, vector database, and relational database to obtain various initial context sub-information. Furthermore, the context manager can filter the initial context sub-information under each source based on the similarity between the initial context sub-information corresponding to each source and the demand direction, obtaining context sub-information under each source. Finally, the context sub-information under each source constitutes the context information corresponding to the agent.
[0053] For example, taking the construction of the context information corresponding to the planning agent as an example, the context manager, based on the role identifier of the planning agent, searches the research_brief field in the task state object to obtain the task description: "Analyze the cause of abnormal vibration of the hydraulic arm of electric shovel No. 3 based on the operation logs, maintenance records, and GPS positioning data of the past 3 months." Then, based on the task description and the role identifier of the planning agent, the context manager determines the demand direction of the task, namely, to plan the task for "Analyze the cause of abnormal vibration of the hydraulic arm of electric shovel No. 3 based on the operation logs, maintenance records, and GPS positioning data of the past 3 months." The context manager performs searches based on the demand direction; for example, it can retrieve maintenance manuals for "electric shovel No. 3" from the vector database, search the first knowledge graph with "electric shovel No. 3" as the starting node, and simultaneously retrieve the operation data of "electric shovel No. 3" for the past three months from the relational database.
[0054] By identifying the role identifier of the agent and determining its corresponding task and task description, and then searching various databases based on the task description, the context information of the agent can be accurately determined. Furthermore, using task state objects as shared information among multiple agents can improve the efficiency of collaborative processing between them.
[0055] Step S402: Compress the context information based on the preset number of lexical units corresponding to the agent to obtain the context summary corresponding to the agent.
[0056] Specifically, step S402 includes: Step S4021: Determine the number of target lexical units in the context information based on the text length of the context information.
[0057] Text length can be measured at the character or word level within the context information. As a concrete example, a pre-trained machine learning model can be used to determine the number of target lexical units in the context information.
[0058] Step S4022: If the number of target words is greater than the preset number of words, then the target context information is filtered from multiple context information based on the source information or text length of each context information.
[0059] The source information of contextual sub-information can characterize which database the contextual sub-information originates from. As a specific example, since vector databases store domain knowledge, which is generally long unstructured text, contextual sub-information originating from vector databases can be identified as target contextual sub-information. Of course, contextual sub-information whose text length exceeds a preset text length threshold can also be identified as target contextual sub-information.
[0060] Step S4023: Compress the target context sub-information to obtain the target sub-summary corresponding to the target context sub-information.
[0061] Compression of the target context sub-information here can be used to simplify the target context sub-information while retaining the key information in the target context sub-information, thereby reducing the number of lexical units in the target context sub-information.
[0062] In some optional implementations, step S4023 above includes: Step b1: Extract hierarchical summaries of the target context sub-information at each preset compression level.
[0063] Step b2: Obtain the number of lexical units in other contextual sub-information, and determine the difference between the preset number of lexical units and the number of lexical units in other contextual sub-information to obtain the remaining number of lexical units.
[0064] Step b3: Based on the number of remaining tokens, select at least one target level summary from each level summary, and the number of tokens in the at least one target level summary is less than or equal to the number of remaining tokens.
[0065] Step b4: Concatenate at least one target-level summary to obtain a target sub-summary.
[0066] The preset compression level here can be a pre-defined compression level. As a specific example, for a long document, there can be three preset compression levels, such as the global summary level (L1), the key point list level (L2), and the paragraph summary level (L3).
[0067] Here, we can first divide the global summary level (L1), key point list level (L2), and paragraph summary level (L3) into groups, such as L1 corresponding to one group, L2 corresponding to one group, L3 corresponding to one group, L1+L2 corresponding to one group, L1+L3 corresponding to one group, and L1+L2+L3 corresponding to one group. Then, based on the number of remaining tokens, we select a group whose total number of tokens (i.e., the number of tokens corresponding to a group) is less than or equal to the number of remaining tokens, and the hierarchical summary in this group is determined as the target hierarchical summary. Finally, we concatenate one or more target hierarchical summaries to obtain the target sub-summary.
[0068] By using the remaining number of lexical units, one or more target-level summaries can be dynamically and intelligently selected from summaries at various levels, maximizing information retention while meeting the agent's lexical budget.
[0069] Step S4024: Based on the fusion of the target sub-summary and other contextual sub-information, the contextual summary corresponding to the agent is obtained. The other contextual sub-information refers to the contextual sub-information other than the target contextual sub-information among multiple contextual sub-information.
[0070] Here, the context sub-information other than the target context sub-information is the uncompressed context sub-information. As a concrete example, the target sub-summary can be integrated with other context sub-information to obtain the context summary corresponding to the agent.
[0071] By determining the source information or text length of the context sub-information, the target context sub-information that needs to be compressed is determined, rather than directly compressing all context sub-information. This approach preserves as much information as possible, resulting in a more accurate context summary with more key information, and ultimately, more precise target context information.
[0072] Step S403: Perform structured assembly of the context summary corresponding to the agent to obtain the target context information corresponding to the agent.
[0073] Specifically, step S403 includes: Step S4031: Based on the source information of the context sub-information corresponding to the target sub-abstract, determine the summary confidence level and the first structured template corresponding to the target sub-abstract.
[0074] Here, the first structured template corresponding to the target sub-summary can be determined based on the source information of the context sub-information corresponding to the target sub-summary. For example, if the source information indicates that the context sub-information corresponding to the target sub-summary comes from a first knowledge graph, then the first structured template can be...<kg_fact> ...< / kg_fact> If the contextual sub-information corresponding to the target sub-summary, representing the source information, comes from a vector database, then the first structured template can be... <document> ...< / document> .
[0075] Here, the confidence level of the target sub-summary can be determined based on the source information of the context sub-information corresponding to the target sub-summary. For example, if the source information indicates that the context sub-information corresponding to the target sub-summary comes from the first knowledge graph, the confidence level of the target sub-summary can be 1; if the source information indicates that the context sub-information corresponding to the target sub-summary comes from the vector database, the confidence level of the target sub-summary can be 3.
[0076] Step S4032: Fill the target sub-summary into the first structured template to obtain the first structured information, and use the summary confidence as the metadata of the first structured information to obtain the first context information.
[0077] Here, summary confidence labels can be constructed based on summary confidence. For example, if the source information represents the contextual sub-information corresponding to the target sub-summary from the first knowledge graph, then the summary confidence label can be... <context source="KnowledgeGraph" trust_tier="1">Furthermore, the summary confidence label can be used as metadata for the first structured information to obtain first context information including the first structured information and metadata. Here, `context_source` represents the source information, `KnowledgeGraph` represents the first knowledge graph, and `trust_tier` represents the summary confidence.
[0078] Step S4033: Based on the source information corresponding to other context sub-information, determine the context confidence level and the second structured template corresponding to the other context sub-information. Please refer to the previous text for details on context confidence level and the second structured template; they will not be repeated here.
[0079] Step S4034: Fill the second structured template with other context sub-information to obtain the second structured information, and use the context confidence as metadata of the second structured information to obtain the second context information. The target context information includes the first context information and the second context information. Please refer to the previous text for details on the second context information, which will not be repeated here.
[0080] The summary confidence corresponding to the target sub-summary and the context confidence corresponding to other context sub-information are added to the target context information, so that the target context information includes confidence. When the agent performs reasoning based on the target context information, if there is a logical contradiction in the target context information, it can give priority to using the content with higher confidence in the target context information for reasoning, thereby obtaining a more accurate target answer.
[0081] Step S404: The agent processes the text of the question to be answered based on the target context information, and obtains and outputs the target answer corresponding to the text of the question to be answered. For details, please refer to [link to details]. Figure 3 Step S304 of the illustrated embodiment will not be described again here.
[0082] The question-answering method provided in this embodiment, for each agent's context information, determines the target context information that needs to be compressed based on the source information or text length corresponding to the context sub-information in the context information; compresses the target context information by combining the remaining number of words in the agent, obtaining a context summary including the target sub-summary and other context sub-information; finally, the corresponding confidence level is fused with the context summary to obtain the target context information. In this way, a more accurate target context information can be obtained. When the agent performs reasoning based on the target context information, if a logical contradiction occurs in the target context information, the agent can prioritize the content with higher confidence in the target context information for reasoning, thereby obtaining a more accurate target answer.
[0083] As a specific example, such as Figure 5 As shown, the context management and storage layer includes a context manager and a storage module. During task execution, the context manager can proactively prepare optimal context information for the agent. The specific process is as follows: If an agent is Figure 1 The coordinator scheduling shown in the diagram involves the selected agent in the context manager first receiving the agent's role identifier. Combining the role identifier with the task state object, the agent is retrieved to determine its corresponding task and task description. Then, based on the role identifier and task description, the agent determines the corresponding demand direction, i.e., the intent. The selected agent, based on the demand direction, initiates queries in parallel to multiple heterogeneous data sources, such as the first knowledge graph, vector database, and relational database, to obtain initial context sub-information corresponding to the first knowledge graph, the vector database, and the relational database. Finally, the retrieved initial context sub-information is fed into a re-ranking model to comprehensively score and rank the information based on the similarity between the demand direction and the initial context sub-information, selecting the highest-value information set, which is the final context information.
[0084] The compression agent receives the token budget (token_budget) allocated to its current task by the coordinator, i.e., the preset number of tokens. It then determines whether the number of target tokens in the context information exceeds the token budget. If it does, the compression agent does not simply truncate the text, but instead determines the target context information to be compressed based on the source information of the context sub-information or the text length. It extracts hierarchical summaries of the target context sub-information at each preset compression level. Finally, based on the remaining number of tokens, it intelligently and dynamically selects at least one target hierarchical summary to maximize information retention while satisfying the token budget constraint, thus obtaining a context summary that includes the target sub-summary and other context sub-information.
[0085] The assembling agent uses structured tags such as XML to encapsulate the selected and compressed context summary, and injects confidence into each piece of information during encapsulation; finally, the assembler agent outputs a well-structured target context information with confidence for the agent to use.
[0086] This embodiment provides a question-and-answer method that can be used in terminal devices. Figure 6 This is a flowchart of a question-and-answer method according to an embodiment of the present invention, such as... Figure 6 As shown, the process includes the following steps: Step S601: Obtain the context information invoked by the agent during the processing of the text of the question to be answered. For details, please refer to [link to relevant documentation]. Figure 3 Step S301 of the illustrated embodiment will not be described again here.
[0087] Step S602: Compress the context information based on the preset number of lexical units corresponding to the agent to obtain the context summary corresponding to the agent. For details, please refer to [link to details]. Figure 3 Step S302 of the illustrated embodiment will not be described again here.
[0088] Step S603: The context summary corresponding to the agent is structurally assembled to obtain the target context information corresponding to the agent. For details, please refer to [link to details]. Figure 3 Step S303 of the illustrated embodiment will not be described again here.
[0089] Step S604: The agent processes the text of the question to be answered based on the target context information to obtain and output the target answer corresponding to the text of the question to be answered.
[0090] Specifically, intelligent agents can include planning agents, execution agents, and answer-generating agents.
[0091] Specifically, step S604 includes: Step S6041: Using the planning agent, the text of the question to be answered is decomposed based on the target context information corresponding to the planning agent to obtain multiple tasks.
[0092] The coordinator can monitor the task status object in real time. If it detects that the request receiving agent writes a new research outline to the `research_brief` field, the coordinator immediately activates the planning agent to break down the task of generating the target answer corresponding to the question text into multiple tasks. Before the planning agent executes the breakdown task issued by the coordinator, the context management and storage layer proactively prepares target context information for the planning agent (the process of preparing target context information by the context management and storage layer is as described above). The planning agent then combines the target context information provided by the context management and storage layer with the question text to be answered to break down the task into multiple tasks. Finally, the planning agent writes its task execution results, i.e., the multiple tasks obtained, into the `task_queue` field of the task status object.
[0093] Following the previous example, taking the generation of the target answer for "analyzing the cause of abnormal vibration of the hydraulic arm of electric shovel No. 3 based on the operation logs, maintenance records and GPS positioning data of the past 3 months" as an example, the target context information corresponding to the planning agent can usually include macro-domain knowledge, similar historical cases and equipment structure information. Moreover, the target context information corresponding to the planning agent can help the planning agent call the Structured Cognitive Framework (SCF) to decompose the task into multiple tasks.
[0094] Step S6042: Utilize the execution agent to execute each task based on the target context information corresponding to the execution agent, and obtain the task execution results corresponding to each task.
[0095] The coordinator can monitor the task status object in real time. If a task is detected under the `task_queue` field, the coordinator immediately activates the execution agent to execute the task under the `task_queue` field in the task status object. Before the execution agent executes the task, the context management and storage layer (the process of preparing the target context information by the context management and storage layer is as described above) actively prepares the target context information for the execution agent. The execution agent then combines the target context information to execute the task, finally obtaining the task execution result. The execution agent writes its own task execution result to the `review_queue` field in the task status object.
[0096] Following the previous example, if the executing agent is scheduled to complete a specific task such as "generating a heatmap," then what the executing agent needs is no longer macro-level knowledge, but rather specific operational guidelines. Therefore, the target context information of the executing agent can be precise technical documents, application programming interface descriptions, code snippets, or specific business data architectures. This target context information allows the executing agent to know how to invoke external tools, such as code interpreters, to generate task execution results.
[0097] It should be noted that the number of executing agents can be one or more, depending on the number of tasks listed in the `task_queue` field of the task state object. Of course, if the tasks in the `task_queue` field have dependencies, the order in which the executing agents are called will depend on these dependencies.
[0098] Step S6043: The answer generation agent is used to fuse the results of multiple tasks based on the target context information corresponding to the answer generation agent, so as to obtain and output the target answer.
[0099] If the coordinator detects that all tasks under each field in the task status object have been completed, the coordinator immediately activates the answer generation agent. Before the answer generation agent executes the task, the context management and storage layer (the process of preparing the target context information by the context management and storage layer is as described above) actively prepares the target context information for the answer generation agent. Then, the answer generation agent combines the target context information with the execution results of multiple tasks generated by the execution agent to generate the target answer, and writes the identifier (ID) information corresponding to its task execution result, i.e., the target answer, into the final_report_id field of the task status object.
[0100] In some alternative implementations, the method further includes: Step c1: During the execution of the task by the agent, the task is decomposed based on the target context information corresponding to the agent to generate structured execution elements, which include the next execution elements.
[0101] Step c2: Use the agent to execute the sub-task corresponding to the next execution element in the structured execution element, and obtain the sub-task execution result.
[0102] Step c3: The agent updates the structured execution elements based on the target context information corresponding to the agent and the execution results of the subtasks, and obtains new structured execution elements.
[0103] Step c4: If the subtask corresponding to the next execution element in the new structured execution element is not the target subtask, then return to the operation of using the agent to execute the subtask corresponding to the next execution element in the structured execution element and obtain the subtask execution result.
[0104] Step c5: If the subtask corresponding to the next execution element in the new structured execution element is the target subtask, then the task execution result is determined based on the execution results of each subtask and the target subtask is executed by the agent. The target subtask representation submits the task execution result to the task state object.
[0105] The structured execution element here can be a structured JSON object. This JSON object can include a thought element, a current_situation element for task completion status, a plan element for task planning, and a next_action element for next execution. Specifically, the thought element represents the agent's free-textual thinking about the current task and state; the current_situation element represents the completion status of each subtask obtained by the agent from breaking down the task it is executing; the plan element represents an ordered, step-by-step list of action plans consisting of multiple subtasks obtained by the agent from breaking down the task it is executing; and the next_action element represents the next specific subtask to be executed based on the list of action plans.
[0106] After receiving the task and target context information provided by the context management and storage layer, the agent takes the task and target context information as input and calls the LLM to generate a JSON object conforming to the Structured Cognitive Framework (SCF) format. The agent then parses this JSON object, extracts the subtasks corresponding to the next execution elements, and executes them. This process makes the agent's decision-making process completely transparent and structured, greatly improving reliability.
[0107] For example, the planning agent generates corresponding structured execution elements based on its target context information. The reasoning elements and task completion status elements in these structured execution elements can be as shown above, while the task plan elements can be multiple tasks decomposed by the planning agent based on the text of the question to be answered. The next execution element can represent submitting each task to the task_queue field in the task status object.
[0108] For example, the executing agent generates corresponding structured execution elements based on its target context information. The reasoning elements and task completion status elements in these structured execution elements can be as shown above, while the task plan elements can be multiple sub-tasks obtained by the executing agent in decomposing the task it is executing. The next execution element can specifically represent sub-task 1 in the task plan element.
[0109] As a specific example, such as Figure 7 As shown, after receiving a task, the agent can invoke a structured cognitive framework and generate structured execution elements based on its corresponding target context information. Then, it executes the subtask corresponding to the next execution element within the structured execution element, obtaining the subtask execution result. Furthermore, the subtask execution result can be merged with the agent's target context to generate new target context information, which is then fed back into the agent as new input. The agent can continue to invoke the structured cognitive framework to output a new structured execution element based on the new target context information. At this point, the task completion status element in the new structured execution element is updated to "Subtask 1 completed" with a result of XX. The task planning element may be fine-tuned based on the subtask execution result of subtask 1; for example, if subtask 1 finds missing data, the task planning element may add a subtask to complete the data. The next execution element will automatically evolve into executing subtask 2. The above steps are repeated continuously until all subtasks corresponding to the task planning element in the new structured execution element of the last round have been completed, and the agent determines that the task objective has been achieved by the reasoning element in the new structured execution element. Then, the next execution element in the new structured execution element of the last round no longer executes the next subtask, but submits the final generated task execution result to the review_queue field in the task status object, that is, outputs the task execution result, thereby ending the current node lifecycle of the agent.
[0110] For example, the structured execution elements for the first round could be: plan: [1. Read data, 2. Plot]; next_action: Read data (id=003). The agent executes the subtask of reading data (id=003) to obtain the data stream. The structured execution elements for the second round could be: current_situation: Data stream has been obtained and contains 500 records; plan: [1. Read data (completed), 2. Plot]; next_action: Call geopandas.plot(). The structured execution elements for the third round could be: current_situation: Plot has been completed; plan: [1. Read data (completed), 2. Plot (completed)]; next_action: Submit the task execution result.
[0111] By leveraging a structured cognitive framework, the output of all agents can be procedurally verified based on a unified plan-execution approach. This transforms the internal thinking and planning processes of the agents from unpredictable black boxes into fully transparent and auditable structured logs. Furthermore, the structured execution elements allow for clear tracing of the logic behind each decision made by the agent, greatly simplifying the debugging process. This reduces the rate of invalid or erroneous tool calls during task execution by more than an order of magnitude, significantly enhancing the stability of the entire question-and-answer system and the reliability of the final results.
[0112] Structured execution elements clearly define the specific process of the agent performing tasks, preventing black-box skipping. Furthermore, subtasks are often full of variables during execution; this process allows for reflection on errors in the reasoning elements of the structured execution elements in the next round, enabling attempts to correct them in subsequent execution elements, rather than rigidly continuing with the next subtask. Additionally, when re-executing new target context information in each round, the need for hierarchical summarization of previous subtask results can be reassessed based on the remaining number of lexical units, ensuring the agent always operates within the optimal context.
[0113] In some optional implementations, each agent further includes a first decision agent and a second decision agent; before using the answer-generating agent to fuse the results of multiple task executions based on the target context information corresponding to the answer-generating agent to obtain and output the target answer, the method further includes: Step d1: The first decision agent is used to detect the task execution result based on the target context information corresponding to the first decision agent, and the result confidence corresponding to the task execution result is obtained.
[0114] Step d2: If the confidence level of the result is greater than or equal to the preset confidence threshold, then the pre-built first knowledge graph is updated based on the task execution result to obtain the second knowledge graph.
[0115] Step d3: The second decision agent is used to reason about the second knowledge graph based on the target context information corresponding to the second decision agent, and the reasoning result is obtained.
[0116] Step d4: If the reasoning result indicates that there is a first new association in the second knowledge graph, then the planning agent generates a first new task based on the first new association and updates the first new task to the task state object.
[0117] The coordinator can monitor the task status objects in real time. If a task is detected under the `review_queue` field, the coordinator immediately activates the first decision agent to execute the task under the `review_queue` field. Before the first decision agent executes the task, the context management and storage layer proactively prepares the target context information for the first decision agent. The first decision agent then combines the target context information to evaluate the task execution result and obtain the result confidence level.
[0118] When the first decision-making agent performs quality control on the task execution results generated by the executing agent, it needs standard answers or verification criteria to determine whether the task execution results of the executing agent are reliable. Therefore, the target context information of the first decision-making agent can be industry standards, historical standard parameters, and node information in the first knowledge graph related to the task execution results, so that the first decision-making agent can evaluate the task execution results from multiple dimensions based on the target context information.
[0119] It should be noted that the number of first decision agents can be one or more, which can be set according to the number of tasks under the review_queue field in the task status object.
[0120] If the confidence level of the result is greater than or equal to a preset confidence threshold, the writing agent in the context management and storage layer can generate an immutable fact-adding event based on the task execution result, such as a JSON object containing the fact subject, relation, object, and metadata, and store this fact-adding event in an append-only event log. Previously, a separate consumer process could be invoked to asynchronously replay the fact-adding event in the event log, adding the content of the fact-adding event to the first knowledge graph to obtain the second knowledge graph. Simultaneously, the newly added node information corresponding to this fact-adding event in the second knowledge graph would be written to the relevant_kg_node_ids field of the task state object.
[0121] The coordinator can monitor the task status objects in real time. If a task is detected under the `relevant_kg_node_ids` field, the coordinator immediately activates the second decision agent to execute the task under the `relevant_kg_node_ids` field. Before the second decision agent executes the task, the context management and storage layer proactively prepares the target context information for the second decision agent. The second decision agent then combines the target context information with the newly added node information in the second knowledge graph to perform reasoning and obtain the reasoning result.
[0122] The second decision-making agent is responsible for uncovering hidden connections within the second knowledge graph, thus requiring verified fragmented facts. Correspondingly, the target context information for the second decision-making agent can be existing highly reliable fact nodes in the second knowledge graph and their logical relationships. This information helps the second decision-making agent conduct exploratory queries through these evidence chains, reflect on the deep connections of known information, and propose a new task that can drive the planning of a new task based on the first new connection and update the task_queue field. Subsequently, the coordinator can activate the executing agent to execute the first new task.
[0123] It should be noted that the number of second decision agents can be one or more, which can be set according to the number of tasks under the relevant_kg_node_ids field in the task status object.
[0124] As a specific example, such as Figure 8 As shown, the executing agent generates the task execution result and submits it to the `review_queue` field in the task state object. When the coordinator detects a task under the `review_queue` field, it schedules the first decision agent to evaluate the task execution result and obtain the result confidence level. If the result confidence level is greater than or equal to a preset confidence threshold, the first decision agent sends a write permission to the writing agent in the context management and storage layer. The writing agent receives the write permission, transforms the task execution result into an immutable fact addition event and stores it in the event log, and writes the task execution result into the first knowledge graph to obtain the second knowledge graph through asynchronous playback. At the same time, it writes the new node information corresponding to the fact addition event in the second knowledge graph to the `relevant_kg_node_ids` field in the task state object. If the coordinator detects a task under the `relevant_kg_node_ids` field, it schedules the second decision agent to perform reasoning on the second knowledge graph starting from the new node information to obtain the reasoning result. If the reasoning result indicates that the second decision agent has discovered a first new relationship, it drives the planning of a first new task based on the first new relationship. If the confidence level of the result is less than the preset confidence threshold, a verification task will be generated for the task execution result.
[0125] If the confidence level of the result is greater than or equal to the preset confidence threshold, an event log is generated based on the task execution result, and the first knowledge graph is updated based on the event log to generate the second knowledge graph. This constructs a trusted memory closed loop of review before storage, avoiding the memory pollution problem of the knowledge graph, ensuring the quality and consistency of information in the second knowledge graph, and thus allowing the verified findings to be precipitated into structured long-term knowledge, laying a solid foundation for subsequent more complex reasoning tasks.
[0126] In some alternative implementations, the method further includes: Step e1: If the confidence level of the result is less than the preset confidence threshold, a verification task is generated based on the task execution result.
[0127] Step e2: Use the execution agent to perform the verification task and obtain the verification result.
[0128] Step e3: If the verification result indicates that the task execution result has passed the verification, then the first knowledge graph is updated based on the task execution result to obtain the second knowledge graph.
[0129] Step e4: If the verification result indicates that the task execution result has failed the verification, the second decision agent is used to reason about the first knowledge graph to obtain the second new relationship, and the planning agent is used to update the task corresponding to the task execution result based on the second new relationship to obtain the second new task and update the task state object with the second new task.
[0130] If the executing agent confirms through the verification task that the previously submitted task execution result is correct (i.e., the verification result indicates that the task execution result has passed verification), the task execution result can be updated to the first knowledge graph to obtain the second knowledge graph. This allows the verified task execution result to be preserved as structured long-term knowledge, laying a solid foundation for subsequent, more complex reasoning tasks. Therefore, the first knowledge graph can be updated to obtain the second knowledge graph in the manner described above. Subsequently, the second decision-making agent can reason on the second knowledge graph in the manner described above to discover the first new relationship and generate the first new task based on the first new relationship. The executing agent can then execute the first new task to obtain the corresponding task execution result.
[0131] If the executing agent confirms through the verification task that the previously submitted task execution result is incorrect, then the task execution result that failed verification is not allowed to be updated to the first knowledge graph, in order to avoid memory pollution in the first knowledge graph. Therefore, at this time, a second decision agent can be scheduled to reason based on the first knowledge graph to obtain a second new association, and update the task corresponding to the task execution result based on the second new association to obtain a second new task. The second new task is then updated in the task_queue field, and subsequent executing agents can execute the second new task to obtain the task execution result corresponding to the second new task.
[0132] In some optional implementations, the process of generating the result confidence score includes: Step f1: Perform consistency detection on the target context information and task execution result corresponding to the executing agent to obtain the first confidence level.
[0133] Step f2 involves performing a confidence test on the basis for generating the results corresponding to the task execution results to obtain the second confidence level.
[0134] Step f3 involves performing a logical correlation test between the first knowledge graph and the task execution result to obtain the third confidence level.
[0135] Step f4: The first confidence level, the second confidence level, and the third confidence level are weighted and summed to obtain the summation result, and the summation result is constrained to obtain the result confidence level.
[0136] The consistency check here is mainly used to detect whether the task execution result output by the executing agent is consistent with the target context information it has obtained, that is, to detect whether the executing agent is deluding itself or misinterpreting the target context information. For example, if the target context information of the executing agent shows "Electric shovel No. 3 is working in area A7", but the task execution result output by the executing agent is "Fault in area B", then the consistency is determined to be low.
[0137] The confidence level test performed here on the basis for generating the task execution result can be used to detect the credibility level and richness of the supporting materials behind the task execution result. For example, if the task execution result of the executing agent is generated based on a first knowledge graph with high confidence and the chain of evidence is complete, then the evidence strength of the task execution result is high.
[0138] This can be based on The sum is obtained by weighting the first confidence level, the second confidence level, and the third confidence level. Where R represents the summation result. Used to indicate the first confidence level. Used to represent the weight corresponding to the first confidence level. Used to indicate the second confidence level. Used to represent the weight corresponding to the second confidence level. Used to represent the third confidence level This is used to represent the weight corresponding to the third confidence level. And, it can be based on... The confidence level of the result is obtained by constraining the summation result, where C represents the confidence level of the result.
[0139] Based on In the constraint processing of the summation result, the maximum value between the summation result R and 0 is taken first to avoid the case where the confidence value of the result is negative, and the minimum value between R and 1 is taken to avoid the case where the confidence value of the result is greater than 1. This ensures that the confidence value of the final result is between 0 and 1.
[0140] By ensuring consistency between the target context information and the task execution results, assessing the confidence level of the basis for generating the task execution results, and evaluating the logical correlation between the first knowledge graph and the task execution results, a relatively accurate result confidence level can be obtained.
[0141] The question-answering method provided in this embodiment successfully simulates the working mode of a human expert team by setting up a clearly defined planning agent, execution agent, and answer generation agent with separated responsibilities and enabling them to cooperate in processing. This architecture, which transfers and processes complex tasks among agents with different professional capabilities, achieves parallel processing and orderly flow of tasks, solving the problems of single agents being unable to handle complex tasks and the chaotic collaboration in simple multi-agent systems.
[0142] As a specific application embodiment of the present invention, such as Figure 9 and Figure 10 As shown, taking the analysis of the root cause of abnormal vibration of the hydraulic arm of the No. 3 main electric shovel in a certain mine as an example, the specific process of the question-and-answer method of this application is introduced.
[0143] Users can input question text, such as "The hydraulic arm of electric shovel #3 has been shaking lately, please investigate what's wrong," into the request receiving agent via the input interface of the external interaction layer. The request receiving agent further clarifies the question text by interacting with the user, thereby obtaining a research outline for the question text and writing the research outline into the research_brief field of the task status object.
[0144] The coordinator monitors the task status objects. If the coordinator detects a task under the `research_brief` field, it schedules the planning agent to the current node, and the context manager prepares the target context information for the planning agent.
[0145] The specific process for obtaining target context information is as follows: The selected agent in the context manager retrieves the task state object to obtain the task and task description corresponding to the planning agent. Then, based on the role identifier and task description of the planning agent, the corresponding demand direction is determined. Based on the demand direction, context sub-information such as "historical hydraulic fault diagnosis cases" and "electric shovel equipment structural knowledge" is retrieved from the first knowledge graph, and context sub-information such as "hydraulic system maintenance manual" is retrieved from the vector database. The compression agent, based on the source information or text length of the context sub-information, filters the target context sub-information from multiple context sub-information sources and compresses the target context sub-information to obtain the target sub-summary corresponding to the target context sub-information. Finally, the target sub-summary and other uncompressed context sub-information are integrated into a context summary. The assembly agent performs structured assembly of the context summary and corresponding confidence scores to obtain the target context summary.
[0146] The planning agent invokes the structured cognitive framework to output structured execution elements, and the task plan elements in the structured execution elements may include: 1. Extracting and fusing the operation logs, maintenance records and GPS data of the No. 3 electric shovel; 2. Performing spatiotemporal correlation analysis on the fused data to generate a fault heat map; 3. Mining the correlation rules between high-incidence periods of faults and specific working conditions (such as slope and material hardness); 4. Forming preliminary attribution hypotheses and submitting the above tasks to the task_queue field of the task status object.
[0147] The coordinator monitors the task status object. If the coordinator detects a task under the `task_queue` field, it schedules the executing agent to the current node. Taking the executing agent executing task 2 as an example, the context manager first prepares the target context information for the executing agent, enabling the agent to obtain target context information including the API description of the pandas library and the geopandas spatial analysis code snippet. The executing agent calls the structured cognitive framework to output structured execution elements, and the task plan elements in the structured execution elements can include: a. reading fused data; b. mapping GPS coordinates to the mining area grid; c. counting the fault frequency in each grid; d. calling geopandas.plot to generate a heatmap. After the executing agent executes, it submits the generated task execution results, including the heatmap file path and a preliminary conclusion that "faults are mainly concentrated in the steep slope section of the A7 mining area," to the `review_queue` field of the task status object.
[0148] The coordinator monitors the task status object. If the coordinator detects a task under the `review_queue` field, it schedules the first decision agent to the current node. First, the context manager prepares the target context information for the first decision agent, enabling it to obtain target context information including the "A7 Mining Area Geological Report" and historical steep slope operation specifications. The first decision agent then calls... The output confidence level is 0.95. The first decision agent issues a write permission to the writing agent in the context manager. The writing agent generates a fact addition event such as FactAdded:{subject:"No. 3 electric shovel",relation:"hasHighFailureRateAt",object:"A7 area steep slope",confidence:0.95,type: "SpatialCorrelation"} and stores it in the event log. Subsequently, based on the fact addition event, the first knowledge graph is asynchronously updated to form the second knowledge graph, and the newly added node information of the fact addition event in the second knowledge graph, such as the ID information of the newly added node, is submitted to the relevant_kg_node_ids field of the task status object.
[0149] The coordinator monitors the task status object. If the coordinator detects a task under the `relevant_kg_node_ids` field, it schedules the second decision agent to the current node. First, the context manager prepares target context information for the second decision agent. Based on this target context information, the second decision agent performs an exploratory query on the second knowledge graph, starting with the newly added node information, obtaining associations of three highly reliable facts, such as (Electric shovel No. 3, in, steep slope A7, high failure rate), (Stiff slope A7, operating condition: climbing and lifting heavy load), and (Hydraulic oil temperature, in, climbing and lifting heavy load, rapid rise). The second decision agent invokes a structured cognitive framework, proposing a deeper new association based on these associations: "Under steep slope and heavy load conditions, is hydraulic system overheating the root cause of the decrease in oil viscosity, leading to hydraulic arm vibration?", and submits this new association to the `new_hypotheses` field of the task status object.
[0150] The coordinator monitors the task status objects. If the coordinator detects a task under the new_hypotheses field, it will schedule the agent to the current node and proceed to the next round of inference. The new research outline may be "verifying the correlation between hydraulic oil viscosity and jitter frequency".
[0151] Once the coordinator determines that all tasks in the task completion state are completed, it will schedule the answer-generating agent to the current node. The answer-generating agent will extract the fault location heatmap, key facts, and root cause hypothesis from the first knowledge graph, and generate an analysis report entitled "Attribution Analysis and Maintenance Suggestions for the No. 3 Electric Shovel Shaking Due to Hydraulic Overheating on the Steep Slope in Zone A7" which is the target answer. The ID information of the target answer will be submitted to the final_report_id field of the task completion state.
[0152] Finally, the target answer is presented to the user through the output interface of the external interaction layer.
[0153] This embodiment also provides a question-and-answer device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0154] This embodiment provides a question-and-answer device, such as... Figure 11 As shown, it includes: The first acquisition module 1101 is used to acquire the context information called by the agent during the process of processing the text of the question to be answered.
[0155] Compression module 1102 is used to compress context information based on the preset number of lexical units corresponding to the agent, so as to obtain the context summary corresponding to the agent.
[0156] Assembly module 1103 is used to perform structured assembly of the context summary corresponding to the agent to obtain the target context information corresponding to the agent.
[0157] The first reasoning module 1104 is used to process the text of the question to be answered based on the target context information using an intelligent agent, and to obtain and output the target answer corresponding to the text of the question to be answered.
[0158] In some optional implementations, the compression module 1102 is further configured to determine the number of target words in the context information based on the text length of the context information; if the number of target words is greater than the preset number of words, then select target context information from multiple context information based on the source information or text length of each context information; compress the target context information to obtain the target sub-summary corresponding to the target context information; and obtain the context summary corresponding to the agent based on the fusion of the target sub-summary and other context information, wherein the other context information is the context information other than the target context information among multiple context information.
[0159] In some optional implementations, the compression module 1102 is further configured to extract hierarchical summaries corresponding to the target context sub-information at each preset compression level; obtain the number of tokens in other context sub-information and determine the difference between the preset number of tokens and the number of tokens in other context sub-information to obtain the remaining number of tokens; based on the remaining number of tokens, select at least one target hierarchical summary from each hierarchical summary, and the number of tokens in at least one target hierarchical summary is less than or equal to the remaining number of tokens; and concatenate at least one target hierarchical summary to obtain a target sub-summary.
[0160] In some optional implementations, the assembly module 1103 is further configured to: determine the summary confidence level and the first structured template corresponding to the target sub-summary based on the source information of the context sub-information corresponding to the target sub-summary; fill the target sub-summary into the first structured template to obtain first structured information, and use the summary confidence level as metadata of the first structured information to obtain first context information; determine the context confidence level and the second structured template corresponding to other context sub-information based on the source information corresponding to other context sub-information; fill the other context sub-information into the second structured template to obtain second structured information, and use the context confidence level as metadata of the second structured information to obtain second context information, wherein the target context information includes the first context information and the second context information.
[0161] In some optional implementations, there are multiple intelligent agents. The first acquisition module 1101 is also used to retrieve the task status object based on the role identifier of the intelligent agent for each intelligent agent, so as to obtain the task corresponding to the intelligent agent. The task status object is used to store the mapping relationship between the role identifier and the task. The task is generated based on the question to be answered. The module also retrieves context sub-information from each database based on the task description corresponding to the task. The context information includes multiple context sub-information.
[0162] In some optional implementations, the first reasoning module 1104 is further configured to use a planning agent to decompose the text of the question to be answered based on the target context information corresponding to the planning agent, and obtain multiple tasks; use an execution agent to execute each task based on the target context information corresponding to the execution agent, and obtain the task execution results corresponding to each task; and use an answer generation agent to fuse the execution results of multiple tasks based on the target context information corresponding to the answer generation agent, and obtain and output the target answer.
[0163] In some alternative embodiments, the device further includes: The first generation module is used to decompose the task based on the target context information corresponding to the agent and generate structured execution elements during the execution of the task by the agent. The structured execution elements include the next execution elements.
[0164] The first execution module is used to execute the sub-task corresponding to the next execution element in the structured execution element using the intelligent agent, and obtain the execution result of the sub-task.
[0165] The second execution module is used to update the structured execution elements based on the target context information corresponding to the agent and the execution results of the subtasks, so as to obtain new structured execution elements.
[0166] The third execution module is used to return the operation of using the agent to execute the subtask corresponding to the next execution element in the new structured execution element if the subtask corresponding to the next execution element in the new structured execution element is not the target subtask, and to obtain the subtask execution result.
[0167] The fourth execution module is used to determine the task execution result based on the execution results of each subtask if the subtask corresponding to the next execution element in the new structured execution element is the target subtask, and to use the agent to execute the target subtask. The target subtask representation submits the task execution result to the task state object.
[0168] In some alternative embodiments, the intelligent agent further includes a first decision-making intelligent agent and a second decision-making intelligent agent; the device also includes: The detection module is used to detect the task execution results using the first decision agent based on the target context information corresponding to the first decision agent before fusing the results of multiple task executions based on the target context information corresponding to the first decision agent to obtain the result confidence corresponding to the task execution results.
[0169] The second generation module is used to update the pre-built first knowledge graph to obtain the second knowledge graph based on the task execution result if the confidence level of the result is greater than or equal to the preset confidence threshold.
[0170] The second reasoning module is used to reason about the second knowledge graph based on the target context information corresponding to the second decision agent, and obtain the reasoning result.
[0171] The third generation module is used to generate a first new task based on the first new relationship in the second knowledge graph if the reasoning result represents a first new relationship, and then update the task state object with the first new task.
[0172] In some alternative embodiments, the device further includes: The fourth generation module is used to generate a verification task based on the task execution result if the confidence level of the result is less than the preset confidence level threshold.
[0173] The fifth execution module is used to execute verification tasks using the execution agent and obtain verification results.
[0174] The fifth generation module is used to update the first knowledge graph to obtain the second knowledge graph if the verification result represents that the task execution result has passed the verification.
[0175] The sixth generation module is used to, if the verification result represents the task execution result failing the verification, use the second decision agent to reason about the first knowledge graph to obtain a second new association, and use the planning agent to update the task corresponding to the task execution result based on the second new association to obtain a second new task and update the second new task to the task state object.
[0176] In some optional implementations, the detection module is further configured to perform consistency detection on the target context information corresponding to the executing agent and the task execution result to obtain a first confidence level; perform confidence detection on the result generation basis corresponding to the task execution result to obtain a second confidence level; perform logical correlation detection on the first knowledge graph and the task execution result to obtain a third confidence level; perform weighted summation on the first confidence level, the second confidence level, and the third confidence level to obtain a summation result, and perform constraint processing on the summation result to obtain the result confidence level.
[0177] The question-answering device provided in this embodiment of the invention can execute the question-answering method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects for executing the method. Further functional descriptions of the various modules and units described above are the same as in the corresponding embodiments described above, and will not be repeated here.
[0178] Figure 12 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. The electronic device may be the terminal device or server described above.
[0179] The following is a detailed reference. Figure 12 The diagram illustrates a structural schematic suitable for implementing an electronic device according to embodiments of the present invention. The electronic device may include a processor (e.g., a central processing unit, graphics processor, etc.) 1201, which can perform various appropriate actions and processes based on a program stored in read-only memory (ROM) 1202 or a program loaded from memory 1208 into random access memory (RAM) 1203. The RAM 1203 also stores various programs and data required for the operation of the electronic device. The processor 1201, ROM 1202, and RAM 1203 are interconnected via a bus 1204. An input / output (I / O) interface 1205 is also connected to the bus 1204.
[0180] Typically, the following devices can be connected to I / O interface 1205: input devices 1206 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 1207 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; memory devices 1208 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1209. Communication device 1209 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 12 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown, and more or fewer devices may be implemented or have instead.
[0181] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 1209, or installed from a memory 1208, or installed from a ROM 1202. When the computer program is executed by the processor 1201, it performs the functions defined in the question-and-answer method of the embodiments of the present invention.
[0182] Figure 12 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.
[0183] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the question-and-answer method shown in the above embodiments is implemented.
[0184] A portion of this invention can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to the invention through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0185] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.< / context>
Claims
1. A question and answer method, characterized by, The method includes: Obtain the context information invoked by the agent during the processing of the text of the question to be answered; The context information is compressed based on the preset number of lexical units corresponding to the agent to obtain the context summary corresponding to the agent. The context summary corresponding to the agent is structured and assembled to obtain the target context information corresponding to the agent; The agent processes the text of the question to be answered based on the target context information to obtain and output the target answer corresponding to the text of the question to be answered.
2. The method of claim 1, wherein, The context information includes multiple context sub-information; the compression of the context information based on the preset number of lexical units corresponding to the agent to obtain the context summary corresponding to the agent includes: Based on the text length of the context information, determine the number of target lexical units in the context information; If the number of target words is greater than the preset number of words, then target context information is selected from the multiple context information based on the source information or text length of each context information. The target context sub-information is compressed to obtain the target sub-summary corresponding to the target context sub-information; Based on the fusion of the target sub-summary and other contextual sub-information, a contextual summary corresponding to the agent is obtained, wherein the other contextual sub-information refers to the contextual sub-information other than the target contextual sub-information among the plurality of contextual sub-information.
3. The method of claim 2, wherein, The step of compressing the target context sub-information to obtain the target sub-summary corresponding to the target context sub-information includes: Extract the hierarchical summary of the target context sub-information at each preset compression level; Obtain the number of lexical units in the other contextual sub-information, and determine the difference between the preset number of lexical units and the number of lexical units in the other contextual sub-information to obtain the remaining number of lexical units; Based on the number of remaining lexical units, at least one target level summary is selected from each of the level summaries, wherein the number of lexical units in the at least one target level summary is less than or equal to the number of remaining lexical units; The target sub-summary is obtained by concatenating the at least one target-level summary.
4. The method according to claim 2, characterized in that, The step of structuring and assembling the context summary corresponding to the agent to obtain the target context information corresponding to the agent includes: Based on the source information of the context sub-information corresponding to the target sub-abstract, the summary confidence and the first structured template corresponding to the target sub-abstract are determined; The target sub-summary is filled into the first structured template to obtain the first structured information, and the summary confidence is used as the metadata of the first structured information to obtain the first context information; Based on the source information corresponding to the other context sub-information, determine the context confidence level and the second structured template corresponding to the other context sub-information. The other context sub-information is filled into the second structured template to obtain the second structured information, and the context confidence is used as the metadata of the second structured information to obtain the second context information. The target context information includes the first context information and the second context information.
5. The method according to claim 1, characterized in that, There are multiple intelligent agents, and the acquisition of context information invoked by the intelligent agents during the processing of the text of the question to be answered includes: For each agent, a task status object is retrieved based on the agent's role identifier to obtain the task corresponding to the agent. The task status object is used to store the mapping relationship between the role identifier and the task. The task is generated based on the question to be answered. Based on the task description corresponding to the task, each database is searched to obtain context sub-information retrieved from each database. The context information includes multiple context sub-information.
6. The method according to claim 5, characterized in that, The intelligent agent includes a planning intelligent agent, an execution intelligent agent, and an answer generation intelligent agent; the step of using the intelligent agent to process the text of the question to be answered based on the target context information, and obtaining and outputting the target answer corresponding to the text of the question to be answered, includes: The planning agent is used to decompose the text of the question to be answered based on the target context information corresponding to the planning agent, thereby obtaining multiple tasks; The execution agent executes each task based on the target context information corresponding to the execution agent, and the task execution result corresponding to each task is obtained; The answer-generating agent is used to fuse the results of multiple task executions based on the target context information corresponding to the answer-generating agent, so as to obtain and output the target answer.
7. The method according to claim 6, characterized in that, The method further includes: During the execution of the task by the intelligent agent, the task is decomposed based on the target context information corresponding to the intelligent agent to generate structured execution elements, which include the next execution elements; The agent executes the subtask corresponding to the next execution element in the structured execution element to obtain the subtask execution result; The structured execution elements are updated using the intelligent agent based on the target context information corresponding to the intelligent agent and the execution result of the subtask, to obtain new structured execution elements; If the subtask corresponding to the next execution element in the new structured execution element is not the target subtask, then return to the operation of using the agent to execute the subtask corresponding to the next execution element in the structured execution element and obtain the subtask execution result; If the subtask corresponding to the next execution element in the new structured execution element is the target subtask, then the task execution result is determined based on the execution results of each subtask and the agent is used to execute the target subtask. The target subtask representation submits the task execution result to the task state object.
8. The method according to claim 6, characterized in that, The intelligent agent further includes a first decision-making intelligent agent and a second decision-making intelligent agent; before using the answer-generating intelligent agent to fuse the execution results of multiple tasks based on the target context information corresponding to the answer-generating intelligent agent to obtain and output the target answer, the method further includes: The first decision-making agent is used to detect the task execution result based on the target context information corresponding to the first decision-making agent, and the result confidence corresponding to the task execution result is obtained; If the confidence level of the result is greater than or equal to the preset confidence threshold, then the pre-constructed first knowledge graph is updated based on the task execution result to obtain the second knowledge graph; The second decision-making agent is used to reason about the second knowledge graph based on the target context information corresponding to the second decision-making agent, and the reasoning result is obtained. If the reasoning result indicates that there is a first new association in the second knowledge graph, then the planning agent generates a first new task based on the first new association and updates the task state object with the first new task.
9. The method according to claim 8, characterized in that, The method further includes: If the confidence level of the result is less than the preset confidence threshold, a verification task is generated based on the task execution result; The verification task is executed using the aforementioned intelligent agent to obtain the verification result; If the verification result indicates that the task execution result has passed verification, then the first knowledge graph is updated based on the task execution result to obtain the second knowledge graph; If the verification result indicates that the task execution result has failed verification, then the second decision agent is used to reason about the first knowledge graph to obtain a second new association, and the planning agent is used to update the task corresponding to the task execution result based on the second new association to obtain a second new task and update the task state object with the second new task.
10. The method according to claim 8, characterized in that, The process of generating the confidence level of the result includes: A consistency check is performed on the target context information corresponding to the executing agent and the task execution result to obtain a first confidence level; A confidence level test is performed on the basis for generating the results corresponding to the task execution results to obtain a second confidence level; Logical correlation detection is performed between the first knowledge graph and the task execution result to obtain a third confidence level; The first confidence level, the second confidence level, and the third confidence level are weighted and summed to obtain a summation result, and the summation result is constrained to obtain the result confidence level.
11. A question-and-answer device, characterized in that, The device includes: The first acquisition module is used to acquire the context information called by the agent during the process of processing the text of the question to be answered; A compression module is used to compress the context information based on a preset number of lexical units corresponding to the agent, so as to obtain a context summary corresponding to the agent. An assembly module is used to perform structured assembly of the context summary corresponding to the agent to obtain the target context information corresponding to the agent. The first reasoning module is used to process the text of the question to be answered based on the target context information using the intelligent agent, and to obtain and output the target answer corresponding to the text of the question to be answered.
12. An electronic device, characterized in that, include: A memory and a processor are communicatively connected, the memory storing computer instructions, and the processor executing the computer instructions to perform the question-and-answer method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the question-and-answer method according to any one of claims 1 to 10.