An intelligent power query method fusing adaptive inference and SQL rectification

By integrating adaptive reasoning and SQL correction, the accuracy and efficiency issues of natural language queries in power control operations have been resolved, enabling efficient and accurate data querying and decision support, and is applicable to various application scenarios in power control cloud.

CN121365081BActive Publication Date: 2026-03-24TELLHOW SOFTWARE
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-23
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

In power dispatching operations, existing technologies based on natural language querying suffer from low query accuracy, numerous ambiguities, and difficulty in meeting real-time business needs. Furthermore, deep learning models are insufficient in multi-turn dialogues and complex multi-table join queries, resulting in low data query efficiency.

Method used

We employ a method that integrates adaptive inference and SQL correction. We use a large language model to understand natural language requests, use an abstract syntax tree to parse and correct SQL query expressions, and combine Siamese neural networks and Transformer neural networks to generate accurate SQL query expressions, and perform syntax and semantic verification.

Benefits of technology

It improves the data query efficiency and decision support capabilities of power dispatching operations, enhances query accuracy and execution efficiency, reduces the probability of model generation errors, supports multi-table joint queries and complex logic construction, and is suitable for various application scenarios of power dispatching cloud.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121365081B_ABST
    Figure CN121365081B_ABST
Patent Text Reader

Abstract

The application discloses a power intelligent question method fusing adaptive reasoning and SQL rectification, relates to the technical field of power system intelligent question, and comprises the following steps: A, converting a natural language query request proposed by a user into a SQL query expression conforming to a power business scene; B, introducing a SQL rectification scheme based on an abstract AST, structurally analyzing the SQL query expression, identifying logical errors existing in SQL grammar and semantics, and rectifying and optimizing; C, structurally summarizing original data obtained by querying through a large language model, and feeding back a user in a natural language form.The application can improve the defects of the prior art, and improve the data query efficiency and decision support capability of power regulation and control business.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent power system query technology, and in particular to an intelligent power system query method that integrates adaptive reasoning and SQL correction. Background Technology

[0002] As the underlying technological foundation of the next-generation control and regulation system, the control cloud provides support for the construction of the analysis and decision-making center of the system. The control cloud platform contains various types of power grid data, such as power grid equipment asset data, power grid operating load data, power grid transaction data, and power grid fault alarm data. Because the data encompasses key information required for different business decisions, customized query SQL services are needed for different business needs. This results in a large workload for later maintenance and cannot promptly meet the query requirements of changing business needs. Therefore, a query technology based on natural language dialogue is needed to retrieve relevant data results from the control cloud based on the user's description of the problem.

[0003] In existing technologies, query technologies based on natural language dialogue mainly fall into two categories: one is based on traditional natural language processing (NLP), including word segmentation, entity recognition, and syntactic structure analysis, extracting query intent and conditions from user questions and concatenating them into SQL statements. This approach suffers from low query accuracy, ambiguity, and vague query results in practical applications, making it difficult to meet the high accuracy requirements of real-time power grid business scenarios. The other is based on deep learning-based Text2SQL technology, which directly transforms natural language questions into SQL statements by training a neural network model. While this method offers higher query accuracy than traditional NLP, it is highly dependent on the quality of data annotation and the number of samples, resulting in a heavy initial data annotation workload. Furthermore, existing Text2SQL models are insufficient in handling the frequent multi-turn dialogue scenarios, complex multi-table join queries, and data summarization and generalization required in power business, severely impacting the application effectiveness in real-world business scenarios. Summary of the Invention

[0004] The technical problem to be solved by this invention is to provide a power intelligent data query method that integrates adaptive reasoning and SQL correction, which can overcome the shortcomings of existing technologies and improve the data query efficiency and decision support capabilities of power control operations.

[0005] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows.

[0006] A smart electricity query method integrating adaptive inference and SQL correction includes the following steps:

[0007] A. Convert the natural language query requests submitted by users into SQL query expressions that conform to the power business scenario;

[0008] B. Introduce an SQL correction scheme based on abstract AST to perform structured parsing of SQL query expressions, identify logical errors in SQL syntax and semantics, and perform correction and optimization.

[0009] C. The large language model performs a structured summary of the raw data obtained from the query and provides feedback to the user in natural language.

[0010] Preferably, in step A, the natural language query request is segmented to remove noise words, and then the characters are uniformly encoded to achieve standardization of the natural language query request.

[0011] As a preferred approach, the word segments obtained after word segmentation are converted into one-dimensional vectors to form the original data matrix. The covariance matrix of the original data matrix is ​​calculated, and the eigenvectors of the covariance matrix are calculated. All eigenvectors are combined to form a feature matrix. The feature matrix is ​​then used to perform a convolution operation on the original data matrix to remove noisy words.

[0012] As a preferred approach, a standardized natural language query request is input into a Siamese neural network to generate a semantic vector of the query request. Then, a cosine similarity calculation is performed between the semantic vector of the control cloud structure information stored in the system to obtain the table structure information that is closest to the query request.

[0013] The semantic similarity is calculated by taking the dot product of the query request semantic vector and the query expression vector. The query expression with the highest semantic similarity is selected for use. The BM25 algorithm is used to calculate the similarity between the structural information semantics and the query expression. The query expression with the highest semantic similarity is selected for use. The two selected query expressions are then input into the Transformer neural network to generate the SQL query expression.

[0014] Preferably, the Transformer neural network includes an equal number of encoders and decoders, with one encoder and one decoder corresponding to each other. Each encoder and decoder includes a feedforward neural network unit. The hidden layer of the feedforward neural network unit in the decoder is updated using a real-time training mode. When the feedforward neural network unit of the corresponding encoder is performing operations, the input and output data of the feedforward neural network unit of the encoder are used to train the hidden layer of the feedforward neural network unit in the corresponding decoder.

[0015] As a preferred option, in step B, the SQL query expression is split into an abstract syntax tree, and the abstract syntax tree is traversed to perform security and integrity checks.

[0016] The abstract syntax tree (AST) consists of several statement nodes, each statement node contains several block nodes, and each block node contains several expression nodes. A differential privacy function is used to calculate the sensitivity of each statement node. The statement nodes are then arranged in ascending order of sensitivity. The test vector is input to the statement node with the lowest sensitivity to obtain feedback data. If the feedback data is invalid, the statement node and other statement nodes with a sensitivity greater than or equal to this node are corrected according to preset rules. If the feedback data is valid, the above process is repeated for the next statement node.

[0017] The beneficial effects of adopting the above technical solution are as follows: This invention comprehensively utilizes the natural language understanding, adaptive reasoning and data summarization capabilities of Large Language Model (LLM), and combines it with an SQL statement parsing and correction mechanism based on Abstract Syntax Tree (AST), thereby effectively improving the accuracy and efficiency of data query in power control business scenarios. Attached Figure Description

[0018] Figure 1 This is a schematic diagram of a specific embodiment of the present invention. Detailed Implementation

[0019] In the following description of the embodiments, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods are omitted so as not to obscure the description of this application with unnecessary detail.

[0020] Reference Figure 1 The intelligent power query method integrating adaptive reasoning and SQL correction provided by this invention includes the following steps:

[0021] A. Convert the natural language query requests submitted by users into SQL query expressions that conform to the power business scenario.

[0022] B. Introduce an SQL correction scheme based on abstract AST to perform structured parsing of SQL query expressions, identify logical errors in SQL syntax and semantics, and perform correction and optimization.

[0023] C. The large language model performs a structured summary of the raw data obtained from the query and provides feedback to the user in natural language.

[0024] In step A, the natural language query request is segmented to remove noise words, and then the characters are uniformly encoded (in UTF-8 format) to achieve standardization of the natural language query request.

[0025] Specifically, users input a natural language query, "Query the maximum load value of Angzhuang Station in the past week," through the web front-end of the cloud platform. The system receives this query via an API interface and performs word segmentation (segmenting the query into "query / past week / Angzhuang Station / maximum load value"). The segmented word segments are converted into one-dimensional vectors to form the original data matrix. The covariance matrix of the original data matrix is ​​calculated, and the eigenvectors of the covariance matrix are calculated. All eigenvectors are combined to form a feature matrix. The feature matrix is ​​then used to perform a convolution operation on the original data matrix to remove noise words. This invention proposes a novel noise word removal method, which differs from traditional PCA dimensionality reduction and denoising, and can reduce the information loss rate.

[0026] The standardized natural language query request is input into the Siamese neural network to generate a semantic vector of the query request. Then, the cosine similarity is calculated by comparing it with the semantic vector of the control cloud structure information stored in the system to obtain the table structure information that is closest to the query request.

[0027] The semantic similarity is calculated by taking the dot product of the query request semantic vector and the query expression vector. The query expression with the highest semantic similarity is selected for use. The BM25 algorithm is used to calculate the similarity between the structural information semantics and the query expression. The query expression with the highest semantic similarity is selected for use. The two selected query expressions are then input into the Transformer neural network to generate the SQL query expression.

[0028] This invention redesigns the feedforward neural network unit of the Transformer neural network. The Transformer neural network includes an equal number of encoders and decoders, with a one-to-one correspondence between them. Each encoder and decoder includes a feedforward neural network unit. The hidden layer of the feedforward neural network unit in the decoder is updated using a real-time training mode. While the corresponding encoder's feedforward neural network unit is performing operations, the input and output data of the encoder's feedforward neural network unit are used to train the hidden layer of the corresponding decoder's feedforward neural network unit. This training process allows the Transformer neural network to maintain high sensitivity to input data.

[0029] For example, the final SQL query expression generated by the natural language query request "Query the maximum load of Angzhuang Station in the past week" is:

[0030] ELECT MAX(MAX_LOAD) AS MAX_LOAD

[0031] FROM station_load

[0032] WHERE STATION_NAME = 'Angezhuang Station'

[0033] AND CREATE_TIME>= DATE_SUB(CURDATE(), INTERVAL 7 DAY).

[0034] In step B, the SQL query expression is decomposed and converted into an abstract syntax tree (Abstract Syntax Tree). The Abstract Syntax Tree is traversed for security and integrity checks. The Abstract Syntax Tree includes several statement nodes, each containing several block nodes, and each block node containing several expression nodes. A differential privacy function is used to calculate the sensitivity of each statement node. The statement nodes are then sorted from lowest to highest sensitivity. The test vector is input to the statement node with the lowest sensitivity to obtain feedback data. If the feedback data is invalid, this statement node and other statement nodes with a sensitivity greater than or equal to this node are corrected according to preset rules. If the feedback data is valid, the above process is repeated for the next statement node. This invention's correction of the Abstract Syntax Tree differs from the traditional method of directly traversing each node. Instead, it sorts each statement node based on its sensitivity and performs multiple rounds of correction, effectively improving the accuracy of the SQL query expression.

[0035] The SQL query expression above has been validated and corrected, resulting in:

[0036] SELECT MAX(MAX_LOAD) AS MAX_LOAD

[0037] FROM station_load

[0038] WHERE STATION_NAME = 'Angezhuang Station'

[0039] AND CREATE_TIME>= TO_DATE(TO_CHAR(SYSDATE - 7, 'YYYY-MM-DD'), 'YYYY-MM-DD').

[0040] This invention proposes a data construction method and task design specifications for power business, enhancing the ability of large language models to understand power business data. Compared with general large language models with the same number of parameters, the accuracy of the generated model after training can be improved by 20%. A syntax structure verification mechanism is introduced into SQL generation, achieving dual constraints from semantics to structure, significantly reducing the probability of model generation errors (reducing SQL syntax problems by 5%), and improving executability and stability. Based on the AST syntax mapping mechanism, multi-database adaptation is achieved, enhancing cross-system and cross-platform applicability and improving the versatility and scalability of the entire question-and-answer system. This invention reduces reliance on traditional manual SQL writing and debugging, allowing non-technical personnel to perform highly complex data acquisition and analysis operations through natural language, significantly improving the operational efficiency and data service capabilities of control operations. It also supports the construction and execution of complex SQL logic such as multi-table joins, historical trends, and anomaly detection, applicable to various power control cloud application scenarios such as equipment monitoring, load analysis, and operation and maintenance assessment. The efficient data acquisition and analysis capabilities of this invention can provide real-time and accurate data support for core business processes such as control strategy formulation, emergency response, and energy efficiency assessment, promoting the evolution of control operations from "rule-driven" to "intelligent-driven."

[0041] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0042] The present invention can implement all or part of the processes in the methods of the above embodiments, or it can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.

[0043] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of this invention is defined by the appended claims and their equivalents.

Claims

1. A power intelligent query method integrating adaptive reasoning and SQL correction, characterized in that... Includes the following steps: A. Convert the natural language query requests submitted by users into SQL query expressions that conform to the power business scenario; B. Introduce an SQL correction scheme based on abstract AST to perform structured parsing of SQL query expressions, identify logical errors in SQL syntax and semantics, and perform correction and optimization. The SQL query expression is broken down and converted into an abstract syntax tree. The abstract syntax tree is then traversed to perform security and integrity checks. The abstract syntax tree consists of several statement nodes, each statement node consists of several block nodes, and each block node consists of several expression nodes. The sensitivity of each statement node is calculated using a differential privacy function. The statement nodes are arranged in order of sensitivity from low to high. The test vector is input into the statement node with the lowest sensitivity to obtain the feedback data of the statement node. If the feedback data is invalid, the statement node and other statement nodes with a sensitivity greater than or equal to this statement node are corrected according to the preset rules. If the feedback data is valid, the above process is repeated for the next statement node to verify and correct it. C. The large language model performs a structured summary of the raw data obtained from the query and provides feedback to the user in natural language.

2. The intelligent power query method integrating adaptive reasoning and SQL correction as described in claim 1, characterized in that: In step A, the natural language query request is segmented to remove noise words, and then the characters are uniformly encoded to achieve standardization of the natural language query request.

3. The intelligent power query method integrating adaptive reasoning and SQL correction according to claim 2, characterized in that: The word segments obtained after word segmentation are converted into one-dimensional vectors to form the original data matrix. The covariance matrix of the original data matrix is ​​calculated, and the eigenvectors of the covariance matrix are calculated. All eigenvectors are then combined to form the feature matrix. The original data matrix is ​​convolved with the feature matrix to remove noisy words.

4. The intelligent power query method integrating adaptive reasoning and SQL correction according to claim 3, characterized in that: The standardized natural language query request is input into the Siamese neural network to generate the semantic vector of the query request. Then, the cosine similarity is calculated by comparing it with the semantic vector of the control cloud structure information stored in the system to obtain the table structure information that is closest to the query request. The semantic similarity is calculated by taking the dot product of the query request semantic vector and the query expression vector. The query expression with the highest semantic similarity is selected for use. The BM25 algorithm is used to calculate the similarity between the structural information semantics and the query expression. The query expression with the highest semantic similarity is selected for use. The two selected query expressions are then input into the Transformer neural network to generate the SQL query expression.

5. The power intelligent query method integrating adaptive reasoning and SQL correction according to claim 4, characterized in that: The Transformer neural network includes an equal number of encoders and decoders, with one encoder and one decoder in a one-to-one correspondence. Each encoder and decoder includes a feedforward neural network unit. The hidden layer of the feedforward neural network unit in the decoder is updated using a real-time training mode. When the feedforward neural network unit of the corresponding encoder is performing operations, the input and output data of the feedforward neural network unit of the encoder are used to train the hidden layer of the feedforward neural network unit of the corresponding decoder.

Citation Information

Patent Citations

  • Self-adaptive SQL (Structured Query Language) differential privacy noise adding method

    CN119201981A

  • Zero training method for SQL (Structured Query Language) generation based on large language model

    CN119691096A