An AI large model-based database simulation test scene intelligent generation method
Patent Information
- Application Number
- CN202610864391.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-16
- Publication Date
- 2026-08-21
AI Technical Summary
对于一个中等规模的业务系统(约50张表、200余条SQL),此过程通常耗时2至4周,且场景覆盖率普遍不足30%,大量隐式关联和边界条件被遗漏
[0026] By using the abstract syntax tree parsing to construct a deterministic database behavior model as the unique truth anchor, this model constrains the generation range of the large language model before inference and serves as a verification criterion for structural consistency after inference. This fundamentally solves the dual bottlenecks of rule engines lacking semantic understanding capabilities and large language models lacking accuracy and verifiability.
Smart Images

Figure CN122616733A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database technology, and in particular to an intelligent generation method for database simulation test scenarios based on AI large models. Background Technology
[0002] Databases are the cornerstone of modern enterprise core systems. In critical sectors such as financial transactions, telecommunications operations, and semiconductor manufacturing, database performance fluctuations or transaction anomalies can trigger large-scale service outages, with direct economic losses from a single incident typically exceeding tens of millions of dollars. Simulation testing, which simulates production loads in a real database environment, is the last line of defense for verifying database performance, stability, and compatibility before deployment, and its necessity is self-evident.
[0003] However, the core aspect of simulation testing—the design and generation of test scenarios—still heavily relies on manual labor. Testers must meticulously read SQL scripts, DDL files, and business documents, manually analyzing table structures, identifying transaction boundaries, and inferring business logic before writing test scenarios line by line. For a medium-sized business system (approximately 50 tables and over 200 SQL statements), this process typically takes 2 to 4 weeks, with scenario coverage generally below 30%, resulting in the omission of numerous implicit relationships and boundary conditions. More critically, manually generated scenarios lack automated verification methods; the correctness of SQL statements and the reasonableness of transaction boundaries within the scenarios can only be checked manually item by item, further exacerbating the efficiency bottleneck.
[0004] To address the aforementioned challenges, two existing technical approaches are as follows:
[0005] The first type is rule-based template engines. These methods can only generate basic operations like CRUD (Create, Read, Update, Delete) based on fixed templates and cannot understand business semantics. For example, a "place an order" operation in the database actually includes five SQL statements: check inventory, lock inventory, insert order, clear shopping cart, and log. These SQL statements belong to the same database transaction and have atomicity constraints and concurrency characteristics. However, the template engine recognizes it as isolated "two SELECT statements plus three INSERT statements," completely losing the atomic semantics and concurrency dependencies of the transaction.
[0006] The second category involves directly using Large Language Models (LLM). While this method possesses semantic understanding capabilities, as a probabilistic model, LLM can confuse JOIN types, miss nested subqueries, and incorrectly infer transaction boundaries when directly parsing SQL. In real-world testing under complex scenarios, the error rate can reach 15% to 30%. More critically, after LLM generates test scenario solutions, the system has no way of determining whether there are factual errors within them. The output of LLM is a black box conclusion, lacking any definitive verification anchors. Therefore, manual review remains the only error correction method, which fundamentally contradicts the original intention of automation to improve efficiency.
[0007] Chinese patent CN121658512A discloses a method for text-to-SQL statement data synthesis based on a large-scale model. This method starts with a web table, uses a large language model to generate related tables and construct a target database, then generates SQL query statements through a complexity-leveling, genetic algorithm expansion, and rule-based error correction mechanism. Finally, it generates candidate natural language questions for each SQL statement and selects the optimal question through multi-dimensional evaluation, constructing a <natural language question, SQL statement> pairing dataset. The core flaw of this method is that its SQL generation and error correction process lacks deterministic verification anchors, relying entirely on the probabilistic output of the large language model and a pre-set rule base for error correction. It cannot automatically verify whether the generated SQL statements are correct at the business semantic level (such as transaction boundary identification and inter-table business relationship judgment). Furthermore, its final output is a <question, SQL> data pair rather than a directly executable database simulation test scenario, and it does not involve multi-layered progressive deterministic verification and autonomous error correction closed loop for the test scenario.
[0008] In summary, the current core bottleneck in this field lies in the lack of semantic understanding capabilities in rule engines and the lack of precision and verifiability in large language models. The absence of a mechanism that can provide precise constraints while driving automatic verification and autonomous error correction prevents the formation of a closed-loop technology process of "generation → verification → error correction → regeneration".
[0009] Therefore, there is an urgent need for an intelligent generation method for database simulation test scenarios that can guarantee semantic understanding capabilities while possessing deterministic verification anchor points and automated error correction capabilities. Summary of the Invention
[0010] In view of this, in order to overcome the shortcomings of the existing technology, the present invention aims to provide a method for intelligent generation of database simulation test scenarios based on AI large models.
[0011] This invention provides an intelligent generation method for database simulation test scenarios based on AI large models, the method comprising:
[0012] Step S1: Perform structured parsing on the input heterogeneous business data, and deterministically extract database behavior features from SQL statements through abstract syntax tree parsing to construct a database behavior model;
[0013] Step S2: Inject the database behavior model as an input constraint into the large language model, drive it to perform business semantic reasoning based on the facts in the database behavior model, and generate test scenario solutions;
[0014] Step S3: Perform a three-layer deterministic verification on the generated test scenario solution, consisting of database behavior model structure verification, real database execution verification, and execution plan verification.
[0015] Step S4: If the three-layer deterministic verification fails, package the error details into a structured error correction feedback and re-inject it into the large language model to trigger regeneration. Repeat steps S2 to S4 until all verifications pass or the preset loop limit is reached.
[0016] Optionally, in the intelligent generation method for database simulation test scenarios based on AI large models of the present invention, in step S1, a database behavior model is constructed in the following manner: each SQL statement is parsed into an abstract syntax tree by a formal syntax parser, and table-column metadata, operation type, table access topology graph, transaction atomic boundary and load characteristics are deterministically extracted from the abstract syntax tree.
[0017] Optionally, in step S2 of the intelligent generation method for database simulation test scenarios based on AI large model of the present invention, when driving the large language model to generate test scenario schemes, it is required to label the specific source of each business semantic inference in the database behavior model. The generated test scenario scheme includes at least SQL templates, transaction boundary definitions, concurrent access parameters, and data preparation and cleaning scripts.
[0018] Optionally, in the intelligent generation method for database simulation test scenarios based on AI large models of the present invention, in step S3, the database behavior model is verified as follows: each inference output by the large language model is deterministically compared with its labeled source to verify whether the table relationship matches the table access topology in the behavior model. Figure 1 The database behavior model is deemed to fail verification if any inference contradicts the database behavior model or lacks a source. This includes checking whether the transaction boundaries are consistent with the SQL set marked in the behavior model, and whether the referenced table and column names exist in the table-column metadata of the behavior model.
[0019] Optionally, in step S3 of the intelligent generation method for database simulation test scenarios based on AI large models of the present invention, real database execution verification is performed in the following manner: the generated SQL statement is submitted to the target database and executed in actual execution mode using transaction rollback mode to verify the correctness of SQL syntax, the existence of tables and columns, data type compatibility and constraint satisfaction; when execution fails, the standard error code and error information returned by the database are captured as error correction signals.
[0020] Optionally, in the intelligent generation method for database simulation test scenarios based on AI large models of the present invention, in step S3, the execution plan is verified in the following manner: the execution plan is obtained by calling the database's EXPLAIN command for the SQL statement that has passed the database behavior model structure verification and real database execution verification; the obtained execution plan is compared with the preset template for consistency; it is verified whether the obtained execution plan uses the expected index, whether the JOIN algorithm is reasonable, and whether there is no unexpected full table scan or Cartesian product; if an unexpected index is used, or if there is inconsistency after comparison, the execution plan verification is determined to be unsuccessful.
[0021] Optionally, in the intelligent generation method for database simulation test scenarios based on AI large models of the present invention, in step S4, the structured error correction feedback is re-injected into the input context of the large language model in the form of deterministic text. The structured error correction feedback includes at least the following fields: the identifier of the failed verification level, the specific inference or original SQL statement of the failed verification, the original error information returned by the database, the correct reference value, and the context positioning information of the repair suggestion.
[0022] Optionally, in the intelligent generation method for database simulation test scenarios based on AI large models of the present invention, in step S4, when the preset loop limit is reached and not all verifications are still not passed, the current test scenario scheme and the specific items that failed verification in each round are packaged and pushed to the manual confirmation queue. The manual review interface only displays the failed items and their corresponding error information.
[0023] Optionally, the intelligent generation method for database simulation test scenarios based on AI large models of the present invention also includes continuous evolution of database behavior models across projects in the following manner: after each project is completed and verified, the database behavior model features of the project are persistently stored in the historical feature library. When building the database behavior model for a subsequent new project, historical verified features with similar table structures or business models to the current project are retrieved from the historical feature library and integrated.
[0024] Optionally, the intelligent generation method for database simulation test scenarios based on AI large models of the present invention retrieves and integrates historical verified features with similar table structures or business models to the current project from the historical feature library in the following manner: For each historical verified feature, its frequency of occurrence and verification pass rate in different projects are recorded. When constructing the database behavior model of a new project, table associations, transaction boundary patterns or load feature patterns that occur more frequently than a preset threshold and have a verification pass rate of a preset percentage are injected into the topology graph or feature set corresponding to the current behavior model.
[0025] The intelligent generation method for database simulation test scenarios based on AI large models of the present invention has the following beneficial technical effects:
[0026] By using the abstract syntax tree parsing to construct a deterministic database behavior model as the unique truth anchor, this model constrains the generation range of the large language model before inference and serves as a verification criterion for structural consistency after inference. This fundamentally solves the dual bottlenecks of rule engines lacking semantic understanding capabilities and large language models lacking accuracy and verifiability.
[0027] Based on this, a three-layer progressive deterministic verification mechanism is superimposed, consisting of behavioral model structure verification, real database execution verification, and execution plan verification. Each layer captures different types of errors and produces precise error correction signals. The structured error correction feedback drives the large language model to make targeted corrections, forming a fully autonomous closed loop of "generation → verification → error correction → regeneration".
[0028] Meanwhile, through the continuous evolution and weighted accumulation mechanism of cross-project behavior models, the deterministic foundation is continuously thickened as projects accumulate, and the inference hit rate and convergence speed of subsequent tasks are improved one after another without relying on the update of the large language model itself. Attached Figure Description
[0029] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0030] Figure 1 This is a flowchart illustrating the intelligent generation method for database simulation test scenarios based on AI large models according to an exemplary embodiment 1 of the present invention.
[0031] Figure 2 A schematic diagram illustrating the process of verifying a database behavior model according to the AI-based large model-based intelligent generation method for database simulation test scenarios in exemplary embodiment 1 of the present invention;
[0032] Figure 3 This is a flowchart illustrating the process of performing real database execution verification using the AI-based large model-based intelligent generation method for database simulation test scenarios according to Exemplary Embodiment 1 of the present invention.
[0033] Figure 4 A flowchart illustrating the execution plan verification process for the AI-based large-scale database simulation test scenario intelligent generation method according to Exemplary Embodiment 1 of the present invention.
[0034] Figure 5 This is a flowchart illustrating the weighted fusion of historical features in the intelligent generation method for database simulation test scenarios based on AI large models according to Exemplary Embodiment 1 of the present invention. Detailed Implementation
[0035] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.
[0036] It should be noted that, in the absence of conflict, the following embodiments and features can be combined with each other; and, based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0037] It should be noted that various aspects of embodiments within the scope of the appended claims are described below. It will be apparent that the aspects described herein can be embodied in a wide variety of forms, and any particular structure and / or function described herein is merely illustrative. Based on this disclosure, those skilled in the art will understand that one aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects set forth herein can be used to implement the device and / or practice the method. Additionally, this device and / or method can be implemented using structures and / or functionalities other than one or more of the aspects set forth herein.
[0038] Example 1
[0039] Exemplary embodiment 1 of the present invention provides a method for intelligent generation of database simulation test scenarios based on AI large models. Figure 1 This is a flowchart illustrating the intelligent generation method for database simulation test scenarios based on AI large models according to an exemplary embodiment 1 of the present invention. Figure 1 As shown, in this embodiment, the method of the present invention is implemented in the following manner:
[0040] Step S1: Perform structured parsing on the input heterogeneous business data, and deterministically extract database behavior features from SQL statements through abstract syntax tree parsing to construct a database behavior model.
[0041] As an optional example, this embodiment uses a formal syntax parser to parse each SQL statement into an abstract syntax tree, and deterministically extracts five types of features from it: table-column metadata, operation type, table access topology, transaction atomic boundaries, and load characteristics. This constructs a database behavior model independent of AI reasoning. This behavior model has a unique truth value and can serve as a deterministic criterion for all subsequent verification steps, avoiding the propagation of errors introduced by the uncertainty of AI reasoning.
[0042] Step S2: Inject the database behavior model as an input constraint into the large language model, drive it to perform business semantic reasoning based on the facts in the database behavior model, and generate test scenario solutions.
[0043] In this embodiment, when driving the large language model to generate test scenario schemes, it is mandatory to label the specific source of each business semantic inference in the database behavior model. The generated test scenario schemes include at least SQL templates, transaction boundary definitions, concurrent access parameters, and data preparation and cleaning scripts, thereby ensuring that the output of the large language model is traceable and verifiable, laying a structured foundation for subsequent automated verification and error correction.
[0044] In this embodiment, the Large Language Model (LLM) refers to a neural network model based on deep learning technology, pre-trained on a large-scale corpus, and possessing the ability to understand and generate natural language. This includes, but is not limited to, GPT series models, Claude series models, Gemini series models, LLaMA series models, DeepSeek series models, Wenxin Yiyan, Tongyi Qianwen, Hunyuan Large Model, Xinghuo Large Model, Baichuan series models, and ChatGLM series models. This embodiment does not limit the specific LLM model used; as long as it possesses SQL semantic understanding capabilities, structured input adherence capabilities, and correction capabilities based on accurate feedback, the technical solution of this invention can be achieved.
[0045] Step S3: Perform a three-layer deterministic verification on the generated test scenario solution, consisting of database behavior model structure verification, real database execution verification, and execution plan verification.
[0046] This invention also provides a deterministic structural verification method based on behavioral models. This method verifies the consistency of table relationships, transaction boundaries, and the existence of table columns by comparing each inference from a large language model with its labeled source item by item. This verification is entirely based on deterministic comparison of structured data, does not rely on database instances, has zero computational overhead, and can efficiently capture various errors generated by large language models at the structural reasoning level at extremely low cost.
[0047] Figure 2 This is a flowchart illustrating the database behavior model verification process of the intelligent generation method for database simulation test scenarios based on AI large models according to Exemplary Embodiment 1 of the present invention. Figure 2 As shown, in this embodiment, the database behavior model is verified as follows: each inference output by the large language model is deterministically compared with its labeled source to verify whether the table relationships match the table access topology in the behavior model. Figure 1 The database behavior model is deemed to fail verification if any inference contradicts the database behavior model or lacks a source. This includes checking whether the transaction boundaries are consistent with the SQL set marked in the behavior model, and whether the referenced table and column names exist in the table-column metadata of the behavior model.
[0048] Figure 3 This is a flowchart illustrating the process of performing real database execution verification using the AI-based large-scale database simulation test scenario intelligent generation method according to Exemplary Embodiment 1 of the present invention. Figure 3 As shown, in this embodiment, real database execution verification is performed as follows: the generated SQL statement is submitted to the target database and executed in transaction rollback mode to verify the correctness of SQL syntax, the existence of tables and columns, data type compatibility, and constraint satisfaction; when execution fails, the standard error code and error information returned by the database are captured as error correction signals.
[0049] This embodiment submits the generated SQL statement to the target database for actual execution in transaction rollback mode, and captures the standard error codes and error messages returned by the database when execution fails. This enables accurate detection of problems such as syntax errors, column name spelling errors, and data type incompatibility that are imperceptible to the behavioral model. The database system's own error codes serve as deterministic error correction signals, providing a precise basis for correction to the large language model.
[0050] Figure 4 A flowchart illustrating the execution plan verification of the AI-based large-scale database simulation test scenario intelligent generation method according to Exemplary Embodiment 1 of the present invention is shown below. Figure 4 As shown, in this embodiment, execution plan verification is performed as follows: The SQL statement that has passed database behavior model structure verification and real database execution verification is processed by calling the database's EXPLAIN command to obtain the execution plan. The obtained execution plan is then compared with a preset template to verify whether the expected index is used, whether the JOIN algorithm is reasonable, and whether there are any unexpected full table scans or Cartesian products. If an unexpected index is used, or if inconsistencies are found after comparison, the execution plan verification is deemed unsuccessful. This verification layer ensures that the generated SQL not only executes correctly but also executes according to the expected performance characteristics, thus avoiding performance risks caused by poor execution plans from the source.
[0051] Step S4: If the three-layer deterministic verification fails, package the error details into a structured error correction feedback and re-inject it into the large language model to trigger regeneration. Repeat steps S2 to S4 until all verifications pass or the preset loop limit is reached.
[0052] In this embodiment, structured error correction feedback is re-injected into the input context of the large language model in the form of deterministic text. This structured error correction feedback includes at least the following fields: the identifier of the failed validation level, the specific inference or original SQL statement that failed, the original error information returned by the database, the correct reference value, and the contextual location information of the repair suggestion. This embodiment enables the large language model to perform targeted correction at the error location, rather than global regeneration, significantly improving error correction efficiency and closed-loop convergence speed.
[0053] In this embodiment, when the preset loop limit is reached and not all verifications have passed, the current test scenario solution and the specific items that failed verification in each round are packaged and pushed to the manual confirmation queue. The manual review interface only displays the failed items and their corresponding error information. This strictly limits manual intervention to a small number of abnormal items that the machine cannot automatically converge, reducing the workload of manual review and maintaining a high level of automation in the overall process while ensuring the quality of the solution.
[0054] This embodiment also includes continuous evolution of the database behavior model across projects in the following manner: After each validated project is completed, the database behavior model features of that project are persistently stored in a historical feature library. When building the database behavior model for a subsequent new project, historically validated features with similar table structures or business models to the current project are retrieved from the historical feature library and integrated. In practical applications, this embodiment allows the deterministic foundation of the database behavior model to continuously strengthen with project accumulation, thereby progressively improving the starting quality of subsequent tasks.
[0055] Figure 5 This is a flowchart illustrating the historical feature weighted fusion process of the intelligent generation method for database simulation test scenarios based on AI large models according to Exemplary Embodiment 1 of the present invention. Figure 5 As shown, in this embodiment, historically verified features with similar table structures or business models to the current project are retrieved and integrated from the historical feature library in the following manner: For each historically verified feature, its frequency of occurrence and verification pass rate in different projects are recorded. When constructing the database behavior model of a new project, table relationships, transaction boundary patterns, or load feature patterns that occur more frequently than a preset threshold and have a verification pass rate of a preset percentage are injected into the topology graph or feature set corresponding to the current behavior model. This filtering mechanism ensures the reliability and universality of the injected features, and the entire evolution process does not depend on the parameter updates or retraining of the large language model itself, exhibiting good scalability and stability.
[0056] Example 2
[0057] Exemplary Example 2 of this invention provides an intelligent generation method for database simulation test scenarios based on an AI large model. This embodiment constructs a deterministic "database behavior model" using AST parsing. This model serves as an input constraint before LLM inference and as a verification criterion for structural consistency after inference. Based on this, real database execution verification and execution plan verification are superimposed, forming a three-layer progressive automatic error correction mechanism. Each of the three layers of verification captures different types of errors, and the generated error correction signals are deterministic and precisely located, directly feeding back to the LLM to trigger targeted corrections, thus forming an unmanned autonomous closed loop.
[0058] Specifically, this embodiment implements the method of the present invention in the following manner:
[0059] Step 1: Structured Analysis of Multimodal Data
[0060] The heterogeneous business data uploaded by users is uniformly parsed into a structured intermediate format, providing standardized input for subsequent steps.
[0061] Step 2: Construction of a Deterministic Behavior Model
[0062] Each SQL statement is parsed into an Abstract Syntax Tree (AST) using a formal syntax parser, and the following features are deterministically extracted from the AST to construct a structured database behavior model:
[0063] Table-column metadata: A complete list of columns for each table, including data types, primary keys, and foreign keys;
[0064] Operation type: Based on the AST node type, SQL is precisely classified into SELECT / INSERT / UPDATE / DELETE / DDL;
[0065] Table access topology graph: Extract co-occurrence relationships between tables from the FROM / JOIN clauses and construct a directed graph;
[0066] Transaction atomic boundaries: Scan BEGIN / COMMIT / ROLLBACK pairs and mark the SQL sets belonging to the same database transaction;
[0067] Load characteristics: Extract columns involved in WHERE conditions, comparison operations, aggregate functions, and sorting fields;
[0068] In this embodiment, all data for the behavioral model comes from deterministic extraction of the AST (Abstract Strategy Template) and is not generated by AI inference. Therefore, it possesses a unique truth value. Any LLM inference that contradicts the behavioral model is considered an LLM error, requiring no manual judgment. In this embodiment, the behavioral model has a dual role. In step three, it serves both as the precise input foundation for LLM inference and as the deterministic criterion for verifying the LLM output.
[0069] Step 3: Three-layer verification-driven LLM autonomous closed loop
[0070] This step constructs an autonomous loop of "generate → verify → correct → regenerate" until it converges.
[0071] A. Inference Generation under Behavioral Model Constraints: The behavioral model is injected into the LLM, which instructs the LLM to perform business semantic reasoning based on the facts in the behavioral model. Each inference must be labeled with its source in the behavioral model. The LLM output includes: business semantic inferences (such as which tables constitute a business process) and test scenario solutions (SQL templates, transaction boundaries, concurrency parameters, etc.).
[0072] B. Three-layer progressive deterministic verification: After the LLM output, it undergoes three layers of verification in sequence:
[0073] The first layer, behavioral model structure verification, involves a deterministic comparison of each inference in the LLM with its labeled source against the behavioral model. This verifies the correctness of table relationships, the consistency of transaction boundaries, and the existence of referenced tables / columns. Any contradictory or unlabeled inference is immediately rejected. This layer is executed offline at zero cost.
[0074] The second layer, real database execution verification: The generated SQL is submitted to the target database for actual execution, using transaction rollback mode to avoid side effects. This verifies the correctness of the SQL syntax, the existence of tables and columns, and data type compatibility. This layer captures errors that the behavioral model cannot detect. An LLM might generate SQL with correct table relationships but misspelled column names under behavioral model constraints; only real execution can expose these errors. The system error code returned by the database (such as "column "foo" does not exist") is a precise error correction signal.
[0075] The third layer is execution plan verification: The execution plan (EXPLAIN) is obtained from the SQL processed through the first two layers to verify whether the expected indexes were used, whether the JOIN algorithm is reasonable, and whether there are any unexpected full table scans or Cartesian products. This layer ensures that the generated SQL not only "can be executed," but also executes with the expected performance characteristics.
[0076] All three layers of verification are deterministic, do not rely on additional AI inference, and produce a binary result (pass / fail).
[0077] C. Precise Error Correction and Autonomous Regeneration: If all three layers of validation pass, the solution is stored in the database, and the closed loop converges. If any layer fails, the failure details (which inference / SQL failed, the specific error content, the correct value, or the error message returned by the database) are packaged into error correction feedback and re-injected into the LLM to trigger generation. The LLM does not receive a general "start over," but rather precise error localization, enabling targeted correction rather than guesswork.
[0078] D. Convergence Determination: Execute A→B→C repeatedly until all passes or the preset upper limit is reached (e.g., 3 rounds). Solutions that fail to converge beyond the upper limit, along with their verification reports, are pushed to a manual confirmation queue. Human reviewers only need to examine the specific items that failed, rather than reviewing the entire solution from the beginning.
[0079] Step 4: Continuous Evolution of Cross-Project Behavioral Models (Supporting Mechanisms)
[0080] Upon completion of each project, the validated scenario solutions and behavioral model features are persistently stored. Subsequent projects incorporate these validated features when building behavioral models. This "deterministic foundation" of the behavioral model continuously strengthens with each project, leading to a sustained improvement in the hit rate and loop closure speed of LLM inference. This evolution is independent of updates to the LLM itself.
[0081] 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.
[0082] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for intelligently generating database simulation test scenarios based on AI large models, characterized in that, The method includes: Step S1: Perform structured parsing on the input heterogeneous business data, and deterministically extract database behavior features from SQL statements through abstract syntax tree parsing to construct a database behavior model; Step S2: Inject the database behavior model as an input constraint into the large language model, drive it to perform business semantic reasoning based on the facts in the database behavior model, and generate test scenario solutions; Step S3: Perform a three-layer deterministic verification on the generated test scenario solution, consisting of database behavior model structure verification, real database execution verification, and execution plan verification. Step S4: If the three-layer deterministic verification fails, package the error details into a structured error correction feedback and re-inject it into the large language model to trigger regeneration. Repeat steps S2 to S4 until all verifications pass or the preset loop limit is reached.
2. The intelligent generation method for database simulation test scenarios based on AI large models according to claim 1, characterized in that, In step S1, the database behavior model is constructed as follows: each SQL statement is parsed into an abstract syntax tree by a formal syntax parser, and table-column metadata, operation types, table access topology, transaction atomic boundaries and load characteristics are deterministically extracted from the abstract syntax tree.
3. The intelligent generation method for database simulation test scenarios based on AI large models according to claim 1, characterized in that, In step S2, when driving the large language model to generate test scenario schemes, it is mandatory to label the specific source of each business semantic inference in the database behavior model. The generated test scenario schemes must include at least SQL templates, transaction boundary definitions, concurrent access parameters, and data preparation and cleaning scripts.
4. The intelligent generation method for database simulation test scenarios based on AI large models according to claim 1, characterized in that, In step S3, the database behavior model is verified as follows: each inference output by the large language model is deterministically compared with its labeled source to verify whether the table relationship is consistent with the table access topology in the behavior model, whether the transaction boundary is consistent with the SQL set marked in the behavior model, and whether the referenced table name and column name exist in the table-column metadata of the behavior model. If any inference contradicts the database behavior model or is not attributed to a source, the database behavior model is deemed to have failed validation.
5. The intelligent generation method for database simulation test scenarios based on AI large models according to claim 1, characterized in that, In step S3, the real database execution verification is performed as follows: the generated SQL statement is submitted to the target database and executed in transaction rollback mode to verify the correctness of SQL syntax, the existence of tables and columns, data type compatibility, and constraint satisfaction; when execution fails, the standard error code and error message returned by the database are captured as error correction signals.
6. The intelligent generation method for database simulation test scenarios based on AI large models according to claim 1, characterized in that, In step S3, the execution plan is verified as follows: the SQL statement that has passed the database behavior model structure verification and the real database execution verification is executed by calling the database's EXPLAIN command to obtain the execution plan. The obtained execution plan is compared with the preset template to verify whether the expected index is used, whether the JOIN algorithm is reasonable, and whether there are any unexpected full table scans or Cartesian products. If an unexpected index is used, or if there is inconsistency after comparison, the execution plan verification is deemed unsuccessful.
7. The intelligent generation method for database simulation test scenarios based on AI large models according to claim 1, characterized in that, In step S4, the structured error correction feedback is re-injected into the input context of the large language model in the form of deterministic text. The structured error correction feedback includes at least the following fields: the identifier of the failed validation level, the specific inference or SQL statement that failed, the original error information returned by the database, the correct reference value, and the contextual location information of the repair suggestion.
8. The intelligent generation method for database simulation test scenarios based on AI large models according to claim 1, characterized in that, In step S4, when the preset loop limit is reached and not all verifications have passed, the current test scenario scheme and the specific items that failed verification in each round are packaged and pushed to the manual confirmation queue. The manual review interface only displays the failed items and their corresponding error information.
9. The intelligent generation method for database simulation test scenarios based on AI large models according to claim 1, characterized in that, The method also includes continuous evolution of the database behavior model across projects in the following manner: after each project is completed and validated, the database behavior model features of the project are persistently stored in the historical feature library. When building the database behavior model for a new project in the future, the historically validated features with similar table structures or business models to the current project are retrieved from the historical feature library and integrated.
10. The intelligent generation method for database simulation test scenarios based on AI large models according to claim 9, characterized in that, The following methods are used to retrieve and integrate historical verified features from the historical feature library that have similar table structures or business models to the current project: For each historical verified feature, record its frequency of occurrence and verification pass rate in different projects. When building the database behavior model of a new project, table relationships, transaction boundary patterns, or load feature patterns that occur more frequently than a preset threshold and have a verification pass rate of a preset percentage are injected into the topology or feature set corresponding to the current behavior model.
Citation Information
Patent Citations
Text-to-SQL (Structured Query Language) statement data synthesis method based on large model
CN121658512A