Question and answer method based on thinking chain and intelligent agent and ChatBI system

By introducing a question-and-answer method based on thinking chains and agents in business intelligence systems, the shortcomings of traditional systems in terms of reasoning and analysis capabilities and accuracy are solved, and more efficient and accurate data analysis and decision-making support are achieved.

CN120012760AInactive Publication Date: 2025-05-16TIANJIN HUIZHIXINGYUAN TECHNOLOGY CO LTD

Patent Information

Application Number
CN202510488907.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-18
Publication Date
2025-05-16
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional business intelligence systems have shortcomings in inference analysis capabilities and accuracy, especially when dealing with complex queries and dynamically adjusting query logic.

Method used

The question-answer method based on thinking chains and agents is adopted, and the question text is received input from users, and the question text is parsed and decomposed into multiple subtasks, the execution order is determined, and dynamically optimized and adjusted during the execution of subtasks to improve the efficiency and accuracy of question-answer.

Benefits of technology

It improves the accuracy and flexibility of query, enhances the understanding and execution speed of complex queries, and improves the effectiveness of data analysis and decision support.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120012760A_ABST
    Figure CN120012760A_ABST
Patent Text Reader

Abstract

The invention provides a question and answer method based on a thinking chain and an intelligent agent and a ChatBI system. The method comprises the steps that a question text input by a user is received, the intelligent agent is used for analyzing and planning the question text, a thinking chain mechanism is used for decomposing the question text into a plurality of subtasks, and the execution sequence of the subtasks is determined. The whole question and answer process is gradually disassembled into a plurality of subtasks through a thinking chain mechanism, and each subtask is sequentially executed according to the execution sequence, so that the accuracy and the flexibility of query are improved. And for the execution process of each sub-task, in response to determining that the execution of the sub-task fails, re-planning the execution sequence of the plurality of sub-tasks until the plurality of sub-tasks are executed in sequence, and obtaining a question and answer result corresponding to the question text. In the execution process of the subtasks, the agent dynamically optimizes the question and answer process by evaluating the execution results of the subtasks in real time, the limitation of static query is avoided, and the question and answer efficiency and the accuracy of question and answer results are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a question-answering method based on thought chains and intelligent agents and a ChatBI system. Background Art

[0002] Currently, the business intelligence system ChatBI (Chat Business Intelligence) is widely used in the fields of data analysis and decision support. With the development of natural language processing technology and large models, business intelligence systems are gradually becoming automated and intelligent in terms of data query, report generation, and user interaction, but there are still problems such as poor reasoning and analysis capabilities and low accuracy. Summary of the invention

[0003] In view of this, the purpose of this application is to propose a question-answering method and ChatBI system based on thought chain and intelligent agent to solve the problems of poor reasoning and analysis ability and low accuracy of traditional business intelligence systems.

[0004] Based on the above purpose, the first aspect of the present application provides a question-answering method based on thought chain and intelligent agent, which is applied to the intelligent agent in the ChatBI system, and the method includes: Receive question text entered by the user; Parsing the question text, decomposing the parsed question text into multiple subtasks using a thinking chain mechanism, and determining the execution order of each subtask; Execute each subtask in sequence according to the execution order. For the execution process of each subtask, in response to determining that the subtask has failed to execute, redetermine the execution order of multiple subtasks and / or multiple subtasks until the multiple subtasks are executed in sequence to obtain the question and answer result corresponding to the question text.

[0005] Based on the same inventive concept, the second aspect of the present application further provides a ChatBI system based on thought chain and intelligent agent, the system includes an intelligent agent, and the intelligent agent includes: The planning module is configured to receive a question text input by a user; parse the question text, decompose the parsed question text into multiple subtasks using a thought chain mechanism, and determine the execution order of each subtask; for the execution process of each subtask, in response to determining that the subtask fails to execute, re-determine the execution order of multiple subtasks and / or multiple subtasks, until the multiple subtasks are executed in sequence, and obtain the question and answer result corresponding to the question text; An execution module, configured to execute each subtask in sequence according to the execution order; A tool module, configured to select a tool and call the tool according to the task requirements of the subtask; The memory module is configured to store data generated by the agent during operation.

[0006] As can be seen from the above, the question-answering method based on thought chain and intelligent agent provided by the present application is applied to the intelligent agent in the ChatBI system, and the method includes: receiving the question text input by the user, parsing the question text, decomposing the parsed question text into multiple subtasks by using the thought chain mechanism, and determining the execution order of each subtask, which is suitable for processing a large amount of related data. The entire question-answering process is gradually disassembled into multiple subtasks through the thought chain mechanism, and each subtask is executed in sequence according to the execution order, which improves the accuracy and flexibility of the query. For the execution process of each subtask, in response to determining that the subtask execution fails, the execution order of multiple subtasks and / or multiple subtasks is re-determined until the multiple subtasks are executed in sequence, and the question-answering result corresponding to the question text is obtained. During the execution of the subtasks, the intelligent agent dynamically optimizes the execution order of multiple subtasks or multiple subtasks by evaluating the execution results of the subtasks in real time, avoiding the limitations of static queries, and improving the efficiency of question-answering and the accuracy of question-answering results. BRIEF DESCRIPTION OF THE DRAWINGS

[0007] In order to more clearly illustrate the technical solutions in the present application or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0008] Figure 1 A flowchart of a question-answering method based on a thought chain and an intelligent agent according to an embodiment of the present application; Figure 2 A schematic diagram of a process for an intelligent agent to plan and execute various subtasks according to an embodiment of the present application; Figure 3 A schematic diagram of a visualization chart of an embodiment of the present application; Figure 4 A schematic diagram of the process flow of executing each subtask in an embodiment of the present application; Figure 5 A schematic diagram of the structure of the ChatBI system based on thought chain and intelligent agent according to an embodiment of the present application; Figure 6 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0009] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0010] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be the usual meanings understood by people with ordinary skills in the field to which the present application belongs. The "first", "second" and similar words used in the embodiments of the present application do not represent any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0011] As described in the background technology, the business intelligence system still has the following shortcomings: (1) Existing business intelligence systems have obvious deficiencies in coordinating data query and analysis processes. There is a lack of close connection and coordination between the various links in problem semantic understanding, query statement generation and execution, and result analysis, which affects the overall analysis efficiency and accuracy.

[0012] (2) Traditional business intelligence systems usually use static query and analysis modes. The analysis process is usually carried out according to preset steps and rules. After the user enters the question, a query statement is generated, and the execution logic is basically fixed. If the query statement is wrong or the query result is incomplete or inaccurate, the system cannot dynamically optimize and adjust according to the feedback. The user needs to manually adjust the query conditions and execute the query again, resulting in low efficiency, lack of adaptability to dynamic changes in the process, and difficulty in adapting to complex and changing business needs.

[0013] (3) Traditional business intelligence systems mainly rely on database query technology and lack the ability to effectively reason about external knowledge, making it difficult to conduct further in-depth mining and analysis of query results.

[0014] (4) The query method of traditional business intelligence systems lacks intelligent memory capabilities and query optimization capabilities. If the query results are incomplete or do not meet expectations, the system will not automatically adjust.

[0015] In view of this, this application proposes a question-answering method based on thought chain and intelligent agent, which integrates natural language processing, knowledge graph and other technologies, combines the thought chain CoT (Chain of Thought) reasoning and agent framework, enhances the understanding of complex queries, improves the execution speed and intelligent decision-making support efficiency, so as to achieve a smoother, more efficient and intelligent data analysis and decision support process.

[0016] The embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0017] This application proposes a question-answering method based on thought chain and intelligent agent, which is applied to the intelligent agent in the ChatBI system. Figure 1 , the method comprises the following steps: Step 102: Receive question text input by the user.

[0018] Specifically, the user can enter a question text through the query interface of the client, and the question text is a natural language query statement. The natural language query statement can be about asking for information about a specific entity, requesting the association between two or more entities, or requesting the ChatBI system to generate a chart based on specific conditions, etc. Natural language query statements belong to unstructured data.

[0019] For example, the question text may be "What are the names of the top three road sections with the highest number of vehicles during the morning rush hour (7:00 to 9:00) on February 21, 2025 in District B of City A?" Step 104: parse the question text, decompose the parsed question text into multiple subtasks using a thought chain mechanism, and determine the execution order of each subtask.

[0020] Specifically, the agent can automatically parse and plan the question text, understand the intent, entities, and contextual information of the user input. Through semantic understanding, the system can capture key information, such as the type of data the user wants to query, the conditions or goals of the query, etc. Based on understanding the user's intent, the agent needs to further extract relevant entities from the question text, such as company name, time range, performance indicators, etc. These entities are key elements for constructing effective queries and generating accurate question and answer results.

[0021] After determining the user needs and clarifying the task objectives, the agent can use the thought chain mechanism to decompose the problem text into multiple subtasks, which are usually more specific, clear, and easier to solve individually. This decomposition helps to gradually get to the essence of the problem and improve the efficiency of problem solving. Thought chain refers to the decomposition of logically complex problems and forming a complete thinking process through a series of logically related thinking. Thought chain is used to improve the performance of complex reasoning tasks, such as arithmetic reasoning, common sense reasoning, and symbolic reasoning. There are logical relationships between the multiple subtasks obtained by decomposition, which are usually manifested as causal relationships, progressive relationships, etc. These logical relationships ensure the coherence and consistency of the thinking process. With the help of thought chain, the agent realizes preliminary planning and determines the reasonable execution order of multiple subtasks.

[0022] Exemplarily, the multiple subtasks executed sequentially after decomposition may include a knowledge understanding and graph alignment subtask, a query statement generation subtask, a query statement execution subtask, a query result reasoning analysis, and a result visualization subtask, etc.

[0023] Step 106: execute each subtask in sequence according to the execution order. For the execution process of each subtask, in response to determining that the subtask has failed to execute, redetermine the execution order of multiple subtasks and / or multiple subtasks until the multiple subtasks are executed in sequence to obtain the question and answer result corresponding to the question text.

[0024] Specifically, after the execution order is determined, the agent can execute each subtask in sequence according to the execution order. The agent can monitor and evaluate the execution process of each subtask in real time, including judging whether each subtask needs to call a tool, whether the tool call is successful, and whether each subtask is executed successfully, so as to dynamically optimize and adjust the entire execution process in a timely manner.

[0025] If a subtask fails to execute, for example, when executing a query statement, if the query result is found to be not as expected, the agent will dynamically adjust the query logic, adjust the query statement, re-determine the subtask, and then re-execute the query. Alternatively, if a subtask fails to execute, the agent can also re-plan the execution order of multiple subtasks. During the execution of multiple subtasks, the agent will gradually verify the reasoning logic of each step to ensure the reliability of the final result. After the execution of multiple subtasks, the question and answer results corresponding to the question text are obtained.

[0026] Based on the above steps 102 to 108, this embodiment provides a question-answering method based on a thought chain and an intelligent agent, including: receiving a question text input by a user, parsing the question text, decomposing the parsed question text into multiple subtasks using a thought chain mechanism, and determining the execution order of each subtask, which is suitable for processing a large amount of associated data. The entire question-answering process is gradually disassembled into multiple subtasks through the thought chain mechanism, and each subtask is executed in sequence according to the execution order, thereby improving the accuracy and flexibility of the query. For the execution process of each subtask, in response to determining that the subtask execution fails, the execution order of multiple subtasks and / or multiple subtasks is re-determined until the multiple subtasks are executed in sequence, and the question-answering result corresponding to the question text is obtained. During the execution of the subtasks, the intelligent agent dynamically optimizes the execution order of multiple subtasks or multiple subtasks by evaluating the execution results of the subtasks in real time, thereby avoiding the limitations of static queries and improving the efficiency of question-answering and the accuracy of question-answering results.

[0027] In some embodiments, the method further includes: in response to determining that the subtask is executed successfully, determining whether it is necessary to re-plan the execution order of the remaining unexecuted subtasks according to the execution result of the subtask, and if so, re-planning the execution order of the remaining unexecuted subtasks.

[0028] Specifically, after the subtask is successfully executed, it is necessary to determine whether new problems or problems that need further verification are found in the process. If there are new problems or problems that need further verification, the intelligent body will use the thinking chain mechanism to dynamically adjust the reasoning path, re-plan the subtasks that need to be executed, adjust the execution order of other unexecuted subtasks, and re-analyze the query results. The entire task execution process has a high degree of dynamic adjustment capabilities. During the execution process, the intelligent body continuously makes adaptive adjustments based on real-time feedback and intermediate results to ensure that the strategy can be optimized in time when problems are encountered.

[0029] The dynamic planning of the intelligent agent runs through the entire question-and-answer process. The ChatBI system can dynamically adjust the subtask planning and execution strategy based on real-time feedback and intermediate results, significantly improving the flexibility and adaptability of the system. Ensure that the execution results of each subtask provide support for subsequent subtasks, thereby improving the executable and correctness of the overall task. This dynamic planning mechanism not only avoids the computational complexity and error accumulation caused by processing the entire problem at one time, but also ensures that the execution logic of each subtask is clear and transparent, significantly improving the executable and correctness of the question-and-answer process. Through this dynamic planning and adaptive adjustment mechanism, the intelligent agent can efficiently complete complex question-and-answer query tasks, ensuring that each step of the question-and-answer query task moves towards the optimal goal, thereby significantly improving the overall performance of the system and user experience.

[0030] In some embodiments, the method further comprises: During the execution of each subtask, it is determined whether a tool needs to be called to execute the subtask. If so, the tool is selected and called. In response to determining that the tool call fails, the tool is reselected and called. Specifically, after determining the execution order of each subtask, in the process of executing each subtask, it may be necessary to call a tool according to the needs of the subtask. At this time, it is determined whether the subtask needs to call a tool. If so, the operation of selecting and calling the tool is performed. Exemplarily, when parsing the question text, a natural language processing tool can be called to parse the question text; when generating a query statement, you can choose to call a large model to generate a query statement; when performing reasoning analysis of the query results, you can choose to use a large model for intelligent analysis to provide accurate answers. If the tool selection fails, the agent can reselect and call the tool to ensure the smooth execution of the subtask. The agent can interact with the external environment when calling the tool, so that the task can be executed automatically without human intervention, improving efficiency while reducing the possibility of human error.

[0031] Figure 2 Figure 1 shows a flow chart of the agent planning and executing each subtask. Figure 2 As shown, Step 1: Receive questions input by users; Step 2: After the agent analyzes the problem, it uses the thinking chain mechanism to decompose it into multiple subtasks; Step 3, start executing each subtask one by one; Step 4: When executing each subtask, determine whether a tool needs to be called. If a tool needs to be called, proceed to step 5. If a tool does not need to be called, proceed to step 8. Step 5. Select and call the tool; Step 6: Determine whether the tool call is successful. If successful, proceed to step 7. If unsuccessful, return to step 5 to reselect and call the tool. Step 7: Get the result after calling the tool; Step 8: Determine whether the current subtask is executed successfully. If successful, proceed to step 9. If not, the agent replans the execution process of each subtask and returns to step 3. Step 9: Determine whether it is necessary to re-plan the remaining unexecuted subtasks according to the execution result of the current subtask. If necessary, re-plan them and return to step 3. If not, proceed to step 10. Step 10: Execute the next subtask; Step 11: After each subtask is completed, end the Q&A session.

[0032] In some embodiments, the decomposed multiple subtasks include a knowledge understanding and graph alignment subtask, a query statement generation subtask, a query statement execution subtask, a query result reasoning analysis subtask, and a result visualization subtask. Each subtask is executed sequentially according to the execution order, including: Calling the tool of the knowledge understanding and graph alignment subtask to verify the intent and entity information according to the pre-built knowledge graph, and determining the target intent and parameters after alignment with the knowledge graph; wherein the intent and entity information are obtained by parsing the question text; Invoke a query statement generation subtask tool to generate a structured query statement based on the target intent, the parameters, and the knowledge graph structure information; Calling a query statement execution subtask tool to execute the query statement in the graph database to obtain the query result; Invoke a tool of the query result reasoning analysis subtask to perform reasoning analysis on the query result to obtain a reasoning analysis result; A tool of the result visualization subtask is called to generate a visualization chart based on the reasoning analysis result.

[0033] Specifically, before executing each subtask, it is necessary to parse the question text entered by the user to identify intent, key entities, and contextual information. By parsing the question text, key information can be captured, such as the type of data the user wants to query, the conditions or goals of the query, etc. During specific execution, the agent can automatically parse the natural language questions raised by the user and understand the user's true intent. Based on understanding the user's intent, the agent needs to further extract relevant entities from the user's question text, such as company name, time range, performance indicators, etc. These entities are key elements for building effective queries and generating accurate results.

[0034] For example, the question text entered by the user is "What are the names of the top three road sections with the highest number of vehicles during the morning rush hour (7:00 to 9:00) on February 21, 2025 in District B of City A?" After parsing, the obtained intent and entity information parameters include: { "intent": "Query the top three road sections with the highest number of vehicles", "parameters": { "City": "City A", "District": "District B", "Date": "2025-02-21", "Time period": "7 to 9", "Indicator": "Number of cars" }}.

[0035] After determining the intent and entity information, the knowledge understanding and graph alignment subtask is executed, and the knowledge understanding and graph alignment subtool needs to be called. In some specific embodiments, the tool of the knowledge understanding and graph alignment subtask is called to verify the intent and entity information according to the pre-built knowledge graph, and determine the target intent and parameters after alignment with the knowledge graph, including: Determine whether the intent and entity information match the data in the knowledge graph. If a match is confirmed, convert the intent and entity information according to the standard fields in the knowledge graph to obtain the target intent and parameters. Specifically, the pre-built knowledge graph is used to verify the intent and entity information, which mainly includes two aspects: one is data mapping, and the other is format verification. During data mapping, the entity information is converted into standard fields in the knowledge graph. For example, the entity information "number of vehicles" is mapped to the "traffic flow" field in the knowledge graph, or it is determined whether the entity information exists (for example, check whether "Area B" is in the knowledge graph database). During format verification, format verification is used to ensure that the format of the entity information conforms to the rules of the knowledge graph, such as date format, time format (7 to 9 o'clock needs to be standardized as 07:00-09:00), and numerical units (for example, whether the traffic flow is stored in "vehicles / hour"). If it does not meet the requirements, the format needs to be converted according to the rules of the knowledge graph.

[0036] Through data mapping, it is possible to determine whether entity information is included in the knowledge graph, and through the structure of the knowledge graph, the meaning of the entity information can be further understood, and which nodes and edges in the knowledge graph the entity information corresponds to. If it is determined that there are corresponding nodes or edges in the knowledge graph, after calling the knowledge understanding and graph alignment tool, the target intent and parameters that match the knowledge graph after alignment are obtained. If it is determined that there are no corresponding nodes or edges in the knowledge graph, or the matching results are inaccurate, the tool module in the intelligent agent will also provide a feedback mechanism, such as giving corresponding clarifying questions and further interacting with the user to enable the user to correct the input parameters.

[0037] The following describes the specific definition of the knowledge understanding and graph alignment tool through a specific example. The input of the knowledge understanding and graph alignment tool is the intent and entity information obtained by parsing the question text, and the output of the knowledge understanding and graph alignment tool is the matched target intent and parameters.

[0038] { "name":"knowledge-understanding-and-alignment", "description": "Observe whether the intent and parameters entered by the user match the knowledge graph", "parameters": { "type": "object", "properties": { "intent": { "description": "User's query intent" }, "parameters": { "description": "Query parameters entered by the user" } }, "required": ["intent", "parameters"] } }.

[0039] Among them, name represents the English name of the knowledge understanding and graph alignment tool. description is a brief description of the knowledge understanding and graph alignment tool, explaining the main functions of the knowledge understanding and graph alignment tool. parameters defines the parameters required by the knowledge understanding and graph alignment tool, type is the parameter type, properties contains the specific parameter name (such as intent, description), and description is the description of the corresponding parameter.

[0040] In a specific example, the output example of the knowledge understanding and graph alignment tool can be { "intent": "Query the top three roads with the highest traffic volume", "parameters": { "Region": "A City B District", "Date": "2025-02-21", "Time period": "07:00-09:00", "Indicator": "Traffic flow" } }.

[0041] Afterwards, the query statement generation subtask is executed, and the query statement generation tool is called to generate a structured query statement based on the target intent, parameters and knowledge graph structure information. The core function of the query statement generation subtask is to convert the target intent and parameters into a structured query statement, so that the required information can be extracted and obtained in the graph database. Exemplarily, the query statement generation tool can be a large model. After training, the large model can recognize the common patterns of the graph query language (structured query statements) and can generate appropriate graph query statements based on the user's intent, specific context and parameters. For example, when processing a complex query request, the large model may need to build a complex query statement containing multiple MATCH clauses, RETURN clauses and WHERE clauses. The ChatBI system will also perform appropriate optimizations based on the complexity of the query, such as by selecting appropriate indexes, sorting and grouping operations to improve the execution efficiency of the query.

[0042] The following describes the specific definition of the query statement generation tool through a specific example. The input of the query statement generation tool is the output of the knowledge understanding and graph alignment tool and the graph definition, and the output of the query statement generation tool is the query statement.

[0043] { "name": "query-statement-generation", "description": "Generate Cypher query statements", "parameters": { "type": "object", "properties": { "intent": { "description": "Query intent after knowledge understanding and graph alignment" }, "parameters": { "description": "Query parameters after knowledge understanding and graph alignment" }, "graph_schema": { "description": "The structure definition of the knowledge graph, including entity, attribute and relationship information" } }, "required":["intent","parameters","graph_schema"] } }.

[0044] Among them, name indicates the English name of the query statement generation tool. description is a brief description of the query statement generation tool, explaining the main functions of the query statement generation tool. parameters defines the parameters required by the query statement generation tool, type is the parameter type, properties contains specific parameters (such as intent, description, graph_schema), and description is a description of the corresponding parameters.

[0045] In a specific example, part of the knowledge graph is defined as follows: { "Entity": { "Road Section": { "Attributes": ["Name", "Traffic Volume", "Area", "Date", "Time Period"] }, }, "region": { "Properties": ["Name"] } }, "relation": { "Road Section-Area": ​​"Belongs to", } } The following is an example of a query statement output by the query statement generation tool: MATCH (r: road section)-[:belongs to]->(a: area {name: "A city B district"}) WHERE r.Date = "2025-02-21" AND r.Time Period = "07:00-09:00" RETURN r.name AS road name, r.traffic volume AS traffic volume ORDER BY r.Traffic volume DESC LIMIT 3.

[0046] After the query statement is generated, the query statement execution subtask is executed, the query statement execution tool is called, the query statement is executed in the graph database, and the query result is obtained. The query statement execution tool initiates a query request to the graph database through the query statement and obtains relevant data from the graph database. The query process involves the use of graph query language, graph traversal and matching technology, graph indexing and other technologies. Graph traversal refers to accessing nodes and edges in the graph according to certain rules, and graph matching is used to find specific subgraphs in the graph. Graph structures that meet specific patterns can be retrieved by pattern matching. Graph indexing technology can help speed up the graph retrieval process. It significantly improves query efficiency by creating indexes for certain attributes in nodes, edges or graph structures. Especially when the scale of the graph database is very large, indexes can significantly reduce query time and resource consumption.

[0047] The input of the query statement execution tool is the generated query statement, and the output of the query statement execution tool is the data obtained from the graph database. The query statement execution tool then converts the obtained data into natural language as the query result.

[0048] The following is a specific example to describe the definition of the query statement execution tool: { "name": "query-statement-execution", "description": "Agent executes query statements against the graph database to obtain query results", "parameters": { "type": "object", "properties": { "query-statement": { "description": "The query to execute" } }, "required": ["query-statement"] } } Among them, name indicates the English name of the query statement execution tool. description is a brief description of the query statement execution tool, explaining the main functions of the query statement execution tool. parameters defines the parameters required by the query statement execution tool, type is the parameter type, properties contains specific parameters (such as query-statement), and description is a description of the corresponding parameters.

[0049] The following is an example of the query results output by the query statement execution tool: query_result: [ { "Road section name": "Road section C", "Traffic volume": 1500}, { "Road section name": "Road section D", "Traffic volume": 1300}, { "Road section name": "Road section E", "Traffic volume": 1100} ].

[0050] It should be noted that after obtaining the query results, the query results need to be quality evaluated to ensure the accuracy, completeness and interpretability of the query results. In some embodiments, after calling the tool for executing the query statement subtask, executing the query statement in the graph database, and obtaining the query results, it includes: performing a quality evaluation on the query results, and adjusting the query statement in response to the query result failing the quality evaluation.

[0051] Specifically, during the query process, the intelligent agent can evaluate the quality of the query results in real time, and adjust the query strategy based on the results of the quality assessment to ensure the accuracy, completeness and interpretability of the answer. For the evaluation of completeness, you can check whether the query results are missing key fields or data; for the evaluation of interpretability, you can check whether the query results are clear and whether relevant information needs to be supplemented. If the query results do not meet expectations, the intelligent agent can automatically optimize the query logic, such as adjusting the query conditions (such as expanding the time range, relaxing the screening conditions, etc.), changing the query method (such as changing from direct query to aggregate calculation), etc. The ChatBI system of this application combines the intelligent agent with the thinking chain to enable the query process to have dynamic adjustment and intelligent feedback capabilities. As a scheduling center, the intelligent agent adjusts the execution strategy in real time according to the query feedback. Multi-step reasoning is performed through the thinking chain to ensure that the query and analysis links are logical.

[0052] In some embodiments, calling the tool of the query result reasoning analysis subtask to perform reasoning analysis on the query result to obtain the reasoning analysis result includes: The large model is called to perform reasoning analysis on the query results to obtain reasoning analysis results, where the reasoning analysis results include at least one of explanation information, prediction information, statistical information, and decision evaluation information corresponding to the query results.

[0053] Specifically, after obtaining the answer to a query on the graph database, in addition to simply returning the query result, the system can provide additional explanations or background information based on the background knowledge of the big model to make the answer more comprehensive and help users understand the meaning behind the data. In addition to adding explanations and combining the reasoning ability of the big model, the system can also predict future trends or simulate possible scenarios. For example, give the future trend of a certain business indicator, or predict the results under different decisions. In addition, by learning from a large amount of data through a big model, potential patterns and rules can be extracted to support more complex decision-making tasks, such as business optimization, risk assessment, etc., enhancing the decision support capabilities. The input of the query result reasoning analysis tool is the query result, and the output is the reasoning analysis result.

[0054] The following is a specific example to describe the definition of the query result reasoning analysis tool. { "name": "inference-analysis", "description": "Agent combines data query results with big models for intelligent analysis, provides accurate answers, and makes intelligent recommendations and assists in decision making", "parameters": { "type": "object", "properties": { "query_result": { "description": "Raw data obtained from query execution" } }, "required": ["query_result"] } }.

[0055] Among them, name indicates the English name of the query result reasoning analysis tool. description is a brief description of the query result reasoning analysis tool, explaining the main functions of the query result reasoning analysis tool. parameters defines the parameters required by the query result reasoning analysis tool, type is the parameter type, properties contains specific parameters (such as query_result), and description is a description of the corresponding parameters.

[0056] The following is an example of the inference analysis results output by the query result inference analysis tool: Road C has the highest total traffic volume, reaching 1,500 vehicles, significantly higher than other roads. This suggests that Road C may be a key route connecting multiple major areas or transportation hubs. The total traffic volume of Road D and Road E is 1,300 and 1,100 vehicles respectively. Although the traffic volume of these roads is slightly lower than that of Road C, they still carry a lot of traffic pressure during the morning rush hour.

[0057] In some embodiments, the tool for calling the result visualization subtask generates a visualization chart based on the reasoning analysis result, including: Converting the inference analysis results into chart data; Converting the chart data into visualization code through a code generation macro model; The visualization code is executed to generate the visualization chart.

[0058] Specifically, when executing the result visualization subtask, the result visualization tool is called. The input of the result visualization tool is the reasoning analysis result, and the output of the result visualization tool is a visualization chart. The result visualization tool first needs to perform basic structural analysis on the reasoning analysis result, identify the type of data (such as value, category, time, etc.), and understand the relationship and trend between the data. The reasoning analysis results in text form are converted into arrays or data frames to obtain chart data.

[0059] After that, the code generation model is used to generate charts based on the chart data. The chart type can be specified by the user or the code generation model can infer the most appropriate chart type based on the structure of the data. Common charts include bar charts, line charts, pie charts, etc., which can help users better understand the trends and relationships behind the data. For example, if the data is presented as a time series, the system may choose a line chart, bar chart, or area chart. If the data contains category labels or numerical comparisons, the system may choose a bar chart, stacked chart, or pie chart. The style and type of the chart will be dynamically selected and adjusted according to the user's intention. The code generation model generates the code required for the chart based on the understanding of the data. Based on common Python visualization libraries (such as Matplotlib, Seaborn, Plotly, etc.), the model automatically generates the corresponding code.

[0060] By executing relevant codes, charts are generated to achieve visualization. The generated charts are finally presented to users through the human-computer interaction interface. By using the front-end framework, the system can display charts in real time and allow users to interact. Users can view the generated charts on the interactive interface, conduct further data analysis, or adjust query parameters to regenerate charts. This interactivity improves the user experience and makes complex data analysis tasks more intuitive and easy to operate.

[0061] The following is a specific example to describe the definition of the result visualization tool. { "name": "data-visualization", "description": "Organize final answers and support data visualization", "parameters": { "type": "object", "properties": { "analysis_result": { "description": "The final result after reasoning and analysis of the query results" }, "visualization_type": { "description": "The type of visualization (e.g. line chart, bar chart, pie chart, etc.)" } }, "required": ["analysis_result"] }.

[0062] Among them, name is the English name of the query result visualization tool. description is a brief description of the result visualization tool, explaining the main functions of the result visualization tool. parameters defines the parameters required by the result visualization tool, type is the parameter type, properties contains specific parameters (such as analysis_result, visualization_type), and description is a description of the corresponding parameters.

[0063] The chart data presented in the form of array or data frame is shown in the following example, ['Route C', 'Route D', 'Route E'] [1500, 1300, 1100].

[0064] Figure 3 The following is a schematic diagram of a visualization chart output by the query result visualization tool. The visualization chart is displayed in the form of a bar chart. The horizontal axis represents the traffic volume, and the vertical axis represents the road section name. By drawing the chart, users can intuitively see the top three road sections with the highest traffic volume, as well as the traffic volume of each road section.

[0065] Based on the execution process of the above subtasks, Figure 4A flowchart for the execution of each subtask is given. After obtaining the user's intent and entity information, the knowledge understanding and graph alignment tool is first called to determine whether the entity matches the graph node. If it does not match, the problem is clarified through multiple interactions with the user. If it matches, the target intent and parameters are output through the knowledge understanding and graph alignment tool. After that, the query statement generation tool is called to generate a query statement. The query statement execution tool is called to execute the query statement in the graph database to obtain the query result. The query result reasoning analysis tool is called to obtain the reasoning analysis result. The result visualization tool is then called to output a visual chart, and the reasoning analysis results and chart data presented in the form of an array or data frame can also be output at the same time. By combining the knowledge graph with the large model, the visual chart or data returned by this application is deeply reasoned, analyzed and summarized, helping users to understand the problem more comprehensively, discover potential opportunities or risks, and make more accurate and effective decisions.

[0066] Corresponding to the above-mentioned embodiment, the present application also provides a ChatBI system based on thought chain and intelligent agent, such as Figure 5 As shown, the system includes an intelligent agent, and the intelligent agent includes: The planning module 501 is configured to receive a question text input by a user; parse the question text, decompose the parsed question text into multiple subtasks using a thought chain mechanism, and determine the execution order of each subtask; for the execution process of each subtask, in response to determining that the subtask fails to execute, re-determine the execution order of multiple subtasks and / or multiple subtasks, until the multiple subtasks are executed in sequence, and obtain the question and answer result corresponding to the question text; An execution module 502 is configured to execute each subtask in sequence according to the execution order; A tool module 503, configured to select a tool and call the tool according to the task requirements of the subtask; The memory module 504 is configured to store data generated by the agent during operation.

[0067] Specifically, the planning module 501 is the core component of the intelligent agent, responsible for planning and dynamically adjusting the execution process of each subtask. During the execution of the subtask, the intelligent agent can adjust the task planning in real time according to the intermediate results and user feedback to ensure the efficient completion of the task and the accuracy of the results. The content of the dynamic planning of the intelligent agent includes: 1. Task acceptance and preliminary planning The planning module first receives the question text input by the user and performs preliminary analysis and planning on it. Based on the complexity of the question, the goal and the existing graph database, a preliminary task execution path is formulated to clarify the order and goals of each subtask.

[0068] 2. Step-by-step execution and real-time evaluation The planning module executes each subtask in the order in which it is executed. During the execution of each subtask, the planning module evaluates the current execution status and intermediate results in real time to determine whether external tools or resources need to be called. If a tool needs to be called, the planning module will select the appropriate tool based on the task requirements and call it.

[0069] 3. Tool calling and exception handling During the tool calling process, the planning module has powerful exception handling capabilities. If the tool calling fails, the planning module will try to call or replace other tools according to the failure reason. For example, if a tool fails due to data format mismatch, the planning module will automatically adjust the data format or select other compatible tools to ensure that the task can continue.

[0070] 4. Result analysis and dynamic adjustment After the tool is successfully called, the planning module will analyze the execution results of the subtask in detail to determine whether the current subtask is successfully executed. If it fails, the planning module will immediately start the re-planning mechanism, readjust the task path based on the current intermediate results and failure reasons, and optimize the execution strategy of subsequent subtasks.

[0071] 5. Query strategy optimization After each subtask is successfully executed, the planning module will dynamically adjust the query strategy based on the execution result of the subtask to optimize the quality of the final answer. For example, if the execution result of a subtask indicates that the current query direction is biased, the planning module will adjust the query parameters or optimize the data processing logic to ensure that subsequent subtasks can approach the target more accurately.

[0072] 6. Dynamic planning and adaptive capabilities The entire task execution process has a high degree of dynamic adjustment capabilities. The planning module continuously makes adaptive adjustments based on real-time feedback and intermediate results during the execution process to ensure that the strategy can be optimized in time when problems are encountered. Through this dynamic planning and adaptive adjustment mechanism, the planning module can efficiently complete complex tasks and ensure that the execution of each subtask is moving towards the optimal goal, thereby significantly improving the overall performance of the system and user experience.

[0073] The execution module 502 in the agent is used to execute the subtasks generated by the planning module 501, directly interact with the external environment, and complete the execution of each subtask.

[0074] The tool module 503 in the agent provides the agent with a series of tools or resources that can be used, which can help the agent complete tasks or achieve goals. Select appropriate tools and call them according to task requirements. The tools that can be called in this application include knowledge understanding and graph alignment tools, query statement generation tools, query statement execution tools, query result reasoning analysis tools, and result visualization tools.

[0075] The memory module 504 in the agent is the part that stores and retrieves information. It records the events experienced by the agent during operation, the knowledge learned, and the state of the environment. The memory module specifically includes short-term memory units (used to store the context of the current task) and long-term memory units (to store persistent knowledge, such as skills, experience, rules, etc.). The memory module 504 is not just a simple storage module, but has intelligent management functions. The memory module 504 can dynamically adjust the storage content and priority of the short-term memory unit and the long-term memory unit according to the user's interaction history and query needs, ensuring that the system can better understand the continuity and relevance of the user's intentions.

[0076] The short-term memory unit is a temporary storage area used by the agent during the execution of the current subtask, mainly used to store contextual information directly related to the current subtask. This information includes: ① User input questions: The agent needs to understand the user's intentions in real time and continuously refer to these instructions during the task execution. ② Intermediate results and execution status: At each step of the subtask execution, the current intermediate results and execution status need to be recorded for dynamic adjustment in the subsequent process. ③ Real-time data and environmental information: When interacting with the external environment, data and feedback are obtained in real time. This information is stored in the short-term memory unit for immediate decision-making and adjustment. ④ Parameters and return results of tool calls: When the agent calls an external tool, the short-term memory unit records the call parameters and returned results for analysis and utilization in the subsequent process. The characteristics of short-term memory are fast reading and writing and short storage time. The agent will dynamically update the content in the short-term memory unit according to the progress of the task to ensure the timeliness and relevance of the information.

[0077] Long-term memory units are the part of the agent that stores persistent knowledge. This knowledge remains stable throughout the life cycle of the agent and is repeatedly used in multiple tasks. The content of long-term memory units includes: various skills acquired by the agent through learning and training, as well as accumulated experience, including success stories and failure lessons. These experiences can help the agent avoid repeated mistakes in similar tasks and optimize execution strategies. Long-term memory also includes user preferences and historical interaction records.

[0078] It should be noted that the method of the embodiment of the present application can be performed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present application, and the multiple devices will interact with each other to complete the described method.

[0079] It should be noted that the above describes some embodiments of the present application. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0080] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the question-and-answer method based on the thinking chain and intelligent agent described in any of the above embodiments is implemented.

[0081] Figure 6 A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.

[0082] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0083] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.

[0084] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0085] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0086] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010 , the memory 1020 , the input / output interface 1030 , and the communication interface 1040 ).

[0087] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.

[0088] The electronic device of the above-mentioned embodiment is used to implement the corresponding question-and-answer method based on thought chain and intelligent agent in any of the aforementioned embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.

[0089] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the question-and-answer method based on the thinking chain and intelligent agent as described in any of the above embodiments.

[0090] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

[0091] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the question-answering method based on the thinking chain and intelligent agent as described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0092] Based on the same concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a computer program product, including computer program instructions. When the computer program instructions are run on a computer, the computer executes the method described in any of the above embodiments, which has the beneficial effects of the corresponding method embodiments and will not be repeated here.

[0093] A person skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.

[0094] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present application difficult to understand, the known power / ground connections to the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device may be shown in the form of a block diagram to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which the embodiments of the present application are to be implemented (that is, these details should be fully within the scope of understanding of those skilled in the art). Where specific details (e.g., circuits) are set forth to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details or with changes in these specific details. Therefore, these descriptions should be considered illustrative rather than restrictive.

[0095] Although the present application has been described in conjunction with specific embodiments of the present application, many alternatives, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the discussed embodiments.

[0096] The embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the present application. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the protection scope of the present application.

Claims

1. A question-answering method based on thought chain and intelligent agent, characterized in that: Applied to an agent in a ChatBI system, the method comprises: Receive question text entered by the user; Parsing the question text, decomposing the parsed question text into multiple subtasks using a thinking chain mechanism, and determining the execution order of each subtask; Execute each subtask in sequence according to the execution order. For the execution process of each subtask, in response to determining that the subtask has failed to execute, redetermine the execution order of multiple subtasks and / or multiple subtasks until the multiple subtasks are executed in sequence to obtain the question and answer result corresponding to the question text.

2. The method according to claim 1, characterized in that The method further comprises: In response to determining that the subtask is successfully executed, it is determined whether it is necessary to re-plan the execution order of the remaining unexecuted subtasks according to the execution result of the subtask, and if so, the execution order of the remaining unexecuted subtasks is re-planned.

3. The method according to claim 1, characterized in that: The method further comprises: During the execution of each subtask, determining whether a tool needs to be called to execute the subtask, and if so, selecting and calling the tool; In response to determining that the tool call has failed, the tool is reselected and called.

4. The method according to claim 1, characterized in that The execution order of the multiple subtasks includes the knowledge understanding and graph alignment subtask, the query statement generation subtask, the query statement execution subtask, the query result reasoning analysis subtask and the result visualization subtask; The step of executing each subtask in sequence according to the execution order includes: Calling the tool of the knowledge understanding and graph alignment subtask to verify the intent and entity information according to the pre-built knowledge graph, and determining the target intent and parameters after alignment with the knowledge graph; wherein the intent and entity information are obtained by parsing the question text; Invoke a query statement generation subtask tool to generate a structured query statement based on the target intent, the parameters, and the knowledge graph structure information; Calling a query statement execution subtask tool to execute the query statement in the graph database to obtain the query result; Invoke a tool of the query result reasoning analysis subtask to perform reasoning analysis on the query result to obtain a reasoning analysis result; A tool of the result visualization subtask is called to generate a visualization chart based on the reasoning analysis result.

5. The method according to claim 4, characterized in that After calling the tool for executing the subtask of the query statement, executing the query statement in the graph database, and obtaining the query result, the following steps are included: Performing a quality assessment on the query result, and in response to the query result failing the quality assessment, adjusting the query statement.

6. The method according to claim 4, characterized in that The verifying the intent and the entity information according to the pre-built knowledge graph to determine the target intent and parameters aligned with the knowledge graph includes: Determine whether the intent and the entity information match the data in the knowledge graph. If a match is determined, convert the intent and the entity information according to the standard fields in the knowledge graph to obtain the target intent and parameters.

7. The method according to claim 4, characterized in that The calling of the tool of the query result reasoning analysis subtask performs reasoning analysis on the query result to obtain the reasoning analysis result, including: The large model is called to perform reasoning analysis on the query result to obtain the reasoning analysis result, wherein the reasoning analysis result includes at least one of explanation information, prediction information, statistical information, and decision evaluation information corresponding to the query result.

8. The method according to claim 4, characterized in that The tool for calling the result visualization subtask generates a visualization chart based on the reasoning analysis result, including: Converting the inference analysis results into chart data; Converting the chart data into visualization code through a code generation macro model; The visualization code is executed to generate the visualization chart.

9. A ChatBI system based on thought chain and intelligent agent, characterized in that: The system includes an agent, wherein the agent includes: The planning module is configured to receive a question text input by a user; parse the question text, decompose the parsed question text into multiple subtasks using a thought chain mechanism, and determine the execution order of each subtask; for the execution process of each subtask, in response to determining that the subtask fails to execute, re-determine the execution order of multiple subtasks and / or multiple subtasks, until the multiple subtasks are executed in sequence, and obtain the question and answer result corresponding to the question text; An execution module, configured to execute each subtask in sequence according to the execution order; A tool module, configured to select a tool and call the tool according to the task requirements of the subtask; The memory module is configured to store data generated by the agent during operation.

10. The system according to claim 9, characterized in that The memory module comprises: A short-term memory unit, configured to store contextual information related to the current subtask; The long-term memory unit is configured to store experience data, user preferences and historical records generated during the operation of the agent.

Citation Information

Patent Citations

  • Large model service orchestration method and device based on task tree and storage medium

    CN118467753A

  • Global optimization method for decomposition and execution of complex data query task

    CN118689899A

  • Task scale scheduling method and device based on large model

    CN119201392A

  • Mental health question-answering system and method based on knowledge graph

    CN119311800A

Cited By

  • Implementation method, system and equipment of commercial intelligent system based on large model ReAct

    CN120372068A

  • Implementation method, system and device of business intelligence system based on large model ReAct

    CN120372068B

  • Multi-agent collaborative data query method and device

    CN120470019A

  • User query processing method and device, equipment, storage medium and program product

    CN120632169A

  • Abnormal problem checking method, checking system, computer system, storage medium and program product

    CN120821599A