Interactive data insight system based on large language model

By using an interactive data insight system based on a large language model, we have solved the technical bottlenecks of enterprise-level data insight systems in natural language interaction and complex data processing, and achieved efficient and secure data analysis and querying.

CN121326933APending Publication Date: 2026-01-13广州中康数字科技有限公司
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202511338373.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-18
Publication Date
2026-01-13

AI Technical Summary

Technical Problem

Existing technologies struggle to meet the comprehensive needs of enterprise-level data insight systems in terms of natural language interaction, semantic understanding, multi-turn conversations, contextual memory, and data security, especially in terms of insufficient support for complex data formats.

Method used

An interactive data insight system based on a large language model is adopted, including an intent recognition and classification module, an entity extraction module, an entity and business term alignment module, an SQL generation module, and a structured query verification module. The system guides the large language model to perform query intent recognition, entity extraction, and semantic disambiguation through prompt templates, generates structured query language SQL statements, and performs syntax parsing and security checks.

Benefits of technology

It significantly enhances the system's ability to understand and respond to multi-round contexts, improves the accuracy of term matching, ensures the syntactic correctness and security of SQL statements, lowers the threshold for data analysis, and improves query efficiency and result controllability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121326933A_ABST
    Figure CN121326933A_ABST
Patent Text Reader

Abstract

The invention discloses an interactive data insight system based on a large language model. The interactive data insight system comprises an intention recognition and classification module, an entity extraction module, an entity and business term alignment module, an SQL generation module and a structured query verification module. The key technical problems that an existing natural language data analysis system is insufficient in semantic understanding, inaccurate in entity alignment, weak in multi-round dialogue support, unstable in SQL generation, lack of safety and the like can be solved, semantic understanding and natural language interaction of complex business data are achieved, the data analysis threshold is greatly reduced, and the data analysis efficiency is improved. And the query efficiency and the result controllability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence and data analysis technology, specifically to an interactive data insight system based on a large language model. Background Technology

[0002] With the development of information technology and big data technology, enterprises and organizations have accumulated a large amount of structured and unstructured data from different business systems, including database tables, log data, report documents, contract texts, customer communication records, etc. How to quickly extract valuable information and gain insights into business trends and risks from this massive amount of data has become a key issue in improving enterprise decision-making efficiency and competitiveness. Therefore, data analysis platforms and BI tools (such as Tableau, Power BI, FineBI, etc.) are widely used to build data visualization dashboards and reports. However, these tools generally suffer from the following problems:

[0003] High barrier to entry: Users need to have technical skills in data modeling, query syntax (such as SQL), and chart configuration;

[0004] Lack of intelligent understanding: Users must use standardized fields, terminology, and operational logic, and cannot express complex intentions using natural language;

[0005] Poor interactivity: Once the chart is generated, subsequent modifications and further explorations are costly, and it does not support continuous follow-up questions or supplementary queries.

[0006] To lower the barrier to entry, academia and industry have attempted to introduce Natural Language Processing (NLP) technology into data query and analysis scenarios, such as Natural Language to SQL (NL2SQL), conversational question-answering systems, and intelligent customer service robots. However, early NLP systems suffered from significant technical bottlenecks: limited semantic understanding capabilities, making it impossible to accurately identify complex user query intents in natural language; inability to handle long text contexts and lack of multi-turn dialogue capabilities; reliance on large amounts of manually labeled data, resulting in poor generalization ability; and weak integration with business datasets, making it difficult to customize interaction needs within the enterprise context.

[0007] Especially in data insight scenarios, user questions are often context-driven, multi-round iterative, and contain implicit business semantics, which traditional rule engines or shallow NLP methods cannot handle.

[0008] In recent years, with the rise of large-scale pre-trained language models (LLMs) such as ChatGPT, Gemini, Claude, KIMI, Qwen, and Doubao, breakthroughs have been made in natural language understanding and generation capabilities. LLMs can complete complex tasks through zero-shot or few-shot learning, supporting free question answering, summarizing, translation, code generation, and more. However, the application of general-purpose large language models in enterprise-level data analysis still has significant limitations: first, they lack an understanding of the semantics of enterprise-specific data, making it difficult to accurately identify field meanings and business rules; second, they pose data security and compliance risks, making them unsuitable for handling sensitive data; and third, they lack sufficient support for complex data formats such as multi-table joins, graph data, and nested structures, making it difficult to meet the actual needs of enterprises.

[0009] In summary, current NLP technologies cannot yet meet the comprehensive needs of enterprise-level data insight systems in terms of natural language interaction, semantic understanding, multi-turn conversations, contextual memory, and data security. Therefore, there is an urgent need for a solution that can integrate the powerful language understanding capabilities of large language models with the private semantic knowledge of enterprise data to achieve controllable, secure, continuous, and interpretable interactive natural language data analysis. Summary of the Invention

[0010] To address the shortcomings of existing technologies, this invention aims to provide an interactive data insight system based on a large language model.

[0011] To achieve the above objectives, the present invention adopts the following technical solution:

[0012] An interactive data insight system based on a large language model includes an intent recognition and classification module, an entity extraction module, an entity and business term alignment module, an SQL generation module, and a structured query verification module.

[0013] The intent recognition and classification module is used to receive natural language query requests and historical dialogue contexts input by users, guide the large language model to recognize query intent through prompt templates, and finally output structured semantic label results. The semantic label results include intent recognition results for insight type and dialogue semantic scenario type.

[0014] The entity extraction module is used to guide the large language model to identify entities after receiving the natural language query request and historical dialogue context input by the user, and output the label results of the entity type.

[0015] The entity-business terminology alignment module is used to map the entities identified by the entity extraction module into standard business terms by querying the terminology standard library. If there are ambiguities or vague expressions of entities, semantic refinement is performed through fuzzy matching and context awareness to achieve the mapping, and finally, structured standard business terms are output.

[0016] The SQL generation module is used to align the output results with entities and standard business terms, converting user-input natural language query requests into structured query language (SQL) statements that conform to the structured database query specification.

[0017] Furthermore, the entity and business terminology alignment module includes a terminology standard library construction and standardization unit, a context-aware semantic disambiguation unit, and a fuzzy matching unit;

[0018] The terminology standard library construction and standardization unit is used to predefine one or more attributes among the standard naming, meaning description, data type, unit information, and optional values ​​of each standard business term in the enterprise's internal structured data to obtain a terminology standard library. It is also used to perform standardization operations on entities in the natural language query requests input by users based on the terminology standard library, mapping them to the standard business terms in the terminology standard library.

[0019] The context-aware semantic disambiguation unit is used to make semantic disambiguation judgments by combining rules and a large language model based on historical dialogue context, user query target and current intent.

[0020] The fuzzy matching unit is used to perform fuzzy matching between the entity and the standard business terms in the terminology standard library when the current entity cannot be completely matched with the standard business terms. The unit recommends the standard business terms with the highest similarity as candidates. If the similarity meets the standard, the current entity is automatically mapped to the standard business term with the highest similarity. Otherwise, the user is allowed to choose or a prompt is given.

[0021] Furthermore, the terminology standard library construction and standardization unit performs standardization operations through one or more of the following methods:

[0022] (1) Based on a predefined thesaurus;

[0023] (2) Semantic similarity matching is achieved based on the embedding vector model, combined with manual review;

[0024] (3) Use large language models to construct prompt templates for terminology comprehension and unification.

[0025] Furthermore, the fuzzy matching unit utilizes a hybrid sparse and dense recall strategy for fuzzy matching, specifically as follows:

[0026] First, a coarse match is performed between the entity to be matched and the standard business terms in the terminology standard library using sparse retrieval to obtain a preliminary set of candidate standard business terms. Then, using a dense semantic representation method based on vector models, the semantic vector of each candidate standard business term in the preliminary set of candidate standard business terms is calculated. Finally, semantic fine ranking is performed based on the cosine similarity between the entity and the candidate standard business terms to obtain the standard business terms with the highest matching degree.

[0027] Furthermore, the SQL generation module adopts a prompt-based engineering approach, which organizes the received information into a context template that the large language model can understand through input prompts in a unified format, thereby driving the large language model to generate SQL statements with grammatical correctness and semantic integrity.

[0028] Furthermore, the system also includes a structured query validation module; the structured query validation module is used to automatically validate and diagnose errors in the SQL statements generated by the SQL generation module, so as to ensure that they are syntactically correct, semantically valid, and can be safely executed in the target database environment.

[0029] Furthermore, the structured query verification module includes a syntax parsing submodule, a schema consistency verification submodule, a semantic rule checking submodule, an execution simulation submodule, a security detection submodule, and an error identification and repair suggestion submodule;

[0030] The syntax parsing submodule is used to parse the lexical and syntactic structure of the SQL statements generated by the SQL generation module, and to determine whether they conform to the specified SQL syntax specifications and whether they can use relevant third-party Python packages.

[0031] The Schema Consistency Verification Submodule is used to compare the table names and field names referenced in the SQL statements generated by the SQL Generation Module with the pre-loaded or real-time read database structure information to identify problems such as missing fields, naming errors, and non-existent tables.

[0032] The semantic rule checking submodule is used to verify the semantic logic validity of the SQL statements generated by the SQL generation module;

[0033] The execution simulation submodule is used to simulate the execution flow of SQL statements in the sandbox database environment using the EXPLAIN PLAN method, analyze query costs, table scan methods and join order, thereby assessing whether there are logical risks or performance vulnerabilities in the SQL statements;

[0034] The safety detection submodule is used to identify potentially hazardous operations;

[0035] Error identification and repair suggestion submodule: It classifies and semantically encapsulates the verification results output by the syntax parsing submodule, schema consistency verification submodule, semantic rule checking submodule, execution simulation submodule, and security detection submodule, and generates automatic repair suggestions.

[0036] The beneficial effects of this invention are as follows:

[0037] 1. This invention adopts a semantic tag recognition mechanism of "insight type + dialogue scenario type". It uses a large language model to jointly model the user's natural language input and historical dialogue to generate structured intent tags. It not only distinguishes query intent (such as trend, comparison, anomaly, etc.) but also identifies user interaction behavior (such as follow-up question, correction, refinement, etc.), which significantly enhances the system's ability to understand and respond to multi-turn contexts.

[0038] 2. This invention employs a hybrid sparse and dense recall strategy to achieve accurate identification of non-standard expressions, synonyms, and ambiguous statements. It has context awareness capabilities and can perform semantic disambiguation and field mapping according to the query scenario, thereby improving the accuracy of terminology matching and solving the problems of diverse terms and redundant expressions in enterprise contexts.

[0039] 3. To address potential errors and risks in SQL generated by language models, this invention establishes a complete SQL verification mechanism, comprising five sub-modules: syntax parsing, field validity verification, semantic logic checking, execution simulation, and security assessment. This mechanism can automatically identify errors and generate repair suggestions before execution, preventing issues such as SQL injection, field spelling errors, and semantic conflicts, and ensuring that statements are stable, secure, and executable.

[0040] In summary, this invention can solve key technical problems in existing natural language data analysis systems, such as insufficient semantic understanding, inaccurate entity alignment, weak support for multi-turn dialogue, unstable SQL generation, and lack of security. It enables semantic understanding and natural language interaction of complex business data, significantly reduces the threshold for data analysis, and improves query efficiency and result controllability. Attached Figure Description

[0041] Figure 1 This is a schematic diagram of the overall architecture of the system according to an embodiment of the present invention;

[0042] Figure 2 This is a schematic diagram illustrating the implementation principle of the intent recognition and classification module in an embodiment of the present invention.

[0043] Figure 3 This is a schematic diagram illustrating the implementation principle of the entity extraction module in this embodiment of the invention.

[0044] Figure 4 This is a schematic diagram illustrating the implementation principle of the entity and business terminology alignment module in an embodiment of the present invention. Detailed Implementation

[0045] The present invention will be further described below with reference to the accompanying drawings. It should be noted that this embodiment is based on the present technical solution and provides detailed implementation methods and specific operation processes, but the protection scope of the present invention is not limited to this embodiment.

[0046] This embodiment provides an interactive data insight system based on a large language model, which aims to perform deep semantic parsing on natural language query requests input by users and automatically convert them into executable data operation instructions or intermediate semantic representations to achieve intelligent access and analysis of complex data.

[0047] This embodiment relies on large language models (LLMs), such as ChatGPT, Claude, KIMI, Qwen, Gemma, etc. It can fully leverage the powerful capabilities of commercial models in natural language understanding, contextual reasoning, and instruction generation by directly calling commercial models or by pre-training and fine-tuning open-source models for enterprise scenarios.

[0048] like Figure 1 As shown, the interactive data insight system based on a large language model in this embodiment includes an intent recognition and classification module, an entity extraction module, an entity and business terminology alignment module, an SQL generation module, and a structured query verification module.

[0049] The intent recognition and classification module is used to perform deep semantic analysis on the natural language query requests input by users using a large language model (LLM), and to identify the core data analysis intent (i.e. insight type) and the current dialogue semantic scenario (i.e. dialogue scenario type) expressed by the user, thereby providing semantic support for subsequent intelligent query generation, context understanding and continuous multi-turn interaction.

[0050] In this embodiment, the intent recognition and classification module uses a large language model to jointly model and semantically analyze the natural language query request input by the user and the historical dialogue context, and outputs a structured semantic label result. This semantic label result serves as an important prerequisite for the entity extraction module, the entity and business term alignment module, the SQL generation module, and the structured query verification module, thereby achieving a robust mapping from natural language issues to data insight logic.

[0051] Specifically, such as Figure 2 As shown, after receiving the natural language query request and historical dialogue context input by the user, the intent recognition and classification module guides the large language model to identify the query intent through the prompt template, and finally outputs structured semantic label results. The semantic label results include intent recognition results for insight type and dialogue semantic scenario type.

[0052] In this embodiment, the correspondence between insight type, dialogue semantic scene type and intent is shown in Table 1.

[0053] Table 1

[0054]

[0055] The entity extraction module is used to extract entity information related to the data structure from natural language query requests. Specifically, such as... Figure 3 As shown in Table 2, after receiving the natural language query request and historical dialogue context input by the user, the entity extraction module guides the large language model to identify entities through the prompt template and outputs the entity category label results, including indicators, dimensions, condition values, operations, context, etc.

[0056] Table 2

[0057]

[0058] The entity and business term alignment module is designed to establish a semantic bridge between natural language and internal structured data of an enterprise, thereby resolving query discrepancies caused by inconsistencies between user descriptions and system fields.

[0059] like Figure 4 As shown, the entity-to-business-term alignment module is used to standardize and map each entity based on the intent recognition results output by the intent recognition and classification module and the entity recognition results output by the entity extraction module. This ensures the feasibility and accuracy of the subsequent structured query construction process. The entity-to-business-term alignment module maps the entities identified by the entity extraction module to standard business terms by querying a terminology standard library. If an entity has ambiguity or vague expression, it is first semantically refined through fuzzy matching and context awareness before being mapped to a standard business term. To improve accuracy and security, a manual review mechanism can be set up to manually review the mapping results, or guide users to confirm the meaning of fields when the confidence level of the results is insufficient, thus avoiding mapping entities to incorrect standard business terms.

[0060] In this embodiment, the entity and business term alignment module further includes a terminology standard library construction and standardization unit, a context-aware semantic disambiguation unit, and a fuzzy matching unit;

[0061] The terminology standard library construction and standardization unit is used to predefine the standard naming, meaning description, data type, unit information, and optional values ​​(enumerated values) of each standard business term in the enterprise's internal structured data, thus obtaining the terminology standard library. The terminology standard library can be dynamically updated through access to the enterprise's metadata management system, data warehouse, data dictionary, etc., ensuring that the entity and business terminology alignment module always operates based on the latest data definition system. The terminology standard library construction and standardization unit is further used to standardize entities in user-input natural language query requests based on the terminology standard library, mapping them to the standard business terms in the terminology standard library. For example, "sales revenue," "revenue," and "operating income" are uniformly mapped to "revenue" or "total_sales."

[0062] Furthermore, in this embodiment, to support the recognition of diverse user expressions, the terminology standard library construction and standardization unit can perform standardization operations in any one or more of the following ways:

[0063] (1) Based on a predefined thesaurus;

[0064] (2) Semantic similarity matching is achieved based on embedding vector models (such as Word2Vec and BERT) and combined with manual review;

[0065] (3) Use Large Language Model (LLM) to construct prompt templates for terminology comprehension and normalization.

[0066] The role of a context-aware semantic disambiguation unit is to solve the problem of semantic ambiguity, that is, the problem of the same term representing different business meanings in different contexts. For example, the word "level" may mean "customer level" or "store level". Specifically, the context-aware semantic disambiguation unit uses information such as historical dialogue context, user query target, and current intent category, combined with rules and large language models (such as ChatGPT) to perform semantic disambiguation judgment on the entities to be mapped, ensuring accurate mapping.

[0067] The fuzzy matching unit is used to perform fuzzy matching between the current entity and standard business terms in the terminology standard library when the current entity cannot be completely matched with standard business terms. This is done using techniques such as edit distance algorithm, Jaccard similarity coefficient, cosine similarity, and embedding similarity. The unit recommends the standard business term with the highest similarity as a candidate. If the similarity meets the standard, the current entity is automatically mapped to the standard business term with the highest similarity; otherwise, the user is given the choice or a prompt is provided.

[0068] More specifically, in this embodiment, the fuzzy matching unit uses a mixed sparse and dense recall strategy to perform fuzzy matching, and the specific process is as follows:

[0069] First, sparse retrieval (such as BM25, TF-IDF) is used to perform a coarse match between the entity to be matched and the standard business terms in the terminology standard library to obtain a preliminary set of candidate standard business terms. Then, using dense semantic representation methods based on vector models (such as BERT, SimCSE, etc.), the semantic vector of each candidate standard business term in the preliminary set is calculated. Finally, semantic refinement is performed based on the cosine similarity between the entity and the candidate standard business terms to obtain the standard business term with the highest matching degree. This process can improve the matching accuracy between similar but differently expressed terms (such as "ibuprofen sustained-release capsules" and "ibuprofen sustained-release tablets," "Ibuprofen SR").

[0070] Specifically, this embodiment uses BM25 for coarse matching of entities and standard business terms; the calculation formula for BM25 is as follows:

[0071]

[0072] Where bm25(Q,D) represents the similarity score between the entity Q to be matched and the standard business term D, N represents the number of all standard business terms, |D| represents the length of the standard business term, avgdl represents the average length of all standard business terms, and q i This represents the elements after Q-segmentation, k1 and b represent hyperparameters, with default values ​​of 1.2 and 0.75 respectively, f(q i (,D) represents the frequency of element i in D, n(q) i ) represents the number of all standard business terms including element i.

[0073] Specifically, for dense semantic representation methods based on vector models (such as BERT, SimCSE, etc.), this embodiment specifically adopts the SimCSE model. The SimCSE model is trained by calculating the loss function based on the BERT results of two dropout layers with different parameters, denoted as α1 and α2 respectively. The specific process is as follows:

[0074] Construct training samples for the model, with samples in the format of "<sales revenue, revenue>", "<operating income, revenue>", etc. Define the loss function as:

[0075]

[0076] Where B is the number of training sample batches. vec i,1 vec i,2 Let α1 and α2 represent the vector results output by SimCSE with respect to the parameters α1 and α2, respectively, and denote the trained model as encoder(·).

[0077] Therefore, the recall result of a mixture of sparse and dense data is defined as:

[0078] scorce=k1*sim(encoder(r_term i ),vec i )+k2*bm25(r_term i D)

[0079] Where, k i Hyperparameters represent the weights of each score, satisfying the following conditions:

[0080] The SQL generation module aligns the output with entities and standard business terms, converting user-input natural language queries into structured query language (SQL) statements that conform to structured database query specifications. This allows for accessing and analyzing internal relational data resources. The SQL generation module combines the semantic modeling and text generation capabilities of a language generation model with multi-source structured domain knowledge to achieve highly accurate and controllable query intent transformation.

[0081] The SQL generation module is suitable for business scenarios involving multi-table structures, complex dimensional indicator systems, and industry-specific semantic backgrounds (such as drug sales, inventory, store channels, medical insurance policies, etc.). It can accurately identify user intent and generate executable SQL statements to meet users' diverse business analysis needs regarding drug sales trends, category comparisons, channel performance, inventory warnings, etc.

[0082] The SQL generation module can receive the following types of input: (1) the user's current natural language query request and its historical dialogue context information, which are used to construct a complete semantic request expression; (2) data table structure information, including metadata of the target data table or table set, such as field definitions, data types, primary and foreign key relationships, field grouping (dimension / indicator) tags, etc.; (3) relevant knowledge of the enterprise domain knowledge base, including structured or semi-structured business knowledge such as drug standard classification, commodity generic name mapping, commonly used analysis templates, field annotations, indicator calculation rules, etc.; (4) structured semantic parsing results, including standardized business terms output by the entity and business term alignment module, the results output during entity extraction, query intent recognition results, and the filtering conditions, time range, sorting methods, etc. output during entity extraction.

[0083] In this embodiment, the SQL generation module adopts a prompt engineering approach, which organizes the received information into a context template that the large language model can understand through input prompts in a unified format, thereby driving the large language model to generate SQL statements with grammatical correctness and semantic integrity.

[0084] In this embodiment, to improve the accuracy and robustness of the generated SQL, the SQL generation module further adopts an optimization mechanism, which includes: (A1) dynamically selecting the generated template structure according to different intent types and entity structures; (A2) explicitly embedding field comments or business logic descriptions in the prompts to guide the large language model to use the fields correctly; (A3) introducing historical multi-turn dialogue content to complete context-related content such as referencing and omissions; and (A4) adopting a multi-candidate generation mechanism to generate multiple candidate SQL statements in a single round and output confidence scores for subsequent evaluation and selection.

[0085] The output of the SQL generation module includes one or more executable SQL statements with the following attributes: 1) accurately expressing the analysis task corresponding to the user's query intent; 2) meeting the field specifications, data type constraints, and logical structure of the target data table; 3) semantically interpretable and supporting collaborative use with upstream entity and business terminology alignment modules and downstream execution and visualization modules. In addition to the SQL statement text itself, the SQL generation module also synchronously outputs structured auxiliary information, including the standard business terms referenced in the generation, auto-completion filtering conditions, analysis dimensions, and the confidence score of the generated statement, to enhance the interpretability and controllability of the system output.

[0086] For example, in response to a user-input natural language question, "What is the sales trend of ibuprofen in Jiangsu Province chain stores in the first quarter of 2024?", the SQL generation module will identify the entities "ibuprofen", "Jiangsu Province", "2024Q1" and the intent "trend analysis", and automatically generate a standard SQL statement that includes multi-table joins, conditional filtering and time aggregation, in combination with the structure of the drug sales details table, the drug information dimension table and the store information table.

[0087] By setting up an SQL generation module, the semantic gap between natural language expression and enterprise data systems can be effectively bridged, improving the accuracy and automation of natural language queries, significantly enhancing the system's adaptability to complex analysis tasks, and demonstrating good practical value and industry adaptability.

[0088] The structured query validation module automatically validates and diagnoses errors in the SQL statements generated by the SQL generation module, ensuring their syntactic correctness, semantic validity, and secure execution within the target database environment. This module forms a crucial intermediate validation link between SQL generation and actual execution, significantly improving the system's robustness, security, and accuracy.

[0089] Specifically, the structured query verification module includes a syntax parsing submodule, a schema consistency verification submodule, a semantic rule checking submodule, an execution simulation submodule, a security detection submodule, and an error identification and repair suggestion submodule.

[0090] The syntax parsing submodule is used to parse the lexical and syntactic structure of the SQL statements generated by the SQL generation module, and to determine whether they conform to the specified SQL syntax specifications (such as MySQL, PostgreSQL, ANSI SQL, etc.) and whether relevant third-party Python packages (such as sqlglot, sqlparse, etc.) can be used.

[0091] The Schema consistency verification submodule is used to compare the table names and field names referenced in the SQL statements generated by the SQL generation module with the pre-loaded or real-time read database structure information (Schema metadata) to identify problems such as missing fields, naming errors, and non-existent tables.

[0092] The semantic rule checking submodule is used to verify the semantic logic legality of the SQL statements generated by the SQL generation module, such as whether aggregate functions match grouping fields, whether subqueries are ambiguous, whether JOIN conditions are missing in multi-table joins, and whether fields in WHERE conditions support corresponding operations.

[0093] The execution simulation submodule is used to simulate the execution flow of SQL statements in the "EXPLAIN PLAN" mode in a sandbox database environment. It is used to analyze query costs, table scan methods, join order, etc., thereby assessing whether there are logical risks or performance hazards in the SQL statements.

[0094] The security detection submodule is used to identify potentially dangerous operations, such as write operations like DELETE, UPDATE, and DROP (when the system is configured in read-only mode), and to prevent high-risk behaviors such as SQL injection and system table access.

[0095] Error identification and repair suggestion submodule: It classifies and semantically encapsulates the verification results output by the syntax parsing submodule, schema consistency verification submodule, semantic rule checking submodule, execution simulation submodule, and security detection submodule, and generates automatic repair suggestions (such as recommending JOIN fields, prompting field spelling corrections, etc.), which can be used as a feedback mechanism for LLM secondary generation optimization.

[0096] For those skilled in the art, various corresponding changes and modifications can be made based on the above technical solutions and concepts, and all such changes and modifications should be included within the protection scope of the claims of this invention.

Claims

1. An interactive data insight system based on a large language model, characterized in that: It includes an intent recognition and classification module, an entity extraction module, an entity and business terminology alignment module, an SQL generation module, and a structured query verification module; The intent recognition and classification module is used to receive natural language query requests and historical dialogue contexts input by users, guide the large language model to recognize query intent through prompt templates, and finally output structured semantic label results. The semantic label results include intent recognition results for insight type and dialogue semantic scenario type. The entity extraction module is used to guide the large language model to identify entities after receiving the natural language query request and historical dialogue context input by the user, and output the label results of the entity type. The entity-business terminology alignment module is used to map the entities identified by the entity extraction module into standard business terms by querying the terminology standard library. If there are ambiguities or vague expressions of entities, semantic refinement is performed through fuzzy matching and context awareness to achieve the mapping, and finally, structured standard business terms are output. The SQL generation module is used to align the output results with entities and standard business terms, converting user-input natural language query requests into structured query language (SQL) statements that conform to the structured database query specification.

2. The system according to claim 1, characterized in that, The entity and business terminology alignment module includes a terminology standard library construction and standardization unit, a context-aware semantic disambiguation unit, and a fuzzy matching unit. The terminology standard library construction and standardization unit is used to predefine one or more attributes among the standard naming, meaning description, data type, unit information, and optional values ​​of each standard business term in the enterprise's internal structured data to obtain a terminology standard library. It is also used to perform standardization operations on entities in natural language query requests input by users based on the terminology standard library, mapping them to standard business terms in the terminology standard library. The context-aware semantic disambiguation unit is used to make semantic disambiguation judgments by combining rules and a large language model based on historical dialogue context, user query target and current intent. The fuzzy matching unit is used to perform fuzzy matching between the entity and the standard business terms in the terminology standard library when the current entity cannot be completely matched with the standard business terms, and recommend the standard business terms with the highest similarity as candidates. If the similarity score meets the standard, the current entity will be automatically mapped to the standard business term with the highest similarity score; otherwise, the user will be given the option to select or a prompt will be provided.

3. The system according to claim 2, characterized in that, The standardization unit for the terminology standard library is constructed and standardized through one or more of the following methods: (1) Based on a predefined thesaurus; (2) Semantic similarity matching is achieved based on the embedding vector model, combined with manual review; (3) Use large language models to construct prompt templates for terminology comprehension and unification.

4. The system according to claim 2, characterized in that, The fuzzy matching unit uses a mixed sparse and dense recall strategy for fuzzy matching. The specific process is as follows: First, a coarse match is performed between the entity to be matched and the standard business terms in the terminology standard library using sparse retrieval to obtain a preliminary set of candidate standard business terms. Then, using a dense semantic representation method based on vector models, the semantic vector of each candidate standard business term in the preliminary set of candidate standard business terms is calculated. Finally, semantic fine ranking is performed based on the cosine similarity between the entity and the candidate standard business terms to obtain the standard business terms with the highest matching degree.

5. The system according to claim 1, characterized in that, The SQL generation module adopts a prompt-based engineering approach. Through input prompts in a unified format, the received information is organized into a context template that the large language model can understand, driving the large language model to generate SQL statements with grammatical correctness and semantic integrity.

6. The system according to claim 1, characterized in that, It also includes a structured query validation module; the structured query validation module is used to automatically validate and diagnose errors in the SQL statements generated by the SQL generation module, so as to ensure that they are syntactically correct, semantically legal and can be safely executed in the target database environment.

7. The system according to claim 6, characterized in that, The structured query verification module includes a syntax parsing submodule, a schema consistency verification submodule, a semantic rule checking submodule, an execution simulation submodule, a security detection submodule, and an error identification and repair suggestion submodule. The syntax parsing submodule is used to parse the lexical and syntactic structure of the SQL statements generated by the SQL generation module, and to determine whether they conform to the specified SQL syntax specifications and whether they can use relevant third-party Python packages. The Schema Consistency Verification Submodule is used to compare the table names and field names referenced in the SQL statements generated by the SQL Generation Module with the pre-loaded or real-time read database structure information to identify problems such as missing fields, naming errors, and non-existent tables. The semantic rule checking submodule is used to verify the semantic logic validity of the SQL statements generated by the SQL generation module; The execution simulation submodule is used to simulate the execution flow of SQL statements in the sandbox database environment using the EXPLAIN PLAN method, analyze query costs, table scan methods and join order, thereby assessing whether there are logical risks or performance vulnerabilities in the SQL statements; The safety detection submodule is used to identify potentially hazardous operations; Error identification and repair suggestion submodule: It classifies and semantically encapsulates the verification results output by the syntax parsing submodule, schema consistency verification submodule, semantic rule checking submodule, execution simulation submodule, and security detection submodule, and generates automatic repair suggestions.

Citation Information

Cited By

  • Semantic recognition and judgment system and method oriented to UB interconnection protocol and IO interconnection chip

    CN122111902A

  • A semantic recognition and adjudication system, method, and I / O interconnect chip for the UB interconnect protocol.

    CN122111902B

  • Query analysis method, device and equipment based on large language model and storage medium

    CN122285852A

  • Data management method, system and equipment based on double-track verification and self-healing mechanism and medium

    CN122332420A