Method for converting large model text into Sql based on problem preprocessing

By using a problem preprocessing workflow, the original problem is clarified and entities are extracted and classified, which solves the ambiguity problem of large models in complex query transformation, generates more accurate SQL query statements, and improves the execution effect and reliability of text to SQL conversion tasks.

CN122064706APending Publication Date: 2026-05-19BEIJING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202512007983.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-29
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

In existing technologies, the original problem is vaguely expressed and the syntax is chaotic, which makes it easy for large models to have ambiguity when matching database table information, generating incorrect SQL statements, especially with low accuracy in complex queries.

Method used

Through a problem preprocessing workflow, including problem rewriting, entity extraction and table matching, and problem classification, clear prompt words are designed, and a large model is used to decompose problems and classify query types to generate accurate SQL query statements.

Benefits of technology

It improves the structuring of problem statements, alleviates the illusion and context management challenges of large models in complex query transformations, and enhances the reasoning accuracy and generation quality of query requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122064706A_ABST
    Figure CN122064706A_ABST
Patent Text Reader

Abstract

The invention discloses a large model text-to-Sql method based on question preprocessing, and the method comprises the following steps: firstly, carrying out the clear rewriting of an original input question, and enabling the expression of the original input question to facilitate the understanding and analysis; secondly, key entity information in the rewriting problem is extracted and preliminarily matched with related database table structure information, and an entity table pair is obtained; then, calculating the semantic similarity of the entity table pair and the table structure information, and screening the closest table as a fine screening database mode in a subsequent prompt template; then, the rewriting questions are classified according to query rules, and special cue words are selected according to classification; and finally, adding the content into a reasoning prompt word, so that the large language model generates an SQL statement close to an original intention. According to the method, the problems of illusion, context management and the like of a large language model in complex query are solved, the actual intention of the problem can be better obtained compared with a previous method, and an effective solution thought is provided for a text-to-SQL task.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of computer and internet technology, and in particular to a method for converting large model text to SQL based on problem preprocessing. Background Technology

[0002] As the amount of data stored in databases continues to increase, various departments need to efficiently query and utilize this data. However, users typically need to write corresponding SQL queries before querying database content. For non-professional users, writing SQL statements requires database expertise, which presents a significant challenge. Text-to-SQL, as a natural language processing technology, effectively solves this problem by converting natural language queries into SQL queries.

[0003] In recent years, with the rapid development of large-scale language models, text-to-SQL tasks have mainly revolved around these large language models. Typically, a few prompt templates containing task descriptions, the original natural language question, and database schema information are designed to guide the model in generating SQL statements.

[0004] In the process of realizing this application, the inventors discovered that the original problem has a series of characteristics such as ambiguous expression and chaotic syntax. When matching database table information, it is easy to cause ambiguity, which often causes the large model to have illusions and map to the wrong table name or column name, thus increasing the difficulty of using the model to generate correct SQL. Summary of the Invention

[0005] This application provides a method for converting large-scale model text to SQL based on problem preprocessing. The technical solution is as follows:

[0006] In a first aspect, embodiments of this application provide a large-scale model text-to-SQL method based on problem preprocessing, the method comprising:

[0007] The design includes prompts for clarity and semantic consistency requirements in the rewritten text, inputting questions and prompt templates into a large model to obtain questions that are more suitable for subsequent entity extraction and question classification modules.

[0008] By designing prompts with entity extraction task descriptions and standardized output formats, a large model decomposes the problem based on the query keywords, outputting multiple entity information related to the problem. This entity information can encompass the entire content that the query needs to find. By modifying the prompts, the entity extraction rules can be adjusted to optimize extraction accuracy.

[0009] By employing a text embedding model, semantic similarity is calculated between the rewritten question and all table structures in the database involved in the question, obtaining multiple table structure information related to the question. Then, relevant prompts are designed, and a large-scale model is used to match each entity with its corresponding unique database table name and fields, forming entity-table pairs, which are stored as JSON files. Next, the text embedding model semantically matches the entity-table pairs with multiple table structure information related to the question, filtering out up to four table structure information most relevant to the entity-table pairs, which are then used as database structure information in the subsequent large-scale model query conversion prompt template.

[0010] Based on whether the problem involves multiple tables or complex nesting, rule prompt words are set. The problem is categorized into three types through the large model: simple single-table queries, simple multi-table queries, and queries with complex nesting. Each type of prompt word contains a task description and special notes for the specific type of query.

[0011] Input a user question, database table structure information, and category hints; output an SQL query and query results. After generating the corresponding SQL query for the question through large-scale model inference, connect to the database corresponding to the question to obtain the final query results.

[0012] This method enhances the large model's ability to understand the problem through multiple preprocessing modules such as problem clarification and rewriting, key entity extraction, and rule-based classification, thereby achieving better results in inference and SQL generation.

[0013] Secondly, embodiments of this application also provide a problem clarification rewriting module, which may include:

[0014] A large model is used to perform a preliminary analysis of the original problem, and prompts are designed to identify ambiguous expressions. The focus is on detecting common types of ambiguity, including unclear referents, elliptical structures, and obscure logical relationships.

[0015] Then, the common sense reasoning ability of the large language model is used to reasonably complete the missing or implicit semantic components, such as making the expression of the question more standardized or changing the question into a more detailed statement, without exceeding the scope of the original question's intent, that is, semantically equivalent to the original question.

[0016] Finally, while preserving the meaning of the question, the descriptive phrases in the question are aligned with possible database table names or field names. This step does not perform exact matching, but rather reduces the semantic gap in subsequent entity linking through terminology adjustment.

[0017] Thirdly, embodiments of this application also provide a problem entity extraction and table matching module, which may include:

[0018] Design task requirements prompts for entity extraction, clearly defining the range of entity types to be extracted, including but not limited to: query subject, such as table name or main query entity, attribute fields, such as "sales amount", condition constraints, join relationships, and implicit multi-table association clues.

[0019] Next, several entity extraction examples were designed and added to the prompt template of the large model to guide the model on how to extract entities, providing effective example guidance. Then, structured output and formatted prompts were designed to ensure the large model outputs the extraction results in a predefined JSON format, guaranteeing direct use by subsequent modules.

[0020] Secondly, the large model is used to decompose the problem based on the query keywords and prompt templates, and output multiple entity information related to the problem. This entity information can encompass the entire content that needs to be queried.

[0021] Next, a text embedding model is used to calculate the semantic similarity between the rewritten question and all table structures in the database involved in the question, obtaining multiple table structure information related to the question. Then, relevant prompt words are designed, and a large model is used to match each entity with the corresponding unique database table name and field, forming entity-table pairs, which are stored as JSON format files for later use.

[0022] Finally, the text embedding model is used to semantically match the entity table pairs with multiple table structure information related to the question, and at most 4 table structure information most relevant to the entity table pairs are selected. The default value is the number of tables in the entity table pairs plus 1. These are used as the database structure information in the subsequent large model query conversion prompt template.

[0023] Fourthly, embodiments of this application also provide a problem classification module, which includes:

[0024] Based on whether the problem involves multiple tables or complex nesting, rule prompts are set, with the core criteria being the number of tables involved and the complexity of the query structure.

[0025] The design defines three different types of queries: simple single-table queries involve only one data table, and the query conditions and output columns are basic operations; simple multi-table queries involve joining two or more tables, but the join relationship is clear, and the overall query structure is flat and does not contain nested queries; complex nested queries involve either single or multiple tables, as long as they contain one or more of the following structures: subqueries, correlated subqueries, multi-level aggregation, or set operations.

[0026] Next, several task examples for problem classification are designed as a reference for the subsequent large model. The prompt template is input, and the large model queries and classifies the problems into three types.

[0027] Finally, special suggestion words were designed for each category. Suggestion words for simple single-table queries focus on precise column name mapping and are relatively concise. Suggestion words for simple multi-table queries emphasize the accurate identification and construction of table join conditions, clearly defining primary and foreign key relationships, and include join relationships in the suggestion words. Suggestion words for complex nested queries are more detailed, including precautions for various types of queries, with particular emphasis on nested statements, subqueries, and join conditions.

[0028] The technical solutions provided in this application embodiment may have the following beneficial effects:

[0029] This application provides a large-scale text-to-SQL method based on question preprocessing. This approach introduces a multi-module question preprocessing process. First, the original input question is rewritten to improve semantic clarity and facilitate understanding by the large language model. Then, key entities are extracted from the rewritten question and preliminarily matched with database table structures to obtain entity table pairs. Further, semantic similarity calculations are used to filter out the table structures most relevant to the question, narrowing the information scope and enhancing content relevance. Subsequently, based on the rewritten question and the filtered table structures, the large language model classifies the query type into three categories: simple single-table queries, simple multi-table queries, and complex nested single / multi-table queries, and adapts differentiated prompt templates accordingly. Finally, the classification results and the refined table structures are combined to construct accurate prompt words, guiding the large language model to generate SQL statements that better match the user's intent. This improves the structured nature of the question expression, alleviates the illusion and context management challenges of the large language model in complex query transformation, enhances its inference accuracy and generation quality for query requirements, and thus effectively improves the execution performance and reliability of text-to-SQL conversion tasks. Attached Figure Description

[0030] Figure 1 This application provides a method for converting large model text to SQL based on problem preprocessing.

[0031] Figure 2 This is an entity extraction and table matching module provided in the embodiments of this application;

[0032] Figure 3 This application provides a method for constructing a prompt template based on problem preprocessing results. Detailed Implementation

[0033] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings. Exemplary embodiments will be described in detail here, examples of which are illustrated in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of methods consistent with some aspects of this application as detailed in the appended claims.

[0034] In the process of developing this application, the inventors discovered that related technologies primarily employ prompting methods when performing text-to-SQL tasks using large language models. Existing methods guide the model to generate SQL statements by designing a small number of prompt templates containing task descriptions, original questions, and database schema information. However, the original questions often possess characteristics such as ambiguous expression and grammatical confusion, which can easily lead to ambiguity when matching database table information. Furthermore, when the questions themselves are complex, they can often cause the large model's reasoning to produce illusions, mapping to incorrect table names or column names, resulting in low SQL generation accuracy.

[0035] In other words, the inventors of this application have discovered that by preprocessing the original problem and using modules such as problem rewriting, entity extraction and table matching, and problem classification, the performance of SQL generation has been improved, which is also a creative effort.

[0036] To address this technical problem, this application provides a large-scale model-based text-to-SQL method based on question preprocessing. The method includes: rewriting the original natural language question using a large-scale model to make its expression clearer; decomposing the question based on query keywords using the large-scale model to obtain relevant entity information; matching each entity with a unique database table name and field using a text embedding model and the large-scale model to form entity table pairs; classifying the question query into three types using the large-scale model; and converting the question into an SQL query statement using the prompt words obtained from question preprocessing, and executing the database query.

[0037] It is evident that this approach can improve the structural clarity of the problem, obtain more accurate contextual database pattern information and controllable task prompts that adapt to specific query categories, and solve problems such as illusion and context management in large models in complex query transformation tasks. This enables the model to reason and analyze more accurately and with higher quality when analyzing prompts, and to better understand the actual intent of the problem, thereby generating precise SQL query statements.

[0038] The following is a description of some terms used in the embodiments of this application.

[0039] Semantic similarity: This measure is the degree of closeness between two texts at the semantic feature level by using a similarity comparison model, and measures their similarity in expressing meaning.

[0040] Sentence Transformers: A class of Python frameworks based on the Transformer architecture, used to encode sentences or phrases into high-dimensional semantic vectors in order to efficiently calculate the semantic similarity between texts.

[0041] Database schema information: This includes keywords, table names, field names, field types, primary keys, and foreign keys related to the database schema structure.

[0042] all-MiniLM-L6-v2: An efficient deep learning text embedding model that maps sentences or paragraphs into a 384-dimensional dense vector feature space.

[0043] Large language models: Machine learning models with a large number of parameters and computational resources. These models require a lot of data and computing power during training and have millions to billions of parameters.

[0044] Hint Templates: A structured template used to systematically build, optimize, and standardize hint words to improve the output quality and consistency of the model.

[0045] Entity extraction: This requires breaking down the user's question into multiple keywords related to the database query. This process is based on a large model and requires manually setting relevant task description prompts.

[0046] Semantic filtering: It is necessary to calculate the semantic similarity between the information of the entity table and the information of the database table structure, and filter the multiple tables that are most similar. This process is based on a text embedding model.

[0047] The Big Language Model Illusion Problem: Big language models occasionally generate content that does not match user input, contradicts previously generated content, or is inconsistent with existing world knowledge.

[0048] The following is combined Figure 1 The following is a detailed description of the overall text-to-SQL method flowchart provided in the embodiments of this application.

[0049] See Figure 1 The present application provides a method for converting large model text to SQL based on problem preprocessing, which may include the following steps:

[0050] First, we introduce the problem rewriting module.

[0051] Specifically, by designing prompts, we can identify ambiguous expressions in the original natural language problem.

[0052] Vague expression refers to common types of ambiguity, including unclear referents, omitted structures, and obscure logical relationships.

[0053] Then, task description prompts were designed, and about ten examples of rewritten questions were added to the prompt template. Subsequently, the common sense reasoning ability of the large language model was used to reasonably complete the missing or implicit semantic components. For example, "the sales revenue of Department A last year" was clarified as "give the sales revenue of Department A in 2023", or "are there any employees with salaries higher than the average?" was transformed into "query employees with salaries higher than the company's average salary". This made the expression of the questions more standardized and complete, and the questions were changed into clearer and more detailed statements, but without exceeding the scope of the original question intent, that is, ensuring that the rewritten questions are semantically equivalent to the original questions.

[0054] Finally, while preserving the meaning of the question, the descriptive phrases in the question are aligned with possible database table names or field names. This step does not perform exact matching, but rather reduces the semantic gap in subsequent entity linking through terminology adjustment, providing more aligned text input for subsequent schema linking and SQL generation.

[0055] Secondly, a problem entity extraction and table matching module is proposed.

[0056] Specifically, design task requirement prompts for entity extraction, and clarify the range of entity types to be extracted, including but not limited to: query subject, such as table name or main query entity, attribute fields, such as "sales amount", condition constraints, join relationships, and implicit multi-table association clues.

[0057] Next, several entity extraction examples were designed and added to the prompt template of the large model to guide the model on how to extract entities, providing effective example guidance. Then, structured output and formatted prompts were designed to ensure the large model outputs the extraction results in a predefined JSON format, guaranteeing direct use by subsequent modules.

[0058] Secondly, the large model is used to decompose the problem based on the query keywords and prompt templates, and output multiple entity information related to the problem. This entity information can encompass the entire content that needs to be queried.

[0059] Next, the semantic similarity of the rewritten question and all table structures in the database involved in the question is calculated using the text embedding model all-MiniLM-L6-v2 to obtain multiple table structure information related to the question. Then, relevant prompt words are designed, and the large model is used to match each entity with the corresponding unique database table name and field, forming entity-table pairs, which are stored as JSON format files for later use.

[0060] Then, the entity table pairs are semantically matched with multiple table structure information related to the question using the text embedding model all-MiniLM-L6-v2. The pre-trained text embedding model all-MiniLM-L6-v2 is used to transform the entity table pair text and the database table structure text information into 384-dimensional vectors. The semantic similarity between the entity table pair text and the database information text is calculated using the cosine similarity calculation function inside the Sentence Transformers framework. The quantized value is between [-1, 1].

[0061] For example, the cosine similarity function is defined as follows:

[0062]

[0063] Where A and Bi represent the vector features of the entity table text and the database information text of different tables, respectively.

[0064] It is worth noting that during the semantic matching process, at most four table structure information that are most relevant to the entity table pair need to be selected. The default value is the number of tables in the entity table pair plus one. These will be used as the database structure information in the subsequent large model query conversion prompt template.

[0065] Then, a problem classification module is proposed.

[0066] Specifically, rule prompts are defined to determine the category of a question based on whether it involves multiple tables or complex nesting. Three different question categories are defined: simple single-table queries involve only one table, with query conditions and output columns consisting of basic operations; simple multi-table queries involve joining two or more tables, but the join relationships are clear, and the overall query structure is flat, without nested queries; complex nested queries, regardless of whether they involve single or multiple tables, contain one or more of the following structures: subqueries, correlated subqueries, multi-level aggregations, or set operations.

[0067] Subsequently, several task examples for problem classification were designed as a reference for the subsequent large-scale model. The prompt template was input, and the large-scale model queried and classified the problems into three types.

[0068] Next, we designed special suggestion words for each category. Suggestion words for simple single-table queries focus on precise column name mapping and are relatively concise. Suggestion words for simple multi-table queries emphasize the accurate identification and construction of table join conditions, clearly defining primary and foreign key relationships, and include join relationships in the suggestion words. Suggestion words for complex nested queries are more detailed, including precautions for various types of queries, with particular emphasis on nested statements, subqueries, and join conditions.

[0069] Finally, based on the prompts from the multi-question preprocessing module, the large model inference generates SQL query statements.

[0070] Specifically, the special classification prompts obtained from the problem classification module and the database table structure information obtained from the entity extraction module are combined to form a more accurate prompt template, and the rewritten and clarified questions are added to make the prompt template more accurate in identifying problems.

[0071] Furthermore, based on more precise prompts, the large model generates SQL statements that are closer to the original intent and executes more accurate query results.

[0072] The technical solutions provided in this application embodiment may have the following beneficial effects:

[0073] This application provides a large-scale text-to-SQL method based on question preprocessing. This approach introduces a multi-module question preprocessing process. First, the original input question is rewritten to improve semantic clarity and facilitate understanding by the large language model. Then, key entities are extracted from the rewritten question and preliminarily matched with database table structures to obtain entity table pairs. Further, semantic similarity calculations are used to filter out the table structures most relevant to the question, narrowing the information scope and enhancing content relevance. Subsequently, based on the rewritten question and the filtered table structures, the large language model classifies the query type into three categories: simple single-table queries, simple multi-table queries, and complex nested single / multi-table queries, and adapts differentiated prompt templates accordingly. Finally, the classification results and the refined table structures are combined to construct accurate prompt words, guiding the large language model to generate SQL statements that better match the user's intent. This improves the structured nature of the question expression, alleviates the illusion and context management challenges of the large language model in complex query transformation, enhances its inference accuracy and generation quality for query requirements, and thus effectively improves the execution performance and reliability of text-to-SQL conversion tasks.

[0074] It should be understood that although the steps have been described above, they are not necessarily to be performed in the order described above. Unless otherwise expressly stated herein, there is no strict order in which these steps are performed, and they may be performed in other orders. Any reasonable order is within the scope of protection of this application, and will not be described in detail here.

[0075] Moreover, at least some steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.

[0076] Corresponding to the above method embodiments, this application also provides an entity extraction and table matching module, see [link to module]. Figure 2 This module may include:

[0077] First, design task requirement prompts for entity extraction, and clarify the range of entity types to be extracted, including but not limited to: query subject (such as table name or main query entity), attribute fields (such as "sales amount", "date of employment", "customer name"), condition constraints (such as comparison conditions, time range, status description), join relationships (such as "customer's order", "employees under department"), implicit multi-table relationship clues, etc.

[0078] Secondly, several examples of entity extraction context were designed and added to the prompt template of the large model to guide the model on how to extract entities and provide effective examples.

[0079] Specifically, the context example may include: the rewritten question, the extracted multiple entities, all of which are in JSON format to facilitate identification and processing by subsequent modules.

[0080] Next, we designed structured output and format specification prompts to ensure that the large model outputs the extracted results in a predefined JSON format, making it easy for subsequent modules to use.

[0081] Then, the task requirement prompts, context examples, and structured output and format specifications are added to the prompt template of the large model. The large model is then used to decompose the problem and extract entities based on the query keywords and task requirements of the prompt template, and output multiple entity information related to the problem. This entity information can encompass the entire content that the problem needs to query.

[0082] Next, the semantic similarity of the rewritten question and all table structures in the database involved in the question is calculated using the text embedding model all-MiniLM-L6-v2 to obtain multiple table structure information related to the question. The specific process is as follows: The pre-trained text embedding model all-MiniLM-L6-v2 is used to convert the question text and the database table structure text information into 384-dimensional vectors. The semantic similarity between the question text and the database information text is calculated using the cosine similarity calculation function inside the Sentence Transformers framework. The quantized value is between [-1, 1].

[0083] For example, the cosine similarity function is defined as follows:

[0084]

[0085] Where A and Bi represent the vector features of the question text and the database information text of different tables, respectively.

[0086] After obtaining multiple table structure information related to the problem, relevant prompt words for matching entities and table information are designed, and multiple contextual examples are designed to guide the large model in matching entities and tables.

[0087] It is worth noting that entity-table matching requires attention to the following aspects: First, filtering should be based on the relevance of entity and table information, using keyword matching (e.g., matching the entity "sales" to the sales table, and the entity "products" to the products table) to obtain the corresponding table name and fields; second, attention should be paid to the completeness of information, and the provided table structure should include table name, field name, field data type, primary key, and foreign key, so that the large model can consider more comprehensive information during reasoning.

[0088] Then, the large model is used to match each entity with a unique database table name and field, forming entity table pairs, and storing them as JSON format files that can be used later.

[0089] Thirdly, embodiments of this application also provide a method for generating large-scale SQL models based on multi-module prompt words, see [link to relevant documentation]. Figure 3 :

[0090] This method aims to construct multi-layered prompt templates using the results from three modules: question rewriting, question entity extraction and table matching, and question classification, thereby guiding a large model to correctly parse natural language questions.

[0091] It is worth noting that the prompt template is divided into four parts: task description (that is, explaining the specific text-to-SQL task that the large model will perform), database schema information with up to four tables (this information is based on the output of entity table matching), special classification notes, and natural language questions.

[0092] Specifically, the database schema information is derived through semantic filtering of entity table pairs and database table structure information. The text embedding model all-MiniLM-L6-v2 is used to semantically match entity table pairs with multiple table structure information relevant to the question. The pre-trained text embedding model all-MiniLM-L6-v2 transforms the entity table pair text and database table structure text information into 384-dimensional vectors. The cosine similarity calculation function within the Sentence Transformers framework is used to calculate the semantic similarity value between the entity table pair text and the database information text, with the quantized value ranging from -1 to 1. Then, semantic filtering provides the most similar table information. During the semantic matching process, at most four table structure information pieces most relevant to the entity table pair are selected, with the default being the number of tables in the entity table pair plus one, as the database structure information in the subsequent large-scale model query transformation prompt template.

[0093] Finally, the prompt template is input into the large model to infer and generate SQL query results. This method rewrites the original problem through the large model, improving the structural clarity of the problem. It also utilizes task module decomposition to extract entities and classify rules in the rewritten problem, obtaining more accurate contextual database pattern information and controllable task prompt words adapted to specific query categories. This solves problems such as illusion and context management in complex query transformation tasks, enabling the large model to reason and analyze more accurately and with higher quality when analyzing the prompt template content provided by multi-module problem preprocessing. Compared to previous methods, it is better able to grasp the actual intent of the problem, thereby generating precise SQL query statements.

Claims

1. A large-scale text-to-SQL method based on problem preprocessing, characterized in that, include: The original natural language problem is rewritten using a large model, making its expression clearer; The large model decomposes the problem based on the query keywords and obtains relevant entity information. By using text embedding models and large models, each entity is matched with a unique database table name and field to form an entity table pair. The query questions are categorized into three types using a large model; Using the prompts obtained from question preprocessing, the question is converted into an SQL query statement using a large model.

2. The method according to claim 1, characterized in that, The rewriting of the original natural language problem includes: By designing prompt words that include requirements for clarity and semantic consistency in rewriting, questions and prompt templates are input into a large model to obtain questions that are more suitable for subsequent entity extraction and question classification modules.

3. The method according to claim 1, characterized in that, The process of decomposing the question based on its query keywords to obtain relevant entity information includes: By designing prompts with entity extraction task descriptions and standardized output formats, the large model decomposes the problem based on the query keywords and outputs multiple entity information related to the problem. This entity information can encompass the entire content that the problem needs to query. By modifying the prompt words, the rules for entity extraction can be adjusted, and the extraction accuracy can be optimized.

4. The method according to claim 1, characterized in that, The process of matching each entity with a corresponding unique database table name and field to form an entity table pair includes: By using a text embedding model, semantic similarity is calculated between the rewritten question and all table structures in the database involved in the question, thereby obtaining information about multiple table structures related to the question. Design relevant prompts and use a large model to match each entity with a unique database table name and field to form an entity table pair. By using a text embedding model, semantic matching of multiple table structure information related to the question is performed on the entity table pair, and up to four table structure information most relevant to the entity table pair are selected as the database structure information in the subsequent large model query transformation prompt template.

5. The method according to claim 1, characterized in that, The query categorization is divided into three types, including: Based on whether the question involves multiple tables or complex nesting, set rule prompts and categorize the questions through a large model; Each category corresponds to three different prompts, and each prompt includes a task description and special notes for the specific type of query.

6. The method according to claim 1, characterized in that, The process of converting a problem into an SQL query using a large model includes: Select the base language model and set the model generation parameters; Input a user question, along with database table structure information and a category hint template, and the large model inference will generate the corresponding SQL query for the question. Connect to the database corresponding to the problem and retrieve the final query results based on the SQL.