Data query method and intelligent question system
By employing a multi-level keyword matching and semantic correction mechanism in the intelligent query system, the problem of insufficient constraints in the decision-making of large language models in existing systems is solved, high-precision data query is achieved, the alignment of SQL semantics with database structure is ensured, and query accuracy is improved.
Patent Information
- Application Number
- CN202512037033.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-30
- Publication Date
- 2026-02-17
AI Technical Summary
Existing intelligent query systems rely excessively on large language models for end-to-end "black box" single-point decision-making. This results in a lack of reliable constraints, verification, and guarantee mechanisms in the conversion process from vague user intent to precise SQL queries. The system struggles to ensure that the generated SQL semantics are strictly aligned with the real database structure, which can easily lead to "illusion" errors. Consequently, the accuracy of the queried data is low, making it difficult to meet the needs of production-level applications.
A multi-level keyword matching mode with matching thresholds from large to small is adopted to select knowledge information groups that match the natural language question from the preset business knowledge base, generate the initial SQL statement, and ensure that the SQL statement reflects the user's business query intent and eliminates potential logical errors through various semantic SQL generation strategies and semantic correction strategies, and finally execute the query on the target database.
It significantly improves the parsing accuracy of fuzzy or complex queries, ensures that the generated SQL statements are strictly aligned with the real database structure, improves the accuracy of query data, and meets the needs of production-level applications.
Smart Images

Figure CN121542295A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a data query method and an intelligent data query system. Background Technology
[0002] In the current era of profound digital transformation, data has become a core asset for enterprise decision-making, and enterprises' demand for data-driven decision-making is becoming increasingly urgent. Intelligent data query systems, serving as a crucial bridge connecting non-technical users with complex databases, allow users to input their query requirements in natural language. The system automatically converts these into data query language (such as SQL) and executes them, significantly lowering the barrier to data use and improving the efficiency of data query and decision-making. These systems are widely used in various business scenarios, including finance, retail, manufacturing, and government.
[0003] With the rapid development of Large Language Model (LLM) technology, text-to-query language conversion (such as Text-to-SQL) technology based on LLM has become the core implementation method of intelligent query systems. Compared with traditional rule-based or statistical learning-based Text-to-SQL solutions, LLM-based solutions have stronger natural language understanding capabilities and sentence structure adaptability, showing certain advantages in simple query scenarios and promoting the widespread application of intelligent query systems.
[0004] However, in complex real-world business scenarios, existing intelligent query systems rely excessively on large language models for end-to-end "black box" single-point decision-making. This results in a lack of reliable constraints, verification, and safeguards in the conversion process from vague user intent to precise SQL queries. The system struggles to ensure strict alignment between the generated SQL semantics and the actual database structure, easily leading to "illusion" errors. Consequently, the accuracy of the system's query data is low, failing to meet production-level application requirements and severely hindering the practical implementation of intelligent query systems. For example, an LLM might generate syntactically correct but semantically incorrect SQL (such as querying non-existent table or field names, or fabricating logical relationships that do not conform to the actual database schema). Summary of the Invention
[0005] Based on the above problems, this application provides a data query method and an intelligent data query system, aiming to solve the technical problem that the accuracy of data query in existing intelligent data query systems is low due to their over-reliance on large language models for end-to-end "black box" single-point decision-making.
[0006] The embodiments of this application disclose the following technical solutions:
[0007] In a first aspect, this application provides a data query method applied to an intelligent data query system, the method comprising:
[0008] Receive a data query request initiated by a user; the data query request includes a natural language question corresponding to the target data requested by the user.
[0009] Based on a multi-level keyword matching pattern with matching thresholds ranging from large to small, keyword matching is performed on the natural language question to filter out knowledge information groups that match the natural language question from a preset business knowledge base; the knowledge information group includes knowledge information that is highly matched with business indicators, data query dimensions, and query constraints related to the query target data.
[0010] Based on the knowledge information group and the preset semantic SQL generation strategies, an initial SQL statement is generated; the initial SQL statement is semantic SQL that reflects the user's business query intent.
[0011] The initial SQL statement is semantically corrected based on a variety of preset semantic correction strategies to obtain the corrected SQL statement;
[0012] The corrected SQL statement is converted into an executable SQL statement for the target database to obtain the target SQL statement, and the target SQL statement is executed to obtain the target data requested by the user.
[0013] In an optional implementation, the multi-level keyword matching mode includes a strict matching mode, a moderate matching mode, and a loose matching mode; the matching degree threshold of the strict matching mode is greater than the matching degree threshold of the moderate matching mode, and the matching degree threshold of the moderate matching mode is greater than the matching degree threshold of the loose matching mode.
[0014] The multi-level keyword matching mode based on matching degree thresholds from large to small performs keyword matching on the natural language question to filter out knowledge information groups that match the natural language question from a preset business knowledge base, including:
[0015] The natural language problem is segmented to obtain multiple target keywords;
[0016] The strict matching mode and the moderate matching mode are executed sequentially to filter out knowledge information that matches each of the keywords from the business knowledge base, thereby obtaining a first set of knowledge information.
[0017] If the first knowledge information set is not empty, then the knowledge information group is generated based on all the knowledge information in the first knowledge information set;
[0018] If the first knowledge information set is empty, the loose matching mode is executed to filter out knowledge information that matches each keyword from the business knowledge base based on the matching degree threshold of the loose matching mode, to obtain the second knowledge information set, and to generate the knowledge information group based on all the knowledge information in the second knowledge information set.
[0019] In an optional implementation, the strict matching mode and the moderate matching mode are executed sequentially to filter out knowledge information that matches each of the keywords from the business knowledge base, thereby obtaining a first knowledge information set, including:
[0020] In the strict matching mode, each target keyword is matched with the keywords in the business knowledge base to obtain a first matching result;
[0021] In the moderate matching mode, each of the target keywords and the keywords in the business knowledge base are converted into high-dimensional vectors, and a second matching result is obtained based on the similarity between the high-dimensional vectors corresponding to each of the target keywords and the high-dimensional vectors corresponding to the keywords in the business knowledge base.
[0022] Based on the first matching result and the second matching result, the first knowledge information set is determined.
[0023] In an optional implementation, the multiple semantic SQL generation strategies include a first semantic SQL generation strategy, a second semantic SQL generation strategy, and a third semantic SQL generation strategy; the first semantic SQL generation strategy is a semantic SQL generation strategy based on multiple fixed rules, the second semantic SQL generation strategy is a semantic SQL generation strategy based on a large language model, and the third semantic SQL generation strategy is a semantic SQL generation strategy based on data query type; the fixed rules are mapping rules between business logic and query logic.
[0024] The generation of initial SQL statements based on the knowledge information group and preset semantic SQL generation strategies includes:
[0025] Based on the knowledge information group, it is determined whether the data query complexity is greater than a preset threshold; the data query complexity is used to characterize the complexity of querying the target data;
[0026] If the data query complexity is greater than the preset threshold, then a first semantic SQL statement is generated based on the first semantic SQL generation strategy and the knowledge information group;
[0027] Based on the second semantic SQL generation strategy and the knowledge information group, generate a second semantic SQL statement;
[0028] Based on the third semantic SQL generation strategy and the knowledge information group, generate third semantic SQL statements;
[0029] The initial SQL statement is generated based on the first semantic SQL statement, the second semantic SQL statement, and the third semantic SQL statement.
[0030] In optional implementations, the data query method also includes:
[0031] If the data query complexity is less than or equal to the preset threshold, the initial SQL statement is generated based on the target semantic SQL generation strategy and the knowledge information group; the target semantic SQL generation strategy is the semantic SQL generation strategy that matches the knowledge information group among the multiple semantic SQL generation strategies.
[0032] In an optional implementation, generating the first semantic SQL statement based on the first semantic SQL generation strategy and the knowledge information group includes:
[0033] From a set of preset fixed rules, a target fixed rule that matches the knowledge information in the knowledge information group is determined;
[0034] Based on the target fixed rules and the knowledge information group, the first semantic SQL statement is generated.
[0035] In an optional implementation, generating the second semantic SQL statement based on the second semantic SQL generation strategy and the knowledge information group includes:
[0036] Based on the aforementioned knowledge information group, semantic SQL is constructed to generate prompt words;
[0037] The semantic SQL generation prompt is input into the large language model, which then generates the second semantic SQL statement based on the semantic SQL generation prompt and historical data query records.
[0038] In optional implementations, the various semantic correction strategies include fixed rule-based semantic correction strategies and large language model-based semantic correction strategies. The fixed rule-based semantic correction strategies include semantic-level correction strategies, temporal-level correction strategies, and syntactic-level correction strategies. The semantic-level correction strategies are used to verify and correct whether the business logic in the semantic SQL is consistent. The temporal-level correction strategies are used to verify and correct the temporal condition expressions in the semantic SQL. The syntactic-level correction strategies are used to verify and correct the syntactic structure of the semantic SQL.
[0039] In an optional implementation, after obtaining the target data requested by the user, the data query method further includes:
[0040] The initial SQL statement is subjected to structured information processing to obtain the processing result; the processing result includes the business indicators, data query dimensions, and query constraints covered by the target data;
[0041] The business entities in the target data are determined based on the data query dimensions;
[0042] Obtain the business attribute information corresponding to the business entity, and add the business attribute information to the business entity of the target data to obtain the target data after addition;
[0043] The added target data and the processing results are displayed on the target page.
[0044] In a second aspect, this application provides an intelligent data query system that implements the data query method described in the above optional implementations. The system includes: a data receiving module, a keyword matching module, a semantic SQL generation module, a semantic correction module, and an SQL statement conversion module.
[0045] The data receiving module is used to receive data query requests initiated by users and send the natural language question corresponding to the target data requested by the user in the data query request to the keyword matching module;
[0046] The keyword matching module is used to receive the natural language question sent by the data receiving module, and perform keyword matching on the natural language question based on a multi-level keyword matching mode with matching degree thresholds from large to small, so as to filter out a knowledge information group that matches the natural language question from a preset business knowledge base; the knowledge information group includes knowledge information that highly matches the business indicators, data query dimensions and query constraints related to querying the target data; the keyword matching module is also used to send the knowledge information group to the semantic SQL generation module;
[0047] The semantic SQL generation module is used to receive a knowledge information group sent by the keyword matching module, and generate an initial SQL statement based on the knowledge information group and a variety of preset semantic SQL generation strategies; the initial SQL statement is a semantic SQL that reflects the user's business query intent; the semantic SQL generation module is also used to send the initial SQL statement to the semantic correction module;
[0048] The semantic correction module is used to receive the initial SQL statement sent by the semantic SQL generation module, and to perform semantic correction on the initial SQL statement based on a number of preset semantic correction strategies to obtain the corrected SQL statement; the semantic correction module is also used to send the corrected SQL statement to the SQL statement conversion module.
[0049] The SQL statement conversion module is used to receive the corrected SQL statement sent by the semantic correction module, convert the corrected SQL statement into an executable SQL statement for the target database, obtain the target SQL statement, and execute the target SQL statement to obtain the target data requested by the user.
[0050] Compared with the prior art, this application has the following beneficial effects:
[0051] In the technical solution of this application, the intelligent query system first receives a data query request initiated by the user, which includes a natural language question corresponding to the target data requested by the user. Secondly, based on a multi-level keyword matching mode with matching degree thresholds from large to small, the system performs keyword matching on the natural language question to filter out a knowledge information group that matches the natural language question from a preset business knowledge base. This knowledge information group includes knowledge information that highly matches the business indicators, data query dimensions, and query constraints related to the target data. Thus, the system accurately captures the user's intent through structured semantic anchors, significantly improves the parsing accuracy of fuzzy or complex queries, and effectively avoids misunderstandings caused by semantic ambiguity.
[0052] Subsequently, based on the knowledge information group and multiple preset semantic SQL generation strategies, an initial SQL statement is generated. This initial SQL statement is a semantic SQL that reflects the user's business query intent, significantly reducing the illusion problem caused by the large language model in a single interaction and ensuring that the subsequently generated executable SQL statement can accurately reflect the actual business logic. Then, based on multiple preset semantic correction strategies, the initial SQL statement is semantically corrected to eliminate potential logical errors (such as referencing non-existent tables / fields, violating business rules, etc.), and a semantically consistent and structurally reasonable corrected SQL statement is output, which significantly enhances the reliability and robustness of the query results. Finally, the corrected SQL statement is converted into an executable SQL statement on the target database to obtain the target SQL statement, and the target SQL statement is executed to accurately obtain the target data requested by the user. This application achieves high-precision data querying through multi-level keyword precision matching and semantic correction mechanisms, effectively ensuring strict alignment between the generated SQL semantics and the real database structure. This solves the technical problem of existing intelligent query systems, which rely excessively on large language models for end-to-end "black box" single-point decision-making, resulting in a lack of reliable constraints, verification, and guarantee mechanisms in the conversion process from vague user intent to precise SQL query. Consequently, it significantly improves the accuracy of data querying in intelligent query systems and effectively meets the needs of production-level applications. Attached Figure Description
[0053] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0054] Figure 1 A flowchart illustrating a data query method provided in this application embodiment;
[0055] Figure 2 A flowchart illustrating another data query method provided in this application embodiment;
[0056] Figure 3 A flowchart illustrating the process of generating a knowledge information group, as provided in this application embodiment;
[0057] Figure 4 A flowchart illustrating another process for generating a knowledge information group, as provided in this application embodiment;
[0058] Figure 5 A flowchart illustrating the generation process of semantic SQL as provided in this application embodiment;
[0059] Figure 6 A schematic diagram of the structure of an intelligent question-and-answer system provided in an embodiment of this application;
[0060] Figure 7 This is a schematic diagram of another intelligent questioning system provided in an embodiment of this application. Detailed Implementation
[0061] As described earlier, in complex business scenarios, existing intelligent query systems rely excessively on large language models for end-to-end "black box" single-point decision-making. This results in a lack of reliable constraints, verification, and safeguards in the conversion process from vague user intent to precise SQL queries. The system struggles to ensure strict alignment between the generated SQL semantics and the actual database structure, easily leading to "illusion" errors. Consequently, the accuracy of the system's query data is low, failing to meet production-level application requirements and severely hindering the practical implementation of intelligent query systems. For example, an LLM might generate syntactically correct but semantically incorrect SQL (such as querying non-existent table or field names, or fabricating logical relationships that do not conform to the actual database schema).
[0062] The inventors have proposed a data query method. In this method, the intelligent query system first receives a data query request initiated by the user, which includes a natural language question corresponding to the target data requested by the user. Secondly, based on a multi-level keyword matching mode with matching degree thresholds from large to small, keyword matching is performed on the natural language question to filter out a knowledge information group that matches the natural language question from a preset business knowledge base. This knowledge information group includes knowledge information that highly matches the business indicators, data query dimensions, and query constraints related to the target data. Thus, the system accurately captures the user's intent through structured semantic anchors, significantly improving the parsing accuracy of fuzzy or complex queries and effectively avoiding comprehension biases caused by semantic ambiguity.
[0063] Subsequently, based on the knowledge information group and multiple preset semantic SQL generation strategies, an initial SQL statement is generated. This initial SQL statement is a semantic SQL that reflects the user's business query intent, significantly reducing the illusion problem caused by the large language model in a single interaction and ensuring that the subsequently generated executable SQL statement can accurately reflect the actual business logic. Then, based on multiple preset semantic correction strategies, the initial SQL statement is semantically corrected to eliminate potential logical errors (such as referencing non-existent tables / fields, violating business rules, etc.), and a semantically consistent and structurally reasonable corrected SQL statement is output, which significantly enhances the reliability and robustness of the query results. Finally, the corrected SQL statement is converted into an executable SQL statement on the target database to obtain the target SQL statement, and the target SQL statement is executed to accurately obtain the target data requested by the user. This application achieves high-precision data querying through multi-level keyword precision matching and semantic correction mechanisms, effectively ensuring strict alignment between the generated SQL semantics and the real database structure. This solves the technical problem of existing intelligent query systems, which rely excessively on large language models for end-to-end "black box" single-point decision-making, resulting in a lack of reliable constraints, verification, and guarantee mechanisms in the conversion process from vague user intent to precise SQL query. Consequently, it significantly improves the accuracy of data querying in intelligent query systems and effectively meets the needs of production-level applications.
[0064] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0065] Method Implementation Examples
[0066] This application provides an embodiment of a data query method applied to an intelligent question-and-answer system. For ease of description, the intelligent question-and-answer system will be referred to as the system below. The system comprises five parts: a natural language keyword matching module (i.e., keyword matching module), a semantic SQL generation module, a semantic correction module, a semantic SQL to database executable SQL conversion module (i.e., SQL statement conversion module), and a structured processor module. After the user inputs a natural language question into the system, the five modules are executed sequentially, ultimately generating an execution return result based on executable data SQL. The statistical results of data related to the user's business domain are returned and displayed through charts. These five core components are executed sequentially, with each component providing input for subsequent components, creating a tightly linked system that ultimately achieves highly accurate question-and-answer results.
[0067] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although the flowchart shows a logical order, in some cases the steps shown or described may be executed in a different order than that shown here.
[0068] See Figure 1 The figure is a flowchart of a data query method provided in an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:
[0069] Step S101: Receive a data query request initiated by the user.
[0070] In step S101, the data query request includes a natural language question corresponding to the target data requested by the user.
[0071] In this embodiment of the application, the system can receive a data query request initiated by a user. The data query request includes a natural language question corresponding to the target data requested by the user. For example, the system can receive a data query request initiated by a user: "What was the total sales in the third quarter of 2024?".
[0072] Step S102: Based on a multi-level keyword matching mode with matching degree thresholds from large to small, keyword matching is performed on the natural language question to filter out knowledge information groups that match the natural language question from a preset business knowledge base.
[0073] In step S102, the knowledge information group includes highly matched knowledge information related to the target data being queried, such as business indicators (e.g., sales revenue, gross profit margin, sales revenue percentage, number of orders, etc.), data query dimensions (e.g., region, city, product category, sales channel, time, etc.), and query constraints (i.e., the user's restrictions and filters on the range of query results, such as region = {'East China', 'North China', 'South China'}, product status = {'On Sale', 'Discontinued'}, customer name LIKE '%Zhang%', etc.).
[0074] In this application embodiment, the multi-level keyword matching mode may include Figure 2 The diagram shows three matching modes: strict (STRICT), moderate (MODERATE), and loose (LOOSE). The strict matching mode has a higher matching threshold (e.g., 90%) than the moderate matching mode (e.g., 70%), and the moderate matching mode has a higher matching threshold than the loose matching mode (e.g., 50%). The system can perform keyword matching on natural language questions based on a multi-level keyword matching mode with decreasing matching thresholds to filter knowledge information groups (i.e., ...) that match the natural language questions from a pre-defined business knowledge base. Figure 2 The parsing results (in the data) indicate that this knowledge information group includes business indicators, data query dimensions, and query constraints that are highly matched with the target data. This allows for the precise capture of user intent through structured semantic anchors, significantly improving the parsing accuracy of fuzzy or complex queries and effectively avoiding misunderstandings caused by semantic ambiguity.
[0075] For example, for natural language questions: querying "salesperson 'Lv XX's' sales percentage", the system can perform keyword matching based on a multi-level keyword matching mode with matching thresholds from high to low. The resulting knowledge information group may include the following:
[0076] DatabaseType=[mysql], Table=[Sales Orders], PartitionTimeField=[Creation Time FORMAT'yyyy-MM-dd'], PrimaryKeyField=[], Metrics=[<Total Amount Percentage COMMENT'Total Amount Based on a Certain Dimension Condition / Total Amount of All Records'AGGREGATE'SUM'>], Dimensions=[], Values=[<Salesperson='Lv XX'>].
[0077] Specifically, see Figure 3 The figure is a flowchart of a knowledge information group generation process provided in an embodiment of this application. The process includes the following steps:
[0078] Step S1021: Perform word segmentation on the natural language problem to obtain multiple target keywords.
[0079] For example, regarding natural language processing: when querying "salesperson 'Lv XX's sales percentage", the system can perform word segmentation to obtain the target keywords: query, salesperson, Lv XX, sales, percentage.
[0080] Step S1022: Perform strict matching mode and moderate matching mode in sequence to filter out knowledge information that matches each keyword from the business knowledge base and obtain the first knowledge information set.
[0081] In the embodiments of this application, such as Figure 2 As shown, the system can sequentially execute strict matching mode and moderate matching mode to filter out knowledge information (i.e., parsing results) that match each keyword from the business knowledge base, and obtain the first set of knowledge information.
[0082] Specifically, see Figure 4 The figure is a flowchart of another knowledge information group generation process provided in an embodiment of this application, which includes the following steps:
[0083] Step S10221: In strict matching mode, the system can perform full-word matching between each target keyword and the keywords in the business knowledge base to obtain the first matching result.
[0084] In the embodiments of this application, such as Figure 2 As shown, in strict matching mode, the system can execute the process corresponding to the SQL retrieval process and use the natural language keyword matching module to directly perform full word matching between each target keyword and the keywords in the business knowledge base, obtaining the first matching result with extremely high accuracy and high confidence.
[0085] Step S10222: In the moderate matching mode, all target keywords and keywords in the business knowledge base are converted into high-dimensional vectors, and the matching is performed based on the similarity between the high-dimensional vectors corresponding to each target keyword and the high-dimensional vectors corresponding to the keywords in the business knowledge base to obtain the second matching result.
[0086] In the embodiments of this application, such as Figure 2 As shown, in the neutral matching mode, the system can execute the process corresponding to the SQL retrieval process. It uses the natural language keyword matching module to convert each target keyword and the keywords in the business knowledge base into high-dimensional vectors. It then performs matching based on the cosine similarity between the high-dimensional vectors corresponding to each target keyword and the high-dimensional vectors corresponding to the keywords in the business knowledge base, resulting in a second matching result with high recall and broad coverage, but whose confidence may be lower than the output result of the strict mode.
[0087] Optionally, in the neutral matching mode, the system can also use the natural language keyword matching module to match each target keyword with keywords in the business knowledge base based on its corresponding matching degree threshold, and combine the above similarity-based matching results to obtain a second matching result.
[0088] Step S10223: Based on the first matching result and the second matching result, determine the first knowledge information set.
[0089] In this embodiment, the system can combine the knowledge information in the high-precision first matching result with the knowledge information in the second matching result with high recall and wide coverage to determine the first knowledge information set, which greatly expands the system's ability to understand the diversity of natural language, while ensuring the system's processing efficiency.
[0090] Step S1023: If the first knowledge information set is not empty, then generate a knowledge information group based on all the knowledge information in the first knowledge information set.
[0091] Step S1024: If the first knowledge information set is empty, then the loose matching mode is executed to filter out the knowledge information that matches each keyword from the business knowledge base based on the matching degree threshold of the loose matching mode, to obtain the second knowledge information set, and to generate a knowledge information group based on all the knowledge information in the second knowledge information set.
[0092] In this embodiment, the system can determine whether to continue executing the loose matching mode by judging whether the first knowledge information set is empty. If the first knowledge information set is not empty, the system can directly generate a knowledge information group based on all the knowledge information in the first knowledge information set. If the first knowledge information set is empty, the loose matching mode is executed to filter out knowledge information that matches each keyword from the business knowledge base based on the matching degree threshold of the loose matching mode, thereby obtaining a second knowledge information set, and generating a knowledge information group based on all the knowledge information in the second knowledge information set.
[0093] Optionally, such as Figure 2 As shown, in loose matching mode, the system can execute the process corresponding to the SQL retrieval process. Using the natural language keyword matching module, based on the corresponding matching degree threshold, it converts each target keyword and the keywords in the business knowledge base into high-dimensional vectors. Then, it matches based on the cosine similarity between the high-dimensional vectors corresponding to each target keyword and the high-dimensional vectors corresponding to the keywords in the business knowledge base, and obtains a second matching result with low confidence and high recall.
[0094] In the embodiments of this application, Figure 2 The natural language keyword matching module shown can be composed of a vector matcher, a keyword matcher, a query condition matcher, a dimension value matcher, and a terminology matcher. During the process of sequentially executing strict matching mode, moderate matching mode, and loose matching mode to perform keyword matching for natural language questions using the natural language keyword matching module, the system can achieve fuzzy keyword matching through the vector matcher; match predefined business indicators, data query dimension names, aliases, business definitions, and other keywords through the keyword matcher to identify and match the most core business indicators and data query dimension information; parse and extract the data time and business time conditions required by the business to guide subsequent semantic SQL generation; match the sampled dimension information with the information after word segmentation of the natural language question through the dimension value matcher to more accurately hit the dimension information; and associate the business description in the natural language question with business knowledge through the terminology matcher to more accurately hit the target business knowledge.
[0095] It should be noted that when the intelligent data query system of this application matches multiple business knowledge groups with high matching degree, it supports the optional configuration to display the corresponding information to the end user for business confirmation, thereby ensuring the accuracy of matching.
[0096] Step S103: Generate initial SQL statements based on knowledge information groups and preset semantic SQL generation strategies.
[0097] In step S103, the initial SQL statement is semantic SQL that reflects the user's business query intent.
[0098] In this embodiment, the multiple semantic SQL generation strategies include a first semantic SQL generation strategy, a second semantic SQL generation strategy, and a third semantic SQL generation strategy. The first semantic SQL generation strategy is a semantic SQL generation strategy based on multiple fixed rules, the second semantic SQL generation strategy is a semantic SQL generation strategy based on a large language model, and the third semantic SQL generation strategy is a semantic SQL generation strategy based on data query type. The fixed rules are mapping rules between business logic and query logic, such as fixed rules for various scenarios like TOP indicator queries, indicator grouping queries, detail queries based on primary keys, dimension detail queries, indicator detail queries, detail filtering queries, and indicator filtering queries. The system can utilize... Figure 2 The semantic SQL generation module shown generates an initial SQL statement based on knowledge information groups and the aforementioned semantic SQL generation strategies. This initial SQL statement is a semantic SQL statement that reflects the user's business query intent, which greatly reduces the illusion problem caused by a large language model in a single interaction and ensures that the subsequently generated executable SQL statements can accurately reflect the actual business logic.
[0099] Specifically, see Figure 5 The figure is a flowchart of a semantic SQL generation process provided in an embodiment of this application. The process includes the following steps:
[0100] Step S1031: Based on the knowledge information group, determine whether the data query complexity is greater than the preset threshold. If yes, proceed with steps S1032 to S1035; otherwise, proceed with step S1036.
[0101] In step S1031, the data query complexity is used to characterize the complexity of the target data being queried.
[0102] In this embodiment of the application, the system can identify the complexity of data queries by the complexity of the indicators of the knowledge information group, the complexity of the dimensions and filtering, the complexity of the query intent (i.e. the query type, such as data statistics query, data detail query, etc.), and the complexity of the data source and association, and determine the semantic SQL generation strategy by judging whether the complexity of the data query is greater than a preset threshold.
[0103] Step S1032: Generate a first semantic SQL statement based on the first semantic SQL generation strategy and knowledge information group.
[0104] In this embodiment of the application, if the data query complexity is greater than a preset threshold, the system can generate a first semantic SQL statement based on the first semantic SQL generation strategy (i.e., a semantic SQL generation strategy based on multiple fixed rules) and the knowledge information group.
[0105] Specifically, the system can determine the target fixed rule that matches the knowledge information in the knowledge information group from a number of preset fixed rules (such as rules for TOP indicator query, indicator group query, detail query based on primary key, dimension detail query, indicator detail query, detail filtering query, indicator filtering query, etc.). Then, the system can generate the first semantic SQL statement based on the target fixed rule and the knowledge information group.
[0106] Step S1033: Generate a second semantic SQL statement based on the second semantic SQL generation strategy and knowledge information group.
[0107] In this embodiment of the application, the system can generate second semantic SQL statements based on the second semantic SQL generation strategy (i.e., the semantic SQL generation strategy based on the large language model) and the knowledge information group.
[0108] Specifically, the system can construct semantic SQL generation prompts based on knowledge information groups; then the system can input the semantic SQL generation prompts into the large language model, and the large language model can generate a second semantic SQL statement based on the semantic SQL generation prompts and historical data query records (i.e., the memory of accurate question examples within the historical period).
[0109] It should be noted that by generating prompt words based on semantic SQL and historical data query records (i.e., accurate question example memory within a historical period) through a large language model, a second semantic SQL statement is generated, which improves the accuracy of semantic SQL.
[0110] Step S1034: Generate a third semantic SQL statement based on the third semantic SQL generation strategy and knowledge information group.
[0111] In this embodiment, the system can generate third semantic SQL statements based on a third semantic SQL generation strategy (i.e., a semantic SQL generation strategy based on data query type, where the data query type is the question type, which may include simple data query, data statistics, data detail query, etc.) and knowledge information groups. Specifically, the system can perform matching and calculation of scenarios such as aggregation, details, and ID matching based on the matched knowledge information groups to generate third semantic SQL statements.
[0112] Step S1035: Generate an initial SQL statement based on the first semantic SQL statement, the second semantic SQL statement, and the third semantic SQL statement.
[0113] In this embodiment of the application, the system can merge and assemble the first semantic SQL statement, the second semantic SQL statement, and the third semantic SQL statement to generate an initial SQL statement that can accurately reflect the actual business logic.
[0114] Step S1036: Generate the initial SQL statement based on the target semantic SQL generation strategy and knowledge information group.
[0115] In step S1036, the target semantic SQL generation strategy is the semantic SQL generation strategy that matches the knowledge information group among multiple semantic SQL generation strategies.
[0116] For example, for natural language problems: querying "sales amount of salesperson 'Lv XX' in January 2024", if the system determines that the data query complexity is less than or equal to a preset threshold based on the corresponding knowledge information group, then the semantic SQL generation strategy matching the knowledge information group can be determined to be a semantic SQL generation strategy based on multiple fixed rules (i.e., the target semantic SQL generation strategy); then the system can generate the initial SQL statement based on the semantic SQL generation strategy based on multiple fixed rules and the knowledge information group.
[0117] It should be noted that this application does not limit the execution order of steps S1032 to S1034. The system can execute S1032 first, then S1033 and finally S1034, or it can execute S1033 first, then S1032 and finally S1034, or it can execute S1034 first, then S1033 and finally S1033. The choice can be made according to actual needs.
[0118] Alternatively, the initial SQL statement can be shown in the following example:
[0119] Knowledge and Information:
[0120] DatabaseType=[mysql], Table=[Sales Orders], PartitionTimeField=[Creation Time FORMAT 'yyyy-MM-dd'], PrimaryKeyField=[], Metrics=[<Total Amount Percentage COMMENT 'Total Amount Based on a Dimension / Total Amount of All Records' AGGREGATE 'SUM'>], Dimensions=[], Values=[<Salesperson='Lv Hongjuan'>]
[0121] Auxiliary information:
[0122] CurrentDate=[2025-12-03]
[0123] Semantic SQL information:
[0124] SELECT
[0125] SUM (total amount) / (
[0126] SELECT
[0127] SUM (Total Amount)
[0128] FROM
[0129] Sales orders
[0130] AS xx_ Total Percentage
[0131] FROM
[0132] Sales orders
[0133] WHERE
[0134] Salesperson = 'xx';
[0135] Step S104: Based on a variety of preset semantic correction strategies, perform semantic correction on the initial SQL statement to obtain the corrected SQL statement.
[0136] In this application embodiment, various semantic correction strategies include fixed-rule-based semantic correction strategies and large-language-model-based semantic correction strategies. Fixed-rule-based semantic correction strategies include semantic-level correction strategies, temporal-level correction strategies, and syntactic-level correction strategies. Semantic-level correction strategies are used to verify and correct the consistency of business logic in semantic SQL; temporal-level correction strategies are used to verify and correct temporal condition expressions in semantic SQL; and syntactic-level correction strategies are used to verify and correct the syntactic structure of semantic SQL. The system can utilize... Figure 2 The semantic correction module shown above performs semantic correction on the initial SQL statement based on the various semantic correction strategies mentioned above, eliminating potential logical errors (such as referencing non-existent tables / fields, violating business rules, etc.), and outputs a semantically consistent and structurally reasonable corrected SQL statement, which significantly enhances the reliability and robustness of the query results.
[0137] Step S105: Convert the corrected SQL statement into an executable SQL statement on the target database to obtain the target SQL statement, and execute the target SQL statement to obtain the target data requested by the user.
[0138] In this embodiment of the application, the system can utilize Figure 2The semantic SQL shown is converted into a database executable SQL module, which transforms the corrected SQL statement into an executable SQL statement on the target database, resulting in the target SQL statement. This target SQL statement is then executed to accurately obtain the target data requested by the user. This application achieves high-precision data querying through multi-level keyword precision matching and semantic correction mechanisms. It effectively ensures strict alignment between the generated SQL semantics and the real database structure, thus solving the technical problem of existing intelligent query systems that rely excessively on large language models for end-to-end "black box" single-point decision-making, leading to a lack of reliable constraints, verification, and guarantee mechanisms in the conversion process from vague user intent to precise SQL queries. This significantly improves the accuracy of data querying in intelligent query systems and effectively meets the needs of production-level applications.
[0139] Optionally, after the system successfully executes the target SQL statement, the recorded query count (i.e., the data query process described above) can be stored to facilitate subsequent evaluation and improvement of the accuracy of the system query count.
[0140] In one feasible implementation, after obtaining the target data requested by the user, the system can utilize... Figure 2 The structured processor module shown first processes the initial SQL statement into structured information to obtain the processing result. The processing result includes the business indicators covered by the target data, the data query dimensions, and the query constraints. Then, the system can determine the business entities in the target data based on the data query dimensions. The system can then obtain the business attribute information corresponding to the business entities and add the business attribute information to the business entities in the target data to obtain the target data after addition. Finally, the system can display the target data after addition and the processing result on the target page.
[0141] In the embodiments of this application, such as Figure 2 As shown, after executing the business database SQL (i.e., the target SQL statement), the system can also assemble the query results through the structured processor module. This includes rewriting error messages for problems that cause exceptions to make the error messages more readable; formatting the parsed information to help users understand the business meaning of the final query results; adding recommended question information and time consumption information for similar problems; and finally returning the query content to the system front end for display.
[0142] The data query method provided in this application achieves high-precision data query through multi-level keyword precise matching and semantic correction mechanism, effectively ensuring that the generated SQL semantics are strictly aligned with the real database structure. This solves the technical problem that existing intelligent query systems rely too much on large language models for end-to-end "black box" single-point decision-making, resulting in a lack of reliable constraints, verification and guarantee mechanisms in the conversion process from vague user intent to precise SQL query. As a result, the accuracy of data query in intelligent query systems is significantly improved, effectively meeting the needs of production-level applications.
[0143] Furthermore, this application decomposes the task into multiple stages: "multi-round knowledge matching, proactive schema alignment (i.e., multi-level keyword matching pattern), semantic SQL generation, semantic verification and error correction, and executable data generation." Each stage has clear input / output and verification mechanisms, effectively constraining the LLM's degrees of freedom, avoiding unwarranted error generation, and significantly reducing the risk of large model illusions. The system can continuously learn from user feedback, constantly optimizing the quality of intent understanding and SQL generation, making the system more accurate with use and possessing long-term evolution capabilities.
[0144] System Implementation Examples
[0145] This application provides an intelligent question-and-answer system, wherein... Figure 6 This is a schematic diagram of the structure of an intelligent question-and-answer system provided in an embodiment of this application, such as... Figure 6 As shown, the device includes: a data receiving module 11, a keyword matching module 12, a semantic SQL generation module 13, a semantic correction module 14, and an SQL statement conversion module 15. From Figure 6 You can see the connections between several modules.
[0146] The data receiving module 11 is used to receive data query requests initiated by users and send the natural language question corresponding to the target data requested by the user in the data query request to the keyword matching module.
[0147] The keyword matching module 12 is used to receive natural language questions sent by the data receiving module, and to perform keyword matching on the natural language questions based on a multi-level keyword matching mode with matching degree thresholds from large to small, so as to filter out knowledge information groups that match the natural language questions from a preset business knowledge base; the knowledge information groups include knowledge information that highly matches the business indicators, data query dimensions and query constraints related to the query target data; the keyword matching module is also used to send the knowledge information groups to the semantic SQL generation module.
[0148] Optionally, the multi-level keyword matching modes include strict matching mode, moderate matching mode and loose matching mode; the matching degree threshold of strict matching mode is greater than that of moderate matching mode, and the matching degree threshold of moderate matching mode is greater than that of loose matching mode.
[0149] The natural language keyword matching module is specifically used for:
[0150] Natural language processing is performed to obtain multiple target keywords;
[0151] The strict matching mode and the moderate matching mode are executed in sequence to filter out the knowledge information that matches each keyword from the business knowledge base, and obtain the first set of knowledge information.
[0152] If the first knowledge information set is not empty, then a knowledge information group is generated based on all the knowledge information in the first knowledge information set;
[0153] If the first knowledge information set is empty, then a loose matching mode is executed. Based on the matching degree threshold of the loose matching mode, knowledge information that matches each keyword is filtered from the business knowledge base to obtain the second knowledge information set. Then, a knowledge information group is generated based on all the knowledge information in the second knowledge information set.
[0154] Optionally, the natural language keyword matching module is also used for:
[0155] In strict matching mode, each target keyword is matched with the keywords in the business knowledge base to obtain the first matching result;
[0156] In the moderate matching mode, each target keyword and the keywords in the business knowledge base are converted into high-dimensional vectors, and the matching is performed based on the similarity between the high-dimensional vectors corresponding to each target keyword and the high-dimensional vectors corresponding to the keywords in the business knowledge base to obtain the second matching result.
[0157] Based on the first matching result and the second matching result, the first knowledge information set is determined.
[0158] Optionally, the natural language keyword matching module can be provided by Figure 7The system consists of a vector matcher, a keyword matcher, a query condition matcher, a dimension value matcher, and a terminology matcher. During the process of sequentially executing strict matching mode, moderate matching mode, and loose matching mode to perform keyword matching for natural language questions using the natural language keyword matching module, the system can achieve fuzzy keyword matching through the vector matcher; match predefined business indicators, data query dimension names, aliases, business definitions, and other keywords through the keyword matcher to identify and match the most core business indicators and data query dimension information; parse and extract the data time and business time conditions required by the business to guide subsequent semantic SQL generation; match the sampled dimension information with the information after word segmentation of the natural language question to more accurately hit the dimension information; and associate the business description in the natural language question with business knowledge to more accurately hit the target business knowledge.
[0159] The semantic SQL generation module 13 is used to receive the knowledge information group sent by the keyword matching module, and generate an initial SQL statement based on the knowledge information group and a variety of preset semantic SQL generation strategies. The initial SQL statement is a semantic SQL that reflects the user's business query intent. The semantic SQL generation module is also used to send the initial SQL statement to the semantic correction module.
[0160] Optionally, the multiple semantic SQL generation strategies include a first semantic SQL generation strategy, a second semantic SQL generation strategy, and a third semantic SQL generation strategy; the first semantic SQL generation strategy is a semantic SQL generation strategy based on multiple fixed rules, the second semantic SQL generation strategy is a semantic SQL generation strategy based on a large language model, and the third semantic SQL generation strategy is a semantic SQL generation strategy based on data query type; the fixed rules are the mapping rules between business logic and query logic;
[0161] Optionally, the semantic SQL generation module includes Figure 7 The diagram shows a rule-based semantic generator, a large-model-based semantic generator, and a question-type-based semantic generator. The rule-based semantic generator can generate semantic SQL statements based on semantic SQL generation strategies using multiple fixed rules and knowledge information groups; the large-model-based semantic generator can generate semantic SQL statements based on semantic SQL generation strategies using a large language model and knowledge information groups; and the question-type-based semantic generator can generate semantic SQL statements based on semantic SQL generation strategies using data query types and knowledge information groups.
[0162] Optionally, the semantic SQL generation module is specifically used for:
[0163] The data query complexity is determined based on the knowledge information group to determine whether it exceeds a preset threshold; the data query complexity is used to characterize the complexity of the target data being queried.
[0164] If the data query complexity exceeds the preset threshold, then a first semantic SQL statement is generated based on the first semantic SQL generation strategy and knowledge information group;
[0165] Generate second semantic SQL statements based on the second semantic SQL generation strategy and knowledge information groups;
[0166] Generate third-semantic SQL statements based on third-semantic SQL generation strategies and knowledge information groups;
[0167] The initial SQL statement is generated based on the first semantic SQL statement, the second semantic SQL statement, and the third semantic SQL statement.
[0168] Optionally, the semantic SQL generation module is also used for:
[0169] If the data query complexity is less than or equal to a preset threshold, an initial SQL statement is generated based on the target semantic SQL generation strategy and the knowledge information group. The target semantic SQL generation strategy is the semantic SQL generation strategy that matches the knowledge information group among a variety of semantic SQL generation strategies.
[0170] Optionally, the semantic SQL generation module is also used for:
[0171] From a set of pre-defined fixed rules, determine the target fixed rule that matches the knowledge information in the knowledge information group;
[0172] Based on the fixed rules of the target and the knowledge information group, the first semantic SQL statement is generated.
[0173] Optionally, the semantic SQL generation module is also used for:
[0174] Semantic SQL prompts are generated based on knowledge information groups;
[0175] The semantic SQL generation prompts are input into the large language model, which then generates a second semantic SQL statement based on the semantic SQL generation prompts and historical data query records.
[0176] The semantic correction module 14 is used to receive the initial SQL statement sent by the semantic SQL generation module, and to perform semantic correction on the initial SQL statement based on a variety of preset semantic correction strategies to obtain the corrected SQL statement; the semantic correction module is also used to send the corrected SQL statement to the SQL statement conversion module.
[0177] Optionally, the various semantic correction strategies include semantic correction strategies based on fixed rules and semantic correction strategies based on large language models. Semantic correction strategies based on fixed rules include semantic-level correction strategies, temporal-level correction strategies, and syntactic-level correction strategies. Semantic-level correction strategies are used to verify and correct whether the business logic in semantic SQL is consistent. Temporal-level correction strategies are used to verify and correct temporal condition expressions in semantic SQL. Syntactic-level correction strategies are used to verify and correct the syntactic structure of semantic SQL.
[0178] Optionally, the semantic correction module includes Figure 7 The diagram shows a rule corrector and a large model corrector. The rule corrector performs semantic correction on the initial SQL statement based on a semantic correction strategy using fixed rules; the large model corrector performs semantic correction on the initial SQL statement based on a semantic correction strategy using a large language model, resulting in a corrected SQL statement.
[0179] The SQL statement conversion module 15 is used to receive the corrected SQL statement sent by the semantic correction module and utilize... Figure 7 The SQL generator shown converts the corrected SQL statement into an executable SQL statement for the target database, obtains the target SQL statement, and executes the target SQL statement to obtain the target data requested by the user.
[0180] Optionally, the intelligent questioning system also includes Figure 7 The structured processor shown is specifically used for:
[0181] After obtaining the target data requested by the user, the initial SQL statement is processed using structured information to obtain the processing result. The processing result includes the business indicators covered by the target data, the data query dimensions, and the query constraints.
[0182] Identify the business entities in the target data based on the dimensions of the data query;
[0183] Obtain the business attribute information corresponding to the business entity, and add the business attribute information to the business entity of the target data to obtain the target data after addition;
[0184] The added target data and processing results will be displayed on the target page.
[0185] It should be noted that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for the system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiments. The system embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate. The components indicated as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the solution in this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0186] The above is merely one specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A data query method, characterized in that, The method, applied to an intelligent data query system, includes: Receive a data query request initiated by a user; the data query request includes a natural language question corresponding to the target data requested by the user. Based on a multi-level keyword matching pattern with matching thresholds ranging from large to small, keyword matching is performed on the natural language question to filter out knowledge information groups that match the natural language question from a preset business knowledge base; the knowledge information group includes knowledge information that is highly matched with business indicators, data query dimensions, and query constraints related to the query target data. Based on the knowledge information group and the preset semantic SQL generation strategies, an initial SQL statement is generated; the initial SQL statement is semantic SQL that reflects the user's business query intent. The initial SQL statement is semantically corrected based on a variety of preset semantic correction strategies to obtain the corrected SQL statement; The corrected SQL statement is converted into an executable SQL statement on the target database to obtain the target SQL statement, and the target SQL statement is executed to obtain the target data requested by the user.
2. The method according to claim 1, characterized in that, The multi-level keyword matching mode includes strict matching mode, moderate matching mode and loose matching mode; the matching degree threshold of the strict matching mode is greater than the matching degree threshold of the moderate matching mode, and the matching degree threshold of the moderate matching mode is greater than the matching degree threshold of the loose matching mode. The multi-level keyword matching mode based on matching degree thresholds from large to small performs keyword matching on the natural language question to filter out knowledge information groups that match the natural language question from a preset business knowledge base, including: The natural language problem is segmented to obtain multiple target keywords; The strict matching mode and the moderate matching mode are executed sequentially to filter out knowledge information that matches each of the keywords from the business knowledge base, thereby obtaining a first set of knowledge information. If the first knowledge information set is not empty, then the knowledge information group is generated based on all the knowledge information in the first knowledge information set; If the first knowledge information set is empty, the loose matching mode is executed to filter out knowledge information that matches each keyword from the business knowledge base based on the matching degree threshold of the loose matching mode, to obtain the second knowledge information set, and to generate the knowledge information group based on all the knowledge information in the second knowledge information set.
3. The method according to claim 2, characterized in that, The strict matching mode and the moderate matching mode are executed sequentially to filter out knowledge information that matches each of the keywords from the business knowledge base, resulting in a first knowledge information set, including: In the strict matching mode, each target keyword is matched with the keywords in the business knowledge base to obtain a first matching result; In the moderate matching mode, each of the target keywords and the keywords in the business knowledge base are converted into high-dimensional vectors, and a second matching result is obtained based on the similarity between the high-dimensional vectors corresponding to each of the target keywords and the high-dimensional vectors corresponding to the keywords in the business knowledge base. Based on the first matching result and the second matching result, the first knowledge information set is determined.
4. The method according to claim 1, characterized in that, The multiple semantic SQL generation strategies include a first semantic SQL generation strategy, a second semantic SQL generation strategy, and a third semantic SQL generation strategy; the first semantic SQL generation strategy is a semantic SQL generation strategy based on multiple fixed rules, the second semantic SQL generation strategy is a semantic SQL generation strategy based on a large language model, and the third semantic SQL generation strategy is a semantic SQL generation strategy based on data query type. The fixed rules are mapping rules between business logic and query logic; The generation of initial SQL statements based on the knowledge information group and preset semantic SQL generation strategies includes: Based on the knowledge information group, it is determined whether the data query complexity is greater than a preset threshold; the data query complexity is used to characterize the complexity of querying the target data; If the data query complexity is greater than the preset threshold, then a first semantic SQL statement is generated based on the first semantic SQL generation strategy and the knowledge information group; Based on the second semantic SQL generation strategy and the knowledge information group, generate a second semantic SQL statement; Based on the third semantic SQL generation strategy and the knowledge information group, generate third semantic SQL statements; The initial SQL statement is generated based on the first semantic SQL statement, the second semantic SQL statement, and the third semantic SQL statement.
5. The method according to claim 4, characterized in that, The method further includes: If the data query complexity is less than or equal to the preset threshold, the initial SQL statement is generated based on the target semantic SQL generation strategy and the knowledge information group; the target semantic SQL generation strategy is the semantic SQL generation strategy that matches the knowledge information group among the multiple semantic SQL generation strategies.
6. The method according to claim 4, characterized in that, The step of generating a first semantic SQL statement based on the first semantic SQL generation strategy and the knowledge information group includes: From a set of preset fixed rules, a target fixed rule that matches the knowledge information in the knowledge information group is determined; Based on the target fixed rules and the knowledge information group, the first semantic SQL statement is generated.
7. The method according to claim 4, characterized in that, The generation of second semantic SQL statements based on the second semantic SQL generation strategy and the knowledge information group includes: Based on the aforementioned knowledge information group, semantic SQL is constructed to generate prompt words; The semantic SQL generation prompt is input into the large language model, which then generates the second semantic SQL statement based on the semantic SQL generation prompt and historical data query records.
8. The method according to claim 1, characterized in that, The various semantic correction strategies include fixed rule-based semantic correction strategies and large language model-based semantic correction strategies. The fixed rule-based semantic correction strategies include semantic-level correction strategies, temporal-level correction strategies, and syntactic-level correction strategies. The semantic-level correction strategies are used to verify and correct whether the business logic in the semantic SQL is consistent. The temporal-level correction strategies are used to verify and correct the temporal condition expressions in the semantic SQL. The syntactic-level correction strategies are used to verify and correct the syntactic structure of the semantic SQL.
9. The method according to claim 1, characterized in that, After obtaining the target data requested by the user, the method further includes: The initial SQL statement is subjected to structured information processing to obtain the processing result; the processing result includes the business indicators, data query dimensions, and query constraints covered by the target data; The business entities in the target data are determined based on the data query dimensions; Obtain the business attribute information corresponding to the business entity, and add the business attribute information to the business entity of the target data to obtain the target data after addition; The added target data and the processing results are displayed on the target page.
10. An intelligent data query system implementing the data query method according to any one of claims 1-9, characterized in that, The system includes: a data receiving module, a keyword matching module, a semantic SQL generation module, a semantic correction module, and an SQL statement conversion module; The data receiving module is used to receive data query requests initiated by users and send the natural language question corresponding to the target data requested by the user in the data query request to the keyword matching module; The keyword matching module is used to receive the natural language question sent by the data receiving module, and perform keyword matching on the natural language question based on a multi-level keyword matching mode with matching degree thresholds from large to small, so as to filter out a knowledge information group that matches the natural language question from a preset business knowledge base; the knowledge information group includes knowledge information that highly matches the business indicators, data query dimensions and query constraints related to querying the target data; the keyword matching module is also used to send the knowledge information group to the semantic SQL generation module; The semantic SQL generation module is used to receive a knowledge information group sent by the keyword matching module, and generate an initial SQL statement based on the knowledge information group and a variety of preset semantic SQL generation strategies; the initial SQL statement is a semantic SQL that reflects the user's business query intent; the semantic SQL generation module is also used to send the initial SQL statement to the semantic correction module; The semantic correction module is used to receive the initial SQL statement sent by the semantic SQL generation module, and to perform semantic correction on the initial SQL statement based on a number of preset semantic correction strategies to obtain the corrected SQL statement; the semantic correction module is also used to send the corrected SQL statement to the SQL statement conversion module. The SQL statement conversion module is used to receive the corrected SQL statement sent by the semantic correction module, convert the corrected SQL statement into an executable SQL statement for the target database, obtain the target SQL statement, and execute the target SQL statement to obtain the target data requested by the user.