The invention relates to the technical field of
natural language processing, and provides an LLM-based complex language question
SQL query generation method and
system, and the method comprises the steps: responding to a target language question request; splitting a requested target language question
sentence into one or more core clauses through a
language model LLM, converting the core clauses into semantic vectors, calculating a matching
score of each core clause and a question normal vector of each table in the schema knowledge document, performing sorting and screening according to the
score size and a
score threshold, and returning a recall result of the core clauses; combining and sorting the recall results of all the core clauses, and screening to generate a recall result of the target language question; and generating a Prompt through a Prompt script, and calling an LLM (
Language Model) to automatically generate an
SQL (Structured
Query Language)
query statement. The method does not depend on field
fine tuning, does not need to reconstruct a wide table, and effectively solves the problem that a target table is difficult to position when a large
language model processes coded value mapping, multiple tables and complex
business logic by constructing a virtual table and splitting a question
sentence into clauses containing complete
semantics and matching the clauses.