The invention relates to a dynamic adaptive Text2
SQL (Structured
Query Language) generation method and
system for the power field. The method comprises the following steps: S1, analyzing a power
database Schema and automatically generating a diversified
natural language-
SQL pair
data set; s2, performing cleaning, optimization and format
standardization on the data, and constructing a high-quality
training set and a high-quality
test set; s3, querying a prediction
database Schema based on a
natural language, and generating an
SQL statement with accurate
pattern matching; s4, a logic disassembly optimization mechanism is introduced, and it is ensured that SQL query conforms to
database rules and meets the requirements of the power industry; s5, finely adjusting the large
language model to improve the accuracy and the performability of SQL generation; s6, performing compression optimization on the trained model to improve reasoning performance, stability and query accuracy; and S7, efficiently deploying the optimized
electric power large
language model, and guaranteeing the stability, response speed and model performance of the
system through real-time monitoring. According to the method, the accuracy and applicability of converting the
natural language query into the SQL statement in the power industry can be effectively improved.