The application discloses a kind of method and device for
natural language conversion
SQL sentence based on
large model, the method includes: S1,
data governance is carried out to
original data table;S2, all values in
database are indexed and relevant values are selected from
database based on user question, the matching degree between user question and relevant value is calculated based on the longest common
substring matching
algorithm, and the relevant value with the highest matching degree is selected;S3,
rewriting is carried out to user question;S4, word segmentation matching is carried out to user question;S5, the seed question and answer
sentence that has been accumulated is stored in vector
database, the weight assignment is carried out to different key words in user question, user question is matched with the seed question and answer
sentence that has been accumulated, and
SQL question and answer sentence is selected;S6, Prompt sentence is constructed by optimizing DDL sentence, and
SQL sentence is generated by calling
large model.The quality of SQL sentence generated by
large model is greatly improved, and the flexibility of user query sentence and the accuracy of SQL
sentence generation are greatly improved.