Data query method and device based on task planning and storage medium

Through the data query method based on task planning, natural language query statements are parsed and query tasks are generated, which solves the problem of difficult to deal with complex query intentions in the existing technology, and achieves accurate query results and good scalability.

CN119782334AInactive Publication Date: 2025-04-08GUANGZHOU SMART SOFTWARE CO LTD

Patent Information

Application Number
CN202411800814.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-04-08
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing natural language query technology is difficult to accurately capture and process user complex query intentions, and it is impossible to accurately query and obtain query results required by users.

Method used

The data query method based on task planning is adopted to parse the natural query statements entered by the task planner, identify the query intention and generate the corresponding query task. These query tasks are input to the task executor, including the text processing model and the code executor, and generate and execute executing code to obtain the results of the query task.

Benefits of technology

It realizes accurate understanding of the user's complex query intentions, generates query tasks and execution code that meet the needs, thereby obtaining accurate query results, significantly improving the processing ability of users' complex query tasks, and having good scalability and flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782334A_ABST
    Figure CN119782334A_ABST
Patent Text Reader

Abstract

The invention relates to a data query method and device based on task planning and a storage medium, and the method comprises the steps: analyzing a natural query statement input by a user through a task planner, recognizing a query intention in the natural query statement, and further generating a query task meeting the requirements of the user. The query tasks are input to a task executor, and the task executor comprises a text processing model and a code executor. The text processing model generates corresponding execution codes according to the query task, and the code executor is responsible for running the codes to obtain a result of the query task. And finally, obtaining a final query result of the natural query statement according to a result of each query task. By means of the method, the processing capacity of the complex query task of the user can be remarkably improved, in addition, good expandability and flexibility are achieved, query requirements in different fields and scenes can be met, and convenient and efficient data query and data analysis services are provided for the user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language query technology, and in particular to a data query method, device and storage medium based on task planning. Background Art

[0002] In the field of natural language query technology, it has become a trend for users to input query statements through natural language to obtain the required data or perform data analysis. Existing conversational data query and data analysis solutions, such as NL2SQL (Natural Language to Structured Query Language), mainly focus on converting natural language questions into SQL statements, or into domain-specific languages. However, these solutions have obvious shortcomings when facing complex query tasks of users. Users' natural query statements often not only contain a single data query requirement, but may also involve multiple data analysis tasks, such as data query, data processing (aggregation, screening, sorting, etc.), visualization, data prediction, attribution analysis, etc., as well as the association or nesting between these tasks. It is difficult for related technologies to accurately capture and process these complex query intentions, and it is impossible to accurately query and obtain the query results required by users. Summary of the invention

[0003] Based on this, the purpose of this application is to provide a data query method based on task planning, which aims to accurately understand the complex query intentions in the user's natural query statements, and generate corresponding query tasks and execution codes, so as to obtain accurate query results.

[0004] The data query method based on task planning described in the embodiment of the present application includes the following steps:

[0005] Get the natural query statement entered by the user;

[0006] Inputting the natural query statement into a task planner to obtain at least one query task; wherein the task planner is used to understand the query intent of the natural query statement and output a query task that meets the query intent;

[0007] Input each of the query tasks into a task executor to obtain a task execution result corresponding to each of the query tasks; wherein the task executor includes a text processing model and a code executor; the text processing model is used to generate an execution code according to the query task, and the code executor is used to run the execution code to obtain the task execution result of the query task;

[0008] The query result of the natural query statement is obtained according to the task execution results of each of the query tasks.

[0009] An embodiment of the present application further provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed, the device where the computer-readable storage medium is located is controlled to implement a method as described in any one of the embodiments of the present application.

[0010] An embodiment of the present application also provides an electronic device, including a processor, a memory, and a computer-readable program stored in the memory, wherein the computer-readable program implements the steps of the method described in any one of the embodiments of the present application when executed by the processor.

[0011] The embodiment of the present application parses the natural query statements input by the user through the task planner, identifies the query intent therein, and then generates query tasks that meet the user's needs. These query tasks are input to the task executor, which includes a text processing model and a code executor. The text processing model generates corresponding execution codes according to the query tasks, and the code executor is responsible for running these codes to obtain the results of the query tasks. Finally, according to the results of each query task, the final query result of the natural query statement is obtained. The method of the embodiment of the present application can accurately understand the user's query intent, and generate query tasks and execution codes that meet the requirements, so as to obtain accurate query results. Through the method of the embodiment of the present application, the processing ability of complex query tasks of users can be significantly improved. In addition, the method of the embodiment of the present application also has good scalability and flexibility, can adapt to the query requirements in different fields and scenarios, and provide users with convenient and efficient data query and data analysis services.

[0012] For better understanding and implementation, the present application is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 A flowchart of a data query method based on task planning according to an embodiment of the present application;

[0014] Figure 2 A schematic diagram of steps for re-correcting a query task when the query task fails to execute in an embodiment of the present application;

[0015] Figure 3 A schematic diagram of the steps for determining the execution order of query tasks of different categories in an embodiment of the present application;

[0016] Figure 4 A schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0017] In order to make the purpose, technical solution and advantages of the present application clearer, the embodiments of the present application will be further described in detail below in conjunction with the accompanying drawings. Wherein, when the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements.

[0018] It should be clear that the implementation methods described in the embodiments described below do not represent all implementation methods consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims. Based on the embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.

[0019] The terms used in this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application are also intended to include plural forms, unless the context clearly indicates other meanings. In addition, in the description of this application, unless otherwise specified, "multiple" refers to two or more. It should also be understood that the term "and / or" used in this article refers to and includes any or all possible combinations of one or more associated listed items, for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone; the character " / " generally indicates that the objects associated before and after are in an "or" relationship.

[0020] It should be understood that, although the terms first, second, third, etc. may be used in the present application to describe various information, such information should not be limited to these terms, and these terms are only used to distinguish similar objects, and do not have to be used to describe a specific order or sequence, nor can they be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances. Depending on the context, the words "if" / "if" used in the present application can be interpreted as "at the time of" or "when" or "in response to determination".

[0021] The present application relates to the field of natural language query technology. In the field of natural language query technology, it has become a trend for users to input query statements through natural language to obtain the required data or perform data analysis. Existing conversational data query and data analysis solutions, such as NL2SQL, mainly focus on converting natural language questions into SQL statements, or into languages ​​for specific fields. However, these solutions have obvious shortcomings when facing complex query tasks of users. Users' natural query statements often not only contain a single data query requirement, but may also involve multiple data analysis tasks, such as data query, data processing (aggregation, screening, sorting, etc.), visual mapping, data prediction, attribution analysis, etc., as well as the association or nesting between these tasks. It is difficult for related technologies to accurately capture and process these complex query intentions, and it is impossible to accurately query and obtain the query results required by users.

[0022] In view of the shortcomings of the natural query statement processing solutions in the prior art when processing complex query tasks, the embodiments of the present application provide a data query method based on task planning, which aims to accurately understand the complex query intentions in the user's natural query statements, and generate corresponding query tasks and execution codes, so as to obtain accurate query results.

[0023] Please refer to Figure 1 The data query method based on task planning described in the embodiment of the present application includes the following steps:

[0024] S101: Obtaining a natural query sentence input by a user;

[0025] S102: Inputting the natural query statement into a task planner to obtain at least one query task; wherein the task planner is used to understand the query intent of the natural query statement and output a query task that meets the query intent;

[0026] S103: Input each of the query tasks into a task executor to obtain a task execution result corresponding to each of the query tasks; wherein the task executor includes a text processing model and a code executor; the text processing model is used to generate an execution code according to the query task, and the code executor is used to run the execution code to obtain the task execution result of the query task;

[0027] S104: Obtaining a query result of the natural query statement according to the task execution results of each of the query tasks.

[0028] The embodiment of the present application parses the natural query statements input by the user through the task planner, identifies the query intent therein, and then generates query tasks that meet the user's needs. These query tasks are input to the task executor, which includes a text processing model and a code executor. The text processing model generates corresponding execution codes according to the query tasks, and the code executor is responsible for running these codes to obtain the results of the query tasks. Finally, according to the results of each query task, the final query result of the natural query statement is obtained. The method of the embodiment of the present application can accurately understand the user's query intent, and generate query tasks and execution codes that meet the requirements, so as to obtain accurate query results. Through the method of the embodiment of the present application, the processing ability of complex query tasks of users can be significantly improved. In addition, the method of the embodiment of the present application also has good scalability and flexibility, can adapt to the query requirements in different fields and scenarios, and provide users with convenient and efficient data query and data analysis services.

[0029] The data query method based on task planning in the embodiment of the present application is performed by a computer device. Each step is described in detail below.

[0030] In step S101, a natural query sentence input by a user is obtained.

[0031] This step is the starting point of the entire query process. The user enters his query requirements through input devices (such as keyboards, touch screens, etc.), and the requirements are expressed in the form of natural language. For example, the user may enter the following query statement: "Please query the sales of all sales records with sales exceeding 1 million last year and the product category is electronic products, sort them from high to low, and calculate the average sales of these sales records."

[0032] For step S102, the natural query statement is input into a task planner to obtain at least one query task; wherein the task planner is used to understand the query intent of the natural query statement and output a query task that meets the query intent.

[0033] In this step, the natural query statement entered by the user is passed to the task planner. The task planner is a module built on natural language processing technology and machine learning algorithms. It is responsible for parsing and understanding the user's query intent and generating query tasks that meet the intent. These query tasks may include data query, data processing (aggregation, screening, sorting, etc.), visualization, data prediction, attribution analysis, etc., and multiple query tasks may be interrelated or nested. By analyzing the keywords, phrases, and sentence structures in the query statement, the task planner can identify the user's query needs and convert them into a series of specific query tasks.

[0034] Taking the query statement entered by the user in the above example as an example, the task planner may parse it into the following query tasks: 1. Query the sales records of electronic products with sales exceeding 1 million last year; 2. Sort the queried sales records from high to low by sales; 3. Calculate the average sales of the sorted sales records. These query tasks are output in a structured data format for subsequent processing.

[0035] In one embodiment, the task planner in step S102 includes a first text processing model and a preset first task prompt text, wherein the first task prompt text includes prompt texts of several preset query task categories; the first task prompt text is used to prompt the first text processing model to output a query task that conforms to the query intent of the natural query statement and satisfies any of the query task categories.

[0036] In this embodiment, the first text processing model is responsible for receiving the natural query sentence input by the user, parsing and understanding it. By analyzing the vocabulary, phrases, sentence structure and context information in the query sentence, the first text processing model can identify the user's query intention and convert it into a structured query task.

[0037] The first text processing model can be based on one or more pre-trained language models, such as BERT, GPT, etc. (these models have been trained on a large amount of text data and can capture the deep semantic and syntactic features of the language), and are fine-tuned to adapt to the specific tasks in this application (i.e., query intent understanding and query information generation). This usually involves further training the pre-trained language model on an annotated data set containing natural query statements and corresponding query tasks, so that it can better understand the query intent and generate accurate query tasks. Of course, the first text processing model can also be an existing large language model, as long as it has the processing capability to complete the tasks of this embodiment, it can be applied in the technical solution of this application, and this embodiment of the application is not limited to this.

[0038] The first task prompt text includes a series of prompt texts for preset query task categories, which describe various query requirements that may be raised by the user. For example, query task categories may include data query, data screening, data sorting, data analysis, etc. Each query task category has a corresponding prompt text, which is used to describe the characteristics of the category and the query operations involved. Similarly, in other embodiments, when the first text processing model is required to process other tasks, the first task prompt text can be set to prompt the first text processing model to process the corresponding tasks and prompt related processing requirements.

[0039] During the working process of the task planner, the first task prompt text is used to guide the working of the first text processing model. When the first text processing model receives the natural query sentence input by the user, it will try to match the query sentence with the preset query task category according to the prompt text in the first task prompt text. Through comparison and analysis, the first text processing model can determine which query task category the user's query intention belongs to, and generate a query task that meets the characteristics of the category accordingly.

[0040] This design provides clear guidance to the first text processing model through the preset first task prompt text, thereby reducing the difficulty and uncertainty of the model in understanding the user's query intention. At the same time, since the first task prompt text contains prompt texts of multiple query task categories, it can also support users to raise multiple different types of query requirements, thereby improving the flexibility and adaptability of the task planner.

[0041] This embodiment enables the task planner to accurately understand the user's query intention and generate query tasks that meet the user's needs. This design also makes the development and maintenance of the query system easier. Developers can easily add or delete query task categories by modifying the first task prompt text without having to retrain and adjust the first text processing model. This not only reduces development costs, but also improves the scalability and maintainability of the query system.

[0042] Please refer to Figure 2 In one embodiment, in step S102, the task planner outputs a query task sequence that conforms to the query intent of the natural query statement; the query task sequence includes at least one query task and the execution order of each query task;

[0043] The step of inputting each query task into the task executor in step S102 to obtain the task execution result corresponding to each query task includes:

[0044] Step S1021, taking the first query task in the execution order as the current query task, and executing the following task execution steps for the current query task:

[0045] Step S1022, inputting the current query task into the task executor;

[0046] Step S1023, when the current query task fails to execute in the task executor, the current query task is updated based on the natural query statement by the task planner; the updated current query task is input into the task executor again until the current query task is successfully executed in the task executor, and the task execution result of the current query task is obtained;

[0047] Step S1024, when the current query task is successfully executed in the task executor and the task execution result of the current query task is obtained, the next sequential query task of the current query task in the execution order is used as the current query task, and the task execution steps are repeated until all the query tasks are successfully executed in the task executor and the corresponding task execution results are obtained.

[0048] In this embodiment, the task planner is not only responsible for parsing natural query statements and generating corresponding query task sequences, but also clearly points out the execution order of each query task in the query task sequence, which is crucial to ensure the logic and accuracy of the query process. Specifically, the query task sequence is composed of at least one query task, each query task carries a specific query intent, and these query tasks are interconnected through a preset execution order to form an orderly task chain. Such a design enables the entire query process to be gradually advanced in a predetermined logical order, thereby ensuring the accuracy and completeness of the query results.

[0049] In step S102, the first query task in the execution order is first used as the current query task, and steps S1022 to S1024 are executed for the query task.

[0050] In step S1022, the current query task is input to the task executor for execution. In the actual execution process, the current query task may fail to execute due to various possible reasons (such as data anomalies, query condition mismatch, etc.). In order to deal with this situation, a query task update mechanism based on natural query statements is designed in step S1023. When the current query task fails to execute in the task executor, the task planner will update the current query task according to the intention and context information of the natural query statement to correct possible errors or adjust the query conditions. The updated query task will be input to the task executor for execution again, and this process will be repeated until the current query task is successfully executed in the task executor and the corresponding task execution result is obtained. When the current query task is successfully executed and the task execution result is obtained, the next sequential query task of the current query task in the execution order is used as the new current query task, and the above-mentioned task execution steps are repeated. This process will continue until all query tasks in the query task sequence are successfully executed in the task executor and the corresponding task execution results are obtained.

[0051] This design not only achieves refined management and execution of query tasks, but also greatly improves the flexibility and fault tolerance of the query process. Even if a query task encounters problems or fails during execution, it can be corrected and restored through automatic updates and iterative execution mechanisms, thus ensuring the smooth progress of the entire query process and the accuracy of the query results.

[0052] In summary, this embodiment achieves efficient, accurate and flexible processing of query tasks by introducing the design of query task sequence and execution order, as well as refined management and optimization of the query task execution process. This not only improves the automation and intelligence level of the query process, but also greatly enhances the stability and reliability of the system.

[0053] In one embodiment, after the step of obtaining the task execution result of the current query task in step S1023 until the current query task is successfully executed in the task executor, the step further includes:

[0054] Step S10231, judging whether the task execution result is correct based on the natural query statement by the task planner;

[0055] Step S10232, if the task execution result is incorrect, update the current query task based on the natural query statement through the task planner; input the updated current query task into the task executor again until the current query task is successfully executed in the task executor and the task execution result of the current query task is correct.

[0056] In this embodiment, in step S10231, after the task executor successfully executes the query task and returns the task execution result to the task planner, the task planner uses its in-depth understanding and analysis capabilities of the natural query statement to verify the returned task execution result. This verification can be based on the expected result in the natural query statement, aiming to determine whether the task execution result matches the user's query intention, that is, whether the result is correct. If the verification result shows that the task execution result is incorrect, then step S10232 will be executed. In step S10232, the task planner adjusts or updates the current query task according to the query intention of the natural query statement. This adjustment or update may include correcting errors in the query statement, adjusting query conditions or parameters, adding information prompts in the query task, etc., to ensure that the updated query task can more accurately and comprehensively reflect the user's query intention. The updated query task will be input into the task executor again for a new round of execution and verification process. This cycle will continue until the query task is successfully executed in the task executor and the returned task execution result is confirmed to be correct after verification by the task planner. Correspondingly, in step S1024, the next sequential query task of the current query task in the execution order is used as the current query task, and the task execution steps are repeated until all the query tasks are successfully executed in the task executor, the corresponding task execution results are obtained, and the task execution results are correct.

[0057] In summary, this embodiment ensures that the result returned to the user is correct by verifying the task execution result through the task planner. When the task execution result is found to be incorrect, the task planner can automatically update and adjust the query task and re-input it to the task executor for execution. By introducing the result verification and task update mechanism of the task planner, a more accurate understanding and response to the user's query intention is achieved, which improves the overall performance of the system and user experience.

[0058] Please refer to Figure 3 ,In one embodiment, the preset query task categories include data query categories, data analysis categories, and data visualization categories;

[0059] The step of inputting the natural query statement into the task planner to obtain at least one query task in step S102 includes:

[0060] Step S1025, when the query task of the natural query statement is a data query category, determining the execution order of the query task to be a first priority;

[0061] Step S1026, when the query task of the natural query statement is a data analysis category, determining the execution order of the query task to be a second priority;

[0062] Step S1027, when the query task of the natural query statement is a data visualization category, determining that the execution order of the query task is a third priority;

[0063] Step S1028: Determine the execution order of each query task according to the priority ranking of each query task.

[0064] This embodiment sets clear priority sorting rules for different types of query tasks, and determines the execution order of query tasks accordingly. Specifically, this embodiment presets three major query task categories, namely data query category, data analysis category, and data visualization category. These categories cover various needs that users may encounter when performing data analysis, from basic data query to advanced data analysis and visualization display. Among them, the data analysis category may include subcategories such as data indicator attribution analysis category, data indicator trend prediction category, and data indicator anomaly detection category.

[0065] In step S102, when a natural query statement is input into the task planner, the task planner determines the query task category to which it belongs based on the content of the query statement, and determines the priority and execution order of the query task accordingly. The specific process is as follows:

[0066] When the query task of a natural query statement is a data query, the query task is given the first priority. Data query is the basis of data analysis, and is the basis of advanced data analysis and visualization. Therefore, prioritizing data query tasks can ensure that more advanced tasks can be completed.

[0067] When the query tasks of natural query statements are data analysis categories such as data indicator attribution analysis, data indicator trend prediction, or data indicator anomaly detection, these query tasks are given the second priority. These tasks belong to the category of advanced data analysis and require in-depth processing and analysis of data, so their execution order is after the data query tasks.

[0068] When the query task of a natural query statement is in the data visualization category, the query task is given the third priority. Data visualization is the process of presenting the analysis results to the user in a graphical way. It is usually performed after the user has obtained the required basic data and analysis results, so its execution order is ranked last.

[0069] Finally, the task planner will determine the execution order of each query task based on the priority of each query task.

[0070] In summary, this embodiment ensures the orderly processing of query tasks of different categories by introducing the concept of query task categories and priority sorting, thereby improving the overall query efficiency and accuracy. At the same time, this embodiment can automatically adjust the execution order of query tasks according to the query needs of different users, providing users with more personalized, efficient and accurate data query services.

[0071] For step S103, each of the query tasks is input into the task executor to obtain the task execution results corresponding to each of the query tasks; wherein, the task executor includes a text processing model and a code executor; the text processing model is used to generate an execution code according to the query task, and the code executor is used to run the execution code to obtain the task execution results of the query task.

[0072] In this step, each query task is passed to the task executor. The task executor is a composite module that includes a text processing model and a code executor. The text processing model is responsible for generating corresponding execution codes according to the specific content of the query task. These execution codes can be SQL statements, Python scripts or codes written in other programming languages, depending on the requirements of the query task and the type of database or data platform. Similar to the first text processing model, the text processing model in this step can be fine-tuned based on one or more pre-trained language models, or it can be an existing large language model. As long as it has the processing capability to complete the tasks of this embodiment, it can be applied in the technical solution of the present application, and the embodiments of the present application are not limited to this.

[0073] For the above query tasks, the text processing model generates the corresponding execution code. Taking the above example, an SQL statement is generated to query the sales records in the database; a Python script is generated to sort the queried sales records and calculate the average sales.

[0074] The generated execution code is then passed to the code executor, which is responsible for running the code and returning the results of the query task. These results may be data tables, charts, statistics, or other forms of data output, depending on the user's task requirements.

[0075] In one embodiment, the task executor in step S103 also includes a preset task prompt text, and the task prompt text includes usage scenario information and a calling interface of each preset functional plug-in; the task prompt text is used to prompt the text processing model to understand the usage scenario corresponding to the query task, and determine the matching functional plug-in according to the usage scenario information of each functional plug-in, obtain the calling interface corresponding to the functional plug-in, and generate execution code according to the calling interface.

[0076] In this embodiment, the task prompt text records in detail the usage scenario information of each preset function plug-in and the corresponding call interface. This information is directly related to whether the task executor can accurately understand the usage scenario of the query task and select the correct function plug-in to execute the query task accordingly. Specifically, the usage scenario information in the task prompt text describes the key elements such as the query task type, input data format, and expected output results applicable to each function plug-in. This information provides a clear framework for the task executor, so that it can select the most suitable one or more from a large number of preset function plug-ins to execute the query task according to the specific requirements of the query task. At the same time, the task prompt text also contains the call interface information of each function plug-in. The call interface is a bridge for the task executor to interact with the function plug-in. It defines how the task executor calls the function plug-in, passes parameters, and receives return results. Through the call interface information, the task executor can accurately generate the execution code, thereby realizing the call and execution of the function plug-in. Similarly, in other embodiments, when the text processing model is required to process other tasks, the text processing model can be prompted to process the corresponding tasks and prompt the relevant processing requirements through the setting of the task prompt text.

[0077] In the execution process of the task executor, after receiving the query task generated by the task planner, the task executor first parses the specific content and requirements of the query task. Then, according to the preset task prompt text, the query task is compared with the usage scenario information of each functional plug-in one by one to determine the most matching functional plug-in. Once the matching functional plug-in is determined, the task executor generates the corresponding execution code according to the calling interface information provided in the task prompt text. The execution code is the instruction set for the task executor to interact with the functional plug-in. It contains all the information required to call the functional plug-in, such as the plug-in name, parameter list, calling method, etc. Finally, the task executor will execute the generated execution code (through the code executor therein) and call the corresponding functional plug-in to execute query and data analysis tasks, etc. After receiving the calling instruction, the functional plug-in will process the input data according to its own logic and algorithm and generate the expected output results. The task executor receives and processes these output results and finally completes the execution of the query task.

[0078] In summary, the task prompt text of this embodiment provides a clear and accurate guidance framework for the task executor, enabling it to more quickly understand the specific requirements and usage scenarios of the query task, and select the most appropriate functional plug-in to execute the query task accordingly. In addition, the task prompt text also greatly simplifies the execution process of the task executor, reducing the complexity and uncertainty of its query task execution. Since the task prompt text contains the usage scenario information and calling interface of the functional plug-in, the task executor can directly generate and execute the execution code without tedious search and matching work, thereby improving the execution efficiency and accuracy of the query task.

[0079] In one embodiment, the task prompt text also includes usage prompt information of the calling interface of each of the functional plug-ins; the usage prompt information is used to prompt the text processing model to understand the target parameter information of the query task when generating execution code according to the calling interface, and pass the target parameter information into the calling interface; wherein, the target parameter information includes basic fields, dimension fields, restriction conditions and analysis indicators; the target parameter information is used to instruct the corresponding functional plug-in to obtain target data according to the basic fields and the dimension fields, and analyze the target data with the analysis indicators under the restriction conditions.

[0080] Among them, the usage prompt information is a key component of the task prompt text, which elaborates on the specific usage of each functional plug-in calling interface and its related details. This information is related to whether the text processing model can accurately pass the target parameter information in the query task to the calling interface in the specified format and order, thereby generating effective execution code.

[0081] Specifically, the usage hint information not only defines the structure of the target parameter information, but also clarifies the specific meaning and usage of these parameter information in the query task.

[0082] The target parameter information includes multiple key elements such as basic fields, dimension fields, limiting conditions, and analysis indicators. Among them, basic fields are the basic data elements involved in the query task, which constitute the data basis of the query task. For example, when the query task is "analyze whether the sales in Guangzhou area in the past three months are abnormal", "sales" is the basic field. Dimension fields are used to refine and classify basic fields so as to more accurately locate and analyze target data. In the above example, "monthly" (the past three months) is the dimension field. Limiting conditions are used to filter and filter query results to ensure that the query results meet actual needs. Limiting conditions can include time range, data range, etc. In the above example, "region = Guangzhou" limits the data range to Guangzhou area. Analysis indicators are the core purpose of the query task, which indicates what kind of analysis needs to be performed on the target data. In the above example, "data anomaly" is the analysis indicator, which requires the function plug-in to analyze the sales in Guangzhou area in the past three months and give a predicted value of whether it is abnormal.

[0083] In summary, the usage prompt information not only clearly describes the meaning and purpose of these parameter information, but also guides the text processing model on how to correctly pass them into the calling interface. In this way, the functional plug-in can accurately query the target data based on the passed target parameter information, and analyze the target data with corresponding analysis indicators under limited conditions.

[0084] In summary, the usage prompt information provides a clear, detailed and specific guidance framework for the text processing model, enabling it to more accurately understand the target parameter information in the query task and correctly pass them to the calling interface in the prescribed format and order. In addition, since the usage prompt information defines in detail the various elements of the target parameter information and the relationship between them, as well as their specific meanings and uses in the query task, the text processing model can easily cope with various complex and diverse query tasks. At the same time, since the usage prompt information of the calling interface is preset in the task prompt text, it is easy to update and expand the functional plug-in without large-scale modification and adjustment of the text processing model.

[0085] In step S104, the query result of the natural query statement is obtained according to the task execution results of each of the query tasks.

[0086] In this step, the results of each query task returned by the task executor are integrated to form the final query result. This query result may be a comprehensive data table, a chart display or a text description, depending on the user's query requirements and the output format of the task executor.

[0087] For the above example, the final query result may be a data table containing sales records of electronic products with sales exceeding 1 million last year. The data table is sorted from high to low by sales and comes with the calculation result of the average sales.

[0088] In one embodiment, the step of obtaining the query result of the natural query statement according to the task execution results of each query task in step S104 includes:

[0089] Step S1041, input the task execution results of each of the query tasks into the task planner to obtain the query results of the natural query statement; wherein, the task planner processes the task execution results corresponding to each of the query tasks based on the query intent of the natural query statement to obtain the query results.

[0090] This embodiment further describes how to obtain the query results of the natural query statement based on the task execution results of each query task. Specifically, in step S1041, the task execution results of each query task obtained by the task executor are input into the task planner. These task execution results are obtained by the task executor after executing the query task sequence one by one, and may include various data, analysis results or visualization charts required by the user.

[0091] Next, the task planner further processes the task execution results corresponding to each query task based on the query intent of the natural query statement. This processing may include data integration, filtering, conversion, and result formatting. Its goal is to ensure that the query results generated in the end can accurately reflect the user's query intent and are presented in a way that is easy for the user to understand and use. For example, if the user's query intent is to understand the sales and growth rate of a product in a certain period of time, the task planner can integrate the task execution results of the two query tasks on sales and growth rate, and generate a report or chart containing these two indicators as the final query result. For another example, if the user's query intent is to find out the cause of the abnormality of a certain data indicator, the task planner can generate a report containing possible causes and corresponding explanations as the final query result based on the task execution results of the attribution analysis query task. Through such a processing process, it can be ensured that the query results finally obtained by the user are accurate, complete, and meet their query intent. At the same time, since the task planner can perform intelligent processing based on the query intent of the natural query statement, users can easily obtain the required query results without having professional data analysis skills or knowledge.

[0092] In summary, this embodiment realizes intelligent parsing and execution of natural query statements by introducing a collaborative working mechanism between a task planner and a task executor. After obtaining the task execution results of each query task, the task planner can intelligently process the results based on the user's query intent and generate query results that meet user needs and are easy to understand.

[0093] In one embodiment, after the step of inputting each query task into the task executor to obtain the task execution result corresponding to each query task in step S1041, the following steps are further included:

[0094] Step S1042, inputting the task execution results of each of the query tasks into a memory; the memory is used to obtain dialogue history information according to the task execution results, and send the dialogue history information to the task planner, so that the task planner understands the query intent of the natural query statement based on the dialogue history information.

[0095] Among them, the memory is a neural network used to store information. It can save and process large amounts of data, context information, intermediate results, and historical data. In complex data queries, dialogue systems, machine learning, or deep learning applications, the memory plays a vital role.

[0096] After step S1041, this embodiment adds step S1042, which aims to enhance the preservation and utilization of context information, intermediate results and historical data in the data query process by introducing a memory, thereby further improving the accurate understanding of the user's query intention. In step S1041, each query task is input into the task executor, and the corresponding task execution results are obtained. These results, as the specific execution output of the query task, are an important basis for subsequent processing and user feedback. Next, in step S1042, the task execution results of each query task are input into the memory. The memory plays a key role in information storage and retrieval here. It can store the task execution results of each processing of a natural query statement, and can be provided to the task planner and the code executor for access and reference when necessary. When the task planner needs to understand the query intention of a new natural query statement in the subsequent steps, it will retrieve relevant historical information from the memory. The comprehensive use of this information enables the task planner to more accurately grasp the actual needs of the user, thereby generating query results that are more in line with the user's expectations.

[0097] This embodiment introduces a memory, which can be used to save the task execution results during the execution process, and can also save the intermediate results during the task execution process, etc., to provide context prompts to the task planner. This achieves a more comprehensive and in-depth understanding of the user's query intention during the data query process. The introduction of the memory brings a more intelligent, efficient and reliable query experience to the data query system.

[0098] Please refer to Figure 4 The embodiment of the present application also provides an electronic device 301, comprising: a processor 302, a memory 303, and a computer program 304 stored in the memory 303 and executable on the processor 302, wherein the processor 302 implements the steps of the method described in any one of the embodiments of the present application when executing the computer program 304.

[0099] Among them, the processor 302 may include one or more processing cores. The processor 302 uses various interfaces and lines to connect various parts in the electronic device 301, and executes various functions and processes data of the electronic device 301 by running or executing instructions, programs, code sets or instruction sets stored in the memory 303, and calling the data in the memory 303. Optionally, the processor 302 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programble Logic Array, PLA). The processor 302 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the touch display; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 302, and it can be implemented by a single chip.

[0100] Among them, the memory 303 may include a random access memory (RAM) or a read-only memory (Read-Only Memory). Optionally, the memory 303 includes a non-transitory computer-readable storage medium. The memory 303 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 303 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch instructions, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 303 may also be optionally at least one storage device located away from the aforementioned processor 302.

[0101] The embodiment of the present application also provides a computer-readable storage medium, the computer-readable storage medium stores a computer program, and the computer program is executed by the processor to implement the steps of the method described in any one of the embodiments of the present application. That is, it can be understood by those skilled in the art that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including several instructions to make a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) perform all or part of the steps of the method described in each embodiment of the present application. The computer program may include a computer program code, and the computer program code may be in the form of source code, object code, executable file or some intermediate form, etc. The aforementioned storage medium includes: any entity or device capable of carrying a computer program code, a recording medium, a U disk, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal, and a software distribution medium, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media does not include electrical carrier signals and telecommunications signals.

[0102] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present application, and the present application is also intended to include these modifications and modifications.

Claims

1. A data query method based on task planning, characterized in that: The method comprises the following steps: Get the natural query statement entered by the user; Inputting the natural query statement into a task planner to obtain at least one query task; wherein the task planner is used to understand the query intent of the natural query statement and output a query task that meets the query intent; Input each of the query tasks into a task executor to obtain a task execution result corresponding to each of the query tasks; wherein the task executor includes a text processing model and a code executor; the text processing model is used to generate an execution code according to the query task, and the code executor is used to run the execution code to obtain the task execution result of the query task; The query result of the natural query statement is obtained according to the task execution results of each of the query tasks.

2. The data query method based on task planning according to claim 1 is characterized in that: The task planner outputs a query task sequence that conforms to the query intent of the natural query statement; the query task sequence includes at least one query task and an execution order of each of the query tasks; The step of inputting each of the query tasks into a task executor to obtain a task execution result corresponding to each of the query tasks includes: The first query task in the execution order is used as the current query task, and the following task execution steps are performed for the current query task: Input the current query task into the task executor; When the current query task fails to execute in the task executor, the current query task is updated based on the natural query statement by the task planner; the updated current query task is input into the task executor again until the current query task is successfully executed in the task executor, and the task execution result of the current query task is obtained; When the current query task is successfully executed in the task executor and the task execution result of the current query task is obtained, the next sequential query task of the current query task in the execution order is taken as the current query task, and the task execution steps are repeated until all the query tasks are successfully executed in the task executor and the corresponding task execution results are obtained.

3. The data query method based on task planning according to claim 2 is characterized in that: After the step of successfully executing the current query task in the task executor and obtaining the task execution result of the current query task, the step further includes: Determining whether the task execution result is correct based on the natural query statement by the task planner; If the task execution result is incorrect, updating the current query task based on the natural query statement through the task planner; The updated current query task is input into the task executor again until the current query task is successfully executed in the task executor and the task execution result of the current query task is correct.

4. The data query method based on task planning according to any one of claims 1 to 3, characterized in that: The task planner includes a first text processing model and a preset first task prompt text, wherein the first task prompt text includes prompt texts of several preset query task categories; the first task prompt text is used to prompt the first text processing model to output a query task that conforms to the query intent of the natural query statement and satisfies any of the query task categories.

5. The data query method based on task planning according to claim 4 is characterized in that: The preset query task categories include data query category, data analysis category and data visualization category; The step of inputting the natural query statement into a task planner to obtain at least one query task includes: When the query task of the natural query statement is a data query category, determining the execution order of the query task to be a first priority; When the query task of the natural query statement is a data analysis category, determining the execution order of the query task to be a second priority; When the query task of the natural query statement is a data visualization category, determining the execution order of the query task to be a third priority; The execution order of each query task is determined according to the priority ranking of each query task.

6. The data query method based on task planning according to claim 1 is characterized in that: The task executor also includes a preset task prompt text, which includes usage scenario information and a calling interface of each preset functional plug-in; the task prompt text is used to prompt the text processing model to understand the usage scenario corresponding to the query task, and determine the matching functional plug-in according to the usage scenario information of each functional plug-in, obtain the calling interface corresponding to the functional plug-in, and generate execution code according to the calling interface.

7. The data query method based on task planning according to claim 6 is characterized in that: The task prompt text also includes usage prompt information of the calling interface of each of the functional plug-ins; the usage prompt information is used to prompt the text processing model to understand the target parameter information of the query task when generating execution code according to the calling interface, and pass the target parameter information into the calling interface; wherein, the target parameter information includes basic fields, dimension fields, restriction conditions and analysis indicators; the target parameter information is used to instruct the corresponding functional plug-in to obtain target data according to the basic fields and the dimension fields, and analyze the target data with the analysis indicators under the restriction conditions.

8. The data query method based on task planning according to claim 1 is characterized in that: The step of obtaining the query result of the natural query statement according to the task execution results of each of the query tasks comprises: The task execution results of each of the query tasks are input into the task planner to obtain the query result of the natural query statement; wherein, the task planner processes the task execution results corresponding to each of the query tasks based on the query intent of the natural query statement to obtain the query result.

9. The data query method based on task planning according to claim 8 is characterized in that: After the step of inputting each query task into the task executor to obtain the task execution result corresponding to each query task, the step further includes: Inputting the task execution results of each of the query tasks into a memory; The memory is used to obtain dialogue history information according to the task execution result, and send the dialogue history information to the task planner, so that the task planner understands the query intent of the natural query statement based on the dialogue history information.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed, the device where the computer-readable storage medium is located is controlled to implement the method according to any one of claims 1 to 9.

11. An electronic device, characterized in that: The method comprises a processor, a memory and a computer-readable program stored in the memory, wherein the computer-readable program implements the steps of the method according to any one of claims 1 to 9 when executed by the processor.

Citation Information

Patent Citations

  • Task processing method and device, equipment and storage medium

    CN118312529A

  • Data query method and device based on text processing model

    CN118708704A

  • Intelligent SQL query generation method and system based on large language model

    CN118861081A

  • Semantic understanding method, electronic device, and storage medium

    US20230089268A1

  • Techniques for processing queries related to network security

    US20240259430A1

Cited By

  • Database question and answer assistant construction method and system and central air conditioner display terminal

    CN121456089A