Method for processing a complex query task

By using constellation data models and text processing models, the accuracy and efficiency issues of complex query tasks in existing technologies have been resolved, enabling a deep understanding of user query intent and the generation of accurate query results.

CN120045698BActive Publication Date: 2025-11-18GUANGZHOU SMART SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510084358.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-20
Publication Date
2025-11-18
Estimated Expiration
2045-01-20

AI Technical Summary

Technical Problem

Existing database query technologies struggle to accurately capture the true intent of users when faced with complex query tasks, resulting in query results that do not accurately meet user needs, especially when multiple data tables and complex calculation logic are involved.

Method used

By employing a constellation data model and a text processing model, the system obtains the user's natural query statement, determines the target query field, filters relevant data tables, and generates a composite query instruction with hierarchical dependencies. Finally, it retrieves the results that meet the user's needs from the data warehouse.

Benefits of technology

It enables accurate querying of complex query tasks, improves query accuracy and efficiency, and better understands the user's query intent to generate query results that meet the user's needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045698B_ABST
    Figure CN120045698B_ABST
Patent Text Reader

Abstract

The application relates to a processing method of a composite query task. A natural query sentence input by a user and related to the composite query task is acquired. First, a target query field matched with a query intention in a preset constellation data model is determined. Then, related data tables are filtered from the constellation data model based on the target query field. The natural query sentence, the filtered data tables and preset prompt information are input into a text processing model, and a composite query instruction with a logical level and a dependency relationship is generated through the model. Finally, a query result meeting the user demand is queried from a data warehouse according to the generated query instruction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of natural language query technology, and in particular to a method for processing complex query tasks. Background Technology

[0002] In today's rapidly developing information technology landscape, users' data query needs are becoming increasingly complex and diverse. Especially in fields like big data analytics and business intelligence, users often expect to quickly obtain precisely calculated and filtered data results using queries expressed in natural language. However, while existing database query technologies have achieved a certain degree of conversion between natural language and database query languages, they still fall short when faced with complex query tasks involving multiple data tables, various data types, and intricate computational logic.

[0003] Specifically, existing query processing technologies typically rely on keyword matching and simple semantic understanding of natural query statements to transform user input into corresponding SQL query statements. However, when faced with complex query requirements, this transformation method often fails to accurately capture the user's true query intent and generate accurate query statements, resulting in query results that do not accurately meet the user's needs. Summary of the Invention

[0004] Based on this, the purpose of this application is to provide a method for processing complex query tasks, which aims to accurately understand the complex query intent in the user's natural query statement, generate accurate query instructions, and thus obtain accurate query results.

[0005] The method for processing composite query tasks described in this application includes the following steps:

[0006] Obtain the user's input natural query statement; the query task pointed to by the natural query statement is a compound query task;

[0007] The target query field is determined from the preset constellation data model that matches the query intent of the natural query statement; the constellation data model includes a structured data table and query fields in the data table;

[0008] Based on the target query field, determine at least one target data table from the constellation data model that includes only the target query field;

[0009] The natural query statement, the target data table, and the preset first task processing text are input into the first text processing model to obtain a composite query instruction; wherein, the first task processing text is used to prompt the first text processing model to understand the query intent of the natural query statement, determine the composite query task that matches the query intent, and generate a composite query instruction based on the target data table and the composite query task; the composite query instruction includes several query instructions with hierarchical dependencies.

[0010] Based on the composite query instruction, the query results of the natural query statement are obtained from the data warehouse corresponding to the constellation data model.

[0011] This application embodiment obtains a natural query statement involving a complex query task input by the user. First, it determines the target query field in a preset constellation data model that matches the query intent. Then, based on the target query field, it filters relevant data tables from the constellation data model. On this basis, the natural query statement, the filtered data tables, and preset prompts are input into a text processing model. This model decomposes the complex query task of the natural query statement into subtasks and generates a complex query instruction with logical hierarchy and dependencies based on the user's query intent and the structure information of the data tables. Finally, based on the generated query instruction, it retrieves query results that meet the user's needs from the data warehouse. In summary, this application embodiment achieves accurate querying of users' complex query tasks, improves query accuracy and efficiency, and has broad application prospects.

[0012] To better understand and implement this application, the following detailed description is provided in conjunction with the accompanying drawings. Attached Figure Description

[0013] Figure 1 This is a flowchart illustrating the method for processing composite query tasks according to an embodiment of this application.

[0014] Figure 2 This is a schematic diagram illustrating the steps of obtaining synonyms from a synonym information database corresponding to user identity information in an embodiment of this application. Detailed Implementation

[0015] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings. Wherein, when the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements.

[0016] It should be understood that the embodiments described below do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of this application.

[0017] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application are also intended to include the plural forms unless the context clearly indicates otherwise. Furthermore, in the description of this application, unless otherwise stated, “a plurality” means two or more. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more associated listed items, for example, A and / or B, which can represent: A alone, A and B together, and B alone; the character “ / ” generally indicates that the preceding and following objects are in an “or” relationship.

[0018] It should be understood that although the terms first, second, third, etc., may be used in this application to describe various information, this information should not be limited to these terms, and these terms are only used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence, nor should they be construed as indicating or implying relative importance. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances. Depending on the context, the word "if" as used in this application can be interpreted as "when," "when," or "in response to determination."

[0019] This application relates to the field of natural language query technology. While existing database query technologies have achieved a certain degree of conversion between natural language and database query languages, they still fall short when faced with complex query tasks involving multiple data tables, various data types, and complex computational logic. Specifically, existing query processing technologies typically rely on keyword matching and simple semantic understanding of natural query statements to convert user input into corresponding SQL query statements. However, this conversion method often fails to accurately capture the user's true query intent and generate accurate query statements when dealing with complex query requirements, resulting in query results that do not accurately meet user needs. Furthermore, existing technologies lack a deep understanding of the complex relationships between data tables, making them prone to errors when handling operations involving multi-table joins and data aggregation.

[0020] To address the shortcomings of existing natural query processing schemes in handling complex query tasks, this application provides a method for processing complex query tasks, aiming to accurately understand the complex query intent in a user's natural query statement, generate accurate query instructions, and thus obtain accurate query results.

[0021] Please refer to Figure 1 The method for processing composite query tasks described in this application includes the following steps:

[0022] S101: Obtain the natural query statement input by the user; the query task pointed to by the natural query statement is a compound query task;

[0023] S102: Determine the target query field from the preset constellation data model that matches the query intent of the natural query statement; the constellation data model includes a structured data table and query fields in the data table;

[0024] S103: Based on the target query field, determine at least one target data table from the constellation data model that includes only the target query field;

[0025] S104: Input the natural query statement, the target data table, and the preset first task processing text into the first text processing model to obtain a composite query instruction; wherein, the first task processing text is used to prompt the first text processing model to understand the query intent of the natural query statement, determine the composite query task that matches the query intent, and generate a composite query instruction based on the target data table and the composite query task; the composite query instruction includes several query instructions with hierarchical dependencies.

[0026] S105: Based on the composite query instruction, retrieve the query results of the natural query statement from the data warehouse corresponding to the constellation data model.

[0027] This application embodiment obtains a natural query statement involving a complex query task input by the user. First, it determines the target query field in a preset constellation data model that matches the query intent. Then, based on the target query field, it filters relevant data tables from the constellation data model. On this basis, the natural query statement, the filtered data tables, and preset prompts are input into a text processing model. This model decomposes the complex query task of the natural query statement into subtasks and generates a complex query instruction with logical hierarchy and dependencies based on the user's query intent and the structure information of the data tables. Finally, based on the generated query instruction, it retrieves query results that meet the user's needs from the data warehouse. In summary, this application embodiment achieves accurate querying of users' complex query tasks, improves query accuracy and efficiency, and has broad application prospects.

[0028] The method for processing composite query tasks described in this application uses a computer as the execution entity. Below, the text processing model of this application embodiment will first be explained, followed by a detailed description of each step.

[0029] In this embodiment, the 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 are able to capture the deep semantic and syntactic features of language). To adapt to the specific tasks in this application, such as query intent understanding and query command generation, the model is fine-tuned. Of course, the text processing model can also be an existing large language model, as long as it has the processing capability for the specific tasks of this application, it can be applied to the technical solution of this application. This embodiment does not limit its application in this regard.

[0030] To enable a text processing model to complete a task as required, task processing text is typically provided. This task processing text requests or prompts the text processing model regarding its task requirements. This includes specific requirements and formatting instructions for the model's output, as well as task-related scenario or contextual information for the model to learn and understand the task at hand. In this embodiment, different sub-texts can be set within the task processing text to request or prompt the text processing model with corresponding task requirements, depending on the query needs. The task processing text provided to the model will also differ depending on the specific task requirements, such as a first task processing text, a second task processing text, etc.

[0031] For step S101, obtain the natural query statement input by the user; the query task pointed to by the natural query statement is a compound query task.

[0032] Complex query tasks, unlike simple single-condition query tasks, involve the combination and collaborative work of multiple sub-query tasks, which have hierarchical dependencies. Specifically, a complex query task cannot be completed by a single query operation; instead, multiple sub-query operations need to be executed sequentially or in parallel according to a certain logical order and interdependencies to ultimately meet the user's information needs. Specifically, complex query tasks generally have the following characteristics: 1. Combination of sub-query tasks: A complex query task contains two or more sub-query tasks, which together constitute a complete set of operations to achieve the final query goal. For example, in a business data analysis scenario, a user might enter a natural query like: "Find companies with annual sales exceeding 10 million and calculate the average profit growth rate of these companies over the past three years." This query task contains two sub-tasks: first, finding companies with annual sales exceeding 10 million (sub-task A); and second, calculating the average profit growth rate of companies that meet the conditions of sub-task A over the past three years (sub-task B). 2. Hierarchical dependencies: There are explicit hierarchical dependencies between the sub-query tasks, meaning that the execution of subsequent sub-tasks depends on the results of preceding sub-tasks. In the example above, the execution of subtask B depends on the result of subtask A, because only by identifying companies with annual sales exceeding 10 million can the average profit growth rate of these companies be calculated. This dependency could be data dependency or logical dependency; subsequent subtasks need to use the data or calculation results filtered by previous subtasks as input or operational basis. III. Logical Complexity: Due to the involvement of multiple subtasks and their dependencies, composite query tasks typically have high logical complexity. This requires not only an accurate understanding and handling of the individual execution logic of each subtask, but also effective management and coordination of the relationships between them to ensure the smooth completion of the entire query task. For example, in a database environment containing multiple tables and complex relationships, different subtasks may involve different tables and require complex join operations (such as multi-table joins) and data filtering operations (such as conditional filtering, grouping aggregation, etc.). Furthermore, the execution order and join methods of these operations need to be arranged according to the specific dependencies to ensure data consistency and the correctness of the query results.

[0033] In this step, the system first receives natural query statements entered by the user through the interface or other means. For example, a user might enter, "For the top 3 brands in terms of sales revenue, please query the top 3 customers in terms of sales revenue for these brands, and the percentage of these customers in each brand's sales revenue." This query statement clearly indicates the user's query requirement, namely, to obtain the top 3 customers in terms of sales revenue for the top 3 brands and their percentage in each brand's sales revenue.

[0034] For step S102, the target query field is determined from the preset constellation data model that matches the query intent of the natural query statement; the constellation data model includes a structured data table and query fields in the data table.

[0035] The constellation data model is an abstract representation used to describe the database structure. It is a data logic layer pre-built based on various data tables stored in the data warehouse. It records several data tables, the basic fields contained in each data table, and the graph relationships between the data tables. Furthermore, it may also record the binding relationships between at least some basic fields and multidimensional operation fields. In other words, the constellation data model does not record the specific business data of the fields in each data table, but only records information related to generating query statements. This information mainly includes the table names, field information, and multidimensional operation field information bound to the basic fields. In addition, the constellation data model establishes graph relationships between the various data tables, which at least include directed graph relationships.

[0036] In this context, "basic fields" generally refer to the fields in the database that record the original business data. More specifically, these basic fields are typically divided into measure fields and dimension fields. The measure fields generally refer to fields in the fact table, and the dimension fields generally refer to fields in the dimension table. The fact table and dimension table are concepts in data modeling within the data warehouse field. Currently, the main data models involved in data warehousing include the star schema, the snowflake schema (which can essentially be considered a type of star schema), and the constellation schema. In a star schema, there is a central data table and other data tables connected to it. The central data table is the fact table, while the other connected data tables are the dimension tables.

[0037] In this step, by matching keywords and phrases in the user's query, the target query fields are determined from the constellation data model that match the query intent. In this example, the target query fields might include "brand," "sales revenue," "customers," and "percentage," etc.

[0038] In one embodiment, step S102, which involves determining the target query field from a preset constellation data model that matches the query intent of the natural query statement, includes:

[0039] Step S1021: Determine the query fields associated with the natural query statement from the preset constellation data model as candidate query fields;

[0040] Step S1022: Input the natural query statement, the candidate query fields, and the preset second task processing text into the second text processing model to obtain several target query fields; wherein, the second task processing text is used to prompt the second text processing model to understand the query intent of the natural query statement and to determine the candidate query fields that match the query intent as target query fields.

[0041] In step S1021, the preset constellation data model is traversed to identify query fields that may be related to the natural query statement. These fields are called candidate query fields, and they constitute the initial set for the subsequent filtering process.

[0042] In step S1022, the natural query statement, candidate query fields, and the preset second task processing text are input into the second text processing model. This model is specifically trained to understand the intent of natural language queries and can select the field from the candidate fields that best matches the query intent. The second task processing text plays a crucial role, providing the model with additional information on how to understand the query intent. Based on this information, the model performs in-depth analysis of the natural query statement and selects the field from the candidate query fields that best matches the query intent as the target query field.

[0043] In summary, this embodiment significantly improves the accuracy and efficiency of query field determination by introducing a second text processing model and combining preliminary screening of candidate query fields with auxiliary understanding of the text processed by the second task.

[0044] In one embodiment, step S1022, the second task processing text is further used to prompt the second text processing model to output a question statement for the semantically ambiguous entity segment when the natural query statement contains semantically ambiguous entity segmentation; the second task processing text is further used to prompt the second text processing model to re-understand the query intent of the natural query statement by combining the answer information input by the user for the question statement.

[0045] The second task processing text in this embodiment adds a prompt text to guide the second text processing model on how to handle semantically ambiguous entity segments when processing natural queries. Specifically, when semantically ambiguous entity segments exist in a natural query, it usually means that certain words or phrases in the query are unclear, ambiguous, or difficult for the model to understand. These entity segments may be technical terms, names of people, place names, etc., which do not have a clear meaning or reference in the current context. The second task processing text prompts the second text processing model that, in this case, it should output a question statement regarding these semantically ambiguous entity segments. The purpose of this question statement is to ask the user for more information so that the model can more accurately understand the query intent.

[0046] Furthermore, the user's responses to the query will be provided as additional contextual information to the second text processing model. The second task will also prompt the model to reinterpret the query intent of the natural query based on these responses. This means the model will adjust or correct its previous understanding based on the user's answers, thereby providing a more accurate response to the user's query.

[0047] In summary, this embodiment enhances the ability of the second text processing model to handle complex or fuzzy queries by processing text in the second task. When natural queries contain semantically ambiguous words, the model can obtain more clues about the query intent by interacting with the user, and by combining the user's answer information, it achieves an accurate understanding of the query intent.

[0048] In one embodiment, step S1021, which involves determining the query field associated with the natural query statement from a preset constellation data model as a candidate query field, includes:

[0049] Step S10211: Perform entity segmentation and word recognition on the natural query statement to obtain several entity segments;

[0050] Step S10212: Obtain each query field of the constellation data model; calculate the semantic similarity between each query field and the natural query statement and the entity word segmentation, and determine the query fields with semantic similarity greater than a preset similarity threshold as candidate query fields.

[0051] In step S10211, entity segmentation and recognition are performed on the natural query statement. This process mainly utilizes entity recognition technology to extract entity segments from the query statement. These segments represent the core information in the query statement and are the basis for subsequent matching of query fields. Step S10212 obtains each query field from the preset constellation data model. Then, using a semantic similarity calculation algorithm, the semantic similarity of each query field with the natural query statement and with the identified entity segments is calculated. The purpose of this step is to find the query field that is most semantically close to the natural query statement or entity segments. Finally, according to a preset similarity threshold, query fields with a semantic similarity greater than the threshold are determined as candidate query fields. These fields have a high semantic matching degree with the natural query statement or entity segments, and are therefore considered as fields that may meet the user's query needs. In summary, this embodiment accurately selects query fields associated with the natural query statement as candidate query fields by introducing entity segmentation and semantic similarity calculation.

[0052] In one embodiment, step S1022, the second task processing text is further used to prompt the second text processing model to understand the query intent of the natural query statement by combining the input business knowledge;

[0053] After step S10211, which involves performing entity segmentation and recognition on the natural query statement to obtain several entity segments, the method further includes the following step:

[0054] Step S10213: Based on the natural query statement and the entity word segmentation, retrieve relevant business knowledge from the preset business knowledge base;

[0055] Step S1022, which involves inputting the natural query statement, the candidate query fields, and the preset second task processing text into the second text processing model to obtain several target query fields, includes:

[0056] Step S10221: Input the natural query statement, the candidate query fields, the business knowledge, and the preset second task processing text into the second text processing model to obtain several target query fields.

[0057] In this embodiment, the second task processing text guides the second text processing model to deeply understand the query intent of the natural query statement by combining the input business knowledge. After entity segmentation and recognition of the natural query statement in step S10211, and obtaining several entity segments, step S10213 retrieves relevant business knowledge from a preset business knowledge base based on the natural query statement and the identified entity segments. That is, it obtains business knowledge related to the natural query statement or entity segments so that the query intent can be understood more accurately in subsequent steps. Then, in step S10221, the natural query statement, candidate query fields, retrieved business knowledge, and preset second task processing text are input into the second text processing model to obtain several target query fields. The improvement in this step is that business knowledge is introduced as input, enabling the second text processing model to more comprehensively understand the query intent of the natural query statement and generate more accurate target query fields accordingly. In summary, by introducing business knowledge, the accuracy and efficiency of processing natural query statements and obtaining target query fields are improved.

[0058] In one embodiment, step S1022, the second task processing text is further used to prompt the second text processing model to understand the query intent of the natural query statement by combining the input synonym information;

[0059] After step S10211, which involves performing entity segmentation and recognition on the natural query statement to obtain several entity segments, the method further includes the following step:

[0060] Step S10214: Determine the synonym of any entity segment from the preset synonym information database; obtain synonym information based on the synonyms of each entity segment.

[0061] Step S1022, which involves inputting the natural query statement, the candidate query fields, and the preset second task processing text into the second text processing model to obtain several target query fields, includes:

[0062] Step S10222: Input the natural query statement, the candidate query fields, the synonym information, and the preset second task processing text into the second text processing model to obtain several target query fields.

[0063] This embodiment considers that when users express a standard term (i.e., a common, widely accepted term that large models can accurately understand), due to different expression habits, cultural backgrounds, professional fields, and other factors, they may use terms with the same or similar meanings but different forms. These terms may belong to specific fields or have specific meanings in certain contexts; therefore, they may not be common terms and cannot be directly and accurately understood by large models. To solve this problem, it is necessary to provide corresponding standard terms, i.e., synonyms, for these habitual terms so that large models can accurately understand users' natural query statements.

[0064] The second task processing text further guides the second text processing model to understand the query intent of the natural query statement by combining the input synonym information. Step S10214 searches for the existence of corresponding synonyms for each entity segment from the preset synonym information database. If a corresponding synonym exists for the entity segment, it is integrated into the synonym information. Step S10222 inputs the natural query statement, candidate query fields, synonym information, and the preset second task processing text into the second text processing model. In this way, the model can combine the synonym information to understand the query intent of the natural query statement more deeply and generate more accurate target query fields accordingly.

[0065] Please refer to Figure 2 In one embodiment, step S10214, which involves determining the synonym of any entity segment from a preset synonym information database, includes:

[0066] Step S102141: Obtain the user identity information of the user who inputs the natural query statement;

[0067] Step S102142: Determine the thesaurus corresponding to the user identity information;

[0068] Step S102143: Determine the synonym corresponding to any of the entity segments from the synonym information database.

[0069] In this embodiment, considering the differences in the expression habits of different types of users, different thesaurus information is set up for different types of users. Specifically, this embodiment maintains multiple thesaurus information, each optimized for different types of users or user groups. For example, one corpus may contain more professional terms, suitable for professionals; another corpus may contain more colloquial vocabulary, suitable for ordinary users.

[0070] In step S102141, user identity information can be obtained through various methods such as user login information, session context, device information, and IP address. This information may directly point to a specific user account, or it may require further analysis and matching to determine the user's identity. Step S102142, by matching the user identity information, determines which thesaurus should be used. Step S102143, within the given thesaurus, attempts to find corresponding synonyms for each entity segment in the natural query statement. This process may involve various techniques such as string matching and semantic similarity calculation.

[0071] In summary, this embodiment can determine the most suitable synonyms for entity segmentation in natural query statements from a preset synonym information library based on the user's identity information, thereby improving the accuracy of the model's understanding of the query intent of natural query statements and generating more accurate target query fields accordingly.

[0072] For step S103, based on the target query field, at least one target data table that includes only the target query field is determined from the constellation data model.

[0073] Based on the identified target query fields, this step further filters the constellation data model to select target data tables that contain these fields. For example, these target data tables may include brand sales data tables, customer information data tables, etc., ensuring that the selected data tables can cover all the information required by the user's query.

[0074] In one embodiment, the target query field includes a dimension field and a metric field; step S103, which involves determining at least one target data table from the constellation data model that includes only the target query field, includes:

[0075] Step S1031: Determine the data table containing any one or more of the metric fields in the constellation data model as the root data table;

[0076] Step S1032: Using the root data table as the root node, determine other data tables in the constellation data model that can reach the root data table according to the graph relationship, and obtain several target star data models by using each root data table as a fact table and the other data tables that can be reached by the fact table as dimension tables.

[0077] Step S1033: Remove the dimension table from the edge of the target star data model that does not include the dimension field, remove the basic fields other than the metric field from the fact table of any target star data model, and remove the basic fields other than the dimension field from the dimension table of any target star data model.

[0078] Step S1034: Obtain the target data table based on the target star-shaped data model.

[0079] In this embodiment, the target query fields include metric fields and dimension fields. First, a data table containing one or more metric fields from the constellation data model is used as the root data table. A fact table centered on the root data table, and other data tables accessible from the fact table, are used as dimension tables to determine several target constellation data models. Dimension tables irrelevant to the query and basic fields (metric fields or dimension fields) irrelevant to the query are removed from each target constellation data model, resulting in a final target constellation data model that only includes the fact table, dimension tables, and basic fields relevant to the query. Through the method of this embodiment, the pre-modeled constellation data model is tailored according to the target query fields. The target data table is determined based on the minimum usable constellation data model obtained from the tailoring, avoiding queries on other irrelevant data tables and fields, reducing the complexity of the first text processing model's understanding, and making the generation of query instructions more efficient and accurate.

[0080] For step S104, the natural query statement, the target data table, and the preset first task processing text are input into the first text processing model to obtain a composite query instruction; wherein, the first task processing text is used to prompt the first text processing model to understand the query intent of the natural query statement, determine the composite query task that matches the query intent, and generate a composite query instruction based on the target data table and the composite query task; the composite query instruction includes several query instructions with hierarchical dependencies.

[0081] In this step, the natural query statement, the target data table, and the pre-defined first task processing text are input into the first text processing model. The first text processing model understands and parses the natural query statement and generates a compound query instruction that matches the user's query intent based on the prompts in the task processing text. The task processing text contains pre-defined prompts or instructions to guide the model in understanding the hierarchical structure and logical relationships of the query. The compound query instruction consists of multiple query instructions with hierarchical dependencies. In this example, the compound query instruction may include two levels of queries: first, querying the top three brands by sales volume; then, querying the top three customers by sales volume within those brands; and calculating the percentage of each customer's sales volume in each brand's total sales.

[0082] In one embodiment, step S104, the first task processing text includes task decomposition prompt text; the task decomposition prompt text is used to prompt the first text processing model to decompose the natural query statement into several sub-query statements with hierarchical dependencies based on the semantic structure features of the natural query statement and preset semantic structure splitting rules; to understand the sub-query task corresponding to each sub-query statement from bottom to top according to the hierarchical dependencies, and to generate sub-query instructions according to the sub-query tasks; and to obtain a composite query instruction based on the sub-query instructions of each sub-query task.

[0083] The semantic structure decomposition rules are used to analyze and process natural language text, breaking it down into units with clearly defined semantic components and structures. Specifically, these rules involve multiple aspects of natural language processing, including syntactic analysis, semantic role labeling, entity recognition, and relation extraction. This can be achieved by fine-tuning existing pre-trained models (such as BERT and GPT). In other words, in this embodiment, the semantic structure decomposition rules can be integrated into the pre-trained model by training it with labeled semantic units. This pre-trained model, once trained, becomes the first text processing model.

[0084] In this embodiment, the task decomposition prompt text provides clear guidance to the first text processing model, enabling it to decompose the original natural query statement into multiple sub-queries with hierarchical dependencies based on the semantic structure features of the natural query statement and the preset semantic structure decomposition rules. This process is similar to breaking down a large problem into multiple smaller problems, each of which (i.e., sub-queries) is more specific and easier to process. For example, for the query "Please query the per capita income of the top five most populous cities", it can be decomposed into "Query the top five most populous cities" and "Query the per capita income of the top five most populous cities".

[0085] After the subquery is decomposed, the model understands the subquery task corresponding to each subquery statement from bottom to top, based on the hierarchical dependencies between these subquery statements. This approach, from concrete to abstract and from partial to global, helps the model more accurately grasp the user's query intent and generate corresponding subquery instructions. Subsequently, the model further integrates these instructions generated from each subquery task to form a complete composite query instruction. This composite query instruction not only contains all the information from the user's original query but also improves the accuracy and efficiency of the query through task decomposition and the generation of subquery instructions.

[0086] In summary, by introducing task decomposition prompts in this embodiment, and through understanding task decomposition and hierarchical dependencies, the model can more accurately grasp the user's query needs and generate query instructions that better match the user's intent. This not only improves query accuracy but also significantly shortens query response time, enhancing the user experience.

[0087] In one embodiment, step S104, the first task processing text is further used to prompt the first text processing model to understand the query intent of the natural query statement by combining the input query semantic enhancement information;

[0088] Step S104, which involves inputting the natural query statement, the target data table, and the preset first task processing text into the first text processing model to obtain a composite query instruction, includes:

[0089] Step S1041: Obtain preset query semantic enhancement information; input the natural query statement, the target data table, the query semantic enhancement information, and the preset first task processing text into the first text processing model to obtain a composite query instruction.

[0090] In this embodiment, the first task processing text guides the first text processing model to combine the input query semantic enhancement information to more deeply understand the query intent of the natural query statement.

[0091] The query semantic enhancement information includes business knowledge related to natural query statements, data table processing, and guidance on generating query instructions. Specifically, it may include date and time conditions, such as requiring all queries to include date and time conditions. If the date and time are not explicitly specified in the natural query statement, a default filter condition is added: date (year, month, day) equal to "2024-10-20"; if specified, no additional filter is needed. It may also include guidance on data table processing, such as requiring that when using sql_json for querying, data should be retrieved from only one table, and that all fields be checked to ensure they are present in that table. It may also include query field selection, such as requiring that when the user request contains words like "each" or "every," the subsequent fields should be added to the SELECT part to ensure the query results include all necessary fields. Similarly, when the user request contains descriptions like TOPN or "top N," the subsequent fields should be added to the SELECT part. Finally, it may include requirements for set operations and result display, such as requiring that when the user request includes "list," the entire set should be retained, and records with no values ​​should be padded for display. It can also include the calculation of special indicators, such as year-on-year, same-year, month-on-month, and previous-period values ​​of indicators related to the number of customers (such as the number of investment advisor customers), which cannot be obtained directly from the table and need to be calculated using a specified plugin.

[0092] In summary, this embodiment additionally obtains query semantic enhancement information in step S104 and uses it as part of the input, enabling the first text processing model to generate more accurate and business-compliant composite query instructions.

[0093] In one embodiment, step S1041, which involves obtaining preset query semantic enhancement information, includes:

[0094] Step S10411: Obtain the user identity information of the user who inputs the natural query statement;

[0095] Step S10412: Obtain the query semantic enhancement information corresponding to the user identity information from the preset query semantic enhancement information database.

[0096] This embodiment takes into account the differences in user backgrounds and query permissions, therefore, different query semantic enhancement information is set for different users. This embodiment maintains a query semantic enhancement information database, which can be adjusted for different users or user groups. Adjustments can involve any aspect, such as different settings for different users in areas related to natural query statements, data table processing, or query instruction generation. This enables the first text processing model to more appropriately understand the user's natural query statements and generate query instructions according to the required specifications.

[0097] Specifically, step S10411 first identifies and obtains the user's identity information when inputting a natural query. Step S10412 uses the user's identity information to search for corresponding query semantic enhancement information in a pre-defined query semantic enhancement information database. This database may be a database, configuration file, or in-memory data structure that stores the mapping relationship between different user identity information and corresponding query semantic enhancement information. In one embodiment, query semantic enhancement information may include, but is not limited to: 1. Business terminology mapping: mapping informal or specific business terms that the user may use to standard terms used internally by the system. 2. Data table preferences: data tables or fields that the user frequently queries. 3. Query patterns: query structures or patterns that the user commonly uses, such as sorting methods, filtering conditions, etc. 4. Access restrictions: determining the data tables and fields that the user can access based on the user's access level.

[0098] In summary, this embodiment can obtain relevant enhancement information from a preset query semantic enhancement information database based on the user's identity information. This information will then be used in step S104, along with the natural query statement, the target data table, and the preset first task processing text, and input into the first text processing model to generate a more accurate and user-friendly composite query instruction, which can better adapt to the needs and query habits of different users.

[0099] In this embodiment, the first text processing model generates corresponding query instructions. Specifically, the query instructions can be structured query statements, such as SQL statements, used to query data in the database; or they can be code sets, such as Python scripts, executed by a code executor to query data from the database and perform specific calculations or processing.

[0100] In one embodiment, step S104, the first task processing text further includes a preset task prompt text, which includes usage scenario information and calling interface of each preset functional plugin; the task prompt text is used to prompt the first text processing model to understand the usage scenario corresponding to the query task, determine the matching functional plugin according to the usage scenario information of each functional plugin, obtain the calling interface corresponding to the functional plugin, and generate execution code (i.e., query instruction) according to the calling interface.

[0101] In this embodiment, the task prompt text records in detail the usage scenario information and corresponding calling interfaces of each preset functional plugin. This information directly relates to whether the first text processing model can accurately understand the usage scenario of the query task and select the correct functional plugin to execute the query task accordingly. Specifically, the usage scenario information in the task prompt text describes key elements such as the applicable query task type, input data format, and expected output results for each functional plugin. This information provides a clear framework for the first text processing model, enabling it to select one or more of the most suitable plugins from among many preset functional plugins to execute the query task based on its specific requirements. Simultaneously, the task prompt text also includes the calling interface information for each functional plugin. The calling interface is the bridge between the query instruction executor and the functional plugin; it defines how the query instruction executor calls the functional plugin, passes parameters, and receives return results. Based on the calling interface information, the first text processing model can accurately generate execution code, thereby enabling the query instruction executor to call and execute the functional plugin. Similarly, in other embodiments, when the first text processing model needs to process other tasks, the task prompt text can be used to prompt the first text processing model to process the corresponding task and provide relevant processing requirements.

[0102] In summary, the task prompt text in this embodiment provides a clear and accurate guiding framework for the first text processing model, enabling it to more quickly understand the specific requirements and usage scenarios of the query task, and select the most suitable functional plugin to generate query instructions accordingly.

[0103] In one embodiment, the task prompt text further includes usage prompts for the calling interfaces of each of the functional plugins; the usage prompts are used to prompt the first text processing model to understand the target parameter information of the query task when generating execution code according to the calling interface, and to pass the target parameter information into the calling interface; wherein, the target parameter information includes basic fields, dimension fields, limiting conditions, and analysis indicators; the target parameter information is used to instruct the corresponding functional plugin to query the target data according to the basic fields and the dimension fields, and to analyze the target data according to the analysis indicators under the limiting conditions.

[0104] The usage prompts are a crucial component of the task prompt text, detailing the specific usage methods and related details of each functional plugin's API call. This information is essential for the first text processing model to accurately transmit the target parameter information from the query task to the API call according to the prescribed format and order, thereby generating valid execution code.

[0105] Specifically, the use of prompts not only defines the structure of the target parameter information, but also clarifies the specific meaning and purpose of these parameters in the query task.

[0106] The target parameter information includes several key elements such as basic fields, dimension fields, limiting conditions, and analysis indicators. Basic fields are the fundamental data elements involved in the query task, forming its data foundation. For example, in the query task "Analyze whether sales in the Guangzhou region over the past 3 months are abnormal," "sales amount" is the basic field. Dimension fields are used to refine and categorize basic fields to more accurately locate and analyze the target data. In the example above, "monthly" (last 3 months) is the dimension field. Limiting conditions are used to filter and select query results, ensuring they meet actual needs. Limiting conditions can include time range, data range, etc. In the example above, "region = Guangzhou" limits the data range to the Guangzhou region. Analysis indicators are the core objective of the query task, indicating what kind of analysis needs to be performed on the target data. In the example above, "data anomaly" is the analysis indicator, requiring the plugin to analyze the sales situation in the Guangzhou region over the past 3 months and provide a predicted value indicating whether it is abnormal.

[0107] In summary, the prompts not only clearly describe the meaning and purpose of these parameters, but also guide the first text processing model on how to correctly pass them to the API call. In this way, the functional plugin can accurately retrieve the target data based on the passed target parameters and perform corresponding analytical indexes on the target data under defined conditions.

[0108] In summary, the usage prompts provide a clear, detailed, and specific guiding framework for the first text processing model, enabling it to more accurately understand the target parameter information in the query task and correctly pass them into the API call according to the prescribed format and order. Furthermore, because the usage prompts define in detail the various elements of the target parameter information, their relationships, and their specific meanings and uses in the query task, the first text processing model can easily handle various complex and diverse query tasks. Simultaneously, since the usage prompts for the API call are pre-defined in the task prompt text, updates and extensions to functional plugins can be easily implemented without requiring large-scale modifications and adjustments to the first text processing model.

[0109] For step S105, based on the composite query instruction, the query result of the natural query statement is obtained from the data warehouse corresponding to the constellation data model.

[0110] Among them, compound query instructions are a set of instructions generated during the processing of compound query tasks. They are structured information formed after a series of processing and transformations of the user's natural query statement. Compound query instructions transform the complex, multi-dimensional, and hierarchically dependent information needs expressed by the user in natural language into a sequence of operation instructions that the machine can understand and execute. They aim to guide the system or model to accurately execute corresponding data query and processing operations to achieve the user's compound query task. Specifically, compound query instructions generally have the following characteristics: 1. A compound query instruction consists of multiple query instructions, each corresponding to a subtask in the compound query task. These query instructions are not simply listed, but arranged in an orderly manner according to the logical relationships and dependencies between the subtasks in the compound query task. For example, for a compound query task involving "finding departments with annual sales exceeding 5 million and calculating the average employee turnover rate of these departments in the past two years," the compound query instructions will contain two or more explicit query instructions: one for finding departments that meet the annual sales condition, and another for calculating the average employee turnover rate of the departments that meet the condition. 2. The various query instructions in a compound query instruction have an execution order corresponding to the hierarchical dependencies in the compound query task. This execution order ensures the orderly execution of each subtask, guaranteeing the coherence and accuracy of the entire query task. In the example above, the query to calculate the average employee turnover rate must be executed after the query to find departments with annual sales exceeding 5 million, because it depends on the department data filtered by the previous query. This demonstrates the strictness of the execution order of compound query commands to avoid erroneous results due to disordered execution. Third, compound query commands are presented in a structured form. This structure can be in text form or a data structure representation within the computer system; for example, in some systems, it may be stored as nested lists, object arrays, or tree structures. This structured representation allows the system or model to clearly identify the specific content of each query command, its execution order, and the dependencies between them, facilitating subsequent execution and processing.

[0111] This step executes a query from the data warehouse corresponding to the constellation data model based on the generated compound query instruction and returns the query results. The query results may be a table or report containing the required information, which users can view and analyze through the interface.

[0112] In one embodiment, step S105, which involves retrieving the query result of the natural query statement from the data warehouse corresponding to the constellation data model based on the composite query instruction, includes:

[0113] Step S1051: Input the composite query instruction into a preset query instruction executor. The query instruction executor determines the execution order of each sub-query instruction in the composite query instruction based on the hierarchical dependency relationship. Execute each sub-query instruction in sequence according to the execution order to obtain the query result of the natural query statement from the data warehouse corresponding to the constellation data model.

[0114] This embodiment inputs a carefully generated composite query instruction into a preset query instruction executor. This composite query instruction contains all the information of the user's query requirements, and the various sub-query instructions have clear hierarchical dependencies. After receiving the composite query instruction, the query instruction executor determines the execution order of the sub-queries based on their hierarchical dependencies, ensuring that the query process proceeds logically and avoiding data corruption or query errors. After determining the execution order, the query instruction executor executes each sub-query instruction sequentially. During execution, relevant data is retrieved and processed from the data warehouse corresponding to the constellation data model to ensure that each sub-query yields the correct result. As each sub-query instruction is executed sequentially, the query instruction executor gradually collects and integrates the results of these sub-queries. Finally, these results are summarized into a complete query result, which accurately reflects the user's original query requirements. In summary, this embodiment significantly improves the execution efficiency and accuracy of composite query instructions by introducing a preset query instruction executor and implementing the determination of the sub-query instruction execution order based on hierarchical dependencies.

[0115] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of this application, and this application also intends to include these modifications and variations.

Claims

1. A method for processing a complex query task, characterized in that, The method comprises the following steps: obtaining a natural query sentence input by a user; the query task pointed to by the natural query sentence is a composite query task; determining, from a preset constellation data model, a query field matching a query intention of the natural query sentence as a target query field; the constellation data model comprises a structured data table and a query field in the data table; determining, from the constellation data model according to the target query field, at least one target data table comprising only the target query field; inputting the natural query sentence, the target data table and a preset first task processing text into a first text processing model to obtain a composite query instruction; wherein the first task processing text is used to prompt the first text processing model to understand the query intention of the natural query sentence, determine a composite query task conforming to the query intention, and generate a composite query instruction based on the target data table and the composite query task; the composite query instruction comprises a plurality of query instructions having a hierarchical dependency relationship; querying, based on the composite query instruction, a query result of the natural query sentence from a data warehouse corresponding to the constellation data model; wherein the first task processing text comprises a task decomposition prompt text; the task decomposition prompt text is used to prompt the first text processing model to decompose the natural query sentence into a plurality of sub-query sentences having a hierarchical dependency relationship according to a semantic structure feature of the natural query sentence and a preset semantic structure decomposition rule; the first text processing model understands a sub-query task corresponding to each of the sub-query sentences from bottom to top according to the hierarchical dependency relationship, and generates a sub-query instruction according to the sub-query task; and the first text processing model obtains a composite query instruction according to the sub-query instructions of the sub-query tasks; the step of querying, based on the composite query instruction, a query result of the natural query sentence from a data warehouse corresponding to the constellation data model, comprises: inputting the composite query instruction into a preset query instruction executor, determining an execution order of each sub-query instruction in the composite query instruction based on the hierarchical dependency relationship by the query instruction executor, and sequentially executing each sub-query instruction according to the execution order to query a query result of the natural query sentence from the data warehouse corresponding to the constellation data model.

2. The method of claim 1, wherein, the step of determining, from a preset constellation data model, a query field matching a query intention of the natural query sentence as a target query field, comprises: determining, from a preset constellation data model, a query field associated with the natural query sentence as a candidate query field; inputting the natural query sentence, the candidate query field and a preset second task processing text into a second text processing model to obtain a plurality of target query fields; wherein the second task processing text is used to prompt the second text processing model to understand the query intention of the natural query sentence, and determine a candidate query field conforming to the query intention as a target query field.

3. The method of claim 2, wherein, the step of determining, from a preset constellation data model, a query field associated with the natural query sentence as a candidate query field, comprises: Entity segmentation and word recognition are performed on the natural query statement to obtain several entity segments; Obtain each query field of the constellation data model; calculate the semantic similarity between each query field and the natural query statement and the entity word segmentation, and determine the query fields with semantic similarity greater than a preset similarity threshold as candidate query fields.

4. The method of claim 3, wherein, The second task processing text is also used to prompt the second text processing model to understand the query intent of the natural query statement by combining the input business knowledge; After the step of performing entity segmentation and recognition on the natural query statement to obtain several entity segments, the method further includes the following step: Based on the natural query statement and the entity word segmentation, relevant business knowledge is retrieved from the preset business knowledge base; The step of inputting the natural query statement, the candidate query fields, and the preset second task processing text into the second text processing model to obtain several target query fields includes: The natural query statement, the candidate query fields, the business knowledge, and the preset second task processing text are input into the second text processing model to obtain several target query fields.

5. The method of claim 3, wherein, The second task processing text is also used to prompt the second text processing model to understand the query intent of the natural query statement by combining the input synonym information; After the step of performing entity segmentation and recognition on the natural query statement to obtain several entity segments, the method further includes the following step: Determine the synonym of any entity segment from the preset synonym information database; obtain synonym information based on the synonyms of each entity segment; The step of inputting the natural query statement, the candidate query fields, and the preset second task processing text into the second text processing model to obtain several target query fields includes: The natural query statement, the candidate query fields, the synonym information, and the preset second task processing text are input into the second text processing model to obtain several target query fields.

6. The method of claim 3, wherein, The second task processing text is also used to prompt the second text processing model to output a question statement targeting the semantically ambiguous entity segment when the natural query statement contains semantically ambiguous entity segmentation; the second task processing text is also used to prompt the second text processing model to re-understand the query intent of the natural query statement by combining the user's answer information to the question statement.

7. The method of claim 1, wherein, The first task processing text is also used to prompt the first text processing model to understand the query intent of the natural query statement by combining the input query semantic enhancement information; The step of inputting the natural query statement, the target data table, and the preset first task processing text into the first text processing model to obtain a composite query instruction includes: Obtain preset query semantic enhancement information; input the natural query statement, the target data table, the query semantic enhancement information, and the preset first task processing text into the first text processing model to obtain a composite query instruction.

8. The method of claim 1, wherein, The target query fields include dimension fields and metric fields; the constellation data model records several data tables, the basic fields included in each data table, and the graph relationships between the data tables; the graph relationships include at least directed graph relationships; The step of determining at least one target data table from the constellation data model that includes only the target query field based on the target query field includes: The data table containing any one or more of the metric fields in the constellation data model is designated as the root data table. Using the root data table as the root node, and based on the graph relationship, determine other data tables in the constellation data model that can reach the root data table. Using each root data table as a fact table and the other data tables that can be reached by the fact table as dimension tables, obtain several target star data models. Remove the dimension tables in the target star data model that do not include the dimension fields from the edges; remove the basic fields in the fact table of any target star data model except for the metric fields; and remove the basic fields in the dimension tables of any target star data model except for the dimension fields. The target data table is obtained based on the target star-shaped data model.

Citation Information

Patent Citations

  • Data query method and device based on text processing model

    CN118708704A

  • Custom multi-dimensional analysis configuration method, system and equipment based on constellation model and medium

    CN119311687A