Power data enhanced analysis method based on large language model empowering Text2SQL

Through the power data augmentation analysis method based on large language models, the Text2SQL model adaptation problem in the power field is solved, efficient natural language query conversion and SQL execution are realized, and the efficiency and accuracy of power data analysis are improved.

CN118964410BActive Publication Date: 2024-12-17STATE GRID INFO TELECOM GREAT POWER SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411449483.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2024-12-17
Estimated Expiration
2044-10-17

AI Technical Summary

Technical Problem

The existing general Text2SQL model is difficult to be directly applicable to the power field, resulting in low efficiency in queries and analysis of power data, and it is difficult for users with non-technical backgrounds to extract information efficiently.

Method used

Using a power data augmentation analysis method based on a large language model, the power-related natural language text and SQL query pairs are collected and preprocessed, and the pre-trained language model is fine-tuned, combining multi-task learning and information extraction to generate a power large language model, and Through adversarial training and automatic parameter adjustment optimization model, it is finally deployed to the power system.

Benefits of technology

It realizes more efficient processing of natural language queries in the power system, converts them into SQL to execute queries, improves the efficiency and accuracy of power data analysis and processing, and enhances the generalization ability and robustness of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118964410B_ABST
    Figure CN118964410B_ABST
Patent Text Reader

Abstract

The present invention relates to a power data enhancement analysis method based on a large language model empowering Text2SQL, comprising the following steps: S1: collecting natural language texts related to power and corresponding SQL query pairs; S2: preprocessing the data collected in step S1; S3: using a pre-trained large language model, fine-tuning the model based on a training data set, combining natural language understanding and information extraction to enhance the generalization ability of the model, and obtaining a large power language model; S4: expanding the training data set and the test data set; S5: evaluating the performance of the large power language model; S6: using adversarial training to enhance the robustness of the model, and using automatic parameter adjustment technology to optimize the model parameters, to obtain an optimized large power language model; S7: packaging the optimized large power language model into a container for deployment, setting a real-time monitoring mechanism after deployment, and tracking the conversion effect of natural language queries to SQL in the power system. The present invention can more effectively process natural language queries in the power system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of large language models, and in particular to an electric power data enhancement analysis method based on a large language model-enabled Text2SQL. Background Art

[0002] In the power system, facing the massive amount of power equipment operation data, user demand questions and answers, and historical fault records, how to efficiently and accurately extract information and perform data queries is a key issue. Traditional query methods generally require users to have a certain technical background and SQL query skills, which is very difficult for users without a technical background. For this reason, Text to SQL (Text2SQL) technology came into being. By automatically converting natural language queries into structured SQL queries, users can directly obtain the required data without having to understand database management systems and query languages.

[0003] However, the data characteristics in the power sector are quite different from general data, including data format, terminology, and the professionalism of application scenarios, making it difficult for the existing general Text2SQL model to be directly applied to the power sector. Therefore, building a dedicated Text2SQL model for the power sector is crucial to improving the efficiency of power data query and analysis. Summary of the invention

[0004] In order to solve the above problems, the purpose of the present invention is to provide a power data enhancement analysis method based on a large language model empowering Text2SQL, which can more effectively process natural language queries in the power system, convert them into SQL execution queries, and provide data support for the operation and decision-making of the power system.

[0005] To achieve the above object, the present invention adopts the following technical solutions:

[0006] A power data enhancement analysis method based on a large language model empowering Text2SQL includes the following steps:

[0007] S1: Collect power-related natural language text and corresponding SQL query pairs, including power equipment operation data, user demand questions and answers, and historical fault records;

[0008] S2: preprocess the data collected in step S1 to construct training data set and test data set;

[0009] S3: Use the pre-trained large language model and fine-tune the model based on the training data set to adapt to the Text2SQL task in the power field. During the fine-tuning process, introduce multi-task learning, combine natural language understanding and information extraction to enhance the generalization ability of the model, and obtain the power large language model;

[0010] S4: Generate natural language and SQL query pairs using the power language model, and expand the training data set and test data set;

[0011] S5: Based on the expanded test data set, test the power language model, evaluate the performance of the power language model, and consider the separate evaluation of complex SQL and simple SQL to adapt to the performance in scenarios with different difficulty levels;

[0012] S6: Based on the evaluation results and the expanded training data set, adversarial training is used to enhance the robustness of the model, and the automatic parameter adjustment technology is used to optimize the model parameters to obtain the optimized power language model;

[0013] S7: Package the optimized power language model into a container for deployment, use Docker to implement model publishing and management, and set up a real-time monitoring mechanism after deployment to track the conversion effect of natural language queries to SQL in the power system.

[0014] Furthermore, preprocessing includes text preprocessing and SQL preprocessing, as follows:

[0015] Text preprocessing: Use regular expressions to match and remove HTML tags from text

[0016] ;

[0017] Among them, RegEx.sub represents the regular expression replacement operation. Matches HTML tags; Text means text; Text Clean The text with HTML tags removed;

[0018] Use regular expressions to remove all characters except letters, numbers, and spaces, and remove extra spaces;

[0019] Text Z =RegEx.sub(A,′′,Text Clean )

[0020] Among them, RegEx.sub is used to remove the special character A; Text Z is the preprocessed text;

[0021] Segment the text based on spaces and punctuation marks, and tag the segmentation results with parts of speech;

[0022] Add specialized vocabulary in the power sector to the dictionary of the part-of-speech tagging model, and use the trained named entity recognition model to identify power-related entities; then annotate the power equipment operation data, associate the data with related equipment and operation status to generate SQL query pairs, and perform annotations and verification;

[0023] SQL preprocessing: Use the SQL parser to ensure the grammatical validity of the SQL statement; obtain table structure information from the database, including table name, field name and its data type, and verify whether the table name and field name in the SQL query exist in the database table structure.

[0024] Furthermore, S3 is specifically:

[0025] Step S31: Based on the natural language query in the power field obtained in S2 and the corresponding SQL statement pair, the training data set is represented as:

[0026]

[0027] in, q i is the ith natural language query, s i is the corresponding SQL query, N is the size of the data set;

[0028] Label the technical terms in the power field, and the labeling results are expressed as:

[0029]

[0030] Among them, entity represents a proper noun in the field of electricity, and M is the number of nouns;

[0031] Step S32: Load the pre-trained large language model BERT:

[0032] ;

[0033] in, are model parameters;

[0034] Step S33: Fine-tune the pre-trained large language model, adopt the task of converting text to SQL, and construct the loss function :

[0035] ;

[0036] in, L CE represents the cross entropy loss, M(q i ) represents the SQL prediction output by the model;

[0037] Step S34: Combining natural language understanding and information extraction tasks to improve the generalization ability of the model, the total loss function L is expressed as:

[0038] ;

[0039]

[0040] ;

[0041] in, , , is the weight coefficient, is the loss of the natural language understanding task, is the loss of the information extraction task; represents the true label of the i-th sample, represents the probability distribution predicted by the model, and C is the number of categories; represents the true entity label of the i-th sample, is the entity probability predicted by the model, and E is the number of entity categories;

[0042] During the training process of step S35, the optimization algorithm Adam is used to update the model parameters until the preset requirements are met to obtain the power language model M finetuned .

[0043] Furthermore, step S4 is specifically as follows:

[0044] S41: Generate natural language and SQL query pairs based on the power language model, and build a reverse generation model to generate corresponding natural language text from the SQL query to expand the test data set, thereby obtaining a preliminary expanded test data set;

[0045] S42: using synonym replacement and word order adjustment to perform data expansion of natural language text;

[0046] S43: Use grammatical rules, power business knowledge base and logical validation to filter the generated data to ensure the correctness and rationality of SQL queries.

[0047] Furthermore, S41 is specifically:

[0048] An initial list of natural language queries is selected from an existing test dataset, represented as:

[0049] ;

[0050] in, It is Natural language queries, is the number of initial natural language queries;

[0051] Using Power Large Language Model M finetuned For each natural language query Generate the corresponding SQL query , the entire generated SQL query set is expressed as:

[0052] ;

[0053] Pair the generated SQL query set with the corresponding natural language query to form the first data set:

[0054] ;

[0055] Train a reverse generation model M using an encoder-decoder architecture reverse , which enables it to generate a natural language query q from a SQL query s:

[0056] Use the reverse generation model to generate the existing SQL query set S init Generate natural language queries:

[0057] ;

[0058] in, is the number of natural language queries generated by the reverse generation model; Represents the first Natural language queries Generated SQL query;

[0059] The generated natural language query is paired with the corresponding SQL query to form the second dataset:

[0060] ;

[0061] Combine the first data set and the second data set to obtain a preliminary expanded data set .

[0062] Furthermore, S42 is specifically:

[0063] Use the synonym dictionary to replace some words in the natural language query and generate a new query:

[0064] ;

[0065] Wherein, synonym-Replace means to replace synonyms based on a synonym dictionary; the synonym dictionary includes synonyms and related words in the field of electric power;

[0066] Generate new natural language queries by adjusting the order of sentence components:

[0067] ;

[0068] Among them, Order-Adjust is the word order adjustment function;

[0069] Pair the new queries generated by synonym replacement and word order adjustment with the corresponding SQL queries to expand the dataset:

[0070] ;

[0071] Among them, (q, s) is the original natural language query and SQL query pair; (q syn ,s) is a pair of new queries generated by synonym replacement and the corresponding SQL query; (q order ,s) is the new query generated by word order adjustment and paired with the corresponding SQL query.

[0072] Furthermore, step S5 is specifically as follows:

[0073] The indicators used to evaluate the performance of the model include accuracy, precision, recall and F1 score. According to the characteristics of SQL queries, including joins, nested subqueries and aggregate functions, they are divided into simple SQL and complex SQL. Simple SQL does not contain joins or subqueries, but only selection and projection operations; complex SQL contains joins, multi-level subqueries and aggregation operations. The above performance indicators are calculated for the split simple SQL dataset Dsimple and complex SQL dataset Dcomplex respectively.

[0074] Furthermore, based on the expanded training data set, adversarial training is used to enhance the robustness of the model. Specifically:

[0075] Initialize the model parameters and perform standard training on the expanded training dataset. Given the input embedding x and label y, the standard cross entropy loss function L total ;

[0076] Using the standard cross entropy loss function L total Update model parameters:

[0077] Calculate the adversarial perturbation δ:

[0078]

[0079] in, is the size of the disturbance; represents the gradient of the objective function L(θ,x,y) with respect to the input x;

[0080] Calculate the input perturbation based on the current model parameters:

[0081] Conduct adversarial training:

[0082] Use the perturbed input for training and update the model parameters through the loss function L(θ,x+δ,y);

[0083] ;

[0084] Where η is the learning rate, Representation parameters The gradient of

[0085] Evaluation is performed at the end of each epoch and the model performance is recorded.

[0086] Furthermore, the automatic parameter tuning technology is used to optimize the model parameters, as follows:

[0087] Define the hyperparameter space that needs to be optimized, including learning rate, batch size, and adversarial perturbation size;

[0088] ① Use the Bayesian optimization library for automatic parameter adjustment:

[0089] ② Randomly select a set of initial hyperparameters and evaluate the performance;

[0090] ③Build and update proxy models;

[0091] ④ Select the next hyperparameter combination through sampling strategy;

[0092] ⑤ Update the proxy model and iterate the above process;

[0093] ⑥Record the best performing hyperparameter combinations and use these hyperparameters for final model training.

[0094] Furthermore, step S7 is specifically as follows: first, package through Docker, encapsulate dependencies and codes into the image together; then, deploy and manage through Kubernetes, use Deployment to configure model copies, and expose services through Service; after deployment, use Prometheus and Grafana for real-time monitoring, define and collect the total number of requests, the number of successful requests, and the number of failed requests.

[0095] The present invention has the following beneficial effects:

[0096] 1. The present invention can more effectively process natural language queries in the power system, convert them into SQL execution queries, provide data support for the operation and decision-making of the power system, comprehensively improve the effect of power data analysis and processing, enable the power system to handle complex query requirements more intelligently and efficiently, and ultimately improve operation and maintenance efficiency and user satisfaction;

[0097] 2. The present invention fine-tunes the pre-trained large language model, considers the proper nouns and business logic in the power field, combines natural language understanding and information extraction, strengthens the generalization ability of the model, and combines the multi-task learning method of natural language understanding and information extraction to make the model more accurate and robust when processing power Text2SQL tasks;

[0098] 3. The present invention generates natural language text from SQL queries through a reverse generation model, expands the scale of the data set, adopts data expansion methods such as synonym replacement and word order adjustment to further enrich and diversify the data set, making the model more robust, and uses grammatical rules and power business knowledge base to filter the generated data to ensure the correctness and rationality of SQL queries and natural language texts. BRIEF DESCRIPTION OF THE DRAWINGS

[0099] Figure 1 The figure is a flow chart of the method of the present invention. DETAILED DESCRIPTION

[0100] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:

[0101] refer to Figure 1 In this embodiment, a method for enhancing power data analysis based on a large language model-enabled Text2SQL is provided, comprising the following steps:

[0102] S1: Collect power-related natural language text and corresponding SQL query pairs, including power equipment operation data, user demand questions and answers, and historical fault records;

[0103] S2: preprocess the data collected in step S1 to construct training data set and test data set;

[0104] S3: Use the pre-trained large language model and fine-tune the model based on the training data set to adapt to the Text2SQL task in the power field. During the fine-tuning process, introduce multi-task learning, combine natural language understanding and information extraction to enhance the generalization ability of the model, and obtain the power large language model;

[0105] S4: Generate natural language and SQL query pairs using the power language model, and expand the training data set and test data set;

[0106] S5: Based on the expanded test data set, test the power language model, evaluate the performance of the power language model, and consider the separate evaluation of complex SQL and simple SQL to adapt to the performance in scenarios with different difficulty levels;

[0107] S6: Based on the evaluation results and the expanded training data set, adversarial training is used to enhance the robustness of the model, and the automatic parameter adjustment technology is used to optimize the model parameters to obtain the optimized power language model;

[0108] S7: Package the optimized power language model into a container for deployment, use Docker to implement model publishing and management, and set up a real-time monitoring mechanism after deployment to track the conversion effect of natural language queries to SQL in the power system.

[0109] In this implementation, preferably, the preprocessing includes text preprocessing and SQL preprocessing, which are as follows:

[0110] Text preprocessing: Use regular expressions to match and remove HTML tags from text

[0111] ;

[0112] Among them, RegEx.sub represents the regular expression replacement operation. Matches HTML tags; Text means text; Text Clean The text with HTML tags removed;

[0113] Use regular expressions to remove all characters except letters, numbers, and spaces, and remove extra spaces;

[0114] Text Z =RegEx.sub(A,′′,Text Clean )

[0115] Among them, RegEx.sub is used to remove the special character A; Text Z is the preprocessed text;

[0116] Segment the text based on spaces and punctuation marks, and tag the segmentation results with parts of speech;

[0117] Add specialized vocabulary in the power sector to the dictionary of the part-of-speech tagging model, and use the trained named entity recognition model to identify power-related entities; then annotate the power equipment operation data, associate the data with related equipment and operation status to generate SQL query pairs, and perform annotations and verification;

[0118] SQL preprocessing: Use the SQL parser to ensure the grammatical validity of the SQL statement; obtain table structure information from the database, including table name, field name and its data type, and verify whether the table name and field name in the SQL query exist in the database table structure.

[0119] In this implementation, preferably, S3 is specifically:

[0120] Step S31: Based on the natural language query in the power field obtained in S2 and the corresponding SQL statement pair, the training data set is represented as:

[0121]

[0122] in, q i is the ith natural language query, s iis the corresponding SQL query, N is the size of the data set;

[0123] Label the technical terms in the power field, such as "transformer", "circuit breaker", etc. The labeling results are expressed as:

[0124]

[0125] Among them, entity represents a proper noun in the field of electricity, and M is the number of nouns;

[0126] Step S32: Load the pre-trained large language model BERT:

[0127] ;

[0128] in, are model parameters;

[0129] Step S33: Fine-tune the pre-trained large language model, adopt the task of converting text to SQL, and construct the loss function :

[0130] ;

[0131] in, L CE represents the cross entropy loss, M(q i ) represents the SQL prediction output by the model;

[0132] Step S34: Combining natural language understanding and information extraction tasks to improve the generalization ability of the model, the total loss function L is expressed as:

[0133] ;

[0134]

[0135] ;

[0136] in, , , is the weight coefficient, is the loss of the natural language understanding task, is the loss of the information extraction task; represents the true label of the i-th sample, represents the probability distribution predicted by the model, and C is the number of categories; represents the true entity label of the i-th sample, is the entity probability predicted by the model, and E is the number of entity categories;

[0137] During the training process of step S35, the optimization algorithm Adam is used to update the model parameters until the preset requirements are met to obtain the power language model M finetuned .

[0138] In this implementation, preferably, step S4 is specifically:

[0139] S41: Generate natural language and SQL query pairs based on the power language model, and build a reverse generation model to generate corresponding natural language text from the SQL query to expand the test data set, thereby obtaining a preliminary expanded test data set;

[0140] S42: using synonym replacement and word order adjustment to perform data expansion of natural language text;

[0141] S43: Use grammatical rules, power business knowledge base and logical validation to filter the generated data to ensure the correctness and rationality of SQL queries.

[0142] In this implementation, preferably, S41: specifically:

[0143] An initial list of natural language queries is selected from an existing test dataset, represented as:

[0144] ;

[0145] in, It is Natural language queries, is the number of initial natural language queries;

[0146] Using Power Large Language Model M finetuned For each natural language query Generate the corresponding SQL query , the entire generated SQL query set is expressed as:

[0147] ;

[0148] Pair the generated SQL query set with the corresponding natural language query to form the first data set:

[0149] ;

[0150] Train a reverse generation model M using an encoder-decoder architecture reverse , which enables it to generate a natural language query q from a SQL query s:

[0151] Use the reverse generation model to generate the existing SQL query set S init Generate natural language queries:

[0152] ;

[0153] in, is the number of natural language queries generated by the reverse generation model; Represents the first Natural language queries Generated SQL query;

[0154] The generated natural language query is paired with the corresponding SQL query to form the second dataset:

[0155] ;

[0156] Combine the first data set and the second data set to obtain a preliminary expanded data set .

[0157] Preferably, an encoder-decoder architecture, specifically, the encoder encodes the input SQL query into a hidden representation, and the decoder generates a corresponding natural language query based on the encoded representation.

[0158] The goal of the optimization model is to minimize the cross entropy loss function between the generated sequence and the target sequence. The output is generated in an autoregressive manner, that is, when the decoder generates the next word at each step, it depends on the word generated in the previous step.

[0159] In this implementation, preferably, S42 is specifically:

[0160] Use the synonym dictionary to replace some words in the natural language query and generate a new query:

[0161] ;

[0162] Wherein, synonym-Replace means to replace synonyms based on a synonym dictionary; the synonym dictionary includes synonyms and related words in the field of electric power;

[0163] Generate new natural language queries by adjusting the order of sentence components:

[0164] ;

[0165] Among them, Order-Adjust is the word order adjustment function;

[0166] Pair the new queries generated by synonym replacement and word order adjustment with the corresponding SQL queries to expand the dataset:

[0167] ;

[0168] Among them, (q, s) is the original natural language query and SQL query pair; (qsyn ,s) is a pair of new queries generated by synonym replacement and the corresponding SQL query; (q order ,s) is the new query generated by word order adjustment and paired with the corresponding SQL query.

[0169] In this implementation, preferably, step S5 is specifically as follows: the indicators used to evaluate the performance of the model include accuracy, precision, recall rate and F1 score, and according to the characteristics of SQL queries, including joins, nested subqueries and aggregate functions, they are divided into simple SQL and complex SQL, wherein simple SQL does not contain joins and subqueries, but only selection and projection operations; complex SQL contains joins, multi-level subqueries, and aggregation operations; the above performance indicators are calculated for the simple SQL data set Dsimple and the complex SQL data set Dcomplex after the splitting.

[0170] In this implementation, preferably, adversarial training is used to enhance the robustness of the model based on the expanded training data set, specifically:

[0171] Initialize the model parameters and perform standard training on the expanded training dataset. Given the input embedding x and label y, the standard cross entropy loss function L total ;

[0172] Using the standard cross entropy loss function L total Update model parameters:

[0173] Calculate the adversarial perturbation δ:

[0174]

[0175] in, is the size of the disturbance, represents the gradient of the objective function L(θ,x,y) with respect to the input x;

[0176] Calculate the input perturbation based on the current model parameters:

[0177] Conduct adversarial training:

[0178] Use the perturbed input for training and update the model parameters through the loss function L(θ,x+δ,y);

[0179] ;

[0180] Where η is the learning rate, Representation parameters The gradient of

[0181] Evaluation is performed at the end of each epoch and the model performance is recorded.

[0182] In this implementation, the automatic parameter tuning technology is used to optimize the model parameters, as follows:

[0183] Define the hyperparameter space that needs to be optimized, including learning rate, batch size, and adversarial perturbation size;

[0184] ① Use the Bayesian optimization library for automatic parameter adjustment:

[0185] ② Randomly select a set of initial hyperparameters and evaluate the performance;

[0186] ③Build and update proxy models;

[0187] ④ Select the next hyperparameter combination through sampling strategy;

[0188] ⑤ Update the proxy model and iterate the above process;

[0189] ⑥Record the best performing hyperparameter combinations and use these hyperparameters for final model training.

[0190] In this implementation, step S7 is specifically as follows: first, package through Docker to encapsulate dependencies and codes into the image; then, deploy and manage through Kubernetes, use Deployment to configure model copies, and expose services through Service; after deployment, use Prometheus and Grafana for real-time monitoring to define and collect the total number of requests, the number of successful requests, and the number of failed requests.

[0191] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0192] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1A device that provides the functions specified in a block or multiple blocks.

[0193] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0194] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0195] The above is only a preferred embodiment of the present invention, and does not limit the present invention in other forms. Any technician familiar with the profession may use the above disclosed technical content to change or modify it into an equivalent embodiment with equivalent changes. However, any simple modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the technical solution of the present invention still belongs to the protection scope of the technical solution of the present invention.

Claims

1. Power data enhancement analysis method based on large language model empowering Text2SQL, It is characterized in that The following steps are involved: S1: Collect power-related natural language text and corresponding SQL query pairs, including power equipment operation data, user demand questions and answers, and historical fault records; S2: preprocess the data collected in step S1 to construct training data set and test data set; S3: Use the pre-trained large language model and fine-tune the model based on the training data set to adapt to the Text2SQL task in the power field. During the fine-tuning process, introduce multi-task learning, combine natural language understanding and information extraction to enhance the generalization ability of the model, and obtain the power large language model; S4: Generate natural language and SQL query pairs using the power language model, and expand the training data set and test data set; S5: Based on the expanded test data set, test the power language model, evaluate the performance of the power language model, consider the separate evaluation of complex SQL and simple SQL, and adapt to the performance in scenarios with different difficulty levels; S6: Based on the evaluation results and the expanded training data set, adversarial training is used to enhance the robustness of the model, and the automatic parameter adjustment technology is used to optimize the model parameters to obtain the optimized power language model; S7: Package the optimized power language model into a container for deployment, use Docker to publish and manage the model, and set up a real-time monitoring mechanism after deployment to track the conversion effect of natural language queries to SQL in the power system; Preprocessing includes text preprocessing and SQL preprocessing, as follows: Text preprocessing: Use regular expressions to match and remove HTML tags from text Text Clean =RegEx.sub(<. >,′′,Text); Among them, RegEx.sub represents the regular expression replacement operation, <. >Matches HTML tags; Text means text; Text Clean The text with HTML tags removed; Use regular expressions to remove all characters except letters, numbers, and spaces, and remove extra spaces; Text Z =RegEx.sub(A,′′,Text Clean ) Among them, RegEx.sub is used to remove the special character A; Text Z is the preprocessed text; Segment the text based on spaces and punctuation marks, and tag the segmentation results with parts of speech; Add specialized vocabulary in the power sector to the dictionary of the part-of-speech tagging model, and use the trained named entity recognition model to identify power-related entities; then annotate the power equipment operation data, associate the data with related equipment and operation status to generate SQL query pairs, and perform annotations and verification; SQL preprocessing: Use SQL parser to ensure the syntax validity of SQL statements; obtain table structure information from the database, including table name, field name and data type, and verify whether the table name and field name in the SQL query exist in the database table structure; S3 is specifically: Step S31: Based on the natural language query in the power field obtained in S2 and the corresponding SQL statement pair, the training data set is represented as: in, q i is the ith natural language query, s i is the corresponding SQL query, N is the size of the data set; Label the technical terms in the power field, and the labeling results are expressed as: Among them, entity represents a proper noun in the field of electricity, and M is the number of nouns; Step S32: Load the pre-trained large language model BERT: ; in, are model parameters; Step S33: Fine-tune the pre-trained large language model, adopt the task of converting text to SQL, and construct the loss function : ; in, L CE represents the cross entropy loss, M(q i ) represents the SQL prediction output by the model; Step S34: Combining natural language understanding and information extraction tasks to improve the generalization ability of the model, the total loss function L is expressed as: ; ; in, , , is the weight coefficient, is the loss of the natural language understanding task, is the loss of the information extraction task; represents the true label of the i-th sample, represents the probability distribution predicted by the model, and C is the number of categories; represents the true entity label of the i-th sample, is the entity probability predicted by the model, and E is the number of entity categories; During the training process of step S35, the optimization algorithm Adam is used to update the model parameters until the preset requirements are met to obtain the power language model M finetuned ; Step S4 is specifically as follows: S41: Generate natural language and SQL query pairs based on the power language model, and build a reverse generation model to generate corresponding natural language text from the SQL query to expand the test data set, thereby obtaining a preliminary expanded test data set; S42: using synonym replacement and word order adjustment to perform data expansion of natural language text; S43: Use grammar rules, power business knowledge base and logic verification to filter the generated data to ensure the correctness and rationality of SQL queries; The S41 is specifically: An initial list of natural language queries is selected from an existing test dataset, represented as: ; in, It is Natural language queries, is the number of initial natural language queries; Using Power Large Language Model M finetuned For each natural language query Generate the corresponding SQL query , the entire generated SQL query set is expressed as: ; Pair the generated SQL query set with the corresponding natural language query to form the first data set: ; Train a reverse generation model M using an encoder-decoder architecture reverse , enabling it to generate natural language queries q from SQL queries s; Use the reverse generation model to generate the existing SQL query set S init Generate natural language queries: ; in, is the number of natural language queries generated by the reverse generation model; Represents the first Natural language queries Generated SQL query; The generated natural language query is paired with the corresponding SQL query to form the second dataset: ; Combine the first data set and the second data set to obtain a preliminary expanded data set ; S42 is specifically: Use the synonym dictionary to replace some words in the natural language query and generate a new query: ; Wherein, synonym-Replace means to replace synonyms based on a synonym dictionary; the synonym dictionary includes synonyms and related words in the field of electric power; Generate new natural language queries by adjusting the order of sentence components: ; Among them, Order-Adjust is the word order adjustment function; Pair the new queries generated by synonym replacement and word order adjustment with the corresponding SQL queries to expand the dataset: ; Among them, (q, s) is the original natural language query and SQL query pair; (q syn ,s) is a pair of new queries generated by synonym replacement and the corresponding SQL query; (q order ,s) Pair the new query generated by word order adjustment with the corresponding SQL query; Step S5 is specifically as follows: The indicators used to evaluate the performance of the model include accuracy, precision, recall and F1 score. According to the characteristics of SQL queries, including joins, nested subqueries and aggregate functions, they are divided into simple SQL and complex SQL. Simple SQL does not contain joins or subqueries, but only selection and projection operations; complex SQL contains joins, multi-level subqueries and aggregation operations. The above indicators are calculated for the simple SQL dataset Dsimple and the complex SQL dataset Dcomplex after splitting. Based on the expanded training data set, adversarial training is used to enhance the robustness of the model. Specifically: Initialize the model parameters and perform standard training on the expanded training dataset. Given the input embedding x and label y, the standard cross entropy loss function L total ; Using the standard cross entropy loss function L total Update model parameters; Calculate the adversarial perturbation δ: where ϵ is the size of the perturbation; represents the gradient of the objective function L(θ,x,y) with respect to the input x; Calculate input disturbances based on current model parameters; Conduct adversarial training: Use the perturbed input for training and update the model parameters through the loss function L(θ,x+δ,y); ; Where η is the learning rate, Representation parameters The gradient of Evaluate at the end of each epoch and record model performance; Use automatic parameter tuning technology to optimize model parameters, as follows: Define the hyperparameter space that needs to be optimized, including learning rate, batch size, and adversarial perturbation size; ① Use the Bayesian optimization library for automatic parameter adjustment; ② Randomly select a set of initial hyperparameters and evaluate the performance; ③Build and update proxy models; ④ Select the next hyperparameter combination through sampling strategy; ⑤ Update the proxy model and iterate the above process; ⑥Record the best performing hyperparameter combinations and use these hyperparameters for final model training.

2. According to claim 1, the power data enhancement analysis method based on large language model empowered Text2SQL, It is characterized in that The step S7 is specifically as follows: firstly, packaging is performed through Docker, and dependencies and codes are encapsulated into an image together; then, deployment and management are performed through Kubernetes, a Deployment is used to configure a model copy, and a service is exposed through a Service; After deployment, use Prometheus and Grafana for real-time monitoring to define and collect the total number of requests, the number of successful requests, and the number of failed requests.