The invention relates to the technical field of natural languages, in particular to a method and
system for improving
SQL generation accuracy of an LLM
large model based on the CoT concept. The method comprises the following steps: firstly, preprocessing
database metadata, and extracting a table structure and field information; the method comprises the steps that firstly, a complex
natural language query task is divided into a plurality of sub-problems with definite
semantics on the basis of the Chain-of-Though concept,
SQL sub-query statements capable of being independently executed are sequentially generated in a multi-pass
SQL mode, and input of each statement is based on an output result or
original data summary of the previous statement. A
verification mechanism is introduced in the
generation process, the grammar and logic validity of the SQL statement is checked, and if a grammar error or no problems of fields and table names are found, the
system automatically recognizes and prompts the error, so that the
executable performance of the SQL is guaranteed. According to the method, the accuracy and the stability of the
large model in the
relational database query task are effectively improved, the illusion phenomenon is reduced, and the practicability and the reliability of an
intelligent agent system are enhanced.