The invention discloses an ICL large
language model data query generation method and
system based on diversity
SQL enhancement, and the method comprises the steps: S1, determining a target query
database, and obtaining a
database Schema; s2, vectorizing a
database Schema, and storing the vectorized
database Schema into a database meta-information vector
library; s3, vectorizing
SQL statements in the
SQL sample set, and storing the vectorized SQL statements in an SQL
sample vector library; s4, performing clustering diversity sample recall on the information stored in the SQL
sample vector library; s5, according to the database summary and the
natural language question of the user, combining the recalled sample question and the corresponding SQL
query statement as model reference information, constructing comprehensive prompt information, and guiding the large
language model to generate SQL query conforming to
semantics and grammar; and S6, inputting the large
language model, and generating SQL statements by the large language model. According to the method, the Prompt is formed by recalling the reasonable related information, the model is guided to correctly generate the SQL, and the accuracy of the SQL statement generated by the large language model can be effectively improved.