Data query method, device, program product and medium based on large language model

By constructing a pre-defined knowledge base and using vector matching technology, the problem of low SQL accuracy in data querying caused by large language models was solved, achieving accurate mapping between users' colloquial expressions and database queries, thus improving the accuracy and convenience of data queries.

CN120804298BActive Publication Date: 2025-11-28KOUBEI SHANGHAI INFORMATION TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511300329.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-11
Publication Date
2025-11-28
Estimated Expiration
2045-09-11

AI Technical Summary

Technical Problem

Existing large language models generate low-quality SQL during data querying, resulting in low query accuracy and difficulty in accurately matching semantic errors between users' colloquial expressions and professional database queries, especially in the case of industry terms and abbreviations.

Method used

A pre-defined knowledge base is constructed to store standard descriptions, colloquial descriptions, and their corresponding vectors of query elements. Vector matching is used to identify the user's natural language query elements and generate accurate query statements. Retrieval Enhancement Generation (RAG) technology is introduced to retrieve similar queries from the case library. Structured query element templates and a vector engine are used to accurately extract and generate SQL.

Benefits of technology

It significantly reduces the semantic error between users' colloquial expressions and database queries, improves the accuracy and convenience of data queries, ensures the accurate execution of complex queries, and reduces the user's understanding and operation costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120804298B_ABST
    Figure CN120804298B_ABST
Patent Text Reader

Abstract

The specification provides a data query method, device, program product and medium based on a large language model, the method comprising: obtaining a natural language query of a user and inputting it to a preset large language model; determining a description text of a current query element required for generating a current query statement according to a recognition result of a query element contained in the natural language query by the large language model; obtaining a current vector corresponding to the description text of the current query element; determining a standard description of a matching query element and field information of the matching query element in a data table based on a preset knowledge base by using a matching vector matched with the current vector; the preset knowledge base stores: a preset standard description of a query element, a preset colloquial description of a query element, a vector of the colloquial description, and a relationship of field information of the preset query element in the data table; and generating the current query statement for data query according to the standard description of the matching query element and the field information in the data table.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This manual relates to the field of artificial intelligence technology, and in particular to data query methods, devices, program products and media based on large language models. Background Technology

[0002] Currently, Large Language Models (LLMs) are becoming increasingly popular. For example, in the field of data querying, users can ask questions to LLMs, which can then be converted into Structured Query Language (SQL) that can be executed in a database. However, the quality of SQL generated by LLMs is currently not high, resulting in low accuracy in data queries. Summary of the Invention

[0003] To overcome the problems existing in related technologies, this manual provides data query methods, devices, program products, and storage media.

[0004] According to a first aspect of the embodiments of this specification, a data query method is provided, the method comprising:

[0005] The system obtains the user's natural language query and inputs it into a preset large language model. Based on the recognition results of the query elements contained in the natural language query by the large language model, it determines the descriptive text of the current query elements required to generate the current query statement.

[0006] Obtain the current vector corresponding to the description text of the currently queried element;

[0007] Based on a preset knowledge base, using the matching vector that matches the current vector, the standard description of the matching query element and the field information of the matching query element in the data table are determined; wherein, the preset knowledge base stores: the standard description of the preset query element, one or more colloquial descriptions of the preset query element, the vector of the colloquial description, and the correspondence between the field information of the preset query element in the data table.

[0008] Based on the standard description of the matching query element and the field information of the matching query element in the data table, the current query statement is generated to perform data query.

[0009] According to a second aspect of the embodiments of this specification, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method embodiments described in the first aspect above.

[0010] According to a third aspect of the embodiments of this specification, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the method embodiments described in the first aspect above.

[0011] According to a fourth aspect of the embodiments of this specification, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the method embodiments described in the first aspect above.

[0012] The technical solutions provided in the embodiments of this specification may include the following beneficial effects:

[0013] In this embodiment, a pre-defined knowledge base is designed to store: standard descriptions of pre-defined query elements, one or more colloquial descriptions of the pre-defined query elements, vectors of the colloquial descriptions, and the correspondence between the field information of the pre-defined query elements in a data table. A large language model is designed to identify query elements in the user's natural language query, determine the descriptive text of the current query element required to generate the current query statement, and perform vector matching between the current vector corresponding to the descriptive text of the current query element and the vector of the colloquial description in the knowledge base. This associates the standard description of the matching query element with the field information of the matching query element in the data table, generating the current query statement for data querying. Therefore, this embodiment can solve the semantic error between "user colloquial expression" and "database professional query," achieving accurate identification of industry jargon, abbreviations, and vague expressions in the user's natural language query, avoiding query failures caused by non-standard user expressions, and significantly reducing the semantic understanding error of NL2SQL.

[0014] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this specification. Attached Figure Description

[0015] Figure 1A This is a schematic diagram of the architecture of a data query system illustrated in this specification according to an exemplary embodiment.

[0016] Figure 1B This is a flowchart illustrating a data query method according to an exemplary embodiment of this specification.

[0017] Figure 1C This is a schematic diagram illustrating a client page according to an exemplary embodiment of this specification.

[0018] Figure 2A This is a flowchart illustrating another data query method according to an exemplary embodiment of this specification.

[0019] Figure 2BThis is a schematic diagram of an interactive process illustrated in this specification according to an exemplary embodiment.

[0020] Figure 2C This is a schematic diagram of a data query system illustrated in this specification according to an exemplary embodiment.

[0021] Figure 3 This is a flowchart illustrating another data query method according to an exemplary embodiment of this specification.

[0022] Figure 4 This is a hardware structure diagram of a computer device containing a data query device according to an exemplary embodiment of this specification.

[0023] Figure 5 This is a block diagram illustrating a data query device according to an exemplary embodiment of this specification.

[0024] Figure 6 This is a block diagram illustrating another data query apparatus according to an exemplary embodiment of this specification. Detailed Implementation

[0025] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this specification. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this specification as detailed in the appended claims.

[0026] The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of this specification. The singular forms “a,” “the,” and “the” as used in this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any and all possible combinations of one or more of the associated listed items.

[0027] It should be understood that although the terms first, second, third, etc., may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this specification, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to determination."

[0028] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this manual are all information and data authorized by the user or fully authorized by all parties. The collection, use and processing of related data shall comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals shall be provided for users to choose to authorize or refuse.

[0029] The technical solution of this invention can be applied to the transaction and delivery services of instant e-commerce platforms, such as Taobao Flash Sale, Taoxianda, Ele.me takeaway and retail.

[0030] The rapid development of Large Language Models (LLMs), especially in natural language understanding and generation, has demonstrated powerful capabilities, offering new possibilities for natural language-driven data querying. However, existing technologies that convert user-generated natural language queries into Structured Query Language (SQL) statements (NL2SQL) suffer from low query accuracy, the "big model illusion," and difficulty in accurately matching industry and enterprise-specific terminology, thus limiting user experience and the accuracy of data results. For example, it is difficult to accurately map colloquial expressions used by users (such as "net_gmv" and "direct_food_sales") to specialized fields in data tables (such as "net_gmv" and "direct_food_sales").

[0031] Based on this, this specification provides a data query method. This embodiment constructs a preset knowledge base and uses vector matching to solve the mapping problem between colloquial expressions in natural language and structured fields in a database, improving the convenience and accuracy of user queries. The embodiments of this specification will now be described in detail.

[0032] Figure 1A This is a schematic diagram of the architecture of a data query system provided in an exemplary embodiment. For example... Figure 1A As shown, the system may include a server 11, a network 12, and several terminals, including but not limited to a personal computer (PC) 13, a mobile phone 14, etc.

[0033] Server 11 can be a physical server containing an independent host, or it can be a virtual server hosted in a host cluster. During operation, server 11 can run server-side programs for a specific application to implement the relevant functions of that application. For example, when server 11 runs a data query service program, it can act as a corresponding data query server.

[0034] PC13 and mobile phone14 are just some of the types of terminals that users can use. In reality, users can obviously also use terminals such as tablets, laptops, PDAs, wearable devices (such as smart glasses, smartwatches, etc.), etc., and one or more embodiments in this specification do not limit this. During operation, the terminal can run a client-side program of an application to implement the relevant functions of that application. For example, the delivery capacity client in this embodiment is an application installed on the terminal, or it can be a mini-program, quick app, or other similar form. Of course, when using web technologies such as HTML5 or similar, the relevant functions can be implemented through a page displayed by a browser. This browser can be a standalone browser application or a browser module embedded in some applications.

[0035] As for the network 12 that enables interaction between terminals such as PC13 and mobile phone 14 and server 11, communication can be achieved using either wired or wireless networks based on the communication methods supported by the respective terminals. This specification does not impose any restrictions on this. For example, PC13 can support both wired and wireless communication, so it can use either wired or wireless networks as needed. Mobile phone 14 typically only supports wireless communication, so it can use a wireless network for communication.

[0036] like Figure 1B As shown, Figure 1B This is a flowchart illustrating a dialogue method according to an exemplary embodiment, comprising the following steps:

[0037] In step 102, the user's natural language query is obtained and input into a preset large language model. Based on the recognition results of the query elements contained in the natural language query by the large language model, the descriptive text of the current query elements required to generate the current query statement is determined.

[0038] In step 104, the current vector corresponding to the description text of the current query element is obtained;

[0039] In step 106, based on a preset knowledge base, the standard description of the matching query element and the field information of the matching query element in the data table are determined using the matching vector that matches the current vector; wherein, the preset knowledge base stores the correspondence between: the preset standard description of the query element, one or more colloquial descriptions of the preset query element, the vector of the colloquial description, and the field information of the preset query element in the data table.

[0040] In step 108, a current query statement is generated to perform data query based on the standard description of the matching query element and the field information of the matching query element in the data table.

[0041] As an example, the data query method in the embodiments of this specification can be provided by... Figure 1A The data query method can be executed on either a server or a client. For example, a client running within the terminal can provide a question-and-answer input function to the user, which can acquire the user's input. This input function includes, but is not limited to, voice input, text input, and visual input. A single input from the user can include one or more of the aforementioned voice, text, images, or video. Optionally, the client can send the acquired user input to the server, which then executes the method of this embodiment to generate SQL, uses the generated SQL to query the data, and returns it to the client for the user. Alternatively, in other scenarios, it is also optional for some processes in the data query method of this embodiment to be executed on the client and some processes to be executed on the server; this embodiment does not limit this.

[0042] As an example, the data query in this embodiment may include a query operation (SELECT) to extract data from the database, commonly known as "data retrieval".

[0043] Considering that in practical applications, it is difficult to accurately match user queries with technical terms (technical terms refer to indicators, dimensions, and other information developed by technical research and development, ensuring structure, determinism, and uniqueness), some industry-recognized terms, abbreviations, or jargon (outside the censorship) become "ineffective," making it difficult to achieve accurate NL2SQL. This embodiment pre-constructs a knowledge base, which stores standard descriptions of preset query elements, one or more colloquial descriptions of the preset query elements, vectors of the colloquial descriptions, and the correspondence between the preset query elements and field information in the data table.

[0044] As an example, colloquial descriptions of each query element can be collected in advance, and the aforementioned correspondence can be established. Each query element can have a standard description, while the number of colloquial descriptions can be one or more. A vector generation model can be used in advance to generate corresponding vectors for each colloquial description; the method of generating vectors in step 104 can be consistent with the method of generating vectors for the colloquial descriptions in advance. As an example, a vector engine can be built for the vectors of each colloquial description in the preset knowledge base, as needed, to perform vector retrieval through the vector engine.

[0045] For example, taking the standard description of a certain indicator, "net GMV", as an example, its colloquial description can include "net G". A vector of "net G" can be generated in advance, and the knowledge entries of this indicator can be stored in a preset knowledge base: standard description "net GMV", colloquial description "net G", vector of colloquial description "net G", and field information of this indicator in the data table.

[0046] As an example, the field information of the query elements stored in the default knowledge base in the data table includes, but is not limited to: field name, field data type, and table information of the data table in which the field is located (such as table name).

[0047] As an example, the query elements in this embodiment include, but are not limited to: indicators and their corresponding aggregation types, dimensions (including dimension names and dimension values), filtering conditions that represent selecting the required dimension values ​​from the dimensions in the data table, time range, year-on-year and month-on-month comparison types, custom comparison time periods, sorting fields, grouping dimensions, and quantity limits (such as limit), etc. Among them:

[0048] A metric refers to a numerical value that a user wants to query, corresponding to the target field in a SELECT statement in SQL. In practical applications, metrics may need to be calculated using certain methods (e.g., sales revenue, number of users, etc., need to be obtained by summation). Optionally, the relevant information about a metric may include the metric name and aggregation type; the metric name refers to the business concept identifier, which is represented by the field name in SQL. The aggregation type refers to the numerical calculation method, which is represented by the aggregation function in SQL, such as the SUM function, the AVG function, and functions that return the number of records that meet specified conditions (e.g., the COUNT(DISTINCT) function).

[0049] A dimension refers to a field name in a data table, while a dimension value is the specific value that the dimension takes. It can be understood as a specific instance of the dimension, used to limit the scope of analysis; it can be used to generate SQL WHERE / HAVING clauses, etc. In practical applications, dimension values ​​are not mandatory in users' natural language queries; they are not required when querying overall values. A filter condition refers to the conditions used to select desired dimension values ​​from a specific dimension in a data table.

[0050] A time range refers to a time window for data, such as the WHERE clause in SQL; it is the time interval in which the data was generated, providing a time constraint for the query. If the user's natural language query does not include a time range, valid data cannot be located.

[0051] Year-on-year and month-on-month comparisons refer to the calculation method for comparison with the same period in history. In SQL, this is equivalent to window functions or multi-table JOINs, representing the calculation rules for the growth rate of the user's current specified period and the benchmark period to be compared. For example, the calculation intent of this query element can be declared at the DSL layer to avoid errors caused by LLM directly generating complex SQL.

[0052] Custom comparison time period refers to any comparison period specified by the user (user-defined time comparison benchmark), which can be a subquery or CTE expression in SQL.

[0053] The sorting field refers to the sorting criteria of the result set. It is the ORDER BY clause in SQL, which specifies the order in which the query results are arranged.

[0054] Grouping dimension is a high-level form of dimension (multi-level grouping), which is equivalent to GROUP BY ROLLUP / CUBE in SQL and can support multi-level aggregation of dimension combinations.

[0055] The quantity limit, or the upper limit of the number of rows returned, is the LIMIT / TOP clause in SQL, which can control the size of the data in the query results.

[0056] Based on this, this embodiment can determine the descriptive text of the current query element required to generate the current query statement from the user's natural language query. In this embodiment, the user's natural language query can be obtained and input into a preset large language model. The large language model and other methods are used to identify whether the user's natural language query contains descriptive text representing the query element. The large language model can output a recognition result for the input natural language query. The recognition result can indicate whether the user's natural language query contains query elements, and if it is determined that it contains query elements, the recognition result can also include specific query element information. In practical applications, other information input to the large language model can be set as needed, such as prompt words, etc. This embodiment does not limit this.

[0057] In some examples, obtaining the user's natural language query and inputting it into a preset large language model includes:

[0058] Retrieve similar historical cases from a pre-defined case library that are semantically similar to the natural language query;

[0059] The similar historical cases, the knowledge in the preset knowledge manual, the preset structured query element template, and the natural language query are input into the preset large language model;

[0060] The case library stores multiple historical query texts, each of which has a corresponding historical structured query element.

[0061] The preset knowledge manual includes: a mapping relationship between the standard descriptions and colloquial descriptions of preset query elements;

[0062] The structured query element template defines the various query elements that need to be extracted.

[0063] As an example, this embodiment designs a process in which a large language model extracts key information (descriptive text of each query element) from a natural language query based on multiple prompts.

[0064] As an example, a case library can be pre-built, which contains multiple historical query texts, each with corresponding historical structured query elements. In practical applications, the similarity between the user's natural language query vector and the vectors of each historical query text in the case library can be used as a criterion for determining whether they are similar, and a similarity threshold can be set as needed. This embodiment does not limit this.

[0065] For example, if a user's natural language query is: "What was the transaction volume in Shanghai yesterday?", the following two similar examples from the case library can be used:

[0066] "What was Beijing's transaction volume yesterday?": "{"Indicator":[{"Indicator Name":"Transaction Volume","Aggregation Type":"Sum"}],"All Dimensions":["Cities"],"Dimension Values":["Shanghai"],"Filter Criteria":["City=Beijing"],"Time Period":["${Yesterday}"],"Comparison Time Period":[],"Sort Field":[],"Grouping Dimension":[],"Limit": null}."

[0067] "How many valid orders were there in Shanghai yesterday?": {"Indicator":[{"Indicator Name":"Valid Orders","Aggregation Type":"Sum"}],"All Dimensions":["City"],"Dimension Value":["Shanghai"],"Filter Criteria":["City=Shanghai"],"Time Period":["${Yesterday}"],"Comparison Time Period":[],"Sort Field":[],"Grouping Dimension":[],"Limit": null}.

[0068] In the above example, "What was the transaction volume in Beijing yesterday?" is the historical query text, and the content after the colon is the corresponding historical structured query element.

[0069] As an example, the preset knowledge manual includes: a mapping relationship between the standard description and the colloquial description of preset query elements; for example, it may include: colloquial and standard descriptions of each indicator in the data table; colloquial and standard descriptions of each dimension in the data table; and colloquial and standard descriptions of the dimension values ​​under each dimension in the data table. The preset knowledge manual may also include other information as needed, and this embodiment does not limit this.

[0070] As an example, the knowledge manual in this embodiment may include:

[0071] Fixed terminology:

[0072] Direct-operated catering: refers to both direct-operated and catering services. "Direct-operated" and "catering services" are both dimensional values. The dimension corresponding to "direct-operated" is "direct agent," and the dimension corresponding to "catering services" is "catering zero." ......

[0074] The dynamic knowledge base (the metrics and dimensions that the user can query) includes:

[0075] Available metrics: Net GMV, number of valid orders, gross GMV, average daily user experience (UE);

[0076] Available dimensions and their corresponding values:

[0077] Cities (Shanghai, Hangzhou, Beijing, Suzhou, Shenzhen, etc.);

[0078] Time slots (breakfast, lunch, afternoon tea, dinner, late-night snack);

[0079] ......".

[0080] As an example, the structured query element template in this embodiment can be understood as a business intent description specification. It can constrain the extraction scope and organization of query elements through predefined field types and structures, achieving a reliable conversion from natural language to executable queries. As an example, the format of the structured query element template can be JSON, XML, etc., and this embodiment does not limit this. The historical structured query elements corresponding to the historical query text in the above embodiment are illustrated using JSON as an example.

[0081] Optionally, the structured query element template defines the various query elements to be extracted, which can be set according to actual needs. For example, the query elements mentioned in the previous embodiments can be defined. As an example, the structured query element template can declare the following query elements through predefined field types:

[0082] Essential elements: indicator information, time range;

[0083] Optional elements include: dimension category, dimension value, filter criteria, time series comparison rules, result sorting rules, grouping rules, and result quantity limits.

[0084] As an example, a structured query feature template could be:

[0085] "{\"Indicator\":[{\"Indicator Name\":\"???\",\"Aggregation Type\":\"???\"}],\"All Dimensions\":[\"???\"],\"Dimension Values\":[\"???\"],\"Filter Conditions\":[\"???\"],\"Time Period\":[\"???\"],\"Comparison Time Period\":[???],\"Sort Field\":[???],\"Grouping Dimension\":[???],\"limit\": ???}".

[0086] The “???” character refers to the descriptive text to be extracted. During extraction, the corresponding descriptive text can be extracted from the user’s natural language query and filled in according to the above template. If the above optional query elements are not extracted, they can be left blank.

[0087] It can be understood that this template is essentially a container for structured query features, which limits the extraction of the following three types of features through predefined fields:

[0088] ① The target definition elements (metrics / aggregation types) determine what to SELECT in SQL;

[0089] ② Constraint elements (dimensional values / filter conditions / time range) can determine the WHERE condition in SQL;

[0090] ③ Control elements (sorting / grouping / limit) in SQL determine how the query results are organized.

[0091] As an example, the JSON fields contained in the structured query feature template can be used for the following purposes:

[0092]

[0093] As can be seen from the above embodiments, this embodiment uses Retrieval-Augmented Generation (RAG) technology, which can retrieve cases similar to the user's query intent from the existing case library. Through cumulative learning, it can improve the ability to accurately extract diverse user intents.

[0094] Optionally, in practical applications, this large language model can be obtained through fine-tuning. For example, during fine-tuning, the training samples of the model are natural language query samples, and the labels of these samples can be the structured query elements corresponding to the natural language query samples. For example, the two cases mentioned above can serve as samples and labels, such as "What was the transaction amount in Beijing yesterday?" as a natural language query sample, and the corresponding historical structured query elements as labels. The differences between the structured query elements identified by the large language model for the input natural language query sample and the structured query elements corresponding to that sample can be obtained. The model is trained (i.e., model parameter updates) with minimizing these differences as the optimization objective. There are multiple structured query elements, and the aforementioned differences can be the differences between each structured query element output by the large language model and each structured query element corresponding to the sample. For example, the difference between "indicator name" in the structured query elements output by the large language model and "indicator name" in the structured query elements corresponding to the sample. Similarly, differences in aggregation type, dimensionality, etc., can also be obtained. Specific differences can optionally be represented by the similarity between the vector of the structured query elements output by the large language model and the vector of the structured query elements corresponding to the sample; the optimization objective can be the weighted average of each structured query element, and the weights of each structured query element can be the same or set as needed. This embodiment does not limit this.

[0095] Optionally, considering the presence of multiple structured query elements, as indicated by the structured query element template above, the structured query elements corresponding to different natural language query samples may be different. For example, some natural language query samples only contain indicators and time ranges, without other structured query elements, while others contain more or all structured query elements. For the training process, multiple batches of training samples can be designed as needed, with different structured query elements corresponding to the labels of different batches. Training can be performed sequentially using each batch of training samples, following the increasing order of the number of structured query elements contained in the labels corresponding to the samples. For example, the labels corresponding to the first batch of training samples might contain structured query elements of the first category (such as indicators and time periods / time ranges), the labels corresponding to the second batch of training samples might contain structured query elements of the second category in addition to those of the first category, the labels corresponding to the third batch of training samples might contain structured query elements of the first, second, and third categories, and so on. The batches containing important structured query elements (such as indicators and time ranges) are ranked higher than the batches containing other structured query elements. In this way, the accuracy of the large language model in extracting important structured query elements can be prioritized for training, and the accuracy of the large language model in extracting other structured query elements can be gradually improved by gradually adding other structured query elements; while important structured query elements are included in each batch of training samples, enabling the large language model to continuously ensure the accuracy of identifying important structured query elements.

[0096] Meanwhile, considering that dimensions and dimensional values ​​are highly scenario-dependent, this embodiment compiles them into a knowledge manual for large models to refer to, further improving the accuracy of extracting key information such as "indicators" and "dimensions".

[0097] As an example, for the descriptive text of the obtained current query element, a vector can be generated, which is referred to as the current vector in this embodiment. A matching vector matching the current vector can be determined in a preset knowledge base. After determining the matching vector, based on the aforementioned correspondence stored in the preset knowledge base, the standard description of the query element corresponding to the matching vector and its field information in the data table can be determined. This allows for the generation of a current query statement corresponding to the user's natural language query for data retrieval.

[0098] As an example, the method for determining whether vectors match can be set according to actual needs. For example, it can be determined by calculating the similarity between vectors. This embodiment does not limit this.

[0099] As an example, the query elements include at least an indicator and a time range; the descriptive text for determining the current query elements required to generate the current query statement may include:

[0100] Determine whether the indicator description text representing the queried indicator and the time description text representing the queried time range can be obtained from the natural language query;

[0101] If the indicator description text is not included, a prompt message will be output to the user to supplement the indicator to be queried in order to obtain the indicator description text of the indicator to be queried.

[0102] If the time description text is not included, output a prompt message to the user to supplement the time range to be queried in order to obtain the time description text of the time range to be queried;

[0103] The obtained indicator description text and time description text are used as the description text of the current query element.

[0104] Considering the needs of data retrieval scenarios, this embodiment designs a completeness check for key information in natural language queries. Specifically, this embodiment designs a check to determine whether the indicator description text representing the queried indicator and the time description text representing the queried time range can be obtained from the natural language query. If either cannot be obtained, a corresponding prompt message will be output, for example:

[0105] If the indicator description text is not included, a prompt message can be output to ask the user to supplement the indicator to be queried. The specific prompt message can be configured according to actual needs. For example, the prompt message could be "No indicator you want to query was detected, please supplement," etc. This embodiment does not limit this. In this way, the user can enter information representing the indicator to be queried (if any) at the prompt, and obtain the indicator description text of the indicator to be queried from the user's new input.

[0106] If the time description text is not included, a prompt message can be output to ask the user to supplement the time range to be queried. The specific prompt message can be configured according to actual needs. For example, the prompt message could be "No time range you queried was detected, please supplement it," etc. This embodiment does not limit this. In this way, the user can enter information representing the time range to be queried (if any) at the prompt, and the time description text of the time range to be queried can be obtained from the user's new input.

[0107] In practical applications, if no indicator description text or time description text is detected, a prompt message can be output. This prompt message can prompt the user to add the indicator to be queried, and it can also prompt the user to add the time range to be queried.

[0108] In some examples, the query elements also include dimensions; the descriptive text for determining the current query elements required to generate the current query statement also includes:

[0109] Determine whether a dimension description text representing the current query dimension can be obtained from the natural language query. If so, use the obtained dimension description text as the description text of the current query element.

[0110] If not, if it is determined that the natural language query involves dimensional information, output a prompt message to the user to supplement the current query dimension, so as to obtain the dimensional description text of the current query dimension and use it as the description text of the current query element.

[0111] In this embodiment, if the query does not involve dimension information (e.g., only querying "total sales"), then dimension description text is unnecessary and can be skipped. If the natural language query explicitly involves dimension information (e.g., "region" in "sales in each region"), then dimension description text must be extracted. If no explicit dimension information is obtained (e.g., the user says "check sales, by region" but does not specify which region), the user can be prompted to provide details of the dimension information. Thus, this embodiment can obtain semantically clear dimension description text.

[0112] In some examples, determining the standard description of the matching query element and the field information of the matching query element in the data table using the matching vector that matches the current vector may include:

[0113] Based on the vectors stored in the preset knowledge base, recall a set of candidate vectors similar to the current vector;

[0114] Determine whether there exists a candidate vector in the candidate vector set whose similarity to the current vector is higher than a preset threshold;

[0115] If so, the determined candidate vector is used as the matching vector, and the standard description of the matching query element corresponding to the matching vector and the field information of the matching query element in the data table are determined.

[0116] To ensure the accuracy of data queries, this embodiment can recall a set of candidate vectors similar to the current vector based on the vectors stored in the knowledge base. The set of candidate vectors can contain one or more candidate vectors. In practical applications, such as using a vector engine, the similarity between the candidate vector and the current vector can be obtained when recalling candidate vectors. This embodiment can set a threshold as needed. This threshold is used to characterize a high similarity between the candidate vector and the current vector. Therefore, for candidate vectors with a similarity higher than the preset threshold, the semantics are clear, and this embodiment can determine them as matching vectors that match the current vector. The standard description of the matching query element corresponding to the matching vector and the field information of the matching query element in the data table are then determined.

[0117] If there is no candidate vector in the candidate vector set whose similarity to the current vector is higher than a preset threshold, i.e. the semantics are ambiguous, specific processing methods can be set as needed in practical applications. This embodiment does not limit this.

[0118] In practical applications, query elements can fall into multiple categories, such as indicators and dimensions. This embodiment also allows for categorized recall. Vector libraries for different categories of query elements are set up. For example, for indicator description text representing the current query indicator in a natural language query, the corresponding candidate vector set is recalled from the indicator vector library (which stores vectors of colloquial descriptions of each indicator); for dimension description text representing the current query dimension in a natural language query, the corresponding candidate vector set is recalled from the dimension vector library (which stores vectors of colloquial descriptions of each dimension). Optionally, when both indicator description text and dimension description text are extracted, the above two recall steps can be executed in parallel to improve processing efficiency.

[0119] In some examples, determining the standard description of the matching query element and the field information of the matching query element in the data table using the matching vector that matches the current vector may further include:

[0120] If there is no vector in the candidate vector set with a similarity higher than a preset threshold, the standard description corresponding to each candidate vector in the candidate vector set is obtained using the preset knowledge base;

[0121] The system outputs a prompt message to the user to select a standard description from the standard descriptions corresponding to each candidate vector. The standard description selected by the user is used as the standard description of the matching query element, and the field information of the corresponding matching query element in the data table is determined.

[0122] As an example, such as Figure 1CThe diagram shown is a schematic representation of a client-side page according to an exemplary embodiment of this specification. In this embodiment, the user's natural language query is taken as "GMV in Hangzhou last week". The query elements (i.e., key information) are obtained by extracting key information from this natural language query, such as... Figure 1C As shown, taking JSON format as an example, it can include the following:

[0123] {"Indicator":[{"Indicator Name":"GMV","Aggregation Type":"Sum"],"All Dimensions":["City"],"Dimension Value":["Hangzhou"],"Filter Conditions":["City=Hangzhou"],"Time Period":["20250711","20250717"],"Year-on-Year / Month-on-Month Comparison Type":[],"Custom Comparison Time Period":[],"Sort Field":[],"Group Dimension":[],"Limit":null}.

[0124] The descriptive text of each query element extracted above can be as follows: Figure 1C The results are displayed on the client's user-interaction page for users to view and retrieve.

[0125] Based on the information extracted above, this embodiment can perform retrieval using a preset knowledge base; for example, retrieval of the indicator name "GMV", the dimension name "City", and the dimension value "Hangzhou"; based on the retrieval results, the standard descriptions of the query element dimensions can be determined as: dimension value "Hangzhou City" and dimension "City". However, the colloquial description of the indicator "GMV" makes it difficult to retrieve reliable standard descriptions. Therefore, based on the standard descriptions of the three recalled candidate indicators, "Net GMV", "Gross GMV", and "Gross Profit", a prompt message can be displayed on the client page. For example... Figure 1C As shown, the prompt message may specifically be "No GMV-related metrics have been recalled. Please select the metric you want to query." It also displays standard descriptions of three candidate metrics for recall through a drop-down list for the user to choose from.

[0126] Optionally, after a user makes a selection, the selected standard description can be obtained as the standard description for matching query elements. For example, if the user selects "Net GMV," it can be used as the standard description of the indicator. Optionally, the extracted key information can also be updated. For example, the indicator in the JSON format key information above, ""Indicator Name":"GMV"", can be updated to ""Indicator Name":"Net GMV"", and a DSL can be generated based on this updated key information later.

[0127] In addition to the above-mentioned methods for indicators, the aforementioned dimensional information can also be presented in the manner described in this embodiment. For example, if it is difficult to recall vectors with similarity higher than a preset threshold using vectors of dimensional description text (including description text of dimensional names and / or description text of dimensional values), the standard descriptions corresponding to each recalled candidate vector can be output to the user for selection.

[0128] Therefore, by introducing the aforementioned clarification interaction mechanism, this embodiment can ensure that the user's intent is clear, significantly reducing query errors and user comprehension costs.

[0129] In some examples, the method may also include:

[0130] If the preset knowledge base does not store the description text of the currently queried element, the description text of the currently queried element and the standard description selected by the user are stored and associated to update the preset knowledge base.

[0131] As an example, suppose the metric description text extracted from a user's natural language query is "Net G", and the standard descriptions of the two recalled candidate metrics are "Net GMV" and "Gross GMV". After displaying a prompt on the client page, the user selects "Net GMV". Since the colloquial description of "Net G" is not stored in the preset knowledge base, it can be associated and stored with the standard description "Net GMV". Subsequently, the preset knowledge base can be updated so that the standard description "Net GMV" in the knowledge base can be updated with the corresponding colloquial description "Net G". When other natural language queries contain "Net G", the standard description "Net GMV" can be retrieved without interrupting the user to clarify, thus improving data query efficiency.

[0132] As can be seen, in this embodiment, by cleaning and processing the data from user behavior tracking points, the semantics outside the knowledge base can be continuously updated, and the accuracy of vector calculation can be optimized, so as to achieve the effect of the knowledge base becoming more and more accurate with use.

[0133] In some examples, generating the current query statement for data retrieval may include:

[0134] After generating a structured domain-specific language, a structured query statement (SQL) is generated using the structured domain-specific language, and then the data is queried using the structured query statement.

[0135] In this embodiment, by introducing "Structured Domain-Specific Language (DSL)" as an intermediate layer, the generation process from natural language to SQL is optimized, which can reduce the difficulty of generating complex queries and improve the accuracy of SQL.

[0136] As an example, the query intent can be declared in a structured format based on the standard description of the matching query elements in step 108 and the field information of the matching query elements in the data table; for example, the aforementioned structured query element template can be used. The above DSL can be converted into executable SQL through predefined DSL-to-SQL mapping rules (such as template engines and syntax parsers). The DSL rules are independent of the SQL syntax; when the database table structure changes (such as field name modifications) or business metric definitions are updated, only the DSL-to-SQL mapping rules need to be adjusted, without modifying the upstream natural language understanding module.

[0137] This embodiment introduces a "two-step data retrieval" scheme using a semantic intermediate layer, significantly improving complex query capabilities. By introducing this semantic intermediate layer (standard semantics), the system's ability to understand and express complex query intent is effectively enhanced, significantly improving query accuracy, stability, and scalability, overcoming the limitations of the NL2SQL solution in terms of business variability and semantic parsing.

[0138] As can be seen from the above embodiments, this embodiment designs a preset knowledge base storing: a standard description of a preset query element, one or more colloquial descriptions of the preset query element, a vector of the colloquial description, and the correspondence between the field information of the preset query element in the data table. It also designs a method to determine the description text of the current query element required to generate the current query statement based on the user's natural language query, and to perform vector matching between the current vector corresponding to the description text of the current query element and the vector of the colloquial description in the knowledge base, thereby associating the standard description of the matching query element with the field information of the matching query element in the data table, and generating the current query statement for data querying. Therefore, this embodiment can solve the semantic error between "user colloquial expression" and "database professional query," achieving accurate identification of industry jargon, abbreviations, and vague expressions in the user's natural language query, avoiding query failures caused by non-standard user expressions, and significantly reducing the semantic understanding error of NL2SQL.

[0139] like Figure 2A The diagram shown is a flowchart illustrating another data query according to an exemplary embodiment of this specification. The data query process in this embodiment may include:

[0140] If the user's input natural language query is obtained, key semantic information can be extracted; specifically, it can be to try to extract indicator description text representing the current query metric, time description text representing the current query time range, and dimension description text representing the current query dimension from the natural language query.

[0141] Next, the integrity of key information can be verified based on the extraction results, that is, to determine whether the key information is complete; specifically, to determine whether the indicator description text representing the current query indicator, the time description text representing the current query time range, and the dimension description text representing the current query dimension have been extracted from the natural language query.

[0142] If key information is incomplete, this embodiment includes an interruption point to prompt the user to complete the information. Specifically, if the indicator description text is not obtained, a prompt message is output prompting the user to supplement the currently queried indicator to obtain its description text. If the time description text is not obtained, a prompt message is output prompting the user to supplement the current query time range to obtain its time description text. If it is determined that the natural language query involves dimensional information, a prompt message is output prompting the user to supplement the current query dimension. If the user terminates the process, the process can end.

[0143] After the prompt message is displayed, the steps of "extracting key semantic information" and "judging whether the key information is complete" can be executed again based on the natural language query entered by the user.

[0144] If the key information is complete, the steps of recalling standard semantics outside the warehouse can be performed; specifically, the current vector corresponding to the description text of the current query element can be obtained, and a set of candidate vectors similar to the current vector can be recalled.

[0145] Next, it can be determined whether the recall semantics are clear; for example, it can be determined whether there are candidate vectors in the candidate vector set that have a similarity to the current vector that is higher than a preset threshold.

[0146] If the semantics of the recall are unclear, for example, if there is no candidate vector in the candidate vector set that has a similarity to the current vector higher than a preset threshold, this embodiment designs an interruption node to prompt the user to clarify; for example, a drop-down selection box can be provided on the front-end interaction, and the user can clarify by making a selection; and, based on the user's selection, the standard semantics can be directly hit, avoiding the repetition of multiple steps such as extraction and recall.

[0147] If the recall semantics are determined to be clear, the steps of standard semantic assembly query DSL (NL2DSL) can be performed. For example, using the matching vector that matches the current vector, the standard description of the matching query element and the field information of the matching query element in the data table can be determined, and the DSL can be generated based on the standard semantics.

[0148] Next, the standard DSL data retrieval (DSL2SQL) steps can be performed, such as generating SQL based on the generated DSL, and executing the SQL to retrieve the data required by the user from the database.

[0149] Finally, results visualization can be performed, for example, displaying the query results in the client for users to view.

[0150] like Figure 2B The diagram shown is a schematic representation of the interaction flow according to an exemplary embodiment of this specification. Figure 2B The example shows that when a user inputs a natural language query for "Hangzhou GMV last week", steps such as key semantic extraction (e.g., extracting query elements such as indicators, dimensions, time ranges, and filtering conditions) can be performed. If the semantics are incomplete, the aforementioned prompts for supplementary information can be executed. If the semantics are complete, the step of recalling standard semantics from external sources can be executed. If the semantics are ambiguous, multiple rounds of clarification can be performed, and ambiguous semantics can be filtered through drop-down boxes. For details, please refer to the description of the aforementioned embodiment.

[0151] In the example of the natural language query "Hangzhou GMV last week" in this embodiment, the key information extracted can be as shown in 2B:

[0152] Indicator: Transaction volume

[0153] Dimension: City

[0154] Time range: 20250602-20250608

[0155] Filter criteria: City = Hangzhou

[0156] After performing the steps of retrieving standard semantics from outside the warehouse based on the above information, the standard semantics obtained are as follows:

[0157] Metric: Net GMV

[0158] Dimension: City

[0159] Time range: 20250602-20250608

[0160] Filter criteria: City = Hangzhou

[0161] Next, based on the standard semantics of the recall described above, the data query DSL (NL2DSL) can be assembled, and the DSL is shown in the table below:

[0162]

[0163] The above DSL includes the following functions:

[0164] Field selection: The select section specifies the "Net GMV" field to be extracted from the data table.

[0165] Filtering conditions: The filter part combines conditions using logical "and": filter the "city" field value "in" (inclusive) ["Hangzhou"].

[0166] Time range: The data in the ds section is limited to the time range of June 2, 2025 to June 8, 2025 (format: YYYYMMDD).

[0167] Based on the above DSL, the steps of DSL2SQL and data query can be performed using the preset standard semantic data retrieval tool.

[0168] As an example, the client-side page can display the analysis results of the natural language query "Hangzhou transaction volume last week", as shown in the table below:

[0169]

[0170] Finally, by executing the above SQL, the query results can be obtained, and the steps to display the queried net GMV on the client's page can be performed.

[0171] like Figure 2C The diagram shown is a schematic representation of a data query system according to an exemplary embodiment of this specification. The method of this embodiment can be implemented as a data query agent. Figure 2C The data query system in the system constructs a data analysis intelligent framework based on Data Search Agent, which can realize end-to-end Agent integration and business self-orchestration. The Agent can include a knowledge base, a large language model, a toolset, and a memory module. The knowledge base can contain: extraction specifications to prompt the large language model how to extract query elements from the user's natural language query; external semantics containing colloquial descriptions of query elements; standard semantics containing standard descriptions of query elements; and indicator definitions for various metrics. It can combine multidimensional semantics and search enhancement RAG technology to support efficient retrieval. The process of DSL generation and standard semantic data retrieval can be integrated into tools for the Agent to call autonomously. The memory module can include a short-term memory module and a long-term memory module. The short-term memory module can be implemented through graph states, which are snapshots of "entity-relationship-context" temporarily saved by the Agent using a graph structure when solving the current task. The long-term memory module can be processed through the aforementioned tracking and recording processes. User behavior tracking points (such as result acceptance rate, multi-round clarification results, and memory relationships between questions and queries) can be obtained through data cleaning, and vector storage can be updated. Therefore, context continuity and historical tracking can be guaranteed.

[0172] This embodiment of the system provides atomic service interfaces, facilitating the rapid construction and iteration of business agents. The user behavior tracking and data cleaning module collects multi-round interaction data, updates the vector library, and continuously optimizes knowledge representation. The underlying system supports multiple models, multiple data sources, and semantic management, ensuring flexibility and scalability in semantic understanding and data access. The logging and monitoring system enables real-time monitoring and fault diagnosis, ensuring stable and efficient system operation.

[0173] As can be seen from the above embodiments, this embodiment innovatively splits the terminology into two parts: external semantics and standard semantics, and introduces a vector engine to calculate similarity to connect the two semantics. While ensuring the semantic professionalism of the data production scenario, it provides users with sufficiently user-friendly business terminology interaction, and further improves the accuracy of key semantic extraction.

[0174] This embodiment breaks down NL2SQL into a two-step data retrieval process: NL2DSL + DSL2SQL. By introducing this scheme, the system's ability to understand and express complex query intent is effectively improved, significantly enhancing the accuracy, stability, and scalability of queries, and overcoming the limitations of the NL2SQL scheme in terms of business variability and semantic parsing.

[0175] like Figure 3 The diagram shown is a flowchart illustrating a data query method according to an exemplary embodiment of this specification. The method may include:

[0176] In step 302, after obtaining the user's natural language query, the query result is obtained based on the steps of the aforementioned data query method embodiment.

[0177] In step 304, the query results are displayed on the client.

[0178] As an example, the solution in this embodiment can be applied to the client, which can run on... Figure 1A On the terminal shown, after obtaining the user's natural language query, the client can send the natural language query to the server, which will then execute the aforementioned... Figure 1B The methods and embodiments shown above obtain the query results and return them to the client, which then displays the results. The specific methods for obtaining the query results can be found in the descriptions of the foregoing embodiments, and will not be repeated here.

[0179] Corresponding to the embodiments of the aforementioned data query method, this specification also provides embodiments of a data query device and the computer equipment on which it is applied.

[0180] The embodiments of the data query device described in this specification can be applied to computer devices, such as servers or terminal devices. The device embodiments can be implemented through software, hardware, or a combination of both. Taking software implementation as an example, as a logical device, it is formed by its processor reading the corresponding computer program instructions from non-volatile memory into memory for execution. From a hardware perspective, such as... Figure 4 The diagram shown is a hardware structure diagram of a computer device containing the data query device described in this manual. (Except for...) Figure 4 In addition to the processor, network interface, memory, and non-volatile memory shown, the computer device in which the data query device is located in the embodiment may also include other hardware depending on the actual function of the computer device, which will not be described in detail here.

[0181] like Figure 5 As shown, Figure 5 This is a block diagram illustrating a data query apparatus according to an exemplary embodiment of this specification, the apparatus comprising:

[0182] The first determining module is used to: acquire the user's natural language query and input it into a preset large language model; and determine the descriptive text of the current query element required to generate the current query statement based on the recognition result of the large language model of the query element contained in the natural language query.

[0183] The acquisition module is used to: acquire the current vector corresponding to the description text of the currently queried element;

[0184] The second determining module is used to: determine the standard description of the matching query element and the field information of the matching query element in the data table based on a preset knowledge base and using a matching vector that matches the current vector; wherein, the preset knowledge base stores the correspondence between: a preset standard description of the query element, one or more colloquial descriptions of the preset query element, a vector of the colloquial description, and the field information of the preset query element in the data table.

[0185] The query module is used to generate a current query statement for data querying based on the standard description of the matching query element and the field information of the matching query element in the data table.

[0186] In some examples, the query elements include at least an indicator and a time range; the first determining module determines the descriptive text of the current query elements required to generate the current query statement, including:

[0187] Determine whether the indicator description text representing the current query indicator and the time description text representing the current query time range can be obtained from the natural language query;

[0188] If the indicator description text is not obtained, a prompt message will be output to the user to supplement the currently queried indicator in order to obtain the indicator description text of the currently queried indicator;

[0189] If the time description text is not obtained, output a prompt message to the user to supplement the current query time range in order to obtain the time description text of the current query time range;

[0190] The obtained indicator description text and time description text are used as the description text of the current query element.

[0191] In some examples, the query elements also include dimensions; the first determining module, which determines the descriptive text of the current query elements required to generate the current query statement, further includes:

[0192] Determine whether a dimension description text representing the current query dimension can be obtained from the natural language query. If so, use the obtained dimension description text as the description text of the current query element.

[0193] If not, if it is determined that the natural language query involves dimensional information, output a prompt message to the user to supplement the current query dimension, so as to obtain the dimensional description text of the current query dimension and use it as the description text of the current query element.

[0194] In some examples, the second determining module uses a matching vector that matches the current vector to determine the standard description of the matching query element and the field information of the matching query element in the data table, including:

[0195] Based on the vectors stored in the preset knowledge base, recall a set of candidate vectors similar to the current vector;

[0196] Determine whether there exists a candidate vector in the candidate vector set whose similarity to the current vector is higher than a preset threshold;

[0197] If so, the determined candidate vector is used as the matching vector, and the standard description of the matching query element corresponding to the matching vector and the field information of the matching query element in the data table are determined.

[0198] In some examples, the second determining module, using a matching vector that matches the current vector, determines the standard description of the matching query element and the field information of the matching query element in the data table, and further includes:

[0199] If there is no candidate vector in the candidate vector set with a similarity higher than the preset threshold, the preset knowledge base is used to obtain the standard description corresponding to each candidate vector in the candidate vector set.

[0200] The system outputs a prompt message to the user to select a standard description from the standard descriptions corresponding to each candidate vector, so that the standard description selected by the user is used as the standard description of the matching query element, and the field information of the corresponding matching query element in the data table is determined.

[0201] In some examples, the device further includes an update module for:

[0202] If the preset knowledge base does not store the description text of the currently queried element, the description text of the currently queried element and the standard description selected by the user are stored and associated to update the preset knowledge base.

[0203] In some examples, the query module generates the current query statement for data retrieval, including:

[0204] After generating a structured domain-specific language, a structured query statement is generated using the structured domain-specific language, and then the data is queried using the structured query statement.

[0205] In some examples, the first determining module acquires the user's natural language query and inputs it into a preset large language model, including:

[0206] Retrieve similar historical query texts that are semantically similar to the natural language query from a pre-defined case library;

[0207] The similar historical query text, the knowledge in the preset knowledge manual, the preset structured query element template, and the natural language query are input into the preset large language model;

[0208] The case library stores multiple historical query texts, each of which has a corresponding historical structured query element.

[0209] The preset knowledge manual includes: a mapping relationship between the standard descriptions and colloquial descriptions of preset query elements;

[0210] The structured query element template defines the various query elements that need to be extracted.

[0211] like Figure 6 As shown, Figure 6 This is a block diagram illustrating another data query apparatus according to an exemplary embodiment of this specification, the apparatus comprising:

[0212] The acquisition module is used to: acquire the user's natural language query and, based on the steps of the aforementioned data query method embodiment, obtain the query result;

[0213] The display module is used to display the query results in the client.

[0214] The specific implementation process of the functions and roles of each module in the above data query device can be found in the implementation process of the corresponding steps in the above data query method, and will not be repeated here.

[0215] Accordingly, this specification also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the aforementioned data query method embodiment.

[0216] Accordingly, embodiments of this specification also provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the data query method embodiment.

[0217] Accordingly, embodiments of this specification also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the data query method embodiments.

[0218] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the solution in this specification according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0219] The above embodiments can be applied to one or more computer devices. The computer device is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions. The hardware of the computer device includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0220] The computer device can be any electronic product that can interact with the user, such as a personal computer, tablet computer, smartphone, personal digital assistant (PDA), game console, interactive network television (IPTV), smart wearable device, etc.

[0221] The computer equipment may also include network equipment and / or user equipment. The network equipment includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud based on cloud computing consisting of a large number of hosts or network servers.

[0222] The network in which the computer device is located includes, but is not limited to, the Internet, wide area network, metropolitan area network, local area network, and virtual private network (VPN).

[0223] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0224] The steps of the various methods described above are only for clarity. In practice, they can be combined into one step or some steps can be split into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent. Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but without changing the core design of the algorithm and process, are also within the scope of protection of this application.

[0225] While this specification contains numerous specific implementation details, these should not be construed as limiting the scope of any invention or the scope of the claims, but rather are primarily intended to describe features of specific embodiments of a particular invention. Certain features described in the various embodiments herein may also be implemented in combination in a single embodiment. Conversely, various features described in a single embodiment may also be implemented separately in various embodiments or in any suitable sub-combination. Furthermore, while features may function in certain combinations as described above and even initially claimed in this way, one or more features from a claimed combination may be removed from that combination in some cases, and a claimed combination may refer to a sub-combination or a variation thereof.

[0226] The terms "specific example" or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with the embodiments or examples, which are included in at least one embodiment or example of this specification. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0227] Other embodiments of this specification will readily occur to those skilled in the art upon consideration of the specification and practice of the invention claimed herein. This specification is intended to cover any variations, uses, or adaptations that follow the general principles of this specification and include common knowledge or customary techniques in the art not claimed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this specification are indicated by the following claims.

[0228] It should be understood that this specification is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this specification is limited only by the appended claims.

[0229] The above description is merely a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of protection of this specification.

Claims

1. A data query method based on a large language model, the method comprising: The system obtains the user's natural language query and inputs it into a preset large language model. Based on the recognition results of the query elements contained in the natural language query by the large language model, it determines the descriptive text of the current query elements required to generate the current query statement. Obtain the current vector corresponding to the description text of the currently queried element; Based on a preset knowledge base, using the matching vector that matches the current vector, the standard description of the matching query element and the field information of the matching query element in the data table are determined; wherein, the preset knowledge base stores: the standard description of the preset query element, one or more colloquial descriptions of the preset query element, the vector of the colloquial description, and the correspondence between the field information of the preset query element in the data table. Based on the standard description of the matching query element and the field information of the matching query element in the data table, the current query statement is generated to perform data query; The step of obtaining the user's natural language query and inputting it into a preset large language model includes: Retrieve similar historical query texts that are semantically similar to the natural language query from a preset case library, and input the similar historical query texts, knowledge from a preset knowledge manual, preset structured query element templates, and the natural language query into a preset large language model; The case library stores multiple historical query texts, each with corresponding historical structured query elements; the preset knowledge manual includes a mapping relationship between the standard description and colloquial description of the preset query elements; and the structured query element template defines the various query elements to be extracted.

2. The method according to claim 1, wherein the query elements at least include indicators and time ranges; determining the descriptive text of the current query elements required to generate the current query statement includes: Determine whether the indicator description text representing the current query indicator and the time description text representing the current query time range can be obtained from the natural language query; If the indicator description text is not obtained, a prompt message will be output to the user to supplement the currently queried indicator in order to obtain the indicator description text of the currently queried indicator; If the time description text is not obtained, output a prompt message to the user to supplement the current query time range in order to obtain the time description text of the current query time range; The obtained indicator description text and time description text are used as the description text of the current query element.

3. The method according to claim 2, wherein the query element further includes dimensions; and determining the descriptive text of the current query element required to generate the current query statement further includes: Determine whether a dimension description text representing the current query dimension can be obtained from the natural language query. If so, use the obtained dimension description text as the description text of the current query element. If not, if it is determined that the natural language query involves dimensional information, output a prompt message to the user to supplement the current query dimension, so as to obtain the dimensional description text of the current query dimension and use it as the description text of the current query element.

4. The method according to claim 1, wherein determining the standard description of the matching query element and the field information of the matching query element in the data table using the matching vector that matches the current vector includes: Based on the vectors stored in the preset knowledge base, recall a set of candidate vectors similar to the current vector; Determine whether there exists a candidate vector in the candidate vector set whose similarity to the current vector is higher than a preset threshold; If so, the determined candidate vector is used as the matching vector, and the standard description of the matching query element corresponding to the matching vector and the field information of the matching query element in the data table are determined.

5. The method according to claim 4, wherein determining the standard description of the matching query element and the field information of the matching query element in the data table using the matching vector that matches the current vector further includes: If there is no candidate vector in the candidate vector set with a similarity higher than the preset threshold, the preset knowledge base is used to obtain the standard description corresponding to each candidate vector in the candidate vector set. The system outputs a prompt message to the user to select a standard description from the standard descriptions corresponding to each candidate vector, so that the standard description selected by the user is used as the standard description of the matching query element, and the field information of the corresponding matching query element in the data table is determined.

6. The method according to claim 5, further comprising: If the preset knowledge base does not store the description text of the currently queried element, the description text of the currently queried element and the standard description selected by the user are stored and associated to update the preset knowledge base.

7. The method according to claim 1, wherein generating the current query statement for data querying includes: After generating a structured domain-specific language, a structured query statement is generated using the structured domain-specific language, and then the data is queried using the structured query statement.

8. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

9. A computer program product comprising a computer program that, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data analysis method and system based on natural language, electronic equipment and storage medium

    CN118132587A

  • Natural language intelligent number asking method and device and storage medium

    CN119025552A

  • DSL-based intelligent dialogue implementation method, device and equipment for generating SQL (Structured Query Language)

    CN119293068A