Database query method and system based on large language model and structured intermediate representation
By calculating semantic loss and weights, dynamically adjusting query confidence, and correcting the structured intermediate representation, the problem of bias accumulation in complex query scenarios is solved, and accurate matching of query commands and user intent is achieved.
Patent Information
- Application Number
- CN202610796949.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-04
- Publication Date
- 2026-08-25
AI Technical Summary
In complex query scenarios, existing technologies suffer from accumulated biases when converting natural language into structured statements, resulting in query commands failing to match the user's actual query needs and database feedback data deviating from the expected range. This lack of dynamic adaptation and error blocking mechanisms further exacerbates the problem.
By calculating the semantic completeness coefficient, statement complexity coefficient, semantic deviation correction factor, and structured transformation baseline loss value, the total loss of semantic structured transformation is calculated. Combined with the database field association cardinality, the adaptive association weight of fields and query confidence are dynamically calculated. Finally, the global error compensation coefficient is calculated to correct the structured intermediate representation to generate database query statements.
It effectively blocks the transmission of conversion deviations in multi-level processing flows, improves the fit of natural language conversion database query commands, and adapts to query intents in complex query scenarios.
Smart Images

Figure CN122633709A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of large language model semantic interaction and database query technology, and discloses a database query method and system based on large language model and structured intermediate representation. Background Technology
[0002] Currently, applications leveraging large language models to drive database queries using natural language are increasingly common. Existing conventional methods use fixed-value loss correction parameters for semantic conversion, and these parameters remain unchanged regardless of the query's characteristics or the database's table structure. This fixed-parameter adaptation model can only handle simple queries with a limited number of conditions and a single structure. When faced with complex queries involving nested conditions and multi-table retrieval, the natural language-to-structure conversion process continuously introduces data biases. These biases propagate through subsequent processing stages such as weight determination, confidence calculation, and command correction. This cascading bias alters the final query's content, causing it to fail to match the user's actual query needs, and resulting in database data deviating from the expected retrieval range. Currently, no industry-standard approach exists that leverages query characteristics and the database's inherent structure to calculate loss and simultaneously prevent the propagation of biases. Therefore, query matching failures in complex query scenarios remain difficult to address effectively.
[0003] Based on the above problems, there is an urgent need for database query processing technology that can dynamically adapt to query scenarios and constrain the spread of conversion deviations. Summary of the Invention
[0004] The purpose of this invention is to overcome the shortcomings of existing technologies and proposes a database query method based on a large language model and structured intermediate representation, in which the processor of a computer device executes the following steps: Calculate the total loss of semantic structured conversion based on the semantic completeness coefficient, statement complexity coefficient, semantic deviation correction factor, and structured conversion baseline loss value; Based on the total loss of the semantic structure transformation and the cardinality of database field association, calculate the adaptive association weight of the database field; The dynamic query confidence is calculated based on the basic matching confidence, the total loss of the semantic structure transformation, and the adaptive association weight of the database fields. The global error compensation coefficient is calculated based on the hierarchical error propagation coefficient, the total loss of the semantic structure transformation, the adaptive association weight of the database fields, and the dynamic query confidence. The structured intermediate representation is corrected using the global error compensation coefficient; the corrected structured intermediate representation is converted into a database query statement, and the database query statement is executed.
[0005] Preferably, the semantic completeness coefficient represents the degree of semantic information completeness of the natural language query statement, the statement complexity coefficient represents the number of nesting levels and the number of conditions of the natural language query statement, the semantic deviation correction factor represents the semantic mapping deviation between the natural language query statement and the database structured statement, and the structured conversion baseline loss value is a preset basic semantic conversion loss value.
[0006] More preferably, the step of calculating the total loss of semantic structure transformation includes: calculating the total loss of semantic structure transformation based on query complexity variables and database table structure variables, wherein the query complexity variables include the statement complexity coefficient, and the database table structure variables include the database field association cardinality.
[0007] More preferably, the adaptive association weight of the database field has an inverse relationship with the total loss of the semantic structuring transformation.
[0008] Further optimized, the four types of calculation results—total loss of semantic structure transformation, adaptive association weight of database fields, dynamic query confidence, and global error compensation coefficient—are solved sequentially using the parameters produced by the preceding operations as input parameters for the subsequent operations. The entire operation process is carried out using dimensionless operation rules, with statement feature parameters, database structure parameters, and model matching parameters all participating in the entire operation process.
[0009] More preferably, in the step of calculating the dynamic query confidence, the value of the dynamic query confidence is determined by the basic matching confidence, the adaptive association weight of the database field, and the total loss of the semantic structure transformation.
[0010] More preferably, in the step of calculating the global error compensation coefficient, the value of the global error compensation coefficient is jointly determined by the total loss of the semantic structure transformation, the adaptive association weight of the database fields, the dynamic query confidence, and the hierarchical error propagation coefficient.
[0011] More preferably, the step of correcting the structured intermediate representation using the global error compensation coefficient is applied to scenarios of multi-table join queries, nested queries, and fuzzy semantic queries.
[0012] A database query system based on a large language model and structured intermediate representation, characterized in that it is deployed on a computer device and includes: The conversion loss calculation module is used to calculate the total loss of semantic structured conversion based on the semantic integrity coefficient, statement complexity coefficient, semantic deviation correction factor, and structured conversion baseline loss value. The weight calculation module is communicatively connected to the conversion loss calculation module. It is used to receive the total semantic structure conversion loss and calculate the adaptive association weight of the database field based on the total semantic structure conversion loss and the association cardinality of the database field. The confidence calibration module is communicatively connected to the weight calculation module. It is used to receive the adaptive association weight of the database field and the total loss of the semantic structure transformation, and to calculate the dynamic query confidence based on the adaptive association weight of the database field, the total loss of the semantic structure transformation, and the basic matching confidence. The error compensation module is communicatively connected to the confidence calibration module. It is used to receive the dynamic query confidence, the total loss of the semantic structure transformation, and the adaptive association weight of the database field. Based on the dynamic query confidence, the total loss of the semantic structure transformation, the adaptive association weight of the database field, and the hierarchical error propagation coefficient, it calculates the global error compensation coefficient and uses the global error compensation coefficient to correct the structured intermediate representation. The query execution module, which is communicatively connected to the error compensation module, is used to convert the corrected structured intermediate representation into a database query statement and execute the database query statement.
[0013] More preferably, the conversion loss calculation module, the weight calculation module, the confidence calibration module, and the error compensation module are each configured with a corresponding calculation formula, and the calculation output of the former module is used as the calculation input of the latter module.
[0014] Technical effects: This invention abandons the conventional processing method of correcting semantic conversion deviations with fixed parameters. Instead, it performs multi-parameter progressive calculations in the order of semantic loss calculation, weight determination, confidence calibration, and error compensation. It uses compensation parameters obtained from real-time calculations to correct structured statements. This allows it to adapt to the processing logic by following the characteristics of the query statement and the state of the database structure, preventing the continuous transmission and accumulation of conversion deviations in multi-level processing flows, avoiding mismatches in query instructions in complex query scenarios, and improving the fit of natural language to database query instructions. Attached Figure Description
[0015] Figure 1 This is a flowchart of the database query method based on a large language model and structured intermediate representation according to the present invention; Figure 2 This is a connection diagram of the database query system based on a large language model and a structured intermediate representation according to the present invention. Detailed Implementation
[0016] 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 and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0017] Please see Figures 1-2 In the traditional technical model that relies on large language models to complete database statement conversion and query, the loss caused by the conversion of natural language to structured statements cannot keep up with the changes in statement form and data table structure. The fixed parameter calculation mode cannot adapt to the error changes caused by different query scenarios. The independently carried out parameter calculation mode will cause errors to accumulate at each level, ultimately causing the query statement to deviate from the user's actual query intent, and the degree of matching of statement conversion cannot be guaranteed. The computer device is equipped with an independent processing core and data storage area. Large language model program files, database interaction program files, and various preset parameter data are uniformly stored in the device's non-volatile storage area. After the device is powered on, the processor retrieves program instructions from the storage area to complete the entire process of statement reception, parameter extraction, numerical calculation, statement correction, and query execution. The storage area is divided into three independent spaces: program storage partition, temporary data cache partition, and fixed parameter storage partition. Different partitions undertake differentiated data storage functions. The program storage partition retains the execution instructions that can be called by the processor. The temporary data cache partition stores intermediate calculation parameters and transformation statement data generated during a single query. The fixed parameter storage partition retains preset unchanging parameters such as the structured transformation baseline loss value and hierarchical error propagation coefficient for a long time. Directional data read and write channels are set between the three types of partitions, and the processor retrieves data from different partitions according to predetermined read and write rules.
[0018] Based on this, this embodiment provides a database query method and system based on a large language model and a structured intermediate representation. The system is executed by a computer processor. It calculates the total semantic-structured conversion loss based on a semantic completeness coefficient, a statement complexity coefficient, a semantic deviation correction factor, and a structured conversion baseline loss value. It then calculates the adaptive association weight of database fields based on the total semantic-structured conversion loss and the database field association cardinality. Finally, it calculates the dynamic query confidence based on the basic matching confidence, the total semantic-structured conversion loss, and the adaptive association weight of the database fields. Finally, it calculates the global error compensation coefficient based on the hierarchical error propagation coefficient, the total semantic-structured conversion loss, the adaptive association weight of the database fields, and the dynamic query confidence. The system then uses the global error compensation coefficient to correct the structured intermediate representation, converts the corrected structured intermediate representation into a database query statement, and executes the database query statement.
[0019] This technical solution relies on the built-in processor of the computer device as a unified computing execution platform. The processor employs a multi-threaded scheduling mechanism to allocate computing resources, with each database query task corresponding to an independent computing thread. Within each thread, computing power is allocated sequentially according to the step sequence, avoiding data corruption and computing power congestion caused by parallel multitasking. Four basic parameters obtained from natural language statement parsing serve as the initial input data. During the parameter extraction phase, the processor retrieves the built-in semantic parsing rules of the large language model, breaking down the user-input natural language query statement segment by segment. Based on the rules, it determines the corresponding parameter values for each statement, and the extracted parameter data is synchronously written to a temporary data cache partition for later retrieval. The device sequentially performs loss calculation, weight calculation, confidence calculation, and compensation coefficient calculation. The preceding and following computational steps form a parameter transfer relationship; the output value of the previous step directly serves as the basis for the computation of the next step. The temporary data cache partition is updated in real-time to store the output results of each step, while retaining the original initial input parameter data to meet the data retrieval requirements of subsequent multi-parameter combination calculations. After all numerical calculations are completed, compensation coefficients are retrieved to adjust the structured intermediate representation obtained through conversion. This structured intermediate representation is stored in a dedicated statement storage sub-area within the cache partition. The correction action directly applies to the data content within this sub-area. The adjusted statement format is converted into a database-recognizable query statement format. The format conversion process matches the database's established interaction syntax rules, removing character fragments that do not conform to grammatical rules and supplementing the necessary character structure. Finally, the statement execution action is initiated to complete the full query process. The entire operation relies on continuous, progressive parameter calculations to correct statement deviations, overcoming the error accumulation problem caused by fixed parameter calculations. Data calculations and statement processing are completed entirely by the device hardware, without any abstract rule-based judgments. The processor, storage partition, model program, and database interaction interface form a complete collaborative operating system. Hardware resource scheduling and software instruction execution work together to ensure that each operation is stably implemented according to predetermined logic. This solution can reduce the amount of deviation retained during the statement conversion process, narrowing the deviation range between the final query statement and the original query intent. Based on the hardware architecture and progressive calculation logic, it is adaptable to processing various common and complex forms of natural language query statements.
[0020] The lack of clear definitions for coefficients in natural language queries makes it difficult for technicians to distinguish the representations of different coefficients, hindering the accurate extraction of parameter data for computation. This leads to classification confusion during parameter extraction, where similar sentence structural features are categorized into different parameter classes, and different sentence features are grouped together with the same parameter value. The extracted parameters deviate from the actual attributes of the sentences, and the initial input data lacks a unified benchmark. All subsequent numerical calculations are based on these biased parameters, amplifying the inherent errors in the sentence conversion process and ultimately affecting the correction of the structured intermediate representation. Database queries fail to accurately match user-submitted queries. Furthermore, the parameter determination logic of the device's internal semantic parsing module lacks a fixed reference, making it impossible to accurately define the judgment dimensions of different parameters during module operation. This results in poor consistency of the parsed parameter data; queries with the same structural features yield different parameter values after multiple parsings, compromising the operational stability of the computational system.
[0021] Based on this, the semantic completeness coefficient represents the degree of semantic information completeness of the natural language query statement, the statement complexity coefficient represents the number of nesting levels and conditions of the natural language query statement, the semantic deviation correction factor represents the semantic mapping deviation between the natural language query statement and the database structured statement, and the structured conversion baseline loss value is a preset basic semantic conversion loss value.
[0022] This section defines the attributes of four basic parameters involved in the initial loss calculation, clarifies the descriptive object corresponding to each parameter, and delineates the statement feature category corresponding to each parameter. The parameter definition rules are synchronously written into the semantic parsing program of the large language model. When the processor calls the parsing program to perform parameter extraction, it strictly determines the value of each parameter corresponding to the statement according to the established categories. The semantic completeness coefficient corresponds to the completeness of the information contained in the statement. The parsing program counts the information content, such as query constraints, query object range, and query result requirements, within the statement, and determines the corresponding coefficient value based on the information coverage. The number of query-related information entries contained in the statement corresponds to the coefficient value. The statement complexity coefficient corresponds to the internal structural composition of the statement. The parsing program decomposes the nested structure of the statement layer by layer, counts the specific number of nested levels, and simultaneously sorts out the total number of parallel and constraint query conditions within the statement. These two statistical data together determine the specific value of the statement complexity coefficient. The semantic deviation correction factor corresponds to the content correspondence between two types of statements with different formats. The parsing program compares the content of natural language statements with the standard expression form of structured statements in the database, counts the number of content fragments with discrepancies in the meaning of the statements, and determines the semantic deviation correction factor value based on the fragment statistical results. The structured transformation baseline loss value is a pre-defined fixed reference value. This value is stored permanently in a fixed parameter storage partition and does not change with the content of the query statement or the query scenario. It serves as a unified basic reference standard for all statement transformation loss calculations. After the parameters are defined, the device can extract parameters according to the established scope when performing statement parsing, avoiding confusion in parameter selection and ensuring that the initial calculation data meets the requirements for operation. The parameter data produced by the semantic parsing module has a unified judgment standard, and statements with the same characteristics can obtain consistent parameter results, maintaining the operational stability of the parameter extraction process. This content unifies the basic parameter judgment criteria, standardizes the execution standard of parameter extraction, ensures that the initial calculation data has a unified reference benchmark, reduces the error accumulation problem caused by parameter deviation from the source of calculation, and provides compliant and effective input data support for subsequent progressive numerical calculations.
[0023] The total loss in semantic structured transformation is calculated based on a single fixed condition, which cannot be adapted to the structure of the statement itself and the layout of the data table. The calculated value cannot accurately reflect the actual transformation loss. A single reference condition can only reflect the loss factors at the structural level of the statement itself, ignoring the effect of the database field layout structure on the statement transformation process. The density of data table field associations varies, and the content deletion and statement reorganization behaviors when converting natural language statements to structured statements are significantly different, resulting in corresponding changes in the loss scale. Fixed calculation conditions cannot adapt to the loss variations caused by differences in data table structure. After the loss value deviates from the actual transformation state, subsequent weight calculation, confidence determination, and error compensation steps cannot match the real transformation scenario. Correction parameters generated based on the deviation loss value are insufficient to offset the content deviation caused by statement transformation, and query tasks corresponding to complex data tables are more likely to experience query intent matching failures.
[0024] Based on this, the step of calculating the total loss of semantic structure transformation includes calculating the total loss of semantic structure transformation according to the query complexity variable and the database table structure variable, wherein the query complexity variable includes the statement complexity coefficient, and the database table structure variable includes the database field association cardinality.
[0025] The loss calculation process incorporates two types of variables from different dimensions: statement ontology attributes and database storage structure attributes, comprehensively covering objective factors affecting the scale of statement conversion loss. The query complexity variable is derived from the statement complexity coefficient corresponding to the statement's structural characteristics. This variable reflects the impact of statement nesting levels and the number of query conditions on the conversion process. More nesting levels, more conditions, and more steps involved in statement reorganization and splitting increase the probability of information loss during conversion. The database table structure variable is derived from the database field association cardinality corresponding to the table's field arrangement. This cardinality counts the number of combinations of inter-field relationships within the target query table. A higher number of field association combinations means more complex data types of fields that the structured statement needs to retrieve, increasing the likelihood of field misalignment and information omission during natural language statement conversion, thus affecting the scale of loss. Two types of variables jointly participate in the loss calculation. The device processor retrieves the values of both types of variables stored in the cache partition, integrates the variable data according to a predetermined calculation logic, and calculates the loss result. The calculation process is no longer limited to a single reference condition, but combines the dual objective conditions corresponding to the query scenario to complete the numerical calculation, so that the final loss value can objectively reflect the loss scale generated in the current statement transformation stage. The variable data is independently called and calculated within the calculation thread, and the two types of variables will not have data overwriting or numerical confusion. The variable combination calculation logic is solidified within the calculation program, and each loss calculation action can be executed according to a unified rule. This calculation mode fits the objective conditions corresponding to the actual query scenario, so that the loss calculation result can accurately reflect the actual loss state of the statement transformation, correct the numerical deviation caused by single variable calculation, and provide loss basic data that fits the actual scenario for subsequent correlation parameter calculations.
[0026] The adaptive correlation weights of database fields lack a fixed reference point for their numerical changes. The weight values cannot adapt to changes in the loss values, and the two values cannot form a mutual constraint. When the weight values are calculated independently, their values are determined solely by the inherent field attributes of the data table, ignoring field matching misalignments caused by statement transformation losses. In queries with large loss values, conventional matching weight values are still used, failing to specifically constrain the corresponding field matching relationships. In queries with small loss values, the weight values are not adjusted accordingly, easily leading to excessive and redundant field matching. After the weights and loss values are decoupled, the accuracy of field matching cannot dynamically adjust with the transformation loss state. The field matching results tend to be homogeneous across different loss scenarios, making it difficult to distinguish the degree of field correlation between different query statements, indirectly reducing the reference value of subsequent confidence assessment results.
[0027] Based on this, the adaptive association weight of the database field has an inverse relationship with the total loss of the semantic structuring transformation.
[0028] This content defines the dynamic relationship between two types of core operational values, clarifying the corresponding pattern of weight values changing in tandem with loss values. This pattern is written into the weight calculation program. When the processor executes the weight value calculation, it simultaneously retrieves the total loss value of the semantically structured transformation that has already been calculated, and determines the weight value range according to the inverse change rule. When the loss value increases or decreases, the weight value is adjusted in the opposite direction. An increase in the corresponding scale of the loss value indicates an increase in information omissions and field misalignments during the statement transformation process. In this case, the adaptive field association weight is lowered to weaken the constraint of the inherent field association relationship on the query statement matching, avoiding query deviations caused by forced matching of misaligned fields. Conversely, a decrease in the corresponding scale of the loss value indicates that the integrity of the statement transformation information remains good. In this case, the adaptive field association weight is raised to strengthen the correspondence between the inherent field association structure of the data table and the query statement, aligning with the field retrieval requirements of the original query statement. The two types of values form a mutually restrictive relationship within the operational system. The weight calculation step no longer operates independently of the loss value; each weight value can match the actual loss state of the current statement transformation. Once the numerical variation pattern is determined, the equipment can perform numerical calculations according to the established correlation when carrying out weight calculations. This prevents the weight values from changing independently from the actual loss state, ensures that the weight values can match the statement conversion state corresponding to the current loss, and dynamically adapts to the field matching requirements under different loss scenarios based on the numerical linkage constraint relationship.
[0029] The progressive computation process lacks unified operational constraints, making it impossible to solve numerical values from successive steps according to fixed standards. Inconsistent dimensionality issues easily arise in computations involving different parameter combinations, leading to discrepancies in the definition of various parameter attributes. Some computational steps lack control over parameter dimensional attributes. When basic numerical addition and subtraction, exponential operations, square root operations, and other special computational forms are executed together, the combination of parameters with different dimensions causes computational logic failure, resulting in the inability to produce valid and usable results. This parameter dimensional inconsistency causes intermediate computational data to become invalid and discarded, requiring the processor to repeatedly execute computational steps, consuming computing power, prolonging the processing time of a single database query task, and simultaneously storing invalid computational data in the cache partition, crowding out temporary data storage space and affecting the execution efficiency of subsequent data read and write operations.
[0030] Based on this, the total loss of semantic structure transformation, the adaptive association weight of database fields, the dynamic query confidence, and the global error compensation coefficient are solved in a progressive numerical manner by relying on the parameters obtained from the previous calculations. The calculation process of the four types of numerical values follows the same dimensional calculation rules.
[0031] The entire numerical computation proceeds sequentially, strictly adhering to the fixed order of loss calculation, weight calculation, confidence calculation, and compensation coefficient calculation. The computation threads sequentially wake up their corresponding subroutines according to the time sequence. The completion of a preceding subroutine triggers the start instruction for the next subroutine, preventing reversed computation steps or parallel computation errors. Each numerical computation retrieves parameters from the previous process, which are passed sequentially according to the computation time sequence. The cache partition stores intermediate parameter results sequentially. Subsequent steps only read the solidified data from the preceding computation, avoiding the retrieval of temporary parameters from incomplete computations, thus forming a closed-loop progressive computation system. All parameters involved in the computation adhere to the same dimensional judgment criteria. All basic parameters are set as dimensionless. Parameter combination operations, basic numerical addition and subtraction operations, and special function operations are all executed according to predetermined dimensional constraints. Exponential and square root operations do not change the inherent dimensionless properties of the parameters. Addition and subtraction operations maintain dimensional consistency, avoiding computational failures caused by inconsistent parameter dimensions. The progressive computation mode ensures consistent and stable parameter transmission, maintaining the integrity of parameter data throughout the entire process of partition reading and writing, module transmission, and thread calls without loss. Unified dimensional rules guarantee the successful completion of all numerical calculations, with each step producing compliant and valid intermediate results. This constraint standardizes the execution criteria of the entire computation system, maintains the stable operation of the progressive computation process, reduces invalid and repetitive calculations, rationally utilizes device computing power and storage resources, and ensures the efficient and orderly advancement of numerical computation.
[0032] Within the progressive calculation system, each value is solved using fixed calculation logic. However, the lack of a concrete definition of this logic can lead to deviations in calculation results across different operating programs. Unifying and defining calculation formulas can solidify the calculation rules, ensuring consistent results under different operating environments. Furthermore, the formulas can fully decompose the mechanisms of action of each parameter in the calculation process, clearly presenting the combination and relationship between parameters. This solution sets up four sets of dedicated dimensionless calculation formulas, each corresponding to one of the four core numerical calculation steps. All formulas use dimensionless parameters for their independent variables, and are designed and written in strict accordance with the fundamental principle of dimensional homogeneity.
[0033] The first set of formulas is for calculating the loss of multi-level coupled semantic transformation, and the specific expression is written as follows: The formula is divided into two independent calculation items. After the two items are calculated, an addition operation is performed to obtain the final loss value. The formula contains five types of independent parameters, among which... Represents the semantic completeness coefficient. Represents the complexity coefficient of a statement. Represents the baseline loss value for structured conversion. Represents the semantic bias correction factor. This formula represents the total loss in semantic structured transformation, with all parameters set to dimensionless. The theoretical basis of this formula stems from the actual loss formation mechanism in the transformation of natural language into structured database statements. Four factors jointly determine the total loss in a single transformation process: the completeness of the statement's information, the complexity of its internal nesting and conditions, the inherent transformation bias of the model, and the misalignment of the semantic mapping between the two types of statements. Since a single linear operation cannot reflect the coupling effect of multiple factors, a combination of exponential and square root operations is used to characterize the effects of different factors. The formula derivation process combines the four objective conditions affecting loss: the completeness of the statement's information, the complexity of its internal structure, the inherent loss of the model, and the mapping bias between the two types of statements. The baseline loss value is combined with the statement's completeness and complexity to form an exponential operation. The exponential operation reflects the suppressive effect of semantic completeness on the loss scale after the statement's complexity increases; the more complex the statement structure, the more significant the offsetting effect of information completeness on loss. Simultaneously, the bias factor and complexity are combined to form a square root operation. The square root operation characterizes the change in semantic mapping bias that is synchronously amplified by the complexity of the statement structure. The sum of the two operation results yields the comprehensive loss value. A thorough verification was conducted at the dimensional level. All basic parameters within the formula are dimensionless. Exponentiation and square root operations are function transformations and do not alter the inherent dimensional attributes of the parameters. The dimensions of the two terms added within the formula remain consistent. The dimensions of the output parameters on the left side of the equation are completely identical to the dimensions of the combined results on the right side. There are no cross-dimensional operations, fully conforming to the dimensional homogeneity principle. In actual device operations, the processor sequentially retrieves the five parameter values stored in the cache partition and performs exponentiation, multiplication, square root, and subtraction operations according to their priority. Finally, the two sub-item results are combined to obtain the total semantic structure transformation loss. The formula can simultaneously consider multiple loss-influencing conditions, objectively calculating the overall loss scale generated in the statement transformation process.
[0034] The source of the confidence score in dynamic queries lacks clear definition, making it impossible to determine the types of parameters involved in the numerical calculation. This makes it difficult to ensure that the confidence score can comprehensively reflect the actual matching status of the statement. As the core reference data for determining the degree of matching between the query statement and the user's needs, the confidence score, which is calculated based on a single parameter, is obviously one-sided. It cannot take into account multiple factors such as statement transformation deviation, field matching correlation, and initial matching benchmark. The judgment result cannot truly reflect the overall matching level of the statement. Subsequent error compensation calculations based on one-sided confidence score values are prone to problems such as excessive or insufficient compensation, and cannot accurately offset the deviation content retained by statement transformation.
[0035] Based on this, in the step of calculating the dynamic query confidence, the value of the dynamic query confidence is determined by the basic matching confidence, the adaptive association weight of the database field, and the total loss of the semantic structure transformation.
[0036] The confidence score calculation process incorporates three different types of operational parameters. These parameters correspond to different reference dimensions for statement matching, complementing and refining the judgment criteria to avoid biases caused by relying on a single parameter. The basic matching confidence score serves as the initial reference value for statement matching. This value, generated by the initial semantic comparison program of the large language model, represents the basic fit between the natural language statement and the standard sample statements in the database, serving as the original baseline data for confidence score determination. The adaptive association weight of database fields reflects the correspondence between data table fields and query statements. The weight value directly reflects the fit between the fields retrieved in the statement and the inherent field association structure of the data table. The higher the field association fit, the better the basic conditions for statement matching. The total loss in semantic structured transformation reflects the scale of deviation generated during the statement transformation process. The loss value records the actual situation of information deletion and content misalignment during the statement transformation process. The larger the loss scale, the lower the integrity of the original statement information. All three types of parameters participate in the confidence score calculation. The device processor synchronously reads the three parameter data from the cache partition, integrates the parameter information according to a predetermined combination operation logic, and calculates the confidence score result based on multi-dimensional reference conditions. The multi-parameter combination calculation mode can comprehensively consider the initial matching status of the statement, the field association status, and the transformation deviation status, so that the final confidence value can fully reflect the overall situation of statement matching and completely cover the core elements affecting the matching judgment result. This limitation clearly defines the source of the confidence value and defines the specific categories of parameters involved in the calculation, so that the calculation result can comprehensively reflect the actual situation of statement matching and provide comprehensive and effective matching judgment reference data for the calculation of global error compensation coefficient.
[0037] The second set of formulas is for calculating the correlation weight of loss-linked fields, and the specific expression is written as follows: The formula is split into two sets of arithmetic units. The values produced by the two sets of units are added together to determine the final weighted result. The formula contains five types of parameters. Represents the cardinality of database field associations. This represents the total loss in semantic structuring transformation. Represents the complexity coefficient of a statement. Represents the semantic completeness coefficient. This represents the adaptive association weight of database fields, with all parameters uniformly defined as dimensionless attributes. The formula design relies on the constraint mechanism of loss on field matching and the influence of statement characteristics. The cardinality of database field associations determines the inherent matching framework of field combinations within the data table. Transformation loss disrupts the correspondence within this inherent matching framework, while statement completeness and complexity alter the scope of field retrieval requested by the statement. These multiple effects collectively influence the weight value. The formula derivation combines the constraint of loss values on field matching with the influence of statement characteristics on weight values. It is divided into two parts, each calculating the corresponding weight reference values for different dimensions. The first part retrieves the field association cardinality and loss values to complete the calculation, reflecting the constraint of loss status on the inherent field matching framework; changes in loss values directly adjust the adaptation range of the field matching framework. The second part retrieves the statement complexity coefficient and semantic completeness coefficient to complete the calculation, reflecting the influence of statement characteristics on the scope of field retrieval requests; statement structure and information completeness change the emphasis of field matching. The results of the two parts are added together to obtain the final weight value. During the dimensionality verification process, both the numerator and denominator of the fraction operations are dimensionless parameters. The output result after division operations retains the dimensionless attribute. The dimensions of the two sets of added terms are consistent, and the dimensions on both sides of the equation are equal. There are no violations of operational rules throughout the process, and all operations can be executed stably according to mathematical principles. During the equipment operation phase, the weight calculation subroutine reads the field association base, loss value, and statement feature parameters, and sequentially completes the addition, subtraction, squaring, and division operations within the fraction. After merging the results, it generates adaptive association weights. The formula calculates the weights based on the dual conditions of loss and statement features, ensuring that the weight values closely match the actual matching state of the fields, achieving a dynamic adjustment effect of weights following loss.
[0038] The calculation parameter range for the global error compensation coefficient is not defined, and the types of parameters involved in the calculation are unclear. The compensation coefficient cannot fully integrate various deviation data generated throughout the entire process. As the core basis for correcting the structured intermediate representation, the compensation coefficient only selects parameters from local steps in the calculation process, which can only offset the transformation deviation generated in a single stage. Deviations in the early stage of the calculation process, deviations in the middle stage of weight matching, and deviations in the later stage of confidence judgment cannot be uniformly summarized and corrected. Residual deviations remain within the structured statements. After format conversion, they are brought into the database query command, and the final query result does not match the user's original query intent. The scattered retention of deviation data will also cause the deviation to accumulate in complex query scenarios, gradually increasing the degree of deviation between the query statement and the actual needs.
[0039] Based on this, in the step of calculating the global error compensation coefficient, the value of the global error compensation coefficient is jointly determined by the total loss of the semantic structure transformation, the adaptive association weight of the database fields, the dynamic query confidence, and the hierarchical error propagation coefficient.
[0040] The compensation coefficient, as the core reference value for correcting statements, integrates four types of parameters—loss, weight, confidence level, and error propagation—in its calculation process. These four parameters correspond to deviation information generated at different stages of the operation process, fully covering the entire process of statement conversion, field matching, confidence judgment, and deviation propagation. The total loss of semantic structured conversion records the original deviation data in the conversion stage, reflecting the amount of information change generated during the conversion of natural language into structured statements. The adaptive association weight of database fields records the corresponding data for field matching, reflecting the adaptation deviation between the field association structure and the query statement. The dynamic query confidence level records the statement matching judgment data, presenting the deviation judgment result corresponding to the overall matching degree of the statement. The hierarchical error propagation coefficient records the proportion of deviation propagated backward, statistically analyzing the retention rate of deviations from earlier stages that are progressively transmitted to subsequent operation steps. These four types of parameters are summarized and stored in a temporary data cache partition. The compensation coefficient calculation subroutine retrieves the values of all four parameters at once, and, combined with the formation stage and propagation ratio of each deviation data, uniformly calculates the compensation value that can offset the deviations throughout the entire process. The compensation coefficients calculated based on multi-dimensional parameters can comprehensively reflect the total amount of deviations retained in the entire calculation process. The compensation values can specifically cover the deviations generated in different stages, and the corrective actions can simultaneously offset the accumulated deviations from multiple stages. This content defines the parameter range for compensation coefficient calculation and clearly defines the parameter categories involved in the numerical calculation, allowing the compensation values to fully integrate the deviation information generated throughout the entire process. This ensures that the structured intermediate representation correction stage can comprehensively eliminate all kinds of deviations retained in the calculation process.
[0041] The third set of formulas is a weighted, coupled confidence iterative calibration formula, specifically expressed as follows: The formula divides the calculation into two independent operation terms. After the operation of each term is completed, the values are combined to obtain the dynamic query confidence score. The formula covers six types of operation parameters. Represents the basic match confidence level. This represents the adaptive association weight of database fields. This represents the total loss in semantic structuring transformation. Represents the semantic completeness coefficient. This represents the dynamic query confidence level, with all parameters set dimensionless. The formula design logic revolves around multiple factors determining the degree of statement matching. Four types of factors interact to jointly determine the final matching confidence level: initial matching benchmark, field matching association status, conversion loss deviation, and statement information completeness. Linear operations cannot reflect the coupling and constraint relationships between these factors; therefore, multiplication combined with squaring operations is used to characterize the interaction of these factors. The formula derivation references three core conditions: initial matching benchmark, field matching weight, and conversion loss deviation. It divides the calculation into two sets of units to calculate the confidence reference values corresponding to different dimensions. The first set integrates the initial confidence, weight values, and loss values through multiplication, reflecting the confidence level corresponding to the actual matching status. The loss value is halved to correct the original matching benchmark, reflecting the weakening effect of deviation on the matching level. The second set combines semantic completeness and the squared weight values to correct the confidence deviation caused by statement information completeness. Statement information completeness compensates for over-matching issues that occur during weighted matching. The results of the two sets of calculations are combined to obtain the calibrated confidence level value. At the dimensional level, each item is checked. Exponentiation, division, and multiplication operations all operate on dimensionless parameters, and the operation process does not change the parameter's dimensional attributes. The dimensions of the two items being added remain consistent, and the dimensions on both sides of the equation remain consistent. The operation process conforms to the rules of mathematical dimensional constraints. When the device performs the confidence calculation, the subroutine completes the division, subtraction, squaring, and multiplication operations in sequence according to the operation priority. After merging the results, it outputs the calibrated confidence value. The multi-condition combination calibration mode can correct the confidence bias caused by the judgment of a single parameter, improve the reference value of the confidence value, and accurately reflect the actual matching level of the statement.
[0042] Structured intermediate representation correction actions are only applicable to simple, routine query scenarios and cannot handle statement deviations arising from various complex query scenarios. The applicability of correction actions is limited. Routine single-table query statements have simple structures and single query conditions, resulting in small-scale deviations from statement transformation. The basic correction mode can handle the deviation offsetting work. However, in the daily business processing of enterprise databases, a large number of query tasks have complex structural characteristics. Multi-table join queries require retrieving field data across multiple data tables. Nested query statements contain multiple layers of progressive limiting conditions. Fuzzy semantic query statements have no fixed standard expression format. In these three complex scenarios, statement transformation deviations take various forms and are scattered in location. The original limited correction mode cannot adapt to the differentiated deviation forms. After the complex scenario query statements are corrected, content deviations still exist, making it difficult to meet the actual business query needs.
[0043] Based on this, the step of using the global error compensation coefficient to correct the structured intermediate representation is applied to scenarios of multi-table join queries, nested queries, and fuzzy semantic queries.
[0044] The statement correction action is no longer limited to basic single-table query scenarios, but also adapts to three types of complex query scenarios. Different scenarios correspond to different statement structures and data retrieval formats. The correction program can automatically identify the scenario category of the current query task and execute correction actions according to the deviation distribution characteristics of the corresponding scenario. Multi-table join queries correspond to queries that retrieve data across different tables. During the statement conversion process, the field correspondence between different tables can easily become disordered. The correction action uses a compensation coefficient to adjust the field association correspondence, organize the matching combination structure of cross-table fields, and eliminate field misalignment deviations. Nested queries correspond to statements containing multiple levels of query conditions. The hierarchical nesting structure can easily cause confusion in the condition hierarchy. The correction action uses a compensation coefficient to adjust the arrangement order of the condition hierarchy, straighten the logical relationship of multiple limiting conditions, and solve the hierarchical division deviation problem. Fuzzy semantic queries correspond to queries with no fixed standard sentence structure. Colloquial and non-standardized expressions can easily cause semantic interpretation deviations. The correction action uses a compensation coefficient to standardize the statement expression format, align the interpreted semantics with the original query meaning, and offset semantic interpretation deviations. After the equipment completes numerical calculations to obtain compensation coefficients, it can uniformly retrieve coefficients to adjust statements in three types of complex scenarios. The correction program has built-in scenario recognition logic, which automatically determines the scenario type based on statement structure characteristics and matches the corresponding deviation correction focus. The correction actions can adapt to various high-frequency and complex query needs in daily business processing, expanding the applicable scenario range of statement correction actions. This application scope sets expanded correction action adaptation scenarios to meet the correction needs of query statements with different structural forms, covering mainstream complex query business types of enterprise databases, and improving the scenario adaptability of the statement correction process.
[0045] The fourth set of formulas is a progressive, transitive global error compensation calculation formula, specifically written as follows: The formula consists of two calculation modules; the results of these modules are summed to determine the global error compensation coefficient. The formula contains six types of parameters. Represents the hierarchical error propagation coefficient. This represents the total loss in semantic structuring transformation. This represents the confidence level of a dynamic query. This represents the adaptive association weight of database fields. Represents the complexity coefficient of a statement. This represents the global error compensation coefficient, with all parameters being dimensionless. The formula design is based on the principle of error propagation and retention at each level, and the principle of supplementing and correcting deviations from complex statements. Deviations generated in the early stages of calculation will propagate to the later stages in a fixed proportion. Deviations retained from different calculation steps are superimposed on each other, and complex statement structures will generate additional implicit deviations. These two types of deviations together constitute the total total deviation. The formula separately calculates the propagated deviation and implicit deviation through different calculation methods. The formula derivation integrates the deviation data retained from the entire process of calculation, and combines multiple factors such as the error propagation ratio, actual loss scale, confidence judgment result, field matching weight, and statement complexity. It divides the calculation into two sets of calculation modules to calculate the compensation reference value. The first module calculates the total deviation retained at each level based on the error propagation coefficient, loss value, and confidence value, reflecting the actual scale of deviations accumulated from the earlier steps. The second module combines the results of the weight and complexity square root calculation to supplement the deviation correction amount corresponding to the statement structure, offsetting the implicit deviations generated by complex sentence structures. The two sets of values are added together to obtain the final compensation coefficient. Dimensional verification results show that the dimensions do not change after square root and multiplication operations are applied to dimensionless parameters, the dimensions of the two added items remain equal, the dimensions of the parameters on both sides of the equation are consistent, there are no operations that violate dimensional rules, and all operation processes can be executed in compliance with regulations. The equipment compensation calculation subroutine reads all five types of basic parameters, performs square root, multiplication, and subtraction operations in the order of operation, and outputs the compensation coefficient after merging the module results. The full-element integrated accounting mode can summarize all kinds of deviations generated by the entire process, generate compensation values that can comprehensively correct statement deviations, and provide accurate reference for adjusting the structured intermediate representation.
[0046] The entire set of calculation formulas relies on the objective operational laws of statement transformation, field matching, confidence determination, and error propagation to complete logical derivation. The parameter combination forms correspond to the action mechanism of different influencing conditions, the dimensional system is unified and standardized, and the calculation logic can be understood and reproduced by those skilled in the art. The various calculation steps within the formulas are clearly broken down, and the parameter calling order and calculation priority remain unchanged. After being integrated into the device calculation subroutine, it can stably produce uniform results. Based on the various values calculated by the formulas, loss statistics, weight matching, confidence determination, and statement correction can be completed sequentially. It adapts to the database query statement transformation and processing needs of different structures and scenarios. The four sets of formulas are interconnected, with the output parameters of the preceding formulas serving as the input data for the following formulas, forming a complete closed-loop calculation logic that corresponds one-to-one with the progressive calculation steps. This solidifies the execution rules of the entire set of numerical calculations and eliminates the deviation of calculation results caused by different devices and different operating periods.
[0047] The separated functional modules perform data operations independently, lacking stable data interaction channels. Results from preceding modules cannot be transmitted to subsequent modules, hindering a coherent parameter progression calculation process. In independent operation, each module can only access its own internally stored fixed parameters, unable to obtain intermediate calculation data from other modules. The parameter transmission link required for progressive calculations is broken, preventing the completion of the entire numerical calculation process according to the sequence of steps. Furthermore, the lack of a unified communication protocol between modules, coupled with undefined data transmission formats and data verification rules, makes data transmission prone to issues such as missing data, character corruption, and numerical tampering. Data transmission reliability cannot be guaranteed, module collaboration is lacking, and the system as a whole cannot achieve complete database query and processing functions.
[0048] Based on this, a conversion loss calculation module deployed on a computer device is used to calculate the total semantic structured conversion loss based on the semantic completeness coefficient, statement complexity coefficient, semantic deviation correction factor, and structured conversion baseline loss value. A weight calculation module is communicatively connected to the conversion loss calculation module, used to receive the total semantic structured conversion loss, and calculate the adaptive association weight of the database fields based on the total semantic structured conversion loss and the database field association cardinality. A confidence calibration module is communicatively connected to the weight calculation module, used to receive the adaptive association weight of the database fields and the total semantic structured conversion loss, and calculate the adaptive association weight of the database fields based on the adaptive association weight of the database fields and the semantic structured conversion baseline loss value. The system calculates the dynamic query confidence score based on the total loss of semantic structured transformation and the basic matching confidence score. An error compensation module, communicatively connected to the confidence score calibration module, receives the dynamic query confidence score, the total loss of semantic structured transformation, and the adaptive association weights of the database fields. Based on these factors, it calculates a global error compensation coefficient and uses it to correct the structured intermediate representation. A query execution module, also communicatively connected to the error compensation module, converts the corrected structured intermediate representation into a database query statement and executes the database query statement.
[0049] The entire query system is divided into five functionally independent modules, arranged sequentially according to the order of computation. These modules are integrated into a single computer device, sharing the same processor, storage partitions, and external interfaces. Communication links between modules are established via the device's internal bus, ensuring stable connections between adjacent modules. The bus uses a unified data transmission protocol, data encapsulation format, and data verification standard. All cross-module data transmissions are encapsulated and parsed according to the protocol specifications. Data integrity is automatically verified upon transmission, and retransmission is triggered if data is missing, ensuring the stability and accuracy of data interaction between modules. Each module independently handles corresponding numerical calculations, statement corrections, and statement execution. Each module contains dedicated subroutines whose functions are matched to the module's defined tasks. The conversion loss calculation module solves for the initial loss value. It retrieves the basic parameters generated by semantic parsing, calls the multi-level coupled semantic conversion loss calculation formula to complete the calculation, and encapsulates the result before transmitting it to downstream modules via the bus. The weight calculation module retrieves loss data to perform weight calculations, generates weight values based on loss-linked fields, and transmits the data synchronously downstream. The confidence calibration module combines dual parameters to determine confidence levels and generates confidence results using a weighted, coupled iterative confidence calibration formula. The error compensation module integrates multiple parameters to generate compensation values and adjusts the statement format. It calculates compensation coefficients using a progressive, global error compensation formula, simultaneously correcting deviations in the structured intermediate representation. The query execution module performs statement format conversion and initiates the query, converting the corrected statement into a database-recognizable format and issuing query commands via the device database interaction interface. Modules transmit computational data step-by-step via communication links, working collaboratively to complete all operations from parameter parsing to statement execution. The hardware and software co-engineering architecture ensures orderly data interaction and computational processing. The operational status of each module can be independently monitored; a single module's malfunction will not directly cause the entire system to fail, providing basic operational fault tolerance. Modular division of labor combined with a communication interaction mode enables the splitting of computational tasks. Each module focuses on completing a single type of computational task, improving the accuracy of individual calculations. Stable data transmission maintains the continuous progress of the entire query process, and the collaborative work of the modules fully realizes the entire processing flow of natural language database queries.
[0050] The system lacks unified data transmission rules for its internal modules. Data output from preceding modules cannot be routed to subsequent modules, hindering coordinated operations and resulting in arbitrary data transmission. The recipients of computational results are not clearly defined, leading to errors and omissions. Downstream modules cannot obtain necessary parameters in a timely manner, causing computational pauses and delays, and extending query processing times. Furthermore, the range of input data retrieved by modules is unconstrained, causing some modules to incorrectly retrieve unrelated computational data. This results in deviations from predetermined requirements, producing invalid results, and undermining the collaborative capabilities of inter-module computation.
[0051] Based on this, the conversion loss calculation module, the weight calculation module, the confidence calibration module, and the error compensation module are each configured with corresponding calculation formulas, and the calculation output of the former module is used as the calculation input of the latter module.
[0052] The system comprises four modules responsible for numerical calculations, each equipped with its own dedicated computational logic. Four types of calculation formulas are matched to the corresponding computational tasks of each module. These formulas are embedded in the subroutines within the modules. Once a module initiates a computation, it automatically calls the corresponding formula to perform the numerical calculation, ensuring that the numerical calculations within each module are completed according to predetermined logic, preventing logical inconsistencies or misuse of calculation rules. A unidirectional data transfer rule is established between modules, ensuring that the data transmission direction matches the sequence of computation steps. Following the order of computation, all output data obtained from the previous module's computation is directly used as the input data for the next module's computation. Data is not transferred across levels or backwards; it flows sequentially according to a fixed direction. After each module completes its computational task, it automatically encapsulates the final result into a standard transmission data frame. The bus pushes this data frame to adjacent downstream modules according to predetermined rules. Downstream modules receive and parse the data frame, extracting internal parameter values as their own computational input, without retrieving data from unrelated modules. The standardized data input / output rules regulate module interaction, integrating disparate module operations into a unified, interconnected computing system. The progress of each module's operations is synchronized, and downstream modules start synchronously upon completion of a preceding operation, creating a tight collaborative relationship between modules. Unified data retrieval and transmission rules prevent data errors and omissions, ensuring that every computational step receives compliant and valid input parameters. The stable operation of the interconnected module computing system, based on its modular architecture and data transmission rules, fully realizes progressive parameter computation and statement correction processing. The overall system operation logic is complete and closed-loop, enabling stable completion of various natural language database query and processing tasks.
[0053] The entire technical solution relies on computer hardware, hierarchical storage partitioning, multi-threaded operation scheduling mechanisms, modular functional units, linked dimensionless operation formulas, and standardized module communication protocols to jointly construct a complete large language model database query and processing system, forming a seamless processing chain from parameter extraction, numerical calculation, statement correction to instruction execution. At the hardware level, the processor provides computing power, storage partitioning enables hierarchical data storage, and the communication bus ensures data interaction between modules. At the software level, semantic parsing rules define parameter attributes, four sets of linked formulas solidify the operation logic, module subroutines break down processing tasks, and the communication protocol standardizes data transmission. All components work together synergistically to address the substantial technical problems inherent in existing fixed-parameter operations, independent module operation, and single-scenario adaptation technologies, such as insufficient dynamic adaptation of losses, cascading errors, weak module interoperability, and limited scenario coverage. The entire operation strictly adheres to the dimensionless homogeneity principle. All special function independent variables and operations (addition, subtraction, multiplication, and division) meet dimensionality matching requirements. Formula derivation closely follows the mechanisms of practical statement transformation and data matching. The various technical features within the solution are interconnected and mutually restrictive; deleting any single feature would prevent the completion of complete query deviation correction and instruction execution. The combination of all technical features constitutes a complete and practical technical solution. Those skilled in the art, referring to the module structure, step sequence, calculation formulas, data interaction rules, and parameter definition standards described in the specification, and using conventional computer equipment, large language model programs, and database interaction programs, can replicate the entire technical solution without creative effort, reproducing the optimized processing effect of natural language database queries. The disclosed content of the solution meets all the requirements for written disclosure under patent law. All technical features defined in the claims can be concretely implemented in the embodiments. The scope of feature definition is clear and unambiguous, without any vague definitions or black-box technical content. The entire solution is repeatable and stable, adaptable to various daily database query business scenarios of enterprises.
[0054] In practical commercial deployment scenarios, the allocation ratio of computing thread resources can be adjusted according to the computing power configuration of the device hardware. High-computing-power devices can process multiple user query requests simultaneously and in parallel, while low-computing-power terminal devices use a single thread to process query tasks sequentially. The data transmission rate between modules can be adapted and adjusted according to the device bus specifications. The values of dimensionless parameters within the calculation formula can be adapted and debugged by combining the density of field associations in the database table and the structural characteristics of daily query statements. The debugging process only changes the specific values of the parameters and does not change the formula calculation structure, step sequence, or module connection relationship. This is a conventional adaptation and adjustment form under the basic architecture of this technical solution and will not deviate from the scope of the core technical solution of this invention. In different deployment environments, the progressive calculation logic, module linkage interaction mode, and multi-scenario statement correction form remain consistent. The core innovative technical features remain stable and unchanged, and can continuously play the role of dynamically adapting and converting losses, suppressing the gradual accumulation of errors, and expanding the coverage of query scenarios. This effectively optimizes the database query processing effect driven by large language models and meets the operational needs of database query business under different scales and usage scenarios.
[0055] The experiment was conducted on a commercial server equipped with a central processing unit, random access memory, and solid-state drive, serving as the computing device for running large language models and database query processing. The software environment employed a Linux operating system, a MySQL database system, and a locally deployed large language model. The test database simulated an e-commerce platform business scenario, containing multiple interconnected data tables. The test query set was written by database engineers, covering three typical complex scenarios: multi-table join queries, nested queries, and fuzzy semantic queries. Three comparative schemes were set up in the experiment. The experimental group used the method and system fully described in the claims of this invention. The computer device's processor sequentially performed semantic structured transformation total loss calculation, database field adaptive association weight calculation, dynamic query confidence calculation, and global error compensation coefficient calculation. The calculated global error compensation coefficient was then used to correct the structured intermediate representation, ultimately converting it into an executable database query statement and executing the query operation. The entire computation process employed dimensionless computation rules, with statement feature parameters, database structure parameters, and model matching parameters all participating in the entire computation process. Control group 1 uses the fixed-parameter correction method described in the background section, applying a fixed loss correction parameter to correct the structured intermediate representation of all queries without performing multi-parameter progressive linkage operations. Control group 2 calculates the total loss of semantic structured transformation and the adaptive association weights of database fields, but does not calculate the global error compensation coefficient, directly generating SQL query statements based on the uncorrected structured intermediate representation.
[0056] During the experiment, the query execution accuracy and statement conversion deviation of each group were recorded under different query scenarios. The results showed that in control group one, which used a fixed parameter correction method, data deviations continuously occurred during the conversion of natural language into structured statements when faced with complex commands such as multi-table join queries and fuzzy semantic queries. These deviations propagated through subsequent processing steps such as weight determination, confidence calculation, and command correction, ultimately resulting in query statements whose content could not match the user's actual query requirements. Control group two, which used no global compensation method, calculated the total loss of semantic-structured conversion and the adaptive join weights of database fields, but did not perform global error compensation coefficient correction. This resulted in deviations from the preceding operations remaining within the structured statements. After format conversion, these deviations were incorporated into the database query command, leading to a significant deviation between the query results and the user's original intent. The experimental group, using the method of this invention, performed multi-parameter progressive calculations in the order of semantic loss calculation, weight determination, confidence calibration, and error compensation. The compensation parameters obtained from real-time calculations were used to correct the structured statements, enabling the system to adapt its processing logic to the query statement characteristics and database structure. The experimental group demonstrated stable query matching capabilities under various complex query scenarios. The generated database query statements were highly consistent with the user's natural language query intent, and there was no problem of query instruction misalignment caused by the propagation of deviations layer by layer.
[0057] The above experiments verified the technical effects of this invention. This invention abandons the conventional method of correcting semantic transformation deviations with fixed parameters. Instead, it relies on multi-parameter linkage operations to suppress the layer-by-layer propagation of data errors, adapting to differentiated database query scenarios and effectively improving query matching anomalies caused by semantic transformation deviations. Compared to schemes that only calculate some parameters without global error compensation, this invention corrects the structured intermediate representation step by adding a global error compensation coefficient, effectively offsetting deviations generated by preceding operations before the final query statement is generated. Compared to fixed parameter correction schemes, this invention demonstrates significant accuracy advantages in complex scenarios such as multi-table join queries, nested queries, and fuzzy semantic queries, meeting the needs of complex database queries in daily business operations. Simultaneously, the additional computational overhead from progressive operations is within an acceptable range, and the overall query response time does not affect the actual user experience. In summary, the technical solution of this invention achieves the technical effects of dynamically adapting to query scenarios, constraining the diffusion of transformation deviations, and improving the fit of natural language to database query instructions.
[0058] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments that can be applied to other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.
Claims
1. A database query method based on a large language model and structured intermediate representation, characterized in that, The following steps are performed by the processor of the computer device: S1: Calculate the total loss of semantic structure conversion based on the semantic completeness coefficient, statement complexity coefficient, semantic deviation correction factor, and structure conversion baseline loss value; S2: Calculate the adaptive association weight of the database fields based on the total loss of the semantic structure transformation and the association cardinality of the database fields; S3: Calculate the dynamic query confidence based on the basic matching confidence, the total loss of the semantic structure transformation, and the adaptive association weight of the database fields; S4: Calculate the global error compensation coefficient based on the hierarchical error propagation coefficient, the total loss of the semantic structure transformation, the adaptive association weight of the database fields, and the dynamic query confidence. S5: Correct the structured intermediate representation using the global error compensation coefficient; convert the corrected structured intermediate representation into a database query statement and execute the database query statement.
2. The method according to claim 1, characterized in that, The semantic completeness coefficient represents the degree of semantic information completeness of the natural language query statement, the statement complexity coefficient represents the number of nesting levels and conditions of the natural language query statement, the semantic deviation correction factor represents the semantic mapping deviation between the natural language query statement and the database structured statement, and the structured conversion baseline loss value is a preset basic semantic conversion loss value.
3. The method according to claim 2, characterized in that, The step of calculating the total loss of semantic structure transformation includes: calculating the total loss of semantic structure transformation based on query complexity variables and database table structure variables, wherein the query complexity variables include the statement complexity coefficient, and the database table structure variables include the database field association cardinality.
4. The method according to claim 3, characterized in that, The adaptive association weight of the database field has an inverse relationship with the total loss of the semantic structuring transformation.
5. The method according to claim 4, characterized in that, The four types of calculation results—total loss of semantic structure transformation, adaptive association weight of database fields, dynamic query confidence, and global error compensation coefficient—are solved by relying on the parameters produced by the preceding operations as the input parameters for the subsequent operations. The entire operation process is carried out using dimensionless operation rules, with statement feature parameters, database structure parameters, and model matching parameters all participating in the entire operation process.
6. The method according to claim 1, characterized in that, In the step of calculating the dynamic query confidence, the value of the dynamic query confidence is determined by the basic matching confidence, the adaptive association weight of the database field, and the total loss of the semantic structuring transformation.
7. The method according to claim 1, characterized in that, In the step of calculating the global error compensation coefficient, the value of the global error compensation coefficient is jointly determined by the total loss of the semantic structure transformation, the adaptive association weight of the database fields, the dynamic query confidence, and the hierarchical error propagation coefficient.
8. The method according to claim 1, characterized in that, The step of correcting the structured intermediate representation using the global error compensation coefficient is applied to scenarios involving multi-table join queries, nested queries, and fuzzy semantic queries.
9. A database query system based on a large language model and structured intermediate representation, characterized in that, Deployed on computer devices, including: The conversion loss calculation module is used to calculate the total loss of semantic structured conversion based on the semantic integrity coefficient, statement complexity coefficient, semantic deviation correction factor, and structured conversion baseline loss value. The weight calculation module is communicatively connected to the conversion loss calculation module. It is used to receive the total semantic structure conversion loss and calculate the adaptive association weight of the database field based on the total semantic structure conversion loss and the association cardinality of the database field. The confidence calibration module is communicatively connected to the weight calculation module. It is used to receive the adaptive association weight of the database field and the total loss of the semantic structure transformation, and to calculate the dynamic query confidence based on the adaptive association weight of the database field, the total loss of the semantic structure transformation, and the basic matching confidence. The error compensation module is communicatively connected to the confidence calibration module. It is used to receive the dynamic query confidence, the total loss of the semantic structure transformation, and the adaptive association weight of the database field. Based on the dynamic query confidence, the total loss of the semantic structure transformation, the adaptive association weight of the database field, and the hierarchical error propagation coefficient, it calculates the global error compensation coefficient and uses the global error compensation coefficient to correct the structured intermediate representation. The query execution module, which is communicatively connected to the error compensation module, is used to convert the corrected structured intermediate representation into a database query statement and execute the database query statement.
10. The system according to claim 9, characterized in that, The conversion loss calculation module, the weight calculation module, the confidence calibration module, and the error compensation module are each configured with a corresponding calculation formula, and the calculation output of the former module is used as the calculation input of the latter module.