Structured query language generation method for semantic proper subset decomposition based on LLM

By constructing a heterogeneous graph and dual-channel node activation, combined with physical truth calibration and virtual association edges, the attention bias and column name drift problems of LLM in complex queries are solved, achieving efficient and accurate SQL generation.

CN122064708AActive Publication Date: 2026-05-19HUAQIAO UNIVERSITY +2
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUAQIAO UNIVERSITY
Filing Date
2026-04-20
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

Existing Text-to-SQL technologies based on Large Language Models (LLM) suffer from attention focus bias, column name drift, value illusion, failure to identify implicit associations, and query topology redundancy when processing complex queries, resulting in erroneous or inefficient SQL statements.

Method used

We employ an LLM-based semantic true subset decomposition method, which constructs heterogeneous graphs, activates dual-channel nodes, calibrates physical truth values, and establishes virtual associative edges. This ensures entity value alignment and generates minimum-cost connected subgraphs, thereby improving query accuracy and efficiency.

Benefits of technology

It significantly improves the completeness of schema node recall, eliminates column name drift and value illusion, optimizes query paths, ensures that the generated SQL statements are effective at the physical execution level, and improves query accuracy and execution performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122064708A_ABST
    Figure CN122064708A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of artificial intelligence and natural language processing, and particularly relates to a structured query language generation method for semantic proper subset decomposition based on LLM, which comprises the following steps executed in sequence: S1, constructing a heterogeneous graph of a database based on Schema; s2, acquiring data filtering logic based on node activation and relation extraction of macro and micro channels; s3, based on the data filtering logic, performing calibration by using actual storage content of a database as a truth value standard; s4, performing synchronous activation based on the virtual association edge; s5, generating a minimum-cost connected subgraph based on the metric closure; s6, carrying out structural integrity expansion and simplified Schema generation; s7, Schema completion based on multi-dimensional annotation enhancement is carried out; s8, generating an SQL (Structured Query Language) statement based on enhanced Schema; and it is ensured that the finally generated SQL statement has the optimal execution performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence and natural language processing technology, specifically relating to a structured query language generation method based on LLM semantic proper subset decomposition. Background Technology

[0002] Text-to-SQL (TTO) technology aims to transform users' natural language queries into executable structured query languages ​​for databases, offering wide-ranging applications in intelligent customer service, business intelligence analytics, and automated reporting. With the rise of Large Language Models (LLMs), leveraging their powerful semantic understanding and code generation capabilities for TTO has become the mainstream approach. The typical method involves directly concatenating the database schema with the natural language question and inputting it into the LLM, which then generates SQL statements end-to-end.

[0003] However, while LLM performs exceptionally well in handling simple queries, existing technologies still have the following significant limitations when facing complex enterprise-level real-world business scenarios: First, existing LLM-based generation methods exhibit a significant "attention focus bias" when processing long and complex sentences with multiple constraints. Because LLM's attention mechanism tends to capture the most prominent core intent of a sentence, it often ignores implicit parallel conditions, time ranges, or specific attribute restrictions, and other peripheral constraints. While existing hinting engineering attempts to guide LLM, it lacks a mechanism for systematically deconstructing and physically isolating the semantics of the problem, resulting in frequently missing constraints in the generated SQL statements and thus retrieving incorrect data results.

[0004] Secondly, existing technologies generally lack empirical awareness of the physical content of the database in value-column alignment. LLM generation is essentially based on probabilistic prediction, making it highly susceptible to "column name drift" and "value illusion." For example, LLM might incorrectly bind entity values ​​to semantically similar but physically different columns (e.g., misclassifying "shipping location" as "receiving location"), or generate synonyms or abbreviations that do not exist in the database. This "empty-to-empty" generation method, detached from the actual stored content of the database, results in SQL statements that, while syntactically correct, fail to hit any valid data during execution.

[0005] In addition, existing pattern linking or graph construction techniques often suffer from significant topological cost blind spots and implicit association recognition failures when constructing query paths and identifying data associations.

[0006] On the one hand, existing algorithms typically ignore the differences in computational costs at the SQL execution level when constructing query topologies. Current technologies often only consider the semantic relevance between tables, treating all join edges (including low-cost intra-table attribute edges and high-cost cross-table foreign key edges) as having equal weight. This results in query subgraphs generated by the algorithms, while logically connected, potentially containing a large number of redundant and computationally expensive cross-table joins, ultimately generating SQL statements with low execution efficiency or even timeouts.

[0007] On the other hand, existing technologies suffer from severe recall deficiencies and difficulties in identifying implicit relationships prevalent in databases. In real-world business databases, there are often numerous "twin columns" (such as IDs or region names with the same name in different tables) with overlapping data value domains but no defined physical foreign keys. Existing technologies typically treat these columns as isolated islands, lacking the ability to perceive global relationships based on data characteristics. When large LLMs perform schema mapping, they often adopt a "single-point wins" matching strategy; that is, if a column has a slightly higher semantic score, the LLM only activates that column and ignores other potentially homogeneous columns, causing the target column that truly matches the business intent to be missed in the initial stage. Simultaneously, due to the lack of explicit marking and differentiation of these implicitly related columns, LLMs often fail to perceive the business boundaries between these columns when generating SQL, easily leading to "misattribution" of column names (e.g., mistakenly using an auxiliary column only for specific business purposes as a primary key column in a query), ultimately resulting in logical deviations in the generated query statements.

[0008] In summary, overcoming the attention blind spot of LLM in complex queries, ensuring accurate alignment between entity values ​​and physical data, and constructing an optimal query topology that conforms to database execution costs and implicit associations are the technical challenges that urgently need to be solved in the current Text-to-SQL technology field. Summary of the Invention

[0009] The purpose of this invention is to provide a structured query language generation method based on LLM semantic proper subset decomposition that improves the alignment accuracy between entity values ​​and physical data.

[0010] To achieve the above objectives, the present invention adopts the following technical solution: 1. A structured query language generation method based on LLM semantic proper subset decomposition, characterized by comprising the following steps executed sequentially: S1: Construct a heterogeneous graph of the database based on the schema, extract the tables and columns in the schema and construct them as table nodes and column nodes respectively. The heterogeneous graph includes internal edges for establishing physical connections between column nodes and table nodes, foreign key edges for physically connecting two column nodes in the database schema that have explicitly defined primary and foreign key association constraints, and virtual association edges for physically connecting column nodes in the schema that have not defined physical foreign key constraints. S2: Node activation and relation extraction based on a macro-micro dual-channel approach, including two parallel execution channel branches. One is the macro-global channel, which inputs the natural language query and the corresponding database schema into the large language model to identify core table nodes and column nodes to form the first set of activated nodes. And parse the data filtering logic in the query; The other is the micro-feature channel, which decomposes the natural language query into several semantic proper subset sequences based on the semantic dimension, and inputs each proper subset into the large language model for schema mapping to form a second set of activation nodes. The decomposition process of the micro-feature channels follows the principles of subset constraint and multi-view coverage; S3: Based on the data filtering logic, use the actual stored content of the database as the truth standard for calibration: if the entity value exists in the prediction column, execute the truth full database diffusion path; otherwise, execute the fragmented full database error correction path. Based on the hybrid scoring model of semantic and literal matching, select high-scoring candidate columns for forced activation and construct a calibration evidence set to correct the illusion values ​​generated by the model. S4: Based on the synchronous activation of virtual associated edges, integrate the node activation results from step S3 to construct a third set of activated nodes. The initial set of activated nodes is , ; Traverse the initial set of activated nodes For each node in the graph, check if it has a virtual associated edge in the heterogeneous graph. If the initial set of activated nodes is detected, The nodes in the set are connected to the initially activated node set via virtual associative edges. For nodes other than those in the initial activation set, the synchronization activation mechanism is triggered, forcibly adding the associated node to the initial activation node set. Obtain the expanded set of terminal active nodes. ; S5: Generate a minimum-cost connected subgraph based on metric closure: Construct a set containing only the terminal active nodes on the heterogeneous graph. A virtual complete graph is constructed, and a metric closure is built based on the topology of the virtual complete graph. The minimum spanning tree algorithm is used to solve the minimum weight subset connecting all terminal nodes on the metric closure, which serves as the logical skeleton of the query. Map the virtual paths in the minimum weight subset back to the real physical paths of the heterogeneous graph, construct a minimum cost connected subgraph, identify the inactive intermediate nodes in the real physical path, mark them as semantic bridging nodes and force them to be activated. S6: Structural Integrity Expansion and Simplified Schema Generation: Perform structural integrity checks on newly activated intermediate table nodes, automatically complete the primary key and foreign key nodes corresponding to the intermediate table node; merge the original terminal node, semantic bridge node and the supplemented primary and foreign key nodes to construct the schema target set, and output the context of the corresponding simplified schema; S7: Schema completion based on multi-dimensional annotation enhancement: Perform descriptive enhancement on the simplified schema: generate basic semantic annotations for parsing field technical abbreviations or terms; and generate discriminative annotations based on the virtual association edges, the discriminative annotations being used to explicitly indicate the business boundaries or usage scenario differences between easily confused node pairs; integrate the above annotations into the simplified schema to generate an enhanced schema that includes complete business semantics and disambiguation guidance; Step S8: SQL statement generation based on enhanced schema: Assemble the original natural language query with the enhanced schema generated in step S7, which includes basic semantic annotations and discriminative annotations, and simultaneously... The triples in the context are used as the basis for determining the physical truth value and are integrated into the prompt word context to construct a complete prompt word template. This prompt word template is then input into the large language model to generate the target SQL statement.

[0011] Preferably, the specific construction steps of the heterogeneous spectrum in step S1 are as follows: S1-1: Read the schema information of the target database and perform a statistical feature scan on all data in the target database; S1-2: To transform the physical structure and implicit data association of the target database into a data structure that the algorithm can process, a heterogeneous graph containing multidimensional attributes is constructed. ; Among them, the node set It contains two types of nodes: table nodes and column nodes ,and , , Indicates the first Each table node They represent the first Each column node Represents the set of edges; S1-3: This heterogeneous graph includes intrinsic edges, foreign key edges, and virtual association edges, wherein the intrinsic edge is for any column node. and its table nodes The established physical connection edge is assigned the first weight to the internal edge. ; This foreign key edge is a physical connection between two column nodes that have explicitly defined primary-foreign key association constraints in the database schema. This foreign key edge is assigned a second weight. Second weight First weight The preset multiple; This virtual association edge is used to connect column nodes in the schema that do not have defined physical foreign key constraints. The steps for constructing this virtual association edge are as follows: Candidate column cleaning based on multi-dimensional features: Traverse all column nodes, perform multiple logical checks on each column node sequentially, and only columns that pass all logical checks simultaneously are marked as valid candidate columns. The first logical judgment is data type and null value filtering, used to remove empty columns and columns of Boolean type; The second logical judgment is cardinality feature filtering, which calculates the deduplication cardinality of column data. If the deduplication cardinality is lower than the first preset threshold, the column is determined to be an enumeration status code or classification identifier and is removed. The third logical judgment is sparsity feature filtering. For numerical columns or text columns that can be converted into numerical values, the sparsity index is calculated using the following formula. : ; in, and These represent the maximum and minimum values ​​in the column's numerical range, respectively. This is the deduplication base for this column; If sparsity index If the sparsity index is less than the second preset threshold, the column is determined to be a dense linear sequence and is removed. If the value is greater than or equal to the second preset threshold, the column is determined to be a discrete entity identifier and is retained. Check the current column pair If an explicit foreign key edge already exists between them, skip it to avoid establishing redundant connections. Otherwise, use the minimum hash signature-based association metric: generate minimum hash signature vectors for the retained candidate column nodes, calculate the Jaccard similarity coefficient between the minimum hash signature vectors, and when the similarity coefficient exceeds the preset third threshold, determine that the two columns have overlapping value ranges and pair them up in a non-repeating combination method to establish virtual association edges.

[0012] Preferably, the decomposition process in step S2 follows the following two segmentation principles: Subset constraints, arbitrarily decomposed subproblems It must be the original problem. proper subsets of, i.e. ; Multi-perspective coverage: The logical union of all semantically derived proper subsets should semantically cover most of the information entropy of the original problem, formally represented as... .

[0013] Preferably, the specific calibration steps in step S3 are as follows: S3-1: Relation Extraction: Parse the data filtering logic output by the large language model to extract a structured set of equivalence relation triples. : ; in, To predict the table name, To predict column names, To predict entity values; S3-2: Specific filtering: for this set of triples Predicted entity values Perform type analysis. For predicted entity values ​​of pure numeric type, only check whether the predicted entity value exists in the corresponding predicted column of the prediction table. If it exists, keep it; otherwise, discard it. For predicted entity values ​​that are not purely numeric, if they are determined to have high semantic referentiality, a truth value calibration and diversion is performed: for predicted entity values ​​that are not purely numeric, the existence of the predicted entity value is queried in the corresponding prediction column of the prediction table. If the predicted entity value exists, it enters the truth value-based full-database diffusion path; otherwise, it enters the fragmented full-database error correction path. Truth-based full-database diffusion path: Physical scan: Traverse all columns in the schema except the source column itself, and verify the existence of the predicted entity value in other columns using database query commands. If it exists, the column is marked as a candidate activation column node, forming a candidate set. Otherwise, no action will be taken; Semantic vector alignment: Invoke the vector embedding model to vectorize the metadata of the source column node and the candidate activation column node to obtain the candidate activation column vector; Threshold truncation and activation: Calculate the cosine similarity between the source column and the candidate activation column node vectors. When the semantic similarity score of the candidate activation column exceeds the threshold, retain it and sort it in descending order according to the cosine similarity value. Select the top-N preset number of high confidence column nodes for activation. Fragmented full-database error correction path: Global retrieval and correction process based on content fragments: Entity segmentation: Using predefined text segmentation rules, the predicted entity value is broken down into text fragments with independent semantics, constructing a search term set containing the predicted entity value and its fragments. ,in That is, the set of equivalence relation triples. In ; Full database blind search: Traverse all tables and columns defined in the database schema, and for each column, physically search whether it contains the set of search terms. For any text fragment in the table, if a match is found in a column of a certain table, that column is marked as a potential target column node. After traversal, all marked columns together constitute a potential target set. ; Hybrid rating re-ranking: Establishing a hybrid rating model based on both semantic and literal metrics: For the target set Each potential target node in Calculate its overall score: ; In the formula, A semantic vector representation of the source column metadata for large model predictions. Represents the set of potential targets The Middle Semantic vector representation of the metadata of each candidate column. Represents the cosine similarity function. Indicates the matching reward coefficient. This represents a text character matching scoring function; The rule for determining the value is: if the retrieved true value Compared with the predicted value The text characters are completely identical. The value is 1; if it only partially contains the element, then... The base value is 0.5. If there is no text character match between the two, then... The value is 0; Error correction activation and truth retention: based on comprehensive scoring For the potential target set Sort the nodes in descending order, select the top 3-K nodes based on their overall scores as the final corrected target column nodes, and forcibly activate them. Constructing a calibration evidence set : ; In the formula: and Representing the first The table name and column names of the potential target nodes that are activated. This represents the actual physical truth value that was hit under the path listed in this table during a full database search.

[0014] Preferably, step S5 is specifically performed as follows: Constructing a metric closure: in this heterogeneous graph Above, construct a set containing only terminal active nodes. Virtual complete graph ,in A set of virtual edges connecting the terminal active nodes; The specific construction steps are as follows: Based on this virtual complete graph, for the set Any two nodes in and Calculate in this heterogeneous spectrum and The shortest path weight between them is then assigned to the value. The corresponding virtual edges are recorded, and all nodes and edges contained in the shortest path are also recorded as physical shortest path information. Complete the construction of the metric closure; Solving the minimum spanning tree logical skeleton: On the constructed metric closure, apply the minimum spanning tree algorithm to find the subset of edges that connects all terminal nodes and has the smallest sum of edge weights. This subset of edges As the logical framework for the query; Physical subgraph reconstruction and connected topology construction: For each virtual edge in the logical skeleton, its corresponding physical shortest path information is retrieved one by one and mapped to the actual physical connection path existing in the database. Topological fusion is performed on all physical connection paths, duplicate nodes and edges are removed, and a seamless connection of all terminal active node sets is constructed. For the minimum cost connected subgraph, identify the inactive intermediate nodes in the physical path of the minimum cost connected subgraph, mark them as necessary semantic bridge nodes and force their activation.

[0015] Preferably, the specific execution steps of step S6 are as follows: Structural integrity expansion and simplification schema generation perform structural integrity checks on the table nodes in the intermediate node: if the table node of the intermediate node is not included in the terminal node set... In the middle, automatically complete the primary key node and foreign key node corresponding to the intermediate table node, and force these related key nodes to be added to the activation queue, thus completing the set of terminal nodes. The semantic bridge node and the supplementary primary and foreign key nodes perform a logical union operation to construct a schema target set. Based on this schema target set, the schema is simplified to obtain a simplified schema.

[0016] Preferably, the specific execution steps of step S7 are as follows: Basic semantic annotation generation: Analyze the metadata of each table and column in the simplified schema and some sample data, use a large language model to parse the technical abbreviations or domain terms in the fields, and generate corresponding business semantic descriptions; Perform conflict resolution annotation injection: Based on the heterogeneous graph, detect whether the virtual association edge exists in the nodes of the simplified schema. If it exists, construct a resolution annotation for the node pair. Otherwise, do not construct a resolution annotation. The resolution annotation is configured to explicitly indicate the business boundary or usage scenario difference between nodes. The basic semantic annotations and the discriminative annotations are integrated into the description information of the simplified schema to obtain the enhanced schema.

[0017] A structured query language generation system based on LLM semantic proper subset decomposition includes a memory and a processor. The memory stores computer-executable instructions, and the processor executes the computer-executable instructions to implement the structured query language generation method based on LLM semantic proper subset decomposition described above.

[0018] By adopting the aforementioned design scheme, the beneficial effects of the present invention are: First, to address the problem that large language models are prone to "single-view focus bias" when processing complex nested queries, leading to the omission of constraints, this application proposes a semantic extraction strategy based on macro and micro dual channels. Existing technologies typically input long and complex sentences directly, causing the model to ignore edge constraints. This application uses micro-feature channels to follow the subset constraint principle, forcibly decomposing complex queries into independent semantic true subsets, forcing the model to activate each local constraint independently; at the same time, it combines macro-global channels to maintain semantic coherence; this dual-track mechanism effectively solves the problem of long-tail constraint loss and significantly improves the completeness of schema node recall. Second, in response to the problem that large models lack awareness of the physical content of the database, which easily leads to "column name drift" and "value illusion", this application establishes a full-database calibration and correction mechanism based on physical truth values; Unlike traditional probabilistic predictions that rely solely on metadata similarity, this application introduces a truth-based flow calibration strategy: for existing predicted values, the drift of column names with the same name but different meanings is corrected through a full-database diffusion path; for non-existent phantom values, the fragmented blind detection error correction path is used to force correction to the true value through a full-database physical retrieval. This mechanism ensures that the generated SQL filtering conditions (WHERE clauses) are absolutely effective at the physical execution layer, fundamentally eliminating invalid queries that are "empty to empty". Third, in response to the problems of multi-table join failure and synonym column confusion caused by implicit associations, this application constructs a virtual association edge and conflict identification annotation system based on statistical features; This application breaks through the limitations of traditional schemas that rely solely on explicit foreign keys. It utilizes sparsity feature filtering and hash signature similarity to mine implicit data associations and establish logical virtual connections. This not only triggers the synchronous activation of homogeneous nodes to prevent omissions, but also generates discriminative annotations based on this, explicitly informing the business boundaries between easily confused columns in the large model, such as distinguishing between "shipping address" and "invoicing address", significantly reducing decision ambiguity in the model. Fourth, to address the problem of high token consumption and inefficient query paths caused by large-scale schema input redundancy, this application proposes a minimum-cost connected subgraph generation method based on metric closure. This application simulates the real database JOIN cost by distinguishing the weight difference between internal and foreign key edges; it uses the minimum spanning tree algorithm to solve the metric closure, which can accurately remove semantically related but topologically redundant intermediate tables, retaining only the logical skeleton with the lowest execution cost. This not only significantly compresses the length of the Prompt context, reserving space for injecting detailed business comments, but also ensures that the final generated SQL statement has optimal execution performance. Attached Figure Description

[0019] Figure 1 This is a schematic diagram of the overall process of the method of the present invention; Figure 2 This is a schematic diagram of the node activation and relationship extraction process based on macro-micro dual channels of the present invention; Figure 3 This is a schematic diagram of the full-database calibration and correction process based on physical truth values ​​according to the present invention; Figure 4 This is a schematic diagram of the process for generating minimum-cost connected subgraphs based on metric closure according to the present invention. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0021] The terms "first," "second," "third," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.

[0022] like Figure 1 As shown, the structured query language generation method based on LLM semantic proper subset decomposition includes the following steps executed sequentially: S1: Constructing a heterogeneous graph of the database based on the schema, the specific steps are as follows: S1-1: Read the schema information of the target database and perform a statistical feature scan on all data in the target database; S1-2: To transform the physical structure and implicit data association of the target database into a data structure that the algorithm can process, a heterogeneous graph containing multidimensional attributes is constructed. ; Among them, the node set It contains two types of nodes: table nodes and column nodes ,and , , Indicates the first Each table node They represent the first Each column node Represents the set of edges; S1-3: This heterogeneous graph includes intrinsic edges, foreign key edges, and virtual association edges, wherein the intrinsic edge is for any column node. and its table nodes The established physical connection edge is assigned the first weight to the internal edge. , In this embodiment, it is set The first weight It represents the natural structural hierarchy between a table and its attribute columns, representing extremely low graph traversal access cost; This foreign key edge is a physical connection between two column nodes that have explicitly defined primary-foreign key association constraints in the database schema. This foreign key edge is assigned a second weight. In this embodiment, it is set In this embodiment, the second weight First weight The preset multiple, i.e. In this embodiment, The difference between the first and second weights is used to simulate the high computational cost of databases when performing cross-table join (JOIN) operations.

[0023] This virtual association edge is used to connect column nodes in the schema that do not have defined physical foreign key constraints. The steps for constructing this virtual association edge are as follows: Candidate column cleaning based on multi-dimensional features: Traverse all column nodes, perform multiple logical checks on each column node sequentially, and only columns that pass all logical checks simultaneously are marked as valid candidate columns. The first logical judgment is data type and null value filtering, used to remove null columns and Boolean type columns, because they lack the specificity of being associated keys; The second logical judgment is cardinality feature filtering, which calculates the deduplication cardinality of column data. If the deduplication cardinality is lower than the first preset threshold, the column is determined to be an enumeration status code or classification identifier and is removed. In this embodiment, the first preset threshold is set to 4. The third logical judgment is sparsity feature filtering. For numerical columns or text columns that can be converted into numerical values, the sparsity index is calculated using the following formula. : ; in, and These represent the maximum and minimum values ​​in the column's numerical range, respectively. This is the deduplication base for this column; If sparsity index If the sparsity index is less than the second preset threshold, the column is determined to be a dense linear sequence and is removed. If the value is greater than or equal to the second preset threshold, the column is determined to be a discrete entity identifier and retained. In this embodiment, the second preset threshold is 5.0.

[0024] Association metric based on minimum hash signature: Generate minimum hash signature vectors for the retained candidate column nodes and pair them up in pairs using a non-repeating combination method; the pairing here is a non-repeating binomial combination in mathematics. For example, if the set is {A,B,C}, all non-repeating binomial combinations are: {A,B},{A,C},{B,C}.

[0025] Before calculating similarity, check the current column pairs. If there is already an explicit foreign key edge between them, skip it directly to avoid establishing redundant connections. Otherwise, calculate the Jaccard similarity coefficient estimate between the minimum hash signature vectors. When the similarity coefficient estimate exceeds the preset third threshold, it is determined that the two columns have overlapping value ranges and establish a virtual association edge. In this embodiment, the third threshold is set to 0.5. This virtual associative edge is configured as a non-ergodic logical connection, meaning that in the topological path calculation matrix of the graph, the weight of this virtual associative edge is defined as infinite. This prevents the SQL generation algorithm from generating incorrect JOIN paths through this edge. This virtual association edge is essentially a pre-embedded "error correction anchor point" designed to address the "column name drift" problem caused by similar column names in large language models. Its specific functions are twofold: Synchronous activation of associated nodes: In the subsequent node activation phase, if the LLM is misled by the literal meaning and only activates one node, for example, when the user asks "Charter Number" and the model mistakenly selects frpm.Charter School Number, the existence of this virtual associated edge will be detected, and the potential target node schools.CharterNum on the other end will be forcibly activated synchronously to ensure that the correct column is also included in the candidate pool.

[0026] Generate discriminative annotations: When building a schema with annotations, the virtual association edge is used to identify the pair of easily confused columns and automatically inject discriminative annotations, such as: "Note: The value domains of these two columns overlap, but the frpm table is only used for lunch data queries, and the schools table is used to associate grade data," thus clearly guiding the large model to select the correct columns when generating SQL statements.

[0027] S2: Node activation and relation extraction based on macro- and micro dual-channel approaches, such as... Figure 2 As shown, this step includes two parallel channel branches: a macro-global channel and a micro-feature channel.

[0028] The following example uses the query "What is the most common type of grade span served in the city of Adelanto?" to illustrate the macro-level perspective.

[0029] The execution flow of the macro-global channel is as follows: Natural language queries and the corresponding database schema are combined to construct prompt words, which are then input into the Qwen3-32B large language model. Leveraging the Qwen3-32B large language model's semantic understanding capabilities across long contexts, the table and column nodes involved in the query intent are identified, forming the first set of activated nodes, denoted as... .

[0030] In this example, the identified set is .

[0031] Meanwhile, the instruction big language model analyzes the data filtering logic present in natural language queries. To ensure the smooth progress of subsequent steps, strict formal constraints are imposed on the data filtering logic through prompt words. Specifically, the output of the instruction big language model must be convertible into an equality filtering condition conforming to the WHERE Column = Value structure, and must meet the following specific requirements: the WHERE Column must be a physical field that can be directly found in the input schema, and is strictly prohibited from being a derived field obtained through arithmetic operations or aggregate functions; the binding operator must be a strict equal sign; and the Value is limited to entity fragments or attribute values ​​identified from the natural language query.

[0032] Based on the above constraints, in this example, the final data filtering logic output by the large language model is "schools.City = Adelanto".

[0033] The micro-feature channel execution flow is as follows: Define the natural language query as the semantic universal set Q. Based on the different semantic dimensions contained in the natural language query, including but not limited to time dimension, geographic dimension, entity attribute dimension, computational logic dimension, constraint filtering dimension, grouping and ranking dimension, decompose the semantic universal set Q into several semantic proper subset sequences. .

[0034] To ensure that the decomposed subproblems can accurately activate edge constraints without compromising semantic integrity, this embodiment specifies that the decomposition process follows the following two semantic proper subset segmentation principles: The first principle is subset constraint, which allows for arbitrary decomposition into subproblems. It must be the original problem. proper subsets of, i.e. That is, subproblems. The language content only contains the original question The information fragments in the text do not contain the original question. This principle ensures that each subproblem is a true reflection of the local characteristics of the original problem, rather than a derivative problem fabricated by the model. It excludes noise or external assumptions that are not present in the model.

[0035] Principle two is multi-perspective coverage: the logical union of all semantically proper subsets should semantically cover as much of the information entropy of the original problem as possible, formally expressed as: The majority of the subproblems here refer to those obtained by LLM decomposition, which cannot achieve a strictly mathematically equivalent decomposition. At the same time, this majority satisfies the constraint that the logical sum of all subproblems completely covers all the core requirements of the original problem Q, with no missing key information, and can support all business scenarios of the original problem.

[0036] Based on the aforementioned semantic proper subset segmentation principle, each segmented semantic proper subset is transmitted as an independent input unit to the Qwen3-32B large language model. The Qwen3-32B large language model is then instructed to focus on the specific semantic dimensions of that semantic proper subset for database schema mapping. Taking the complex natural language query "List the contact emails of charter schools in San Francisco that were opened after 2015.", which contains multiple semantic dimensions such as time, location, and object, as an example, it is decomposed according to semantic dimensions into a proper subset containing only time constraints ("schools opened after 2015"), a proper subset containing only location constraints ("schools in San Francisco"), and a proper subset containing only object attributes ("contact emails of charter schools"). The Qwen3-32B large language model then performs independent schema mapping for each of these proper subsets to accurately activate the database table nodes and column nodes corresponding to each semantic dimension, forming a second set of activated nodes. .

[0037] S3: Full library calibration and correction based on physical truth values. See also Figure 3 This step is based on the data filtering logic generated by the macro channel, and uses the actual stored content of the database as the truth standard for calibration.

[0038] In this embodiment, the specific calibration steps are as follows: S3-1: Relation Extraction: Parsing the data filtering logic output by the Qwen3-32B large language model. This parsing involves conventional data cleaning, such as removing quotation marks and spaces, to extract a set of structured equivalence relation triples. : ; in, To predict the table name, To predict column names, To predict entity values.

[0039] S3-2: Specific filtering: First, for this set of triples... Predicted entity values Perform type analysis for purely numeric values, such as schools.ID = 1. Given the lack of specificity in databases for purely numeric values ​​(the number "1" can appear in any ID or status column), a full database search would easily lead to a high false positive recall rate. Therefore, for such values, only calibrate whether the predicted entity value exists in the predicted... If it exists, keep it; if it does not exist, discard it and do not proceed to the subsequent "full-database diffusion" or "error correction" processes, in order to avoid introducing irrelevant noise.

[0040] For entity values ​​that are not purely numeric, such as “Merged” and “Orange County”, they are determined to have high semantic referentiality and proceed to the subsequent truth value calibration process.

[0041] Truth value calibration routing: For entity values ​​that are not purely numeric, determine whether the entity value exists in the corresponding prediction column of the prediction table. If the entity value exists, it indicates that the prediction path is physically valid, but column name drift needs to be prevented. Therefore, enter the full database diffusion path based on the truth value. Otherwise, it indicates that the prediction path or the value itself is wrong. Therefore, enter the fragmented full database error correction path.

[0042] Truth-based full-database diffusion path: Although entity values ​​may pass calibration in the predicted columns, this could stem from logical illusions in the large model or sporadic data overlap in the database. For example, the large model might incorrectly predict "Apple" as belonging to the Fruit column, which happens to contain that value, when the actual business intent should point to the Brand column. To address this, do the following: Physical scan: Using the confirmed true value as the only trusted anchor, traverse all columns in the schema except the source column itself, and verify the existence of the entity value in other columns using database query commands. If it exists, the column is marked as a candidate active column node, forming a candidate set. Otherwise, no action will be taken.

[0043] Semantic vector alignment: To eliminate noise with identical values ​​but unrelated meanings, such as "Apple" appearing in different columns (one column is "Fruit," representing the fruit name, and another is "Brand," representing the company name), a vector embedding model is invoked to vectorize the metadata of the source column nodes and candidate active column nodes, obtaining the candidate active column vectors. When extracting metadata, database column comments are extracted first; if comments are missing, column names are used.

[0044] Threshold truncation and activation: Calculate the cosine similarity between the source column and the candidate activation column vectors. Set a filtering threshold; in this embodiment, the filtering threshold is set to 0.75. Only when the semantic similarity score of a candidate activation column exceeds the threshold is it retained and sorted in descending order of cosine similarity value. That is, when it exceeds the threshold, the column node is considered to have high confidence. The top-N preset number of high-confidence column nodes are truncated and activated; in this embodiment, the preset number is set to 2.

[0045] Fragmented full-database error correction path: When an entity value is not present in the predicted column, it is determined that the large model may have generated column name drift or value illusion, and then a global retrieval and correction process based on content fragments is initiated: Entity segmentation: Addressing potential spelling differences or formatting inconsistencies in long entity values, this process utilizes predefined text segmentation rules, including but not limited to regular expressions, space delimiters, or NLP segmentation algorithms, to break down the predicted entity value into text fragments with independent semantics. This constructs a search term set containing the predicted entity value itself and its fragmented components. ,in That is, the set of equivalence relation triples. In For example, the filtering logic output by the large model is frpm.County Name = Alameda County, while the actual value stored in the database is Alameda. Based on spaces and semantic boundaries, the set of search terms is constructed as {Alameda County, Alameda, County}.

[0046] Full database blind search: Traverse all tables and columns defined in the database schema. For each column, physically search whether it contains the set of search terms. This involves searching for any text fragment in a table. Once a match is found in a column of a table, that column is marked as a potential target column node. After traversal, all marked columns together constitute the potential target set. .

[0047] Hybrid scoring rearrangement: for a large set of potential targets returned from a full-database blind search. The columns corresponding to the true intent are selected from the data, and a hybrid scoring model based on both semantic and literal metrics is established.

[0048] For the target set Each potential target node in Calculate its overall score: ; In the formula, A semantic vector representation of the source column metadata for large model predictions. Represents the set of potential targets The Middle Semantic vector representation of the metadata of each candidate column. Represents the cosine similarity function. In this embodiment, the matching reward coefficient is represented. , This represents a text character matching scoring function; The rule for determining the value is: if the retrieved true value Compared with the predicted value The text characters are completely identical. The value is 1; if it only partially contains the element, then... The base value is 0.5. If there is no text character match between the two, then... The value is 0; this mechanism ensures that columns that match perfectly have a higher activation priority when semantic scores are similar, thereby effectively suppressing long-tail noise caused by text fragment matching.

[0049] Error correction activation and truth retention: based on comprehensive scoring For the potential target set The nodes are sorted in descending order, and the top 3-K nodes based on their overall scores are selected as the final corrected target column nodes, which are then forcibly activated. Simultaneously, to preserve the definitive information obtained from the physical retrieval, a calibration evidence set is constructed, denoted as... This set consists of several "table-column-truth value" triples, formally represented as: In the formula: and Representing the first The table name and column name of each activated potential target node define the physical storage path of the data. This represents the actual physical truth value that was hit under the path listed in this table during a full database search.

[0050] S4: Based on the synchronous activation of virtual associated edges, first integrate the node activation results of step S3 to construct a third set of activated nodes. Therefore, the initial set of activated nodes is: , Then, traverse the initial set of activated nodes. For each node in the graph, examine its heterogeneous map constructed in step S1. Does a virtual associated edge exist in the data? If an initial set of activated nodes is detected... Nodes in the set (e.g., frpm.Charter School Number) are connected to the initial set of nodes via virtual associative edges. For any node other than schools.CharterNum, the synchronization activation mechanism is immediately triggered, forcibly adding the associated node to the initial set of activated nodes. This results in an expanded set of terminal activation nodes. .

[0051] Step S5: Generate minimum-cost connected subgraphs based on metric closure: See [link / reference] Figure 4 Construct a set of terminal active nodes on the heterogeneous graph. The virtual complete graph, denoted as ,in This is the set of virtual edges required to connect the terminal activation nodes. A metric closure is constructed based on this virtual complete graph as the topological foundation. The minimum spanning tree algorithm is then used to solve for the minimum weight subset connecting all terminal nodes within this metric closure, which serves as the logical skeleton for the query. Map the virtual paths in the minimum weight subset back to the real physical paths of the heterogeneous graph, construct a minimum cost connected subgraph, identify the inactive intermediate nodes in the real physical path, mark them as semantic bridging nodes and force them to be activated. Step S5 is specifically performed as follows: in the heterogeneous spectrum Above, construct a set containing only terminal active nodes. Virtual complete graph ,in This is the set of virtual edges connecting the active nodes of the terminal graph. Based on this virtual complete graph, traverse... Any two nodes in and Calculate nodes in this heterogeneous graph and The weighted shortest path between the nodes is calculated, and the total weight value of that path is assigned to the virtual complete graph. middle and The corresponding virtual edges, and simultaneously record all nodes and edges contained in the shortest path as physical shortest path information. Complete the construction of the metric closure.

[0052] Solving for the minimum spanning tree logical skeleton: Apply a minimum spanning tree algorithm, such as Prim's algorithm or Kruskal's algorithm, to the constructed metric closure. The goal of the minimum spanning tree algorithm is to find a subset of edges that connects the virtual complete graph. The solution is to find the subset of edges connecting all terminal nodes with the smallest sum of edge weights. This subset of edges is used as the logical framework for the query. It represents the minimum semantic cost required to connect all query intent keywords at the logical level. For example, in complex queries involving multiple table joins, MST can automatically eliminate redundant loops and prioritize the join scheme with the smallest total weight (i.e., the fewest number of joins or the closest correlation).

[0053] Physical subgraph reconstruction and connected topology construction: For each virtual edge in the logical skeleton, retrieve its corresponding physical shortest path information and map it to the actual physical connection path existing in the database. Perform topology fusion on all physical connection paths, remove duplicate nodes and edges, and construct a seamless connection to the set of all terminal active nodes. Find the minimum-cost connected subgraph. Identify the inactive intermediate nodes along the physical paths of this minimum-cost connected subgraph, mark them as necessary semantic bridge nodes, and force their activation.

[0054] S6: Structural integrity expansion and simplified schema generation. For the table nodes in the newly activated intermediate nodes from step S5, perform a structural integrity check. If the table node of this intermediate node is not included in the terminal node set... In the process, the primary key node and foreign key node corresponding to the intermediate table node will be automatically retrieved, and these associated key nodes will be forcibly added to the activation queue. Finally, the terminal node set will be... Semantic bridging nodes and supplementary primary and foreign key nodes undergo a logical union operation; here, column nodes with primary and foreign key association constraints are the primary and foreign key nodes. A schema target set is constructed, and then the schema is simplified based on this target set to generate a simplified schema.

[0055] S7: Schema completion based on multi-dimensional annotation enhancement. For the simplified schema generated in step S6, hierarchical descriptive information enhancement processing is performed, including basic semantic annotation generation and conflict resolution annotation injection.

[0056] Specifically, the first step is to generate basic semantic annotations: analyze the metadata of each table and column in the simplified schema and some sample data, use a large language model to parse the technical abbreviations or domain terms in the fields, and generate corresponding business semantic descriptions. For example, the field "MailStrAbr" is parsed and marked as "Abbreviation of mailing address".

[0057] Subsequently, conflict resolution annotation injection is performed: based on the heterogeneous graph of the database constructed in step S1, it is detected whether the virtual association edge exists in the nodes of the simplified schema. If it exists, a resolution annotation is constructed for the node pair; otherwise, no resolution annotation is constructed. The resolution annotation is configured to explicitly indicate the business boundary or usage scenario difference between nodes, for example: "Note: This column overlaps with the [Associated Column Name] value range, but this table is only used for [specific business] data query."

[0058] S8: SQL statement generation based on enhanced schema: Assemble the original natural language query with the enhanced schema generated in step S7, which includes basic semantic annotations and discriminative annotations, and simultaneously... The triples in the context are used as the basis for determining the physical truth value and are integrated into the prompt word context to construct a complete prompt word template. This prompt word template is then input into the large language model to generate the target SQL statement.

[0059] This embodiment also provides a system for implementing the above method.

[0060] A structured query language generation system based on LLM semantic proper subset decomposition includes a memory and a processor. The memory stores computer-executable instructions, and the processor executes the computer-executable instructions to implement the aforementioned structured query language generation method based on LLM semantic proper subset decomposition.

[0061] To further illustrate the improvements provided by the concepts disclosed in this application, experimental results will now be described.

[0062] To objectively verify the effectiveness of the technical solution of this invention, this embodiment constructs a rigorous controlled variable testing environment. Regarding the selection of the core model, this embodiment uses the Qwen3-32B large language model as the benchmark model. This model is called through the standard API (Application Programming Interface) provided by the Moda community; simultaneously, to ensure the determinism of the inference results and the reproducibility of the experiment, the temperature parameter of the model inference is configured to a default value of 0.

[0063] Regarding the test data, this embodiment uses the development set of BIRD (Big Bench for Large-scale Database Grounded Text-to-SQL), a well-known and challenging benchmark dataset in the Text-to-SQL field, as the test source.

[0064] To balance testing costs and statistical significance with limited computing power, this embodiment uses stratified random sampling to select 500 representative samples from the 1534 data points in the BIRD development set to construct the test set. The sample distribution of the test set strictly follows the principle of difficulty stratification, specifically including: 200 samples of easy difficulty, 200 samples of medium difficulty, and 100 samples of difficult difficulty.

[0065] This embodiment sets up two sets of comparative experiments. Except for the technical solutions, the hardware and software environments are completely identical. The control group uses only the Qwen3-32B model, employing standard prompting engineering, directly inputting the database schema and natural language questions (including external knowledge) into the model, without including any processing modules of this invention. The experimental group, on the other hand, deploys the system described in this invention completely based on the Qwen3-32B model.

[0066] The experiment uses execution accuracy as the core evaluation metric. This metric is determined by comparing the execution results of the SQL statements generated by the model in the database with the execution results of standard SQL. Detailed test data on 500 test samples is shown in Table 1. Table 1 Performance comparison of the Qwen-32B base model before and after applying this invention

[0067] Analysis of the data in Table 1 shows that, compared to the comparative example, the embodiments of this application achieve a significant improvement in overall performance. The overall execution accuracy of the embodiments increases from 50.20% in the comparative example to 61.60%, an absolute improvement of 11.40%. Specifically, the accuracy of the embodiments improves by 12.50% on easy difficulty samples, by 9.50% on medium difficulty samples, and by 8.00% on hard difficulty samples. This indicates that, without changing the base model parameters, the method-level optimization of this invention effectively taps into the model's potential capabilities and significantly improves the query success rate.

[0068] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A structured query language generation method based on LLM semantic proper subset decomposition, characterized by: The steps are as follows, performed sequentially: S1: Construct a heterogeneous graph of the database based on the schema, extract the tables and columns in the schema and construct them as table nodes and column nodes respectively. The heterogeneous graph includes internal edges for establishing physical connections between column nodes and table nodes, foreign key edges for physically connecting two column nodes in the database schema that have explicitly defined primary and foreign key association constraints, and virtual association edges for physically connecting column nodes in the schema that have not defined physical foreign key constraints. S2: Node activation and relation extraction based on a macro-micro dual-channel approach, including two parallel execution channel branches. One is the macro-global channel, which inputs the natural language query and the corresponding database schema into the large language model to identify core table nodes and column nodes to form the first set of activated nodes. And parse the data filtering logic in the query; The other is the micro-feature channel, which decomposes the natural language query into several semantic proper subset sequences based on the semantic dimension, and inputs each proper subset into the large language model for schema mapping to form a second set of activation nodes. The decomposition process of the micro-feature channels follows the principles of subset constraint and multi-view coverage; S3: Based on the data filtering logic, use the actual stored content of the database as the truth standard for calibration: if the entity value exists in the prediction column, execute the truth full database diffusion path; otherwise, execute the fragmented full database error correction path. Based on the hybrid scoring model of semantic and literal matching, select high-scoring candidate columns for forced activation and construct a calibration evidence set to correct the illusion values ​​generated by the model. S4: Based on the synchronous activation of virtual associated edges, integrate the node activation results from step S3 to construct a third set of activated nodes. The initial set of activated nodes is , ; Traverse the initial set of activated nodes For each node in the graph, check if it has a virtual associated edge in the heterogeneous graph. If the initial set of activated nodes is detected, The nodes in the set are connected to the initially activated node set via virtual associative edges. For nodes other than those in the initial activation set, the synchronization activation mechanism is triggered, forcibly adding the associated node to the initial activation node set. Obtain the expanded set of terminal active nodes. ; S5: Generate a minimum-cost connected subgraph based on metric closure: Construct a set containing only the terminal active nodes on the heterogeneous graph. A virtual complete graph is constructed, and a metric closure is built based on the topology of the virtual complete graph. The minimum spanning tree algorithm is used to solve the minimum weight subset connecting all terminal nodes on the metric closure, which serves as the logical skeleton of the query. Map the virtual paths in the minimum weight subset back to the real physical paths of the heterogeneous graph, construct a minimum cost connected subgraph, identify the inactive intermediate nodes in the real physical path, mark them as semantic bridging nodes and force them to be activated. S6: Structural Integrity Expansion and Simplified Schema Generation: Perform structural integrity checks on newly activated intermediate table nodes, automatically complete the primary key and foreign key nodes corresponding to the intermediate table node; merge the original terminal node, semantic bridge node and the supplemented primary and foreign key nodes to construct the schema target set, and output the context of the corresponding simplified schema; S7: Schema completion based on multi-dimensional annotation enhancement: Perform descriptive enhancement on the simplified schema: generate basic semantic annotations for parsing field technical abbreviations or terms; and generate discriminative annotations based on the virtual association edges, the discriminative annotations being used to explicitly indicate the business boundaries or usage scenario differences between easily confused node pairs; integrate the above annotations into the simplified schema to generate an enhanced schema that includes complete business semantics and disambiguation guidance; Step S8: SQL statement generation based on enhanced schema: Assemble the original natural language query with the enhanced schema generated in step S7, which includes basic semantic annotations and discriminative annotations, and simultaneously... The triples in the context are used as the basis for determining the physical truth value and are integrated into the prompt word context to construct a complete prompt word template. This prompt word template is then input into the large language model to generate the target SQL statement.

2. The structured query language generation method based on LLM semantic proper subset decomposition as described in claim 1, characterized in that: The specific construction steps of the heterogeneous spectrum in step S1 are as follows: S1-1: Read the schema information of the target database and perform a statistical feature scan on all data in the target database; S1-2: To transform the physical structure and implicit data association of the target database into a data structure that the algorithm can process, a heterogeneous graph containing multidimensional attributes is constructed. ; Among them, the node set It contains two types of nodes: table nodes and column nodes ,and , , Indicates the first Each table node They represent the first Each column node Represents the set of edges; S1-3: This heterogeneous graph includes intrinsic edges, foreign key edges, and virtual association edges, wherein the intrinsic edge is for any column node. and its table nodes The established physical connection edge is assigned the first weight. ; This foreign key edge is a physical connection between two column nodes that have explicitly defined primary-foreign key association constraints in the database schema. This foreign key edge is assigned a second weight. Second weight First weight The preset multiple; This virtual association edge is used to connect column nodes in the schema that do not have defined physical foreign key constraints. The steps for constructing this virtual association edge are as follows: Candidate column cleaning based on multi-dimensional features: Traverse all column nodes, perform multiple logical checks on each column node sequentially, and only columns that pass all logical checks simultaneously are marked as valid candidate columns. The first logical judgment is data type and null value filtering, used to remove empty columns and columns of Boolean type; The second logical judgment is cardinality feature filtering, which calculates the deduplication cardinality of column data. If the deduplication cardinality is lower than the first preset threshold, the column is determined to be an enumeration status code or classification identifier and is removed. The third logical judgment is sparsity feature filtering. For numerical columns or text columns that can be converted into numerical values, the sparsity index is calculated using the following formula. : ; in, and These represent the maximum and minimum values ​​in the column's numerical range, respectively. This is the deduplication base for this column; If sparsity index If the sparsity index is less than the second preset threshold, the column is determined to be a dense linear sequence and is removed. If the value is greater than or equal to the second preset threshold, the column is determined to be a discrete entity identifier and is retained. Check the current column pair If an explicit foreign key edge already exists between them, skip it to avoid establishing redundant connections. Otherwise, use the minimum hash signature-based association metric: generate minimum hash signature vectors for the retained candidate column nodes, calculate the Jaccard similarity coefficient between the minimum hash signature vectors, and when the similarity coefficient exceeds the preset third threshold, determine that the two columns have overlapping value ranges and pair them up in a non-repeating combination method to establish virtual association edges.

3. The structured query language generation method based on LLM semantic proper subset decomposition as described in claim 2, characterized in that: The decomposition process in step S2 follows the following two segmentation principles: Subset constraints, arbitrarily decomposed subproblems It must be the original problem. proper subsets of, i.e. ; Multi-perspective coverage: The logical union of all semantically derived proper subsets should semantically cover most of the information entropy of the original problem, formally represented as... .

4. The structured query language generation method based on LLM semantic proper subset decomposition as described in claim 3, characterized in that: The specific calibration steps for step S3 are as follows: S3-1: Relation Extraction: Parse the data filtering logic output by the large language model to extract a structured set of equivalence relation triples. : ; in, To predict the table name, To predict column names, To predict entity values; S3-2: Specific filtering: for this set of triples Predicted entity values Perform type analysis. For predicted entity values ​​of pure numeric type, only check whether the predicted entity value exists in the corresponding predicted column of the prediction table. If it exists, keep it; otherwise, discard it. For predicted entity values ​​that are not purely numeric, if they are determined to have high semantic referentiality, a truth value calibration and diversion is performed: for predicted entity values ​​that are not purely numeric, the existence of the predicted entity value is queried in the corresponding prediction column of the prediction table. If the predicted entity value exists, it enters the truth value-based full-database diffusion path; otherwise, it enters the fragmented full-database error correction path. Truth-based full-database diffusion path: Physical scan: Traverse all columns in the schema except the source column itself, and verify the existence of the predicted entity value in other columns using database query commands. If it exists, the column is marked as a candidate activation column node, forming a candidate set. Otherwise, no action will be taken; Semantic vector alignment: Invoke the vector embedding model to vectorize the metadata of the source column node and the candidate activation column node to obtain the candidate activation column vector; Threshold truncation and activation: Calculate the cosine similarity between the source column and the candidate activation column node vectors. When the semantic similarity score of the candidate activation column exceeds the threshold, retain it and sort it in descending order according to the cosine similarity value. Select the top-N preset number of high confidence column nodes for activation. Fragmented full-database error correction path: Global retrieval and correction process based on content fragments: Entity segmentation: Using predefined text segmentation rules, the predicted entity value is broken down into text fragments with independent semantics, constructing a search term set containing the predicted entity value and its fragments. ,in That is, the set of equivalence relation triples. In ; Full database blind search: Traverse all tables and columns defined in the database schema, and for each column, physically search whether it contains the set of search terms. For any text fragment in the table, if a match is found in a column of a certain table, that column is marked as a potential target column node. After traversal, all marked columns together constitute a potential target set. ; Hybrid rating re-ranking: Establishing a hybrid rating model based on both semantic and literal metrics: For the target set Each potential target node in Calculate its overall score: ; In the formula, A semantic vector representation of the source column metadata for large model predictions. Represents the set of potential targets The Middle Semantic vector representation of the metadata of each candidate column. Represents the cosine similarity function. Indicates the matching reward coefficient. This represents a text character matching scoring function; The rule for determining the value is: if the retrieved true value Compared with the predicted value The text characters are completely identical. The value is 1; if it only partially contains the element, then... The base value is 0.

5. If there is no text character match between the two, then... The value is 0; Error correction activation and truth retention: based on comprehensive scoring For the potential target set Sort the nodes in descending order, select the top 3-K nodes based on their overall scores as the final corrected target column nodes, and forcibly activate them. Constructing a calibration evidence set : ; In the formula: and Representing the first The table name and column names of the potential target nodes that are activated. This represents the actual physical truth value that was hit under the path listed in this table during a full database search.

5. The structured query language generation method based on LLM semantic proper subset decomposition as described in claim 4, characterized in that: Step S5 is executed in the following steps: Constructing a metric closure: in this heterogeneous graph Above, construct a set containing only terminal active nodes. Virtual complete graph ,in A set of virtual edges connecting the terminal active nodes; The specific construction steps are as follows: Based on this virtual complete graph, for the set Any two nodes in and Calculate in this heterogeneous spectrum and The shortest path weight between them is then assigned to the value. The corresponding virtual edges are recorded, and all nodes and edges contained in the shortest path are also recorded as physical shortest path information. Complete the construction of the metric closure; Solving the minimum spanning tree logical skeleton: On the constructed metric closure, apply the minimum spanning tree algorithm to find the subset of edges that connects all terminal nodes and has the smallest sum of edge weights. This subset of edges As the logical framework for the query; Physical subgraph reconstruction and connected topology construction: For each virtual edge in the logical skeleton, its corresponding physical shortest path information is retrieved one by one and mapped to the actual physical connection path existing in the database. Topological fusion is performed on all physical connection paths, duplicate nodes and edges are removed, and a seamless connection of all terminal active node sets is constructed. For the minimum cost connected subgraph, identify the inactive intermediate nodes in the physical path of the minimum cost connected subgraph, mark them as necessary semantic bridge nodes and force their activation.

6. The structured query language generation method based on LLM semantic proper subset decomposition as described in claim 5, characterized in that: The specific execution steps of step S6 are as follows: Structural integrity expansion and simplification schema generation perform structural integrity checks on the table nodes in the intermediate node: if the table node of the intermediate node is not included in the terminal node set... In the middle, automatically complete the primary key node and foreign key node corresponding to the intermediate table node, and force these related key nodes to be added to the activation queue, thus completing the set of terminal nodes. The semantic bridge node and the supplementary primary and foreign key nodes perform a logical union operation to construct a schema target set. Based on this schema target set, the schema is simplified to obtain a simplified schema.

7. The structured query language generation method based on LLM semantic proper subset decomposition as described in claim 6, characterized in that: The specific execution steps of step S7 are as follows: Basic semantic annotation generation: Analyze the metadata of each table and column in the simplified schema and some sample data, use a large language model to parse the technical abbreviations or domain terms in the fields, and generate corresponding business semantic descriptions; Perform conflict resolution annotation injection: Based on the heterogeneous graph, detect whether the virtual association edge exists in the nodes of the simplified schema. If it exists, construct a resolution annotation for the node pair. Otherwise, do not construct a resolution annotation. The resolution annotation is configured to explicitly indicate the business boundary or usage scenario difference between nodes. The basic semantic annotations and the discriminative annotations are integrated into the description information of the simplified schema to obtain the enhanced schema.

8. A structured query language generation system based on LLM semantic proper subset decomposition, comprising a memory and a processor, wherein the memory stores computer-executable instructions, characterized in that: The processor executes the computer-executable instructions to implement the structured query language generation method based on LLM semantic proper subset decomposition as described in any one of claims 1-7.