Intelligent number asking method and system based on large model

By utilizing metadata for entity mapping and semantic rewriting in the data query system, and combining it with the simulated execution and automatic correction of the generative model, the problems of field reference errors and semantic deviations in the conversion of natural language into structured query statements are solved, achieving efficient and high-precision data querying.

CN122045346APending Publication Date: 2026-05-15SHANGHAI TOBACCO GROUP CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANGHAI TOBACCO GROUP CO LTD
Filing Date
2025-12-26
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing technologies suffer from field referencing errors and semantic biases when converting natural language into structured query statements, and lack pre-validation mechanisms, resulting in low data query efficiency and accuracy.

Method used

By utilizing the target database's metadata for entity mapping and semantic rewriting, and combining this with a generative model to simulate and automatically correct the initial query statement, a closed-loop verification mechanism is established to ensure the syntactic and logical correctness of the query statement.

Benefits of technology

It significantly improves the accuracy and robustness of generated SQL statements, reduces the difficulty of model understanding, avoids risks in the production environment, and enables efficient and high-precision data querying.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122045346A_ABST
    Figure CN122045346A_ABST
Patent Text Reader

Abstract

The invention provides an intelligent number asking method and system based on a large model, and belongs to the field of data processing.The method comprises the steps that mapping matching is conducted on entities in an original query request through field information in metadata of a target database, semantic rewriting is conducted on the original query request based on a matching result, and an optimized query request is obtained; inputting the optimized query request and the metadata into a generative model to obtain an initial query statement; in a virtual execution environment constructed by utilizing the metadata, performing simulation execution on the initial query statement to obtain a simulation feedback result; if the simulation feedback result indicates that execution is abnormal, the initial query statement is corrected based on the simulation feedback result and metadata, a target query statement is obtained and sent to a target database to be executed, and a data query result is obtained. According to the method, semantic rewriting based on entity mapping is carried out on the query request, and simulation correction based on the virtual execution environment is introduced, so that efficient and high-precision intelligent data query is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to an intelligent data query method and system based on a large model. Background Technology

[0002] With the explosive growth of enterprise data, how to use large language models to automatically convert natural language into structured query statements (NL2SQL) to assist non-technical personnel in performing efficient data queries has become a research hotspot in the field of data intelligence.

[0003] In existing technologies, general-purpose pre-trained large language models are typically used to convert natural language into SQL statements. However, these approaches have significant limitations in practical applications. On the one hand, when processing queries in specific vertical domains, general-purpose models struggle to accurately establish the semantic correspondence between business terms in natural language and physical fields in the database, leading to frequent field referencing errors or semantic deviations in the generated queries. On the other hand, existing technologies often lack pre-validation mechanisms for the generated statements, resulting in SQL statements frequently containing syntax errors or logical fallacies. These errors are only exposed when executed directly in the production database, leading to low efficiency and accuracy in data querying. Summary of the Invention

[0004] This invention provides an intelligent data query method and system based on a large model to overcome the shortcomings of existing technologies and achieve efficient and high-precision intelligent data query.

[0005] This invention provides an intelligent question-answering method based on a large model, comprising the following steps: By utilizing the field information in the metadata of the target database, the entities in the original query request targeting the target database are mapped and matched, and the original query request is semantically rewritten based on the matching results to obtain an optimized query request. The optimized query request and the metadata are input into the generative model to obtain the initial query statement output by the generative model; wherein, the generative model is obtained by fine-tuning the parameters of the large language model; In a virtual execution environment constructed using the aforementioned metadata, the initial query statement is simulated and executed to obtain simulated feedback results; the virtual execution environment is a simulation runtime environment independent of the target database. If the simulation feedback result indicates an execution error, the initial query statement is corrected based on the simulation feedback result and the metadata to obtain a verified target query statement; The target query statement is sent to the target database for execution, and the data query results are obtained.

[0006] According to the intelligent query method based on a large model provided by the present invention, before mapping and matching entities in the original query request for the target database using field information in the metadata of the target database, the method further includes: The original data tables in the target database are subjected to multi-level filtering to generate filtered data tables; the multi-level filtering includes table-level filtering to remove empty tables and log tables, and field-level filtering to remove fields with high repetition rates. In the filtered data table, primary key fields and candidate key fields are selected, and Bloom filters are created for each. The Bloom filter is used to perform existence checks on field values ​​between different tables and to calculate the field matching rate; When the field matching rate exceeds a preset threshold, it is determined that there is a relationship between the tables, and the metadata is generated based on the relationship and the table structure.

[0007] According to the intelligent query method based on a large model provided by the present invention, the step of mapping and matching entities in the original query request for the target database using field information in the metadata of the target database includes: The entity to be matched is extracted from the original query request using a large language model; Calculate the character edit distance between the entity to be matched and the field name in the metadata; If the character edit distance meets the first preset condition, then the entity to be matched is directly mapped to the corresponding field name; If the character edit distance does not meet the first preset condition, then calculate the semantic vector cosine similarity between the entity to be matched and the field name in the metadata; If the semantic vector cosine similarity satisfies the second preset condition, then the entity to be matched is mapped to the corresponding field name.

[0008] According to the intelligent question-answering method based on a large model provided by the present invention, the generative model is trained through the following steps: Obtain a training sample set; the training sample set includes natural language questions and standard structured query statements corresponding to the natural language questions; The training sample set is input into the large language model to obtain the predicted query statement; The reward score of the predicted query statement is calculated from the format reward dimension, complexity reward dimension and execution correctness reward dimension respectively, and the total reward value of the predicted query statement is calculated based on each reward score; The network parameters of the large language model are updated based on the total reward value until the large language model converges, thus obtaining the generative model.

[0009] According to the intelligent query counting method based on a large model provided by the present invention, the step of calculating the reward score of the predicted query statement from the dimensions of format reward, complexity reward, and execution correctness reward, and calculating the total reward value of the predicted query statement based on each of the reward scores, includes: Based on the markup language structure of the predicted query statement, a first reward score for the format reward dimension is determined; wherein, when the markup language structure conforms to a preset structure, the first reward score is set to a first preset score; when the markup language structure does not conform to the preset structure, the first reward score is set to a second preset score. The second reward score of the complexity reward dimension is obtained by weighting and summing the frequency of each operator in the predicted query statement with the preset weight corresponding to each operator. Based on the simulated execution results of the predicted query statement, a third reward score for the execution correctness reward dimension is determined; wherein, when the simulated execution result is consistent with the standard result in the training sample set, the third reward score is set as a third preset score; when the simulated execution result is inconsistent with the standard result in the training sample set, the third reward score is set as a fourth preset score. The first reward score, the second reward score, and the third reward score are weighted and summed according to the preset dimension weights to obtain the total reward value.

[0010] According to the intelligent query method based on a large model provided by the present invention, the step of correcting the initial query statement to obtain a verified target query statement includes: Obtain the error type code contained in the simulated feedback result; Extract the table structure definitions of the data tables involved in the initial query statement; The error type code, the table structure definition, and the initial query statement are combined into a prompt word template; The prompt word template is input into the generation model to obtain the query statement regenerated by the generation model until the simulation execution is error-free or the preset correction number threshold is reached, and the target query statement is obtained.

[0011] According to the intelligent query method based on a large model provided by the present invention, the step of simulating the execution of the initial query statement in a virtual execution environment constructed using the metadata to obtain simulated feedback results includes: Create a lightweight database image in memory that has the same metadata structure as the target database; The initial query statement is executed in the lightweight database image, and the syntax state and logical reference state during the execution process are monitored to generate the simulated feedback result.

[0012] This invention also provides an intelligent data retrieval system based on a large model, comprising the following modules: The first processing module is used to use field information in the metadata of the target database to map and match entities in the original query request for the target database, and to semantically rewrite the original query request based on the matching results to obtain an optimized query request. The second processing module is used to input the optimized query request and the metadata into the generation model to obtain the initial query statement output by the generation model; wherein, the generation model is obtained by fine-tuning the parameters of the large language model; The third processing module is used to simulate the execution of the initial query statement in a virtual execution environment constructed using the metadata, and obtain simulated feedback results; the virtual execution environment is a simulation running environment independent of the target database; The fourth processing module is used to modify the initial query statement based on the simulation feedback result and the metadata if the simulation feedback result indicates an execution error, so as to obtain a verified target query statement. The fifth processing module is used to send the target query statement to the target database for execution to obtain the data query results.

[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the intelligent query method based on a large model as described above.

[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the intelligent query method based on a large model as described above.

[0015] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the intelligent query method based on a large model as described above.

[0016] In summary, one or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages: This invention effectively eliminates the semantic differences between natural language spoken expressions and database professional field definitions by using metadata to accurately map and match entities in the original query request, reducing the difficulty of model understanding. Combined with a parameter-tuned generation model, it significantly improves the business fit and accuracy of the initial query statement generation. Furthermore, by constructing a virtual execution environment independent of the target database to simulate and test the generated statements, and establishing an automatic correction closed-loop mechanism based on the simulation feedback results, it can detect and fix syntax errors or logical reference defects in SQL statements in advance while completely isolating the risks of the production environment. This significantly enhances the robustness of the generated SQL statements and the success rate of final execution, achieving efficient and high-precision intelligent data querying. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0018] Figure 1 This is one of the flowcharts of the intelligent question-answering method based on a large model provided by the present invention.

[0019] Figure 2 This is the second flowchart of the intelligent question-answering method based on a large model provided by the present invention.

[0020] Figure 3 This is the third flowchart of the intelligent question-answering method based on a large model provided by the present invention.

[0021] Figure 4 This is the fourth flowchart of the intelligent question-answering method based on a large model provided by the present invention.

[0022] Figure 5 This is the fifth flowchart of the intelligent question-answering method based on a large model provided by the present invention.

[0023] Figure 6 This is the sixth flowchart of the intelligent question-answering method based on a large model provided by this invention.

[0024] Figure 7 This is the seventh flowchart of the intelligent question-answering method based on a large model provided by this invention.

[0025] Figure 8 This is a schematic diagram of the structure of the intelligent question-and-answer system based on a large model provided by the present invention.

[0026] Figure 9This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0027] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0028] It should be noted that in the description of this invention, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. The terms "upper," "lower," etc., indicating orientation or positional relationships according to the accompanying drawings, are only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the system or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0029] The terms "first," "second," etc., used in this invention are used to distinguish similar objects, not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class, without limiting the number of objects; for example, a first object can be one or more. Furthermore, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0030] The following is combined Figures 1 to 9 This invention describes the intelligent questioning method, system, electronic device, storage medium, and computer program product based on a large model provided by the present invention.

[0031] This invention provides an intelligent data query method based on a large model. This method can be applied to servers, cloud computing platforms, or electronic devices with high-performance computing capabilities. In practical applications, this method is typically integrated into enterprise-level (e.g., cigarette factories) data query systems to assist non-technical personnel in efficiently querying complex business data using natural language.

[0032] Figure 1 This is one of the flowcharts illustrating the intelligent question-answering method based on a large model provided in this embodiment of the invention. For example... Figure 1 As shown, the method includes the following steps: Step 101: Utilize the field information in the metadata of the target database to map and match the entities in the original query request for the target database, and semantically rewrite the original query request based on the matching results to obtain an optimized query request.

[0033] In this embodiment, the target database refers to the production environment database that actually stores business data, such as the production and operation management database of a cigarette factory, which contains multi-dimensional business data tables including production, sales, and inventory. Metadata refers to data that describes the data, specifically including structured information such as table names, field names (column names), field types, field comments, and relationships between tables in the target database. The original query request refers to a natural language question entered by the user, such as "Please query what the cigarette production volume was in June 2025?".

[0034] In practice, the system first receives the original query request input by the user. Then, the system parses the original query request and identifies the key entities within it. Here, "entity" refers to terms in the request that involve specific business objects, including but not limited to time descriptions (such as "June 2025"), business indicator names (such as "cigarette production" and "sales volume"), and product attributes (such as "Brand A").

[0035] Subsequently, the system uses field information from the target database's metadata to perform mapping and matching with the identified entities. This mapping and matching aims to establish a correspondence between natural language words and physical fields in the database. For example, the entity "June 2025" in the original query request is mapped to the corresponding field name "Production Date" (or a similar time field) in the metadata, and the entity "Cigarette Production" is mapped to the corresponding field name "Production" in the metadata.

[0036] After completing entity mapping, to reduce the difficulty of subsequent model understanding, the system semantically rewrites the original query request based on the matching results. Semantic rewriting refers to replacing colloquial expressions or vague entities in the original query request with standard field names or values ​​from the database, thereby generating an optimized query request that is more standardized and less ambiguous. For example, after rewriting, the original query request is transformed into a more semantically explicit form, such as "What is the 'production' of 'production date' '2025-06'?", thus making the question more consistent with the database schema.

[0037] Step 102: Input the optimized query request and metadata into the generative model to obtain the initial query statement output by the generative model.

[0038] In this embodiment, the generative model is a specially trained deep learning model, whose core architecture is typically based on large language models such as Transformer. This generative model has the ability to understand natural language instructions and convert them into structured query language (SQL).

[0039] Specifically, the generative model is obtained by fine-tuning the parameters of a large language model. This fine-tuning process utilizes sample data from a specific domain (such as the cigarette manufacturing industry), enabling the model to understand the domain's specific terminology and complex table structure logic, thus achieving higher Text-to-SQL conversion accuracy than a general large model.

[0040] Specifically, the system combines the optimized query request obtained in step 101 with the metadata of the target database (such as the relevant table structure definitions and Create Table statements) into a prompt word, which is then input into the generative model. The generative model performs reasoning based on the input context information to generate a corresponding initial query statement (i.e., a preliminary generated SQL statement).

[0041] Step 103: In the virtual execution environment built using metadata, the initial query statement is simulated and executed to obtain the simulation feedback result; the virtual execution environment is a simulation running environment independent of the target database.

[0042] To prevent syntax errors or performance issues that might result from executing the generated SQL statements directly on the production database, this step introduces a virtual execution environment. This virtual execution environment is a simulated runtime environment built in memory, independent of the target database (production database). It has the same metadata structure as the target database (i.e., the same table structure and relationships), but does not contain all the business data, or only a small amount of sample data.

[0043] The system places the initial query statement generated from the model into this virtual execution environment for trial execution. The execution result is the simulation feedback result. This simulation feedback result is used to indicate whether the initial query statement is syntactically correct, logically refers to whether tables or fields exist, etc.

[0044] Step 104: If the simulation feedback indicates an execution error, the initial query statement is corrected based on the simulation feedback and metadata to obtain the verified target query statement.

[0045] When the simulation feedback shows that the execution failed (e.g., an error message such as "column name does not exist," "syntax error," or "inappropriate function usage"), it is determined to be an execution exception. In this case, the system will not directly discard the statement, but will activate the automatic correction mechanism.

[0046] The system combines the error information (such as error codes and descriptions) from the simulation feedback results with metadata and the original initial query statement, and then feeds it back to the generation model or a dedicated correction module. Based on the specific error messages, the model analyzes the causes and regenerates the corrected query statement. This correction process can be iterative until the generated query statement can be successfully executed in the virtual execution environment, or until a preset number of attempts is reached. The final, verified query statement is the target query statement.

[0047] Of course, if the simulation feedback result in step 103 directly indicates successful execution, then the initial query statement is directly determined as the target query statement.

[0048] Step 105: Send the target query statement to the target database for execution and obtain the data query results.

[0049] After ensuring the query statement is syntactically and logically correct, the system sends the final target query statement to the actual target database (i.e., the production database) for execution via the database connection interface. The target database retrieves and calculates data based on the statement and returns the final data query results.

[0050] Furthermore, the system can also use large models to intelligently summarize and analyze the returned data query results. For example, it can present the data to users in the form of charts (such as bar charts showing sales volume in different months) or generate a text interpretation, thereby completing the closed loop from "natural language questioning" to "visualized data answering".

[0051] In summary, by utilizing metadata to perform entity mapping and semantic rewriting of the original query request, the ambiguity of natural language is effectively reduced, making the questions input to the generative model clearer and more explicit, thereby improving the accuracy of SQL generation. By introducing a virtual execution environment independent of the target database for simulated execution, not only can syntax or logical errors generated by the generative model be automatically corrected, but the performance risks and security vulnerabilities caused by directly executing erroneous SQL in the production database are also avoided. This significantly improves the robustness and security of the intelligent query system, making it suitable for data query scenarios in vertical fields (such as cigarette factories) with complex table structures and sensitive data.

[0052] Before executing step 101 in the above embodiment, the system first needs to extract and construct high-quality metadata from the complex underlying database. Considering that in a real business environment (such as a cigarette manufacturing enterprise), the database may contain a large number of non-business tables and lack explicit foreign key constraints, this embodiment introduces an automated metadata discovery mechanism.

[0053] Reference Figure 2 , Figure 2 This is the second flowchart illustrating the intelligent question-answering method based on a large model provided in this embodiment of the invention. For example... Figure 2 As shown, the metadata construction process specifically includes the following steps: Step 201: Perform multi-level filtering on the original data tables in the target database to generate filtered data tables.

[0054] First, the system retrieves table information from the target database. To ensure the accuracy and efficiency of the analysis, the system performs multi-level filtering.

[0055] The first level is table-level filtering. The system evaluates whether the tables contain valid business data and filters out tables that do not meet the criteria, specifically including empty tables (without data records) and excessively long tables (such as extremely large tables with more than 100 million rows, usually system logs or transaction records). At the same time, the system will also remove system tables and log tables.

[0056] The second level is field-level filtering. When processing table fields, in order to intelligently filter out fields suitable for relationship discovery, the system will filter out fields that are clearly unsuitable as primary keys or foreign keys. Specifically, the system can calculate analytical indicators such as the average string length of field values ​​and the deduplication rate to eliminate fields that are too simple or have an excessively high repetition rate. For example, a field that only contains the two values ​​"yes" and "no" has an extremely high repetition rate and has no association value, so it will be eliminated.

[0057] Step 202: Select the primary key field and candidate key field from the filtered data table, and create Bloom filters for each.

[0058] Next, the system identifies the primary key and candidate keys. The identification criteria can be: the primary key identification criterion is 100% not null and unique; the candidate key identification criterion is 100% not null.

[0059] To optimize query efficiency, the system creates a Bloom filter for each identified primary key field and candidate key field. Bloom filters are used to quickly determine whether a value exists in a set.

[0060] Step 203: Use a Bloom filter to perform existence checks on field values ​​between different tables and calculate the field match rate.

[0061] In the relationship discovery phase, the system calculates the matching of column names between pairs of tables. Specifically, it samples a certain number of data from one table (e.g., 10,000 rows) and uses the Bloom filter created above to check if these sampled data exist in the primary key / candidate key of another table.

[0062] Based on the detection results, the system calculates the field matching rate. The formula for calculating the matching rate is: Matching rate = Number of matching values ​​ / Number of samples.

[0063] Step 204: When the field matching rate exceeds the preset threshold, determine that there is a relationship between the tables, and generate metadata based on the relationship and table structure.

[0064] If the calculated matching rate exceeds the preset threshold, the system assumes that the two tables are related in the corresponding fields and records the relationship between the fields.

[0065] Taking data from a cigarette factory as an example, the metadata containing table relationship information generated by the system through the above process is shown in Table 1 below: Table 1. Example of table relationship information Serial Number Database Name 1 Table 1 Name Table 1 Notes Table 1 Column Names Table 1 Column Name Notes Database Name 2 Table 2 Name Table 2 Notes Table 2 Column Names Table 2 Column Name Notes Relationship description 1 public monthly_generation_report Monthly Production Status Table nf years publc fulldomain_kpi Global Indicator Table year Statistical Year The year in the monthly production report is related to the statistical year in the overall indicators report. 2 ... ... ... ... ... ... ... ... ... ... As shown in Table 1, the system successfully identified a relationship between the "nf (year)" field in the "Monthly Production Status Table" and the "year (statistical year)" field in the "Global Indicator Table".

[0066] Ultimately, based on these identified relationships and table structures (including column information and comments), the system constructs structured metadata. For example, a portion of the metadata structure obtained by the system is shown below: (1) Industrial Distribution Information Table: Includes fields rq(date, comment: none, business primary key: no) and fl(varchar, comment: domestic and foreign tobacco classification, business primary key: no).

[0067] (2) Production and operation metadata: including fields zbmc(varchar, note: indicator name of total industrial output value and industrial added value, business primary key: no) and bysj(decimal, note: actual data for each month, business primary key: no).

[0068] (3) Monthly production status table: includes fields jymc(varchar, comment: cigarette name, business primary key: no) and sjsl(double, comment: actual production quantity, business primary key: no).

[0069] (4) Global indicator table: includes fields such as indicator_name(varchar, comment: indicator name, business primary key: no) and indicator_value(varchar, comment: indicator value, business primary key: no).

[0070] This cleaned and supplemented metadata, with added relational information, will provide a solid foundation for subsequent large-scale models to accurately understand complex queries such as "2025 cigarette production".

[0071] Upon receiving the user's original query request, in order for the computer to understand the specific business meaning involved in the request, the system executes the entity mapping operation in step 101. (Refer to...) Figure 3 , Figure 3 This is the third flowchart illustrating the intelligent question-answering method based on a large model provided in this embodiment of the invention. For example... Figure 3 As shown, the process specifically includes the following steps: Step 301: Use a large language model to extract the entities to be matched from the original query request.

[0072] The system first combines metadata and pre-built data dictionary samples (such as non-floating-point unique values ​​extracted from the database) to form prompt words, which are then input into the large language model along with the user's original query request. Based on the extraction rules in the prompt words, the large model identifies and extracts key entities to be matched from the natural language problem.

[0073] For example, for a common query from cigarette factories: "What was the cigarette production in June 2025?", the large model extracts the following entity results for matching: Entity 1: "June 2025"; Entity 2: "Cigarette production".

[0074] Step 302: Calculate the character edit distance between the entity to be matched and the field name in the metadata; if the character edit distance meets the first preset condition, then directly map the entity to be matched to the corresponding field name.

[0075] The system sequentially traverses each table column name (field name) in the metadata and calculates the character edit distance between the entity to be matched and the field name. In this embodiment, the Levenshtein distance algorithm is used to measure the degree of difference between the two strings.

[0076] The system sets a first preset condition, such as a Levenshtein similarity score greater than 0.8. If the calculated score meets this condition, it means that the entity and the field name are highly consistent in wording, and the system performs an exact match directly.

[0077] For example, if the metadata contains a field named "cigarette production", and the extracted entity is also "cigarette production", and the Levenshtein similarity between the two is extremely high (close to 1.0), then the entity "cigarette production" will be directly mapped to the field name "cigarette production".

[0078] Step 303: If the character edit distance does not meet the first preset condition, calculate the semantic vector cosine similarity between the entity to be matched and the field name in the metadata; if the semantic vector cosine similarity meets the second preset condition, map the entity to be matched to the corresponding field name.

[0079] If literal matching fails (i.e., the first preset condition is not met), the system enters the semantic fuzzy matching stage. The system uses a pre-trained model (such as the Transformer model) to convert the entity to be matched and the field names in the metadata into high-dimensional vector representations, and calculates the semantic vector cosine similarity between them.

[0080] The system sets a second preset condition, such as a cosine similarity greater than 0.75. If this condition is met, it means that although the two words are different literally, they are highly related semantically, and the system maps them together.

[0081] For example, regarding the entities "June 2025" and "cigarette production" in the above question, assume that the corresponding fields in the metadata are actually "production date" and "production volume".

[0082] For the entity "cigarette production" and the field "production": although there are literal differences, the semantic similarity calculated by the Transformer model is very high, so the mapping is successful.

[0083] For the entity "June 2025" and the field "Production Date": semantic analysis is used to identify that it is a time description and map it to the corresponding date type field "Production Date".

[0084] Ultimately, the system outputs the following entity mapping results: the entity "June 2025" is mapped to the field "Production Date"; the entity "Cigarette Production" is mapped to the field "Production".

[0085] To give another more complex example, a user queries: "Please query the monthly transportation volume data from 2020 to 2024, including year, brand, domestic and foreign sales tobacco classification, price category, and whether it is brand A."

[0086] After the system extracts the entities, it obtains the following mapping results (displayed in dictionary form) through the above dual matching strategy: [{'2020':'year'},{'2024':'year'},{'monthly transport quantity':'indicator_name'},{'indicator value':'indicator_value'},{'year':'year'},{'unit of measurement':'measuring_unit'}].

[0087] In this example, "monthly transportation volume" was semantically matched and mapped to the "indicator_name" field in the metadata table (such as the global indicator table), demonstrating the system's ability to understand complex business terms.

[0088] This embodiment employs a dual strategy that integrates precise character matching (Levenshtein distance) and semantic fuzzy matching (Transformer cosine similarity) to achieve high accuracy and generalization in entity mapping. By prioritizing character matching, accurate identification of proper nouns is ensured; while in cases of literal mismatch, semantic vector analysis accurately understands the abstract logic such as "monthly transportation quantity" corresponding to "indicator_name," effectively solving the problem of inconsistencies between colloquial questions from non-technical personnel and professional database field definitions, laying a crucial foundation for generating accurate SQL statements subsequently.

[0089] The generative model used in step 102 above is not a general pre-trained model, but a specialized model deeply optimized for the specific business scenario of a cigarette factory. This generative model is obtained by fine-tuning the parameters of a basic large language model using reinforcement learning methods. (Refer to...) Figure 4 , Figure 4 This is the fourth flowchart illustrating the intelligent question-answering method based on a large model provided in this embodiment of the invention. Figure 4 As shown, the generative model training process specifically includes the following steps: Step 401: Obtain the training sample set; the training sample set includes natural language questions and standard structured query statements corresponding to the natural language questions.

[0090] First, the system needs to construct a high-quality training sample set. These samples not only come from general Text-to-SQL datasets, but more importantly, they include a large number of real-world cases built on the business database of cigarette factories.

[0091] A typical training sample consists of the following three main parts: 1. Natural Language Prompt (sql_promp): Describes the user's query intent. For example: "Please query the monthly transportation volume data from 2020 to 2024, including indicator name, indicator value, year and unit of measurement."

[0092] 2. Standard structured query statement (SQL): This refers to a manually written or verified correct answer. For example: "SELECT indicator_name, indicator_value, year, measuring_unit". FROM public.globalmetricsdatabase WHERE indicator_name = 'Monthly shipment volume' AND year BETWEEN 2020 AND 2024;

[0093] 3. Database context information (sql_context): contains the structure definition of the related tables (CREATE TABLE statement). For example: "CREATE TABLE public.globalmetricsdatabase(id INT PRIMARY KEY,indicator_name VARCHAR(255), indicator_value FLOAT, year INT, measuring_unitVARCHAR(50));".

[0094] Step 402: Input the training sample set into the large language model to obtain the predicted query statement.

[0095] The system loads a pre-trained large language model (e.g., a Transformer-based model) and performs LoRA (Low-Rank Adaptation) adaptation to efficiently fine-tune its parameters. In each training epoch, the system combines the natural language question (sql_prompt) and contextual information (sql_context) from the training sample set as input to the large language model. The model then generates a predicted query statement (GeneratedSQL) based on the current policy network parameters.

[0096] Step 403: Calculate the reward score for the predicted query statement from the format reward dimension, complexity reward dimension, and execution correctness reward dimension respectively, and calculate the total reward value of the predicted query statement based on each reward score.

[0097] To guide the model in generating higher-quality SQL, this embodiment abandons the traditional loss function based solely on text similarity and instead employs a multi-dimensional reward mechanism based on reinforcement learning. The system calculates reward scores in three dimensions based on the generated predicted query statement: Format Reward: Checks whether the model output conforms to the expected XML tag format, ensuring that the output results can be automatically parsed by the program.

[0098] Complexity Reward: Encourages the model to generate statements containing complex logic (such as JOIN, GROUP BY, etc.) to prevent the model from collapsing to generate only simple queries.

[0099] Execution Accuracy Reward: The generated SQL is actually run in the in-memory database to verify whether the result is correct.

[0100] The system performs a weighted sum of the scores from these three dimensions to obtain the total reward signal for the predicted query. Specific calculation details will be elaborated in subsequent embodiments.

[0101] Step 404: Update the network parameters of the large language model according to the total reward value until the large language model converges, thus obtaining the generative model.

[0102] The system uses the calculated total reward value as a feedback signal and employs the Generalized Reinforcement Learning with Policy Optimization (GRPO) algorithm to update the network parameters of the large language model (specifically, updating the weights of the LoRA layer). Through continuous iterative training (e.g., setting a maximum number of training steps and gradient accumulation steps), the system maximizes the total reward value obtained by the SQL statements generated by the model. When the model's loss value tends to stabilize or reaches the preset convergence condition, training stops, and the final generative model is obtained.

[0103] After training, the generative model was tested using validation data to evaluate the accuracy and efficiency of the generated SQL queries. The performance of the optimized SQL generation model was evaluated on the validation set to ensure that the generated SQL statements met requirements in terms of syntax, logic, and execution results. For user natural language questions in the test set, the optimized SQL generation model was used to generate SQL statements, which were then executed in a real database to verify their accuracy and robustness. Performance comparisons before and after GRPO fine-tuning are shown in Table 2. Table 2. Performance Comparison Table: index Baseline model After GRPO fine-tuning Simple query accuracy 82.3% 89.7% Accuracy of complex queries 61.5% 78.2% Average reward value 1.24 2.57 As shown in Table 2, after fine-tuning GRPO, the model's accuracy improved from 82.3% to 89.7% for simple queries; for complex queries, the model's accuracy improved from 61.5% to 78.2%; and the average reward value improved from 1.24 to 2.57.

[0104] This embodiment significantly enhances the performance of the generative model in specific vertical domains (such as cigarette production) by introducing a reinforcement learning fine-tuning mechanism, particularly by combining a multi-dimensional reward function that considers format, complexity, and execution correctness. Compared to traditional supervised learning, this method substantially improves the model's accuracy and robustness when facing complex business queries.

[0105] To enable large models to accurately perceive the quality of generated results during reinforcement learning training, this embodiment designs a three-dimensional reward function. (Refer to...) Figure 5 , Figure 5 This is the fifth flowchart illustrating the intelligent question-answering method based on a large model provided in this embodiment of the invention. Figure 5 As shown, step 403 above specifically includes the following steps: Step 501: Determine the first reward score for the format reward dimension based on the markup language structure of the predicted query statement.

[0106] First, the system evaluates the standardization of the generated content. Large models sometimes output redundant explanatory text, which can interfere with subsequent program extraction. Therefore, this embodiment sets strict formatting rewards. The system checks whether the predicted query statement is strictly wrapped in a preset markup language structure (such as XML tags), for example, checking whether the output conforms to... <reasoning> ...< / reasoning> <sql> ...< / sql> Format.

[0107] When the generated structure perfectly matches the preset structure, the system will award the first bonus score (i.e., the format bonus). Rf The first bonus score is set to the first preset score (e.g., 1.0). When the structure does not meet the requirements (e.g., incorrect label closure or missing labels), the first bonus score is set to the second preset score (e.g., 0.0).

[0108] This mechanism will serve as a hard constraint, forcing the model to develop a habit of standardized output.

[0109] Step 502: The frequency of each operator in the predicted query statement is weighted and summed with the preset weight of each operator to obtain the second reward score of the complexity reward dimension.

[0110] Secondly, the system evaluates the logical depth of the generated SQL. To prevent the model from tending to generate simple statements, this embodiment introduces a complexity reward. The system first parses the predicted query statement and counts the frequency of various SQL operators. k i The system predefines an operator weight table, assigning different preset weights to operators of varying difficulty. w i As shown in Table 3: Table 3. Examples of SQL Operator Weight Configuration Operators JOIN UNION INTERSECT EXCEPT SELECT Preset weights 0.6 0.8 0.8 0.8 1 Operators WITH WHERE GROUP BY HAVING ORDER BY Preset weights 0.8 0.2 0.5 0.7 0.3 Operators LIMIT COUNT SUM AVG MAX Preset weights 0.1 0.3 0.3 0.3 0.3 Operators MIN DISTINCT CASE OVER AND Preset weights 0.3 0.3 0.4 1 0.15 Operators OR IN LIKE BETWEEN EXISTS Preset weights 0.2 0.2 0.1 0.2 0.3 Furthermore, the system calculates the complexity score according to the following formula. complexity _ score : .

[0111] The system then maps the complexity score to a second reward score (i.e., the complexity reward). R complexity The specific calculation method is as follows: .in, .

[0112] In this way, if the model generates a statement that includes JOIN or GROUP BY, it will receive a higher bonus score.

[0113] Step 503: Based on the simulated execution results of the predicted query statement, determine the third reward score of the execution correctness reward dimension.

[0114] Finally, and most importantly, the system evaluates the usability of the SQL. The system executes the predicted query in an in-memory database and compares the execution result (Result Set) with the execution results of standard structured query statements (GroundTruth SQL) in the training sample set.

[0115] When the simulation is executed successfully and the results are completely consistent, the system will award the third bonus score (i.e., the execution correctness bonus). Rs Set it to the third preset score, for example, 1.0.

[0116] When an error occurs or the result does not match, the third reward score will be set to the fourth preset score, for example, 0.0.

[0117] Step 504: According to the preset dimension weights, the first reward score, the second reward score, and the third reward score are weighted and summed to obtain the total reward value.

[0118] The system sets preset dimension weights based on the importance of each dimension (e.g., wf =1.0, wc=0.6, ws =1.2). Final total reward value ( Rtotal The calculation formula is: Rtotal =( wf × Rf )+( wc × R complexity )+( ws × Rs ); For example, if the model generates an SQL statement that is correctly formatted (1.0 point), of moderate complexity (0.38 points after normalization), and executes correctly (1.0 point), its total reward value is: 1.0 × 1.0 + 0.6 × 0.38 + 1.2 × 1.0 = 1.0 + 0.228 + 1.2 = 2.428. This total reward value will serve as a positive feedback signal, guiding the direction of updating the generated model parameters.

[0119] This embodiment achieves a comprehensive quantitative evaluation of SQL generation quality by constructing a three-dimensional reward function that includes format, complexity, and execution result. In particular, the complexity reward design, by assigning higher weights to advanced operators, effectively overcomes the inertia of large models when generating code, significantly improving the model's ability to handle complex business logic such as multi-table joins and grouped statistics. Simultaneously, the execution correctness reward is given the highest weight, ensuring that the generation model always prioritizes correct results, thereby training a standardized and accurate generation model.

[0120] In step 103 above, to ensure the security and reliability of the generated SQL statements, this embodiment constructs a special simulation environment. (Refer to...) Figure 6 , Figure 6 This is the sixth flowchart illustrating the intelligent question-answering method based on a large model provided in this embodiment of the invention. Figure 6 As shown, step 103 specifically includes the following steps: Step 601: Create a lightweight database image in memory that has the same metadata structure as the target database.

[0121] The system utilizes high-performance in-memory database technologies (such as DuckDB or SQLite in-memory mode) to build a virtual execution environment.

[0122] Specifically, the system reads the metadata of the target database and executes a series of CREATETABLE statements in the in-memory database to create a table structure, field definitions, and index structure that are completely identical to those of the target database.

[0123] It's important to note that, to maintain lightweight and high speed, this image environment typically doesn't load actual business data, or only loads a very small amount (e.g., a few) of anonymized sample data. This allows the entire environment to be built and destroyed in milliseconds, without consuming any I / O resources from the production database.

[0124] Step 602: Execute the initial query statement in the lightweight database mirror and monitor the syntax and logical reference states during execution to generate simulated feedback results.

[0125] After the image is built, the system will place the initial query statement generated by the model into this environment for trial execution. The system monitors two core states in real time during the execution process: Syntax status: Checks whether the SQL statement conforms to standard SQL syntax (e.g., whether keywords are spelled correctly, whether parentheses are closed, and whether subquery structures are valid).

[0126] Logical reference status: Checks if the database objects referenced in the SQL statement exist and are valid. For example: checks if the referenced table and column names exist in the mirror (preventing the model from creating non-existent fields). Checks data type compatibility (e.g., preventing string fields from being used for mathematical calculations). Checks the compliance of logical operations (e.g., whether non-aggregate columns are correctly included in the GROUP BY statement).

[0127] In addition, the system can use the Query Planner to further detect potential performance defects, such as identifying inefficient logic that could lead to a full table scan or the risk of N+1 queries.

[0128] Based on the above monitoring, the system generates simulated feedback results. If all checks pass, the feedback result is "Execution successful". If any check fails, the feedback result will include specific exception information for use by the subsequent automatic correction module.

[0129] In step 104 above, when the virtual execution environment reports an execution exception, the system initiates an automatic correction process. This process aims to leverage the understanding and reasoning capabilities of the large model to correct defective SQL statements. (Refer to...) Figure 7 , Figure 7 This is the seventh flowchart illustrating the intelligent question-answering method based on a large model provided in this embodiment of the invention. Figure 7 As shown, step 104 specifically includes the following steps: Step 701: Obtain the error type code contained in the simulation feedback result.

[0130] First, the system parses the simulation feedback returned by the virtual execution environment. This result is not just a simple "failure" flag, but contains detailed database engine error information. The system extracts the error type code and the specific error description text from it.

[0131] Common error types include: Grammatical errors: such as spelling errors or missing keywords.

[0132] Logical errors: such as referencing a non-existent column name, data type mismatch, or using a non-aggregate column in an aggregate function.

[0133] Step 702: Extract the table structure definitions of the data tables involved in the initial query statement.

[0134] To enable the model to understand how to modify its data, it must be provided with the correct reference information. The system analyzes the initial query that failed to execute, identifying the names of the data tables involved. Then, the system extracts the complete table structure definitions of these data tables from the metadata, including table names, column names, data types, and column comments.

[0135] For example, if the SQL involves a "monthly production status table", the system will extract the CREATE TABLE statement for that table or a similar structured description.

[0136] Step 703: Combine the error type code, table structure definition, and initial query statement into a prompt word template.

[0137] The system will populate a preset dynamic prompt template with the information collected above, including the specific error type code / description, the correct table structure definition, and the problematic initial query statement.

[0138] For example, the constructed prompt words might look like this: SQL execution error type: [Error code: Column 'prod_date' not found] Table structure reference: [Table name: monthly_report(fields: production_date, quantity,...)], Please fix the following SQL statement: "[SELECT prod_date, sum(quantity) FROM monthly_report...]".

[0139] Step 704: Input the prompt word template into the generation model, obtain the query statement regenerated by the generation model, until the simulation execution is error-free or the preset correction number threshold is reached, and obtain the target query statement.

[0140] The system inputs the constructed prompt words into the generation model (which can be the same SQL generation model or a dedicated repair model). The model analyzes the prompt words, recognizes that the previous error was that production_date was mistakenly written as prod_date, and then generates the corrected SQL statement.

[0141] The system retrieves the regenerated query statement and sends it back into the virtual execution environment for simulated execution.

[0142] If the execution is successful (without any errors), the correction process ends, and the statement is confirmed as the target query statement.

[0143] If the error persists, the system will repeat steps 701 to 703 above to generate new error correction prompts for the next round of correction.

[0144] To prevent infinite loops, the system sets a preset threshold for the number of corrections (e.g., 3 times). If the simulation still fails after 3 iterations of corrections, the system will terminate the attempt and return a "cannot answer" message or a request for manual intervention to the user.

[0145] This embodiment achieves closed-loop control of SQL generation by constructing a feedback-based automatic correction mechanism. The system not only detects errors but also guides the large model to perform targeted repairs by combining "error codes" with "correct table structures" as prompts. This mechanism effectively solves common problems caused by model illusions, such as misspelled field names and omitted grouping logic, significantly improving the system's final execution success rate when facing complex and uncommon queries, and enhancing the robustness and user experience of the intelligent query system.

[0146] Reference Figure 8 , Figure 8 This is a schematic diagram of the structure of the intelligent question-and-answer system based on a large model provided by the present invention. The system includes: The first processing module is used to map and match entities in the original query request for the target database using field information in the metadata of the target database, and to semantically rewrite the original query request based on the matching results to obtain an optimized query request. The second processing module is used to input the optimized query request and metadata into the generative model to obtain the initial query statement output by the generative model; wherein, the generative model is obtained by fine-tuning the parameters of the large language model; The third processing module is used to simulate the execution of the initial query statement in a virtual execution environment built using metadata, and obtain simulated feedback results; the virtual execution environment is a simulation running environment independent of the target database; The fourth processing module is used to correct the initial query statement based on the simulation feedback result and metadata if the simulation feedback result indicates an execution error, so as to obtain the target query statement that has passed the verification. The fifth processing module is used to send the target query statement to the target database for execution and obtain the data query results.

[0147] It should be noted that the intelligent questioning system based on a large model provided by the present invention can execute the intelligent questioning method based on a large model of any of the above embodiments during specific operation, which will not be elaborated in this embodiment.

[0148] Figure 9 This is a schematic diagram of the structure of the electronic device provided by the present invention, such as... Figure 9 As shown, the electronic device may include: a processor 910, a communication interface 920, a memory 930, and a communication bus 940, wherein the processor 910, the communication interface 920, and the memory 930 communicate with each other through the communication bus 940. The processor 910 can call logical instructions in the memory 930 to execute a large-model-based intelligent query method. This method includes: using field information from the metadata of the target database to map and match entities in the original query request for the target database, and semantically rewriting the original query request based on the matching results to obtain an optimized query request; inputting the optimized query request and metadata into a generative model to obtain an initial query statement output by the generative model; wherein the generative model is obtained by fine-tuning the parameters of a large language model; simulating the execution of the initial query statement in a virtual execution environment constructed using metadata to obtain simulation feedback results; the virtual execution environment is a simulation runtime environment independent of the target database; if the simulation feedback result indicates an execution anomaly, correcting the initial query statement based on the simulation feedback result and metadata to obtain a verified target query statement; and sending the target query statement to the target database for execution to obtain data query results.

[0149] Furthermore, the logical instructions in the aforementioned memory 930 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0150] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, and when the program instructions are executed by a computer, the computer is able to execute the intelligent query method based on a large model provided in the above embodiments.

[0151] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the intelligent querying method based on a large model provided in the above embodiments.

[0152] The system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0153] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods of various embodiments or some parts of embodiments.

[0154] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A smart question-answering method based on a large model, characterized in that, include: By utilizing the field information in the metadata of the target database, the entities in the original query request targeting the target database are mapped and matched, and the original query request is semantically rewritten based on the matching results to obtain an optimized query request. The optimized query request and the metadata are input into the generative model to obtain the initial query statement output by the generative model; wherein, the generative model is obtained by fine-tuning the parameters of the large language model; In a virtual execution environment constructed using the aforementioned metadata, the initial query statement is simulated and executed to obtain simulated feedback results; the virtual execution environment is a simulation runtime environment independent of the target database. If the simulation feedback result indicates an execution error, the initial query statement is corrected based on the simulation feedback result and the metadata to obtain a verified target query statement; The target query statement is sent to the target database for execution, and the data query results are obtained.

2. The intelligent question-answering method based on a large model according to claim 1, characterized in that, Before mapping and matching entities in the original query request for the target database using field information from the target database's metadata, the process also includes: The original data tables in the target database are subjected to multi-level filtering to generate filtered data tables; the multi-level filtering includes table-level filtering to remove empty tables and log tables, and field-level filtering to remove fields with high repetition rates. In the filtered data table, primary key fields and candidate key fields are selected, and Bloom filters are created for each. The Bloom filter is used to perform existence checks on field values ​​between different tables and to calculate the field matching rate; When the field matching rate exceeds a preset threshold, it is determined that there is a relationship between the tables, and the metadata is generated based on the relationship and the table structure.

3. The intelligent question-answering method based on a large model according to claim 1, characterized in that, The process involves using field information from the metadata of the target database to map and match entities in the original query request targeting the target database. include: The entity to be matched is extracted from the original query request using a large language model; Calculate the character edit distance between the entity to be matched and the field name in the metadata; If the character edit distance meets the first preset condition, then the entity to be matched is directly mapped to the corresponding field name; If the character edit distance does not meet the first preset condition, then calculate the semantic vector cosine similarity between the entity to be matched and the field name in the metadata; If the semantic vector cosine similarity satisfies the second preset condition, then the entity to be matched is mapped to the corresponding field name.

4. The intelligent question-answering method based on a large model according to claim 1, characterized in that, The generative model is trained through the following steps: Obtain a training sample set; the training sample set includes natural language questions and standard structured query statements corresponding to the natural language questions; The training sample set is input into the large language model to obtain the predicted query statement; The reward scores for the predicted query statement are calculated from the format reward dimension, complexity reward dimension, and execution correctness reward dimension, respectively, and the total reward value of the predicted query statement is calculated based on each reward score. The network parameters of the large language model are updated based on the total reward value until the large language model converges, thus obtaining the generative model.

5. The intelligent question-answering method based on a large model according to claim 4, characterized in that, The calculation of reward scores for the predicted query statement from the dimensions of format reward, complexity reward, and execution correctness reward, and the calculation of the total reward value for the predicted query statement based on each reward score, includes: Based on the markup language structure of the predicted query statement, a first reward score for the format reward dimension is determined; wherein, when the markup language structure conforms to a preset structure, the first reward score is set to a first preset score; when the markup language structure does not conform to the preset structure, the first reward score is set to a second preset score. The second reward score of the complexity reward dimension is obtained by weighting and summing the frequency of each operator in the predicted query statement with the preset weight corresponding to each operator. Based on the simulated execution results of the predicted query statement, a third reward score for the execution correctness reward dimension is determined; wherein, when the simulated execution result is consistent with the standard result in the training sample set, the third reward score is set as a third preset score; when the simulated execution result is inconsistent with the standard result in the training sample set, the third reward score is set as a fourth preset score. The first reward score, the second reward score, and the third reward score are weighted and summed according to the preset dimension weights to obtain the total reward value.

6. The intelligent question-answering method based on a large model according to claim 1, characterized in that, The step of modifying the initial query statement to obtain the verified target query statement includes: Obtain the error type code contained in the simulated feedback result; Extract the table structure definitions of the data tables involved in the initial query statement; The error type code, the table structure definition, and the initial query statement are combined into a prompt word template; The prompt word template is input into the generation model to obtain the query statement regenerated by the generation model until the simulation execution is error-free or the preset correction number threshold is reached, and the target query statement is obtained.

7. The intelligent question-answering method based on a large model according to claim 1, characterized in that, The process of simulating the execution of the initial query statement in a virtual execution environment constructed using the metadata, and obtaining simulated feedback results, includes: Create a lightweight database image in memory that has the same metadata structure as the target database; The initial query statement is executed in the lightweight database image, and the syntax state and logical reference state during the execution process are monitored to generate the simulated feedback result.

8. An intelligent question-and-answer system based on a large model, characterized in that, include: The first processing module is used to use field information in the metadata of the target database to map and match entities in the original query request for the target database, and to semantically rewrite the original query request based on the matching results to obtain an optimized query request. The second processing module is used to input the optimized query request and the metadata into the generation model to obtain the initial query statement output by the generation model; wherein, the generation model is obtained by fine-tuning the parameters of the large language model; The third processing module is used to simulate the execution of the initial query statement in a virtual execution environment constructed using the metadata, and obtain simulated feedback results; the virtual execution environment is a simulation running environment independent of the target database; The fourth processing module is used to modify the initial query statement based on the simulation feedback result and the metadata if the simulation feedback result indicates an execution error, so as to obtain a verified target query statement. The fifth processing module is used to send the target query statement to the target database for execution to obtain the data query results.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the intelligent questioning method based on a large model as described in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the intelligent questioning method based on a large model as described in any one of claims 1 to 7.