Query method based on query auxiliary information
By obtaining user information and query auxiliary information, and combining the constellation data model with the text processing model, the problem of accuracy in understanding user intent in database query technology is solved, and more accurate natural language query results are achieved.
Patent Information
- Application Number
- CN202510101376.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-22
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-01-22
AI Technical Summary
Existing database query technologies have difficulty accurately understanding users' natural language query intentions, especially in the face of the diverse expression habits and professional terminology of different user groups, resulting in inaccurate query results.
By obtaining user information, utilizing query auxiliary information and constellation data models, combining text processing models and query instruction generation models, accurately determining target query fields and data tables, and generating query instructions to improve the accuracy of natural language queries.
It significantly improves the accuracy of natural language queries, can meet users' complex and diverse data query needs, and provide a more accurate data query experience.
Smart Images

Figure CN120045582B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of natural language query technology, and in particular to a query method based on query auxiliary information. Background Art
[0002] With the rapid development of information technology, especially the rise of big data analysis and business intelligence, users' data query needs are becoming increasingly complex and diverse. Traditional database query technologies rely on structured query languages (such as SQL) to perform data retrieval. However, this high-tech query method is particularly inconvenient for non-expert users. To improve the user experience, existing database query technologies have begun to attempt to convert natural language into database query language, but this process presents many challenges.
[0003] Specifically, natural language is ambiguous and diverse. Different users or user groups have different identities and backgrounds and often have their own expression habits and professional terminology. These situations are usually not understood by natural language processing models, making it difficult for natural language processing models to accurately capture users' true needs when understanding user query intent. For example, when a user mentions "our department," they actually mean the specific department they work in, but the model usually cannot accurately understand this statement. In addition, even the same word can have different meanings for different users or in different scenarios, further increasing the difficulty of natural language processing. Summary of the Invention
[0004] Based on this, the purpose of this application is to provide a query method based on query auxiliary information to improve the accuracy of natural language queries, thereby meeting the complex and diverse data query needs of users.
[0005] The query method based on query auxiliary information described in the embodiment of the present application includes the following steps:
[0006] Obtaining a natural query statement input by a user and user information of the user;
[0007] Acquire auxiliary query information of the user according to the user information; wherein the auxiliary query information is additional information associated with the user and specific to the natural query statement;
[0008] Obtaining various query fields of a preset constellation data model, and determining query fields associated with the natural query statement as candidate query fields; wherein the constellation data model includes a structured data table and query fields in the data table;
[0009] Inputting the natural query statement, the candidate query fields, the query auxiliary information, and a preset first task processing text into a first text processing model to obtain a plurality of target query fields; 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 in combination with the query auxiliary information, and to determine the candidate query fields that meet the query intent as target query fields;
[0010] Determining at least one target data table including only the target query field from the constellation data model;
[0011] Inputting the natural query statement and the target data table into a query instruction generation model to obtain a query instruction; wherein the query instruction generation model is used to understand the query intent of the natural query statement, determine a query task that meets the query intent, and generate a query instruction based on the target data table and the query task;
[0012] Based on the query instruction, a query result of the natural query statement is obtained by querying from a data warehouse corresponding to the constellation data model.
[0013] The present embodiment obtains a user's natural query and user information, obtains query auxiliary information based on the user information, and then determines candidate query fields associated with the natural query by matching query fields in a preset constellation data model. The natural query, candidate query fields, query auxiliary information, and a preset first task processing text are input into a first text processing model. The first text processing model, combined with the query auxiliary information, understands the query intent of the natural query and determines the candidate query fields that meet the query intent as target query fields. Furthermore, at least one target data table containing only the target query fields is determined from the constellation data model. The natural query and the target data table are input into a query instruction generation model to generate a query instruction. Finally, based on the query instruction, a query result for the natural query is obtained from the data warehouse. In summary, the present embodiment introduces query auxiliary information associated with the user to enhance the large model's understanding of the user's query intent, helping the large model to more accurately interpret the user's natural query, thereby accurately filtering the target query field from the candidate query fields and further accurately determining the target data table. Finally, the large model combines the query intent and the target data table to generate a query instruction and obtain the query result. It significantly improves the accuracy of natural language queries, can meet users' complex and diverse data query needs, and bring users a more accurate data query experience.
[0014] For better understanding and implementation, the present application is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 Schematic diagram of a flow chart of a query method based on query auxiliary information according to an embodiment of the present application;
[0016] Figure 2 Schematic diagram of the steps of obtaining synonym information from a user's synonym information database in an embodiment of the present application;
[0017] Figure 3 A schematic diagram of the steps for adding synonym information to a user's synonym information database in an embodiment of the present application;
[0018] Figure 4 Schematic diagram of the steps for generating a query instruction by combining the user's query semantic enhancement information in an embodiment of the present application. DETAILED DESCRIPTION
[0019] To make the objectives, technical solutions, and advantages of this application more clear, the following will further describe the embodiments of this application in detail with reference to the accompanying drawings. In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements.
[0020] It should be understood that the embodiments described in the following examples do not represent all embodiments consistent with this application. Rather, they are merely examples of devices and methods consistent with certain aspects of this application, as detailed in the appended claims. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of this application without inventive effort are intended to fall within the scope of protection of this application.
[0021] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "the" and "the" used in this application are also intended to include plural forms, unless the context clearly indicates otherwise. In addition, in the description of this application, unless otherwise stated, "a plurality" refers to two or more. It should also be understood that the term "and / or" used herein 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.
[0022] 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. Moreover, these terms are only used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence, nor can they be understood to indicate or imply relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to the specific circumstances. Depending on the context, the words "if" / "if" used in this application can be interpreted as "at the time of" or "when" or "in response to determining".
[0023] The present application relates to the field of natural language query technology. Existing database query technology converts natural language into database query language, but there are many challenges in this process. Specifically, natural language is ambiguous and diverse, and different users or user groups often have their own expression habits and professional terms. These differences cause existing natural language processing models to often encounter difficulties in understanding user query intentions and it is difficult to accurately capture the user's real needs. For example, when a user mentions "our department", it actually refers to the specific department where they are located, but the model usually cannot accurately understand this statement. In addition, even the same vocabulary may refer to different meanings for different users or in different scenarios, which further increases the difficulty of natural language processing.
[0024] In this regard, an embodiment of the present application provides a query method based on query auxiliary information, which introduces corresponding query auxiliary information for different users to improve the accuracy of natural language queries, thereby meeting the users' complex and diverse data query needs.
[0025] Please refer to Figure 1 The query method based on query auxiliary information described in the embodiment of the present application includes the following steps:
[0026] S101: Obtaining a natural query statement input by a user and user information of the user;
[0027] S102: Acquire auxiliary query information of the user according to the user information; wherein the auxiliary query information is additional information associated with the user and specific to the natural query statement;
[0028] S103: Acquire various query fields of a preset constellation data model, and determine query fields associated with the natural query statement as candidate query fields; wherein the constellation data model includes a structured data table and query fields in the data table;
[0029] S104: Inputting the natural query statement, the candidate query fields, the query auxiliary information, and a preset first task processing text into a first text processing model to obtain a plurality of target query fields; 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 in combination with the query auxiliary information, and to determine the candidate query fields that meet the query intent as target query fields;
[0030] S105: Determine at least one target data table including only the target query field from the constellation data model;
[0031] S106: Inputting the natural query statement and the target data table into a query instruction generation model to obtain a query instruction; wherein the query instruction generation model is used to understand the query intent of the natural query statement, determine a query task that meets the query intent, and generate a query instruction based on the target data table and the query task;
[0032] S107: Based on the query instruction, query the data warehouse corresponding to the constellation data model to obtain the query result of the natural query statement.
[0033] The present embodiment obtains a user's natural query and user information, obtains query auxiliary information based on the user information, and then determines candidate query fields associated with the natural query by matching query fields in a preset constellation data model. The natural query, candidate query fields, query auxiliary information, and a preset first task processing text are input into a first text processing model. The first text processing model, combined with the query auxiliary information, understands the query intent of the natural query and determines the candidate query fields that meet the query intent as target query fields. Furthermore, at least one target data table containing only the target query fields is determined from the constellation data model. The natural query and the target data table are input into a query instruction generation model to generate a query instruction. Finally, based on the query instruction, a query result for the natural query is obtained from the data warehouse. In summary, the present embodiment introduces query auxiliary information associated with the user to enhance the large model's understanding of the user's query intent, helping the large model to more accurately interpret the user's natural query, thereby accurately filtering the target query field from the candidate query fields and further accurately determining the target data table. Finally, the large model combines the query intent and the target data table to generate a query instruction and obtain the query result. It significantly improves the accuracy of natural language queries, can meet users' complex and diverse data query needs, and bring users a more accurate data query experience.
[0034] The query method based on query auxiliary information described in the embodiment of the present application is executed by a computer. The following first describes the text processing model of the embodiment of the present application, and then describes each step in detail.
[0035] In the embodiments of the present application, 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 can capture the deep semantic and syntactic features of the language), and are fine-tuned to adapt to the specific tasks in this application, such as query intent understanding, query instruction generation, etc. Of course, the text processing model can also be an existing large language model. As long as it has the processing capability of the specific tasks of this application, it can be applied to the technical solution of this application. This embodiment of the present application does not limit this.
[0036] In order for the text processing model to complete the task as required, it is usually necessary to provide a task processing text. The task processing text is used to require or prompt the task requirements of the text processing model, which includes specific requirements and format instructions for the model output. It can also include task-related scenario information or context information for the model to learn and understand the task to be processed, etc. In the embodiment of the present application, different sub-texts can be set in the task processing text according to the needs of the query, which are used to require or prompt the text processing model for the corresponding task requirements. The task processing text provided to the model in different task processing requirements is also different, such as the first task processing text, the second task processing text, and so on.
[0037] In step S101 , a natural query statement input by a user and user information of the user are obtained.
[0038] In this step, a natural query statement is received from the user through a user interface (such as a webpage or app). A natural query statement is a data query requirement expressed in natural language by the user, such as "Query our department's sales data for last month." At the same time, user information related to the user is also obtained, including but not limited to user identity information, such as username, user identity type, and user attributes.
[0039] In step S102, query auxiliary information of the user is obtained according to the user information; wherein the query auxiliary information is additional information associated with the user and for the natural query statement.
[0040] Among them, query auxiliary information is additional information related to the user's natural query statement, which is used to help the model understand the user's query intent more accurately. For example, if the user belongs to the "Sales Department", the query auxiliary information may include business terms related to the "Sales Department", common query conditions, etc. This information can be extracted from the database of the user's department, user profiles, or historical query data. This step determines the user's type based on user information and selects the corresponding synonym information library accordingly. This information is crucial for understanding the user's query intent, especially when the user uses specific industry terms or idioms.
[0041] Please refer to Figure 2 In one embodiment, the query auxiliary information in step S102 includes synonym information; and the step of obtaining the user's query auxiliary information based on the user information includes:
[0042] Step S1021, performing entity segmentation recognition on the natural query sentence to obtain a plurality of entity segmentations;
[0043] Step S1022: determining a synonym information database corresponding to the user information, and determining a synonym corresponding to any entity participle from the synonym information database;
[0044] Step S1023: Obtain synonym information based on the synonyms of each entity segmentation.
[0045] To more accurately understand and respond to the query needs of different types of users, this embodiment provides customized synonym information libraries for different types of users, especially considering the differences in idiomatic expressions, identity backgrounds, etc. These synonym information libraries are specifically designed based on the user's characteristics (such as department, position, industry, etc.) and contain synonyms and near-synonyms that are closely related to the user.
[0046] Step S1021 uses word segmentation technology to divide the query statement into meaningful words or phrases and perform entity recognition to obtain several entity segmentations. Step S1022 selects the corresponding synonym information library according to the type of user (such as department, position, etc.). In one embodiment, the user information includes user department information or position information, so that the corresponding synonym information library is selected based on the user department information or position information. In the synonym information library, it is searched whether there is a synonym of any entity segmentation. If so, the entity segmentation and its synonyms are added to the synonym information in step S1023. The synonym information will be used as query auxiliary information to understand the user's query intention and generate query instructions in subsequent steps.
[0047] In one example, for users in the sales department, the synonym information library may contain synonym relationships such as "sales data = sales amount", "sales data = sales quantity", "department = user's specific department name (such as sales department, finance department)". When it is recognized that the user has entered a query statement such as "query our department's sales data last month", the user's synonym information library can be used to replace "department" with the user's "specific department name", and replace "sales data" with specific sales data indicators related to the department, such as "sales (amount)" or "sales (quantity)", etc., so as to more accurately understand the user's query intention. In an example, for users in Department A, "sales data" refers to "sales amount", while for users in Department B, "sales data" refers to "sales quantity".
[0048] In summary, this embodiment, by providing customized synonym databases for different types of users, can more accurately understand the user's query intent. Even if the user uses specific industry terms or idiomatic expressions, it can still generate query instructions that meet the user's needs. This innovation enhances the ability to adapt to different user needs and expression habits.
[0049] Please refer to Figure 3 In one embodiment, before the step of obtaining the user's query auxiliary information based on the user information in step S102, the following steps are further included:
[0050] Step S201: In response to a synonym information creation instruction, the synonym information creation instruction is parsed to obtain user information and synonym information; the synonym information includes a standard vocabulary and a user's habitual expression vocabulary corresponding to the user information for the standard vocabulary;
[0051] Step S202: Add the synonym information to the synonym information database corresponding to the user information.
[0052] Among them, in step S201, the synonym information creation instruction is an instruction triggered by a system administrator or a user with corresponding authority, which is used to instruct the creation of synonym information for a specific user or user group. After receiving the synonym information creation instruction, it is first parsed to extract the user information and synonym information contained in the instruction. Among them, the user information may include the user's identity information, such as user name, department, position, etc., which is used to determine which user or user group the synonym information will apply to. Synonym information is the core content of the instruction, including standard vocabulary and the user's habitual expression vocabulary for the standard vocabulary. For example, for users in the sales department, the standard vocabulary may be "sales volume", and the habitual expression vocabulary may be "sales performance" or "total sales volume", etc.
[0053] In step S202, the synonym database is a database specifically used to store synonym information. It is organized according to user identity information (such as department, position, etc.). After parsing the user information and synonym information, this information is added to the synonym database corresponding to the user. In this way, when the user or user group performs a query, this synonym information can be used to more accurately understand the user's query intent.
[0054] In summary, in this embodiment, system administrators or users with appropriate permissions can create and update synonym databases for different users or user groups based on actual needs. This provides sufficient query-assisted information for users' natural query statements, enabling the text processing model to more accurately understand the user's query intent and improve query accuracy. This also facilitates subsequent maintenance and optimization, allowing the synonym database to be continuously optimized as user needs and expression habits change.
[0055] In step S103, each query field of a preset constellation data model is obtained, and the query field associated with the natural query statement is determined as a candidate query field; wherein the constellation data model includes a structured data table and query fields in the data table.
[0056] The constellation data model is an abstract representation used to describe the database structure. It is a data logic layer established in advance based on the 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 each data table. In addition, 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 the relevant information used to generate query statements. This information mainly includes the table name of the data table, the field information of the data table, and the multidimensional operation field information bound to the basic fields. In addition, the constellation data model establishes graph relationships between the various data tables, and these graph relationships include at least directed graph relationships.
[0057] Among them, the basic fields are generally the fields that record the original business data in the database. More specifically, the basic fields are generally divided into metric fields and dimension fields. The metric fields generally refer to the fields in the fact table, and the dimension fields generally refer to the fields in the dimension table. Among them, the fact table and the dimension table are concepts in data modeling in the field of data warehouse. At present, the main data models involved in the field of data warehouse are star data model, snowflake data model generated on the basis of star data model (which can also be considered as a kind of star data model) and constellation data model. In the star data model, it includes a data table located in the center and other data tables connected to the central data table. Among them, the central data table is the fact table, and the other data tables connected to it are dimension tables.
[0058] In this step, the pre-set constellation data model is accessed to obtain all available query fields. Then, through text analysis of the natural query (such as keyword matching and semantic analysis), query fields associated with the natural query are identified as candidate query fields. For example, for the natural query "Query our department's sales data for last month," query fields such as "department," "time," and "sales" might be identified as candidate query fields.
[0059] In one embodiment, the step of obtaining the query fields of the preset constellation data model and determining the query fields associated with the natural query statement as candidate query fields in step S103 includes:
[0060] Step S1031, obtaining various query fields of a preset constellation data model;
[0061] Step S1032 : determining a query field whose semantic similarity with the natural query statement or any of the entity segmentations is greater than a preset similarity threshold as a candidate query field.
[0062] Step S1031 obtains each query field in the preset constellation data model. Then, step S1032 uses a semantic similarity calculation algorithm to calculate the semantic similarity of each query field with the natural query statement and the identified entity segmentation. The purpose of this step is to find the query field that is semantically closest to the natural query statement or entity segmentation. Finally, based on the preset similarity threshold, the query fields with a semantic similarity greater than the threshold are determined as candidate query fields. These fields have a high degree of semantic matching with the natural query statement or entity segmentation, and are therefore regarded as fields that may meet the user's query needs. In summary, this embodiment accurately selects query fields associated with natural query statements as candidate query fields by introducing entity segmentation recognition and semantic similarity calculation.
[0063] For step S104, the natural query statement, the candidate query fields, the query auxiliary information and the preset first task processing text are input into the first text processing model to obtain several target query fields; 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 in combination with the query auxiliary information, and determine the candidate query fields that meet the query intent as target query fields.
[0064] In this step, the natural query statement, candidate query fields, query auxiliary information, and the preset first task processing text are combined into an input set and input into the first text processing model. The first text processing model combines the query auxiliary information to understand the query intent of the natural query statement and selects the target query fields that meet the query intent from the candidate query fields. For example, for the natural query statement "Query our department's sales data last month", the model may determine that the target query fields are "Department A", "Time", and "Sales" based on the query auxiliary information "User's department = Department A".
[0065] In one embodiment, the first task processing text in step S104 is further used to prompt the first text processing model to understand the query intent of the natural query statement in combination with the input business knowledge;
[0066] After the step S1021 of performing entity segmentation recognition on the natural query to obtain a plurality of entity segmentations, the following steps are further included:
[0067] Step S10211: Based on the natural query sentence and the entity segmentation, relevant business knowledge is retrieved from a preset business knowledge base;
[0068] The step of inputting the natural query statement, the candidate query fields, the query auxiliary information, and the preset first task processing text into the first text processing model to obtain a plurality of target query fields in step S104 includes:
[0069] Step S1041 : input the natural query statement, the candidate query fields, the query auxiliary information, the business knowledge, and the preset first task processing text into a first text processing model to obtain a plurality of target query fields.
[0070] In this embodiment, the first task processing text guides the first text processing model to deeply understand the query intent of the natural query statement in combination with the input business knowledge. After performing entity segmentation recognition on the natural query statement in step S1021 and obtaining a number of entity segmentations, step S10211 retrieves relevant business knowledge from a preset business knowledge base based on the natural query statement and the identified entity segmentations. That is, business knowledge related to the natural query statement or entity segmentation is obtained so that the query intent can be understood more accurately in subsequent steps. Then, in step S1041, the natural query statement, candidate query fields, query auxiliary information, retrieved business knowledge and the preset first task processing text are input into the first text processing model together to obtain a number of target query fields. The improvement of this step is that business knowledge is introduced as input, so that the first text processing model can 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.
[0071] For step S105, at least one target data table including only the target query field is determined from the constellation data model.
[0072] Based on the target query fields obtained in S104, this step filters out data tables from the constellation data model that contain only these target query fields as target data tables. These target data tables serve as the basis for subsequent query instruction generation and data query. For example, if the target query fields are "Department A," "Time," and "Sales," then the sales data table for Department A may be filtered out as the target data table.
[0073] In one embodiment, the target query field includes a dimension field and a metric field; and the step of determining at least one target data table including only the target query field from the constellation data model in step S105 includes:
[0074] Step S1051, determining a data table containing any one or more metric fields in the constellation data model as a target data table;
[0075] Step S1052: Taking the target data table as the root node, based on the graph relationship, determine other data tables in the constellation data model that can reach the target data table, and use each target data table as a fact table and the other data tables that can be reached by the fact table as dimension tables, to obtain multiple target star data models.
[0076] Step S1053: removing edge dimension tables that do not include the dimension fields in the target star data model, removing basic fields other than the metric fields in any fact table of the target star data model, and removing basic fields other than the dimension fields in any dimension table of the target star data model.
[0077] Step S1054: obtaining a target data table according to the target star data model.
[0078] The target query fields of this embodiment include metric fields and dimension fields. First, a data table containing any one or more metric fields in the constellation data model is used as a root data table; a fact table centered on the root data table and other data tables that can reach the fact table are used as dimension tables to determine several target star data models; dimension tables irrelevant to the query in each target star data model are removed, as well as basic fields (metric fields or dimension fields) irrelevant to the query, so that the target star data model finally obtained only includes fact tables, dimension tables and basic fields related to the query. Through the method of the embodiment of the present application, the constellation data model modeled in advance is trimmed according to the target query field, and the target data table is determined based on the minimum available star data model obtained by trimming, thereby avoiding querying other irrelevant data tables and irrelevant query fields, reducing the complexity of understanding the query instruction generation model, and making the generation of query instructions more efficient and accurate.
[0079] For step S106, the natural query statement and the target data table are input into a query instruction generation model to obtain a query instruction; wherein, the query instruction generation model is used to understand the query intent of the natural query statement, determine the query task that meets the query intent, and generate a query instruction based on the target data table and the query task.
[0080] In this step, the natural query statement and the target data table are input into the query instruction generation model. The query instruction generation model is a trained machine learning model that can understand the query intent of the natural query statement and generate query instructions that meet the query intent based on the target data table. The query instruction can be a structured query statement such as an SQL statement, which is used to query data in the database; it can also be a generated code set such as a Python script, which is executed by a code executor to query data from the database and perform specific calculations or processing. In one example, the model may generate an SQL query statement based on the input, which filters out the "sales" data of "Department A" in "Time = October (assuming the current month is November)" from the target data table.
[0081] In one embodiment, the query instruction generation model in step S106 is a second text processing model; the step of inputting the natural query statement and the target data table into the query instruction generation model to obtain the query instruction includes:
[0082] Step S1061, input the natural query statement, the target data table and the preset second task processing text into the second text processing model to obtain a query instruction; 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, determine the query task that meets the query intent, and generate a query instruction based on the target data table and the query task.
[0083] In this embodiment, the query instruction generation model is a second text processing model. To enable the second text processing model to complete the task in step S106, a second task processing text is also pre-set. This second task processing text not only prompts the model to understand the query intent of the natural query statement but also guides the model on how to determine the corresponding query task based on this intent. Once the query task is determined, the model generates the final query instruction based on the structure and content of the target data table and the specific requirements of the query task.
[0084] Please refer to Figure 4 In one embodiment, the second task processing text in step S1061 is further used to prompt the second text processing model to understand the query intent of the natural query statement in combination with the input query semantic enhancement information;
[0085] The step of inputting the natural query statement, the target data table, and the preset second task processing text into the second text processing model to obtain a query instruction in step S1061 includes:
[0086] Step S10611: acquiring the user's query semantic enhancement information from a preset query semantic enhancement information library according to the user information;
[0087] Step S10612: input the natural query statement, the target data table, the query semantic enhancement information, and the preset second task processing text into a second text processing model to obtain a query instruction.
[0088] In this embodiment, the second task processing text guides the second text processing model to combine the input query semantic enhancement information to more deeply understand the query intent of the natural query statement.
[0089] Query semantic enhancement information includes business knowledge related to natural query statements, data table processing, and guidance on query generation. 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 filter condition (year, month, and day) equal to "2024-10-20" is added by default; if it is already specified, it is not necessary to add it. It may also include data table processing guidance, such as requiring that when using sql_json queries, data is only retrieved from a single table and that all fields are checked to ensure that the table is present. It may also include query field selection, such as requiring that when a user request contains words such as "each" or "each", subsequent fields be added to the SELECT portion to ensure that the query results include all necessary fields. When a user request contains a "TOPN" or "first N" description, subsequent fields are also added to the SELECT portion. It may also include requirements for set operations and result display, such as requiring that when a user request contains "list", the set be retained in its entirety, and records without values be displayed with blanks. Special indicator calculations can also be included. For example, year-on-year, same-period, quarter-on-quarter, and previous-period values for indicators related to the number of clients (such as the number of investment advisory clients) cannot be directly obtained from the table and require calculation using a designated plug-in. By including query semantic enhancement information as part of the input, the first text processing model generates more accurate query instructions that meet business needs.
[0090] Furthermore, this embodiment takes into account differences in user identities, backgrounds, and query permissions. Therefore, different query semantic enhancement information is configured for different users. This embodiment maintains a query semantic enhancement information repository that can adjust query semantic enhancement information for different users or user groups. This adjustment can involve any aspect, such as business knowledge related to natural query statements, data table processing, or query instruction generation, all of which can be customized for different users. This enables the second text processing model to more appropriately understand the user's natural query statements and generate query instructions according to the required specifications. Specifically, step S10611 uses the user's identity information to search for the corresponding query semantic enhancement information in a pre-set query semantic enhancement information repository. This repository may be a database, configuration file, or in-memory data structure that stores mappings between different user identity information and corresponding query semantic enhancement information. In one embodiment, the query semantic enhancement information may include, but is not limited to: 1. Business term mapping: mapping informal or specific business terms that users may use to standard terminology used within the system. 2. Data table preferences: mapping the data tables or fields that users frequently query. 3. Query patterns: query structures or patterns commonly used by users, such as sorting methods and filtering conditions. 4. Authority restriction: Determine the data tables and fields that the user can access based on the user's authority level. Step S10612 also inputs the query semantic enhancement information into the second text processing model to obtain a query instruction.
[0091] In summary, this embodiment can retrieve relevant enhanced information from a preset query semantic enhancement information library based on the user's identity information. This information is then used in step S106 to be input into the second text processing model along with the natural query statement, the target data table, and the preset second task processing text, to generate a more accurate and user-specific composite query instruction, better adapting to the needs and query habits of different users.
[0092] In one embodiment, in step S106, the second task processing text 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 second text processing model to understand the usage scenario corresponding to the query task, and determine the matching functional plug-in based on the usage scenario information of each functional plug-in, obtain the calling interface corresponding to the functional plug-in, and generate an execution code (i.e., a query instruction) based on the calling interface.
[0093] In this embodiment, the task prompt text details the usage scenario information and corresponding call interfaces for each pre-set functional plug-in. This information is directly related to whether the second text processing model can accurately understand the usage scenario of the query task and select the correct functional plug-in to execute the query task accordingly. Specifically, the usage scenario information in the task prompt text describes key elements such as the query task type, input data format, and expected output results applicable to each functional plug-in. This information provides a clear framework for the second text processing model to select one or more of the most suitable pre-set functional plug-ins to execute the query task based on the specific requirements of the query task. The task prompt text also includes the call interface information for each functional plug-in. The call interface is the bridge for the query instruction executor to interact with the functional plug-in. It defines how the query instruction executor calls the functional plug-in, passes parameters, and receives return results. Based on the call interface information, the second text processing model can accurately generate execution code, allowing the query instruction executor to call and execute the functional plug-in. Similarly, in other embodiments, when the second text processing model is required to handle other tasks, the task prompt text can be set to prompt the second text processing model to handle the corresponding task and indicate the relevant processing requirements.
[0094] In summary, the task prompt text of this embodiment provides a clear and accurate guidance framework for the second text processing model, 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 generate query instructions accordingly.
[0095] 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 second 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 based on the basic fields and the dimension fields, and analyze the target data with the analysis indicators under the restriction conditions.
[0096] Usage prompts are a key component of the task prompt text, detailing the specific usage and details of each plug-in's call interface. This information is crucial for the second text processing model to accurately pass the query task's target parameter information into the call interface in the specified format and order, thereby generating valid execution code.
[0097] 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.
[0098] Target parameter information includes several key elements, including base fields, dimension fields, constraints, and analysis metrics. Base fields are the fundamental data elements involved in a query task and form the data foundation for the query. For example, if the query task is "Analyze whether sales in the Guangzhou region over the past three months are abnormal," "Sales" is the base field. Dimension fields are used to refine and categorize base fields for more precise location and analysis of the target data. In the example above, "Month" (over the past three months) is the dimension field. Constraints are used to filter and select query results to ensure they meet actual requirements. Constraints can include time ranges and data ranges. In the example above, "Region = Guangzhou" limits the data range to the Guangzhou region only. Analysis metrics are the core purpose of the query task and indicate the type of analysis to be performed on the target data. In the example above, "Data Anomaly" is the analysis metric, which requires the function plug-in to analyze sales in the Guangzhou region over the past three months and provide a predicted value to indicate whether there is an anomaly.
[0099] In summary, the usage prompts not only clearly describe the meaning and purpose of these parameters, but also guide the second text processing model on how to correctly pass them into the calling interface. This allows the functional plug-in to accurately query the target data based on the passed target parameter information and analyze the target data according to the corresponding analysis indicators under the specified conditions.
[0100] In summary, the usage prompt information provides a clear, detailed, and specific guidance framework for the second text processing model, enabling it to more accurately understand the target parameter information in the query task and correctly pass them into the calling interface in the prescribed format and order. In addition, because 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 meaning and use in the query task, the second text processing model can easily cope with various complex and diverse query tasks. At the same time, because 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 the need for large-scale modification and adjustment of the second text processing model.
[0101] In step S107, based on the query instruction, a query result of the natural query statement is obtained from the data warehouse corresponding to the constellation data model.
[0102] This step executes a data query task from the data warehouse corresponding to the constellation data model based on the query instruction generated in S106, and obtains the query results. The query results contain the data required by the user. For example, the query result may be a table or chart containing "Department A's sales last month." In one embodiment, the query instruction is executed by a preset query instruction executor, and the query results of the natural query statement are obtained from the data warehouse corresponding to the constellation data model.
[0103] In one embodiment, the query task pointed to by the natural query statement is a compound query task; the second task processing text is used to prompt the second text processing model to determine a compound query task that meets the query intent of the natural query statement, and generate a compound query instruction based on the target data table and the compound query task; the compound query instruction includes several query instructions with hierarchical dependencies.
[0104] A complex query task, unlike a simple single-condition query task, involves the combination and coordinated operation of multiple sub-query tasks, with hierarchical dependencies between these sub-query tasks. Specifically, a complex query task cannot be completed through a single query operation. Instead, multiple sub-query operations must 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 form a complete set of operations to achieve the ultimate query objective. For example, in a business data analysis scenario, a user might enter a natural query statement 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: one is to find companies with annual sales exceeding 10 million (called sub-task A), and the other is to calculate the average profit growth rate of companies that meet the conditions of sub-task A over the past three years (called sub-task B). 2. Hierarchical dependencies: Sub-query tasks have clear hierarchical dependencies, meaning that the execution of subsequent sub-tasks depends on the results of previous sub-tasks. In the above example, the execution of subtask B depends on the results of subtask A because only by first identifying companies with annual sales exceeding 10 million can the average profit growth rate of these companies be calculated. This dependency can be data-dependent or logical, requiring subsequent subtasks to use the data or calculation results filtered out by previous subtasks as input or a basis for operation. 3. Logical Complexity: Due to the involvement of multiple subtasks and their dependencies, complex query tasks typically have high logical complexity. This requires not only accurate understanding and processing 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 with multiple data tables and complex relationships, different subtasks may involve different data tables and require complex join operations (such as multi-table joins) and data filtering operations (such as conditional filtering, grouping aggregation, etc.). The execution order and connection methods of these operations need to be arranged according to the specific dependencies to ensure data consistency and the correctness of the query results.
[0105] This embodiment obtains a natural query statement input by the user and involves a compound query task. For example, the user may input "Please query the top 3 customers in sales of the top 3 brands, and the proportion of these customers in brand sales". First, the target query field that matches the query intent in the preset constellation data model is determined. Then, based on the target query field, the relevant data table is filtered out from the constellation data model. On this basis, the compound query task of the natural query statement is decomposed into subtasks through the second text processing model, and a compound query instruction with a logical hierarchy and dependency relationship is generated according to the user's query intent and the structural information of the data table. Finally, according to the generated compound query instruction, the query result that meets the user's needs is queried from the data warehouse. In summary, the embodiment of the present application realizes accurate query of the user's compound query task, improves the accuracy and efficiency of the query, and has broad application prospects.
[0106] In one embodiment, the second task processing text includes a task decomposition prompt text; the task decomposition prompt text is used to prompt the second text processing model to split the natural query statement into several sub-query statements with hierarchical dependencies based on the semantic structure characteristics of the natural query statement and preset semantic structure splitting rules; understand the sub-query tasks corresponding to each of the sub-query statements from bottom to top based on the hierarchical dependencies, and generate sub-query instructions based on the sub-query tasks; and obtain a compound query instruction based on the sub-query instructions of each of the sub-query tasks.
[0107] Among them, the semantic structure splitting rules are used to analyze and process natural language texts and split natural language texts into units with clear semantic components and structures. Specifically, the semantic structure splitting rules involve multiple aspects of natural language processing, including syntactic analysis, semantic role labeling, entity recognition, relationship extraction, etc., which can be achieved by fine-tuning existing pre-training models (such as BERT, GPT, etc.). That is to say, in this embodiment, the semantic structure splitting rules can be to train the pre-training model by using training text and labeling semantic units, so that they are built into the processing logic of the pre-training model. The pre-training model that has completed this training is the second text processing model.
[0108] In this embodiment, the task decomposition prompt text provides clear guidance to the second text processing model, so that it can decompose the original natural query statement into multiple sub-query statements with hierarchical dependencies based on the semantic structure characteristics of the natural query statement and the preset semantic structure splitting rules. This process is similar to subdividing a large problem into multiple small problems, and each small problem (i.e., sub-query statement) is more specific and easier to handle. For example, for the query "Please query the per capita income of the top five cities in terms of population", the split is "Query the top five cities in terms of population" and "Query the per capita income of the top five cities in terms of population".
[0109] After the split is complete, the model will understand the subquery tasks corresponding to each subquery statement from bottom to top, based on the hierarchical dependencies between these subquery statements. This approach, from concrete to abstract, from local to global, helps the model more accurately grasp the user's query intent and generate corresponding subquery instructions. Subsequently, the model will further integrate the subquery instructions generated by each subquery task to form a complete composite query instruction. This composite query instruction not only contains all the information of the user's original query, but also improves the accuracy and efficiency of the query through task decomposition and subquery instruction generation.
[0110] In summary, this embodiment introduces task decomposition prompt text. By understanding task decomposition and hierarchical dependencies, the model can more accurately grasp the user's query needs and generate query instructions that better align with the user's intent. This not only improves query accuracy but also significantly shortens query response time, enhancing the user experience.
[0111] The above embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art may make various modifications and improvements without departing from the spirit of the present application, and the present application is intended to encompass such modifications and variations.
Claims
1. A query method based on query auxiliary information, characterized in that: The following steps are involved: Obtaining a natural query statement input by a user and user information of the user; Acquire auxiliary query information of the user according to the user information; wherein the auxiliary query information is additional information associated with the user and specific to the natural query statement; Obtaining various query fields of a preset constellation data model, and determining query fields associated with the natural query statement as candidate query fields; wherein the constellation data model includes a structured data table and query fields in the data table; Inputting the natural query statement, the candidate query fields, the query auxiliary information, and a preset first task processing text into a first text processing model to obtain a plurality of target query fields; 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 in combination with the query auxiliary information, and to determine the candidate query fields that meet the query intent as target query fields; Determining at least one target data table including only the target query field from the constellation data model; Inputting the natural query statement and the target data table into a query instruction generation model to obtain a query instruction; wherein the query instruction generation model is used to understand the query intent of the natural query statement, determine a query task that meets the query intent, and generate a query instruction based on the target data table and the query task; Based on the query instruction, querying from the data warehouse corresponding to the constellation data model to obtain a query result of the natural query statement; The query auxiliary information includes synonym information; the step of obtaining the user's query auxiliary information based on the user information includes: Perform entity segmentation recognition on the natural query sentence to obtain a number of entity segmentations; Determine a synonym information database corresponding to the user information, and determine a synonym corresponding to any of the entity participles from the synonym information database; Obtaining synonym information according to the synonyms of each entity segmentation; The query instruction generation model is a second text processing model; the step of inputting the natural query statement and the target data table into the query instruction generation model to obtain a query instruction includes: The natural query statement, the target data table and the preset second task processing text are input into the second text processing model to obtain a query instruction; 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, determine the query task that meets the query intent, and generate a query instruction based on the target data table and the query task.
2. The query method based on query auxiliary information according to claim 1, characterized in that: Before the step of obtaining the user's query auxiliary information according to the user information, the step further includes: In response to a synonym information creation instruction, parsing the synonym information creation instruction to obtain user information and synonym information; the synonym information includes a standard vocabulary and a user's habitual expression vocabulary corresponding to the user information for the standard vocabulary; The synonym information is added to the synonym information database corresponding to the user information.
3. The query method based on query auxiliary information according to claim 1, characterized in that: The step of obtaining each query field of the preset constellation data model and determining the query field associated with the natural query statement as a candidate query field includes: Get each query field of the preset constellation data model; A query field whose semantic similarity with the natural query statement or any of the entity segmentations is greater than a preset similarity threshold is determined as a candidate query field.
4. The query method based on query auxiliary information according to claim 1, characterized in that: 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 in combination with input business knowledge; After the step of performing entity segmentation recognition on the natural query sentence to obtain a plurality of entity segmentations, the method further includes the following steps: Based on the natural query sentence and the entity segmentation, relevant business knowledge is retrieved from a preset business knowledge base; The step of inputting the natural query sentence, the candidate query fields, the query auxiliary information, and the preset first task processing text into the first text processing model to obtain a plurality of target query fields includes: The natural query statement, the candidate query fields, the query auxiliary information, the business knowledge, and a preset first task processing text are input into a first text processing model to obtain a plurality of target query fields.
5. The query method based on query auxiliary information according to claim 1, characterized in that: 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 in combination with the input query semantic enhancement information; The step of inputting the natural query statement, the target data table, and the preset second task processing text into the second text processing model to obtain a query instruction includes: According to the user information, obtaining the user's query semantic enhancement information from a preset query semantic enhancement information library; The natural query statement, the target data table, the query semantic enhancement information and the preset second task processing text are input into a second text processing model to obtain a query instruction.
6. The query method based on query auxiliary information according to claim 1, characterized in that: The query task pointed to by the natural query statement is a compound query task; the second task processing text is used to prompt the second text processing model to determine a compound query task that meets the query intent of the natural query statement, and generate a compound query instruction based on the target data table and the compound query task; the compound query instruction includes several query instructions with hierarchical dependencies.
7. The query method based on query auxiliary information according to claim 6, characterized in that: The second task processing text includes a task decomposition prompt text; the task decomposition prompt text is used to prompt the second text processing model to split the natural query statement into several sub-query statements with hierarchical dependencies according to the semantic structure characteristics of the natural query statement and the preset semantic structure splitting rules; understand the sub-query tasks corresponding to each of the sub-query statements from bottom to top according to the hierarchical dependencies, and generate sub-query instructions according to the sub-query tasks; and obtain a compound query instruction according to the sub-query instructions of each of the sub-query tasks.
8. The query method based on query auxiliary information according to claim 1, characterized in that: The target query field includes a dimension field and a metric field; the constellation data model records a plurality of data tables, basic fields included in each data table, and graph relationships between each data table; the graph relationship includes at least a directed graph relationship; The step of determining at least one target data table including only the target query field from the constellation data model comprises: Determine a data table in the constellation data model that contains any one or more metric fields as a target data table; Taking the target data table as a root node, determining other data tables in the constellation data model that can reach the target data table based on the graph relationship, and using each target data table as a fact table and the other data tables that can be reached by the fact table as dimension tables, thereby obtaining several target star data models; Removing edge dimension tables that do not include the dimension fields in the target star data model, removing basic fields other than the metric fields in any fact table of the target star data model, and removing basic fields other than the dimension fields in any dimension table of the target star data model; A target data table is obtained according to the target star data model.
Citation Information
Patent Citations
Data query method and device based on text processing model
CN118708704A
Large model training method and data query method based on large model
CN118780398A