Model performance optimization method, apparatus, device, and storage medium
By expanding and transforming the initial dataset to generate the target dataset and evaluating the performance of the large language model, the problem of incomplete traditional datasets is solved, and the accuracy of SQL statement transformation of the large language model is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING 360 INTELLIGENT TECHNOLOGY CO LTD
- Filing Date
- 2024-12-24
- Publication Date
- 2026-06-26
Smart Images

Figure CN122285694A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of large language model technology, and in particular to model performance optimization methods, apparatus, devices and storage media. Background Technology
[0002] Currently, there are many publicly available datasets and evaluation methods for NL2SQL (Natural Language to SQL), such as Spider, BIRD, WikiSQL, and KaggleDBQA. However, these datasets are all products of traditional AI technologies. GPT-3 introduced a large model with over a hundred billion parameters, providing a completely new technical implementation for NL2SQL. In the large model stage, the development of NL2SQL technology has presented new challenges and requirements to traditional datasets. However, traditional datasets suffer from incomplete data and insufficient coverage of business scenarios, making it impossible to accurately judge the accuracy of the SQL transformation results from large models.
[0003] Therefore, improving the richness of datasets to accurately evaluate the performance of large language models is a problem that urgently needs to be solved.
[0004] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main purpose of this application is to provide a model performance optimization method, apparatus, device and storage medium, which aims to solve the technical problem that traditional datasets have defects such as incomplete data and incomplete coverage of business scenarios, which makes it impossible to accurately judge the accuracy of SQL transformation results of large models.
[0006] To achieve the above objectives, this application proposes a model performance optimization method, which includes:
[0007] An initial dataset is obtained, and the initial dataset is expanded into a target dataset by using a large language model. The target dataset consists of a question and a corresponding reference database query statement.
[0008] The problem is then transformed into a practical database query statement using the large language model.
[0009] Data is queried based on the actual database query statement and the reference database query statement to obtain the actual query result and the reference query result;
[0010] The performance of the large language model is evaluated based on the reference database query statement, the actual database query statement, the reference query result, and the actual query result to obtain the model performance score.
[0011] The large language model is optimized based on the model performance score and the target dataset to obtain the optimized large language model.
[0012] In one embodiment, the performance evaluation of the large language model based on the reference database query statement, the actual database query statement, the reference query result, and the actual query result to obtain a model performance score includes:
[0013] The performance of the large language model is evaluated based on the reference database query statement and the actual database query statement to obtain a first score.
[0014] The performance of the large language model is evaluated based on the reference query results and the actual query results to obtain a second score.
[0015] The model performance score is determined based on the first score and the second score.
[0016] In one embodiment, the step of evaluating the performance of the large language model based on the reference database query statement and the actual database query statement to obtain a first score includes:
[0017] Obtain the first metadata of the query statement in the reference database;
[0018] Generate second metadata based on the actual database query statement;
[0019] The performance of the large language model is evaluated based on the first metadata and the second metadata to obtain a first score.
[0020] In one embodiment, the step of evaluating the performance of the large language model based on the first metadata and the second metadata to obtain a first score includes:
[0021] A consistency comparison is performed based on the first metadata and the second metadata;
[0022] When the first metadata and the second metadata are consistent, the preset score will be used as the first score;
[0023] When the first metadata and the second metadata are inconsistent, the difference data between the first metadata and the second metadata is obtained, and a first score is determined based on the difference data.
[0024] In one embodiment, determining the first score based on the difference data includes:
[0025] Based on the discrepancy data, determine the first error type of the actual database query statement;
[0026] Obtain the score corresponding to the first error type;
[0027] The first score is determined based on the score corresponding to the first error type and the preset score.
[0028] In one embodiment, before obtaining the first metadata of the reference database query statement, the method further includes:
[0029] The query statement from the reference database is parsed to generate an abstract syntax tree;
[0030] Metadata decomposition is performed on the abstract syntax tree to obtain the first metadata of the reference database query statement.
[0031] In one embodiment, the step of evaluating the performance of the large language model based on the reference query results and the actual query results to obtain a second score includes:
[0032] The number of first query rows and the number of first query columns are determined based on the reference query results, and the number of second query rows and the number of second query columns are determined based on the actual query results.
[0033] The performance of the large language model is evaluated based on the number of rows in the first query, the number of columns in the first query, the number of rows in the second query, and the number of columns in the second query, to obtain a second score.
[0034] In one embodiment, the step of evaluating the performance of the large language model based on the first query row count, the first query column count, the second query row count, and the second query column count to obtain a second score includes:
[0035] A consistency comparison is performed based on the number of rows in the first query, the number of columns in the first query, the number of rows in the second query, and the number of columns in the second query.
[0036] When the number of rows in the first query is the same as the number of columns in the second query, and the number of columns in the first query is the same as the number of rows in the second query, the preset score will be used as the second score.
[0037] When the number of rows in the first query is inconsistent with the number of columns in the second query and / or the number of columns in the first query is inconsistent with the number of rows in the second query, the second error type of the actual database query statement is determined based on the reference query result and the actual query result, and the second score is determined based on the second error type.
[0038] In one embodiment, the step of expanding the initial dataset using a large language model to obtain the target dataset includes:
[0039] The questions in the initial dataset are subjected to ambiguity analysis using a large language model, and the ambiguity analysis results are obtained.
[0040] When the ambiguity analysis result indicates that the question is ambiguous, the question and its corresponding answer are removed from the initial dataset, and the step of performing ambiguity analysis on the questions in the initial dataset to obtain the ambiguity analysis result is re-executed.
[0041] When the ambiguity analysis result indicates that the question is unambiguous, the question is expanded using a large language model to obtain a new question;
[0042] Obtain the reference database query statement corresponding to the new problem;
[0043] The initial dataset is updated based on the new problem and the corresponding reference database query statement to obtain the expanded initial dataset.
[0044] In one embodiment, the step of converting the problem into an actual database query statement using the large language model includes:
[0045] The problem is analyzed using a large language model to obtain the problem keywords and problem structure;
[0046] The question is transformed into an SQL query statement by using a large language model based on the question keywords and the question structure.
[0047] Furthermore, to achieve the above objectives, this application also proposes a model performance optimization device, which includes:
[0048] The expansion module is used to obtain an initial dataset and expand the initial dataset into a target dataset using a large language model. The target dataset consists of a question and a corresponding reference database query statement.
[0049] The conversion module is used to convert the problem into an actual database query statement using the large language model;
[0050] The query module is used to perform data queries based on the actual database query statement and the reference database query statement to obtain the actual query results and the reference query results;
[0051] The evaluation module is used to evaluate the performance of the large language model based on the reference database query statement, the actual database query statement, the reference query result, and the actual query result, and obtain the model performance score.
[0052] An optimization module is used to optimize the large language model based on the model performance score and the target dataset to obtain an optimized large language model.
[0053] In one embodiment, the evaluation module is further configured to perform performance evaluation on the large language model based on the reference database query statement and the actual database query statement to obtain a first score;
[0054] The performance of the large language model is evaluated based on the reference query results and the actual query results to obtain a second score.
[0055] The model performance score is determined based on the first score and the second score.
[0056] In one embodiment, the evaluation module is further configured to obtain first metadata of the reference database query statement;
[0057] Generate second metadata based on the actual database query statement;
[0058] The performance of the large language model is evaluated based on the first metadata and the second metadata to obtain a first score.
[0059] In one embodiment, the evaluation module is further configured to perform a consistency comparison based on the first metadata and the second metadata;
[0060] When the first metadata and the second metadata are consistent, the preset score will be used as the first score;
[0061] When the first metadata and the second metadata are inconsistent, the difference data between the first metadata and the second metadata is obtained, and a first score is determined based on the difference data.
[0062] In one embodiment, the evaluation module is further configured to determine a first error type of the actual database query statement based on the difference data;
[0063] Obtain the score corresponding to the first error type;
[0064] The first score is determined based on the score corresponding to the first error type and the preset score.
[0065] In one embodiment, the evaluation module is further configured to parse the query statement of the reference database and generate an abstract syntax tree;
[0066] Metadata decomposition is performed on the abstract syntax tree to obtain the first metadata of the reference database query statement.
[0067] In one embodiment, the evaluation module is further configured to determine the first number of query rows and the first number of query columns based on the reference query results, and to determine the second number of query rows and the second number of query columns based on the actual query results;
[0068] The performance of the large language model is evaluated based on the number of rows in the first query, the number of columns in the first query, the number of rows in the second query, and the number of columns in the second query, to obtain a second score.
[0069] In one embodiment, the evaluation module is further configured to perform a consistency comparison based on the first query row count, the first query column count, the second query row count, and the second query column count;
[0070] When the number of rows in the first query is the same as the number of columns in the second query, and the number of columns in the first query is the same as the number of rows in the second query, the preset score will be used as the second score.
[0071] When the number of rows in the first query is inconsistent with the number of columns in the second query and / or the number of columns in the first query is inconsistent with the number of rows in the second query, the second error type of the actual database query statement is determined based on the reference query result and the actual query result, and the second score is determined based on the second error type.
[0072] In addition, to achieve the above objectives, this application also proposes a model performance optimization device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the model performance optimization method as described above.
[0073] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and which, when executed by a processor, implements the steps of the model performance optimization method described above.
[0074] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the model performance optimization method described above.
[0075] This application provides a model performance optimization method. The method involves first obtaining an initial dataset, then expanding the initial dataset into a target dataset using a large language model. The target dataset consists of a question and a corresponding reference database query statement. The large language model then converts the question into an actual database query statement. Based on the actual and reference database query statements, data queries are performed to obtain actual query results and reference query results. The large language model's performance is evaluated based on the reference query statement, the actual query statement, the reference query results, and the actual query results to obtain a model performance score. Finally, the large language model is optimized based on the model performance score and the target dataset to obtain an optimized large language model. By increasing the data richness of the dataset, the performance evaluation of the large language model can be accurately performed, thereby effectively improving the accuracy of the large language model's SQL statement conversion.
[0076] In summary, this application expands the initial dataset using a large language model to obtain a target dataset consisting of the question and the corresponding reference database query statement. This effectively improves the data richness of the dataset. Furthermore, the large language model converts the question into an actual database query statement, and combines this with the reference database query statement to perform result queries. Based on the actual query results and the reference query results, combined with the corresponding actual and reference database query statements, the performance of the large language model can be accurately evaluated. Therefore, the large language model can be optimized based on its performance score and the target dataset, effectively improving the accuracy of its SQL statement conversion. This overcomes the shortcomings of traditional datasets, such as incomplete data and incomplete coverage of business scenarios, which prevent accurate judgment of the accuracy of the large model's SQL conversion results. By increasing the data richness of the dataset, the performance of the large language model can be accurately evaluated, thereby effectively improving the accuracy of the large language model's SQL statement conversion. Attached Figure Description
[0077] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0078] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0079] Figure 1 This is a flowchart illustrating the performance optimization method for the model in this application, as provided in Embodiment 1.
[0080] Figure 2 This is a flowchart illustrating Embodiment 2 of the model performance optimization method of this application;
[0081] Figure 3 A flowchart of the overall performance evaluation of a large model provided in an embodiment of the model performance optimization method of this application;
[0082] Figure 4 This is a schematic diagram of the module structure of the model performance optimization device in an embodiment of this application;
[0083] Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the model performance optimization method of this application embodiment.
[0084] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0085] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0086] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0087] The main solution of this application embodiment is as follows: First, an initial dataset is obtained, and the initial dataset is expanded into a target dataset using a large language model. The target dataset consists of a question and a corresponding reference database query statement. The large language model is then used to convert the question into an actual database query statement. Data queries are performed based on the actual and reference database query statements to obtain actual query results and reference query results. The performance of the large language model is evaluated based on the reference query statement, the actual query statement, the reference query results, and the actual query results to obtain a model performance score. Finally, the large language model is optimized based on the model performance score and the target dataset to obtain an optimized large language model.
[0088] Currently, there are many publicly available datasets and evaluation methods for NL2SQL (Natural Language to SQL), such as Spider, BIRD, WikiSQL, and KaggleDBQA. However, these datasets are all products of traditional AI technologies. GPT-3 introduced a large model with over a hundred billion parameters, providing a completely new technical implementation for NL2SQL. In the large model stage, the development of NL2SQL technology has presented new challenges and requirements to traditional datasets. However, traditional datasets suffer from incomplete data and insufficient coverage of business scenarios, making it impossible to accurately judge the accuracy of the SQL transformation results of large models. Therefore, how to improve the data richness of datasets to accurately evaluate the performance of large language models is a problem that urgently needs to be solved.
[0089] This application expands the initial dataset using a large language model to obtain a target dataset consisting of the question and the corresponding reference database query statement. This effectively improves the data richness of the dataset. The large language model then converts the question into an actual database query statement, and combines this with the reference database query statement to perform the result query. Based on the actual query result and the reference query result, combined with the corresponding actual and reference database query statements, the performance of the large language model can be accurately evaluated. Therefore, the large language model can be optimized based on its performance score and the target dataset, effectively improving the accuracy of its SQL statement conversion. This overcomes the shortcomings of traditional datasets, such as incomplete data and incomplete coverage of business scenarios, which prevent accurate judgment of the accuracy of the large model's SQL conversion results. By increasing the data richness of the dataset, the performance of the large language model can be accurately evaluated, thereby effectively improving the accuracy of the large language model's SQL statement conversion.
[0090] Based on this, embodiments of this application provide a model performance optimization method, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the model performance optimization method of this application.
[0091] In this embodiment, the model performance optimization method includes steps S10 to S50:
[0092] Step S10: Obtain the initial dataset and expand the initial dataset into a target dataset using a large language model. The target dataset consists of a question and a corresponding reference database query statement.
[0093] It should be noted that the initial dataset includes multiple questions under specific business scenarios and corresponding reference database query statements. The questions and reference database query statements in the initial dataset can be pre-constructed manually or collected through actual business scenarios. This embodiment does not impose specific restrictions on this.
[0094] Understandably, both the initial dataset and the target dataset consist of questions and corresponding reference database query statements. The questions in the initial dataset and the target dataset refer to query questions described in natural language, and the database query statements are SQL statements for these questions, i.e., structured query language statements. The reference database query statements are standard SQL statements predefined based on the questions and are used to evaluate the accuracy of the query statements generated by the large language model.
[0095] It's worth noting that by expanding the questions in the initial dataset using a large language model, more diverse questions are generated, thus enriching the dataset's content. The expansion process can include synonym substitution, adding contextual information, and introducing relevant domain knowledge to enrich the question's expression and increase its complexity. Compared to the questions in the initial dataset, the expanded questions can cover a wider range of business scenarios and richer query requirements, effectively improving the dataset's data richness.
[0096] It is worth noting that when constructing the initial dataset, it is necessary to cover various types of database scenarios, including abnormal data, complex business scenarios, data warehouse scenarios, outlier construction, and processing of unstructured and semi-structured data (such as JSON format), etc. This embodiment does not impose specific limitations on these aspects.
[0097] In the specific implementation, the process of building the initial dataset requires constructing multi-turn dialogue questions, fuzzy questions, and multi-answer questions, and writing answers based on the questions. Unlike the traditional uniqueness of answers, fuzzy answers and exhaustive answers need to be constructed. For example, for the question "How were yesterday's sales?", the answer needs to include a series of indicators such as sales volume, number of orders, and return rate; for the question "What is Zhang San's personal information?", the answer needs to include information such as "gender, age, and address", thereby generating the initial dataset.
[0098] In a feasible implementation, step S10, "expanding the initial dataset using a large language model to obtain a target dataset," specifically includes: performing ambiguity analysis on the questions in the initial dataset using a large language model to obtain ambiguity analysis results; when the ambiguity analysis results indicate that the questions are ambiguous, removing the questions and their corresponding answers from the initial dataset and re-executing the step of performing ambiguity analysis on the questions in the initial dataset to obtain ambiguity analysis results; when the ambiguity analysis results indicate that the questions are unambiguous, expanding the questions using a large language model to obtain new questions; obtaining the reference database query statement corresponding to the new questions; and updating the initial dataset according to the new questions and the corresponding reference database query statement to obtain the expanded initial dataset.
[0099] It's important to note that ambiguity analysis includes, but is not limited to, analysis of lexical, syntactic, and semantic ambiguity. Its purpose is to ensure the clarity and queryability of the query. Natural language processing techniques, such as part-of-speech tagging and dependency parsing, can be used to identify and resolve potential ambiguities during ambiguity analysis. If a query is ambiguous, it may not be directly translatable into a valid database query, or the translated query may not accurately reflect the user's query intent. Therefore, removing ambiguous queries effectively improves dataset quality. This ensures that each query in the target dataset is clear and has a specific query objective, thereby improving the accuracy of performance evaluation.
[0100] Understandably, ambiguity analysis results are used to identify and eliminate questions that might lead to inaccurate model performance evaluations. During ambiguity analysis, if a question is ambiguous—that is, has multiple possible interpretations or answers—it is unsuitable for training and evaluating the model because it could result in inconsistent evaluation results. Therefore, removing these ambiguous questions from the initial dataset ensures that all questions in the dataset are explicit and have a single correct answer, thereby improving the quality of the dataset and the accuracy of the evaluation.
[0101] It's worth noting that after completing ambiguity analysis and removing ambiguous questions, the large language model will expand the remaining questions to generate new ones. These new questions will be more diverse, covering a wider range of business scenarios and query needs, thus further enriching the dataset. During the expansion process, methods such as synonym substitution, adding contextual information, and introducing relevant domain knowledge can be used to increase the complexity and diversity of the questions' expressions.
[0102] Specifically, after obtaining new questions, corresponding reference database queries, i.e., standard SQL statements, need to be written for these questions to evaluate the accuracy of the queries generated by the large language model. When writing reference database queries, it is necessary to ensure that the statements accurately reflect the query intent of the question and cover all possible answers. For example, for a question about sales, the reference database query might need to include queries for metrics such as sales revenue, number of orders, and return rate. After writing these queries, these new questions and their corresponding reference database queries are added to the initial dataset to form the expanded initial dataset, i.e., the target dataset.
[0103] Step S20: The problem is converted into an actual database query statement using the large language model.
[0104] It should be noted that the large language model in this embodiment is a model capable of processing natural language and generating structured query language. This model understands the context and semantics of the problem during processing, thereby generating accurate SQL query statements. The large language model can be a model built based on deep learning techniques, such as models based on the Transformer architecture, like BERT and GPT. These models, through pre-training on large amounts of data, can capture the complexity and diversity of natural language, thus performing well on specific tasks. This embodiment does not impose specific limitations on this.
[0105] Understandably, the actual database query statement is an SQL statement generated by the large language model based on the question, used to execute query operations in the database. During the conversion process, the large language model takes into account the contextual information of the question to ensure that the generated query statement accurately reflects the user's query intent.
[0106] In one feasible implementation, step S20 may include: parsing the question using a large language model to obtain question keywords and question structure; and performing SQL transformation on the question using the large language model based on the question keywords and question structure to obtain an actual database query statement.
[0107] It should be noted that when parsing a question, the large language model uses its internal natural language processing mechanism to identify key information and structure in the question, thereby constructing an SQL query statement that matches the semantics of the question.
[0108] Specifically, the large language model parses the question, understands the user's intent from the natural language query, identifies keywords, and analyzes the grammatical structure of the natural language query to identify key entities, predicates, and operators. In this way, it maps the information in the natural language to the database structure and generates actual database query statements that conform to SQL syntax based on the understood intent and the mapping results.
[0109] Step S30: Perform a data query based on the actual database query statement and the reference database query statement to obtain the actual query result and the reference query result.
[0110] It's important to note that data querying refers to the process of executing both actual and reference database query statements within a database. The actual query result is the result obtained from the database based on the SQL statement generated by the user using a large language model, while the reference query result is the result obtained from a predefined standard SQL statement. By comparing these two sets of results, the accuracy of the query statement generated by the large language model can be evaluated.
[0111] Step S40: Based on the reference database query statement, the actual database query statement, the reference query result, and the actual query result, the performance of the large language model is evaluated to obtain a model performance score.
[0112] It should be noted that the purpose of performance evaluation is to quantify the performance of the large language model in processing natural language queries and generating database query statements. In this implementation, performance evaluation is conducted from two dimensions: query statements and query results. This approach can more comprehensively reflect the model's performance and effectively improve the accuracy of performance evaluation.
[0113] Step S50: Optimize the large language model based on the model performance score and the target dataset to obtain the optimized large language model.
[0114] It should be noted that a pre-set score threshold is used to determine whether the large language model needs optimization. If the model's performance score is lower than the set threshold, it indicates that the model has shortcomings in processing natural language queries and generating database query statements, and needs adjustment and improvement.
[0115] Understandably, the optimization process may involve retraining the model using the target dataset, adjusting model parameters, etc., with the goal of improving the accuracy and efficiency of the model's SQL transformation. After optimization, the large language model will be able to more accurately understand the question's intent, generate higher-quality database query statements, and thus provide more reliable query results.
[0116] This embodiment provides a model performance optimization method. First, an initial dataset is obtained, and then a target dataset is obtained by expanding the initial dataset into a question using a large language model. The target dataset consists of a question and a corresponding reference database query statement. The large language model then converts the question into an actual database query statement. Data queries are performed based on the actual and reference database query statements to obtain actual query results and reference query results. The performance of the large language model is evaluated based on the reference query statement, the actual query statement, the reference query results, and the actual query results to obtain a model performance score. Finally, the large language model is optimized based on the model performance score and the target dataset to obtain an optimized large language model. By increasing the data richness of the dataset, the performance of the large language model can be accurately evaluated, thereby effectively improving the accuracy of the SQL statement conversion of the large language model.
[0117] In summary, this embodiment expands the initial dataset using a large language model to obtain a target dataset consisting of the question and the corresponding reference database query statement. This effectively improves the data richness of the dataset. Furthermore, the large language model converts the question into an actual database query statement, and combines this with the reference database query statement to perform result queries. Based on the actual query results and the reference query results, combined with the corresponding actual and reference database query statements, the performance of the large language model can be accurately evaluated. Therefore, the large language model can be optimized based on its performance score and the target dataset, effectively improving the accuracy of its SQL statement conversion. This overcomes the shortcomings of traditional datasets, such as incomplete data and incomplete coverage of business scenarios, which prevent accurate judgment of the accuracy of the large model's SQL conversion results. By increasing the data richness of the dataset, the performance of the large language model can be accurately evaluated, thereby effectively improving the accuracy of the large language model's SQL statement conversion.
[0118] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in Embodiment 1 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 3 Step S40 further includes steps S401-S403:
[0119] Step S401: Based on the reference database query statement and the actual database query statement, perform a performance evaluation on the large language model to obtain a first score.
[0120] It should be noted that, in this embodiment, the performance of the large language model is evaluated from the perspective of database query statements. This can reflect the accuracy of the model in generating query statements. The main focus is on the structural and syntactic correctness of the query statements, thereby locating the error points in the actual database query statements generated by the large model. Based on the error points, points are deducted from the preset score to obtain the first score.
[0121] In one feasible implementation, step S401 may include: obtaining first metadata of the reference database query statement; generating second metadata based on the actual database query statement; and performing a performance evaluation on the large language model based on the first metadata and the second metadata to obtain a first score.
[0122] It should be noted that metadata refers to additional information describing database query statements, such as table names, field names, data types, query conditions, etc. This embodiment does not impose specific restrictions on this.
[0123] Understandably, by comparing the first and second metadata, errors that may occur in the large language model when generating query statements can be accurately identified, such as missing indicators or syntax errors, thereby accurately generating the first score.
[0124] In one feasible implementation, the step of evaluating the performance of the large language model based on the first metadata and the second metadata to obtain a first score includes: performing a consistency comparison based on the first metadata and the second metadata; when the first metadata and the second metadata are consistent, using a preset score as the first score; when the first metadata and the second metadata are inconsistent, obtaining the difference data between the first metadata and the second metadata, and determining the first score based on the difference data.
[0125] It should be noted that the consistency comparison based on the primary and secondary metadata refers to comparing table names, field names, query conditions, etc., one by one in the primary and secondary metadata to ensure that the generated query statement is consistent with the standard query statement in terms of structure and content. If the two are completely consistent, it means that the query statement generated by the large language model is correct, and the preset full score can be used as the first score. If there are inconsistencies, the amount of points deducted is determined according to the severity of the differences, thus obtaining the first score. This evaluation method can ensure the objectivity and accuracy of the evaluation results.
[0126] It is understood that the preset score is the pre-set maximum score; in this embodiment, 10 points is used as the maximum score for explanation. The difference data refers to the portion of the second metadata that is inconsistent with the first metadata, including but not limited to inconsistencies in fields or query conditions.
[0127] In one feasible implementation, determining the first score based on the difference data specifically includes: determining the first error type of the actual database query statement based on the difference data; obtaining the score corresponding to the first error type; and determining the first score based on the score corresponding to the first error type and the preset score.
[0128] It should be noted that, based on the difference data, the error types appearing in the SLQ statements generated by the large language model are determined. In this embodiment, the errors that may exist in the SLQ statements generated by the large language model are classified, such as performance problems, missing indicators, syntax errors, missing sorting, and other error types.
[0129] Understandably, different error types correspond to different score deduction standards. For example, performance issues may deduct fewer points, while serious errors such as missing sorting may deduct more points. In this way, the error types of query statements generated by large language models can be quantitatively evaluated, resulting in a more accurate initial score. The quantitative standards could be one point deducted for performance issues, two points for missing metrics, three points for syntax errors, and four points for missing sorting, etc.
[0130] It is worth noting that this implementation uses a deduction method, subtracting the score corresponding to the error type from the preset full score to obtain the final score. This evaluation method, which deducts scores based on error type, can more accurately reflect the specific problems of the large language model when generating database query statements.
[0131] In one feasible implementation, before obtaining the first metadata of the reference database query statement, the method further includes: parsing the reference database query statement to generate an abstract syntax tree; and decomposing the abstract syntax tree into metadata to obtain the first metadata of the reference database query statement.
[0132] It's important to note that an Abstract Syntax Tree (AST) is a tree-like data structure used to represent the syntactic structure of a program. By parsing a query statement to generate an AST, we can gain a deeper understanding of the query's syntactic structure and logical relationships, thereby extracting more precise metadata information.
[0133] Understandably, in this implementation, the SQL parser parses the query statement of the reference database to generate an AST tree, and then the metadata of the AST tree is decomposed to obtain the first metadata containing detailed information such as table name, field name, data type, and query conditions. This can improve the accuracy of performance evaluation and ensure that the evaluation results can truly reflect the performance of the large language model when generating database query statements.
[0134] Step S402: Evaluate the performance of the large language model based on the reference query results and the actual query results to obtain a second score.
[0135] It should be noted that this implementation evaluates the performance of the large language model from the perspective of query results, indirectly assessing the model's performance in processing natural language queries and generating database query statements based on the accuracy of the query results. In this process, the primary focus is on the correctness and completeness of the query results to ensure that the model can accurately understand the question intent and generate high-quality database query statements.
[0136] Understandably, by comparing the reference query results with the actual query results, we can further pinpoint the errors in the actual database query statements generated by the large model. Similarly, based on these errors, we can deduct points from the preset score to obtain a second score.
[0137] In one feasible implementation, step S402 may include: determining the first number of query rows and the first number of query columns based on the reference query results; determining the second number of query rows and the second number of query columns based on the actual query results; and performing a performance evaluation on the large language model based on the first number of query rows, the first number of query columns, the second number of query rows, and the second number of query columns to obtain a second score.
[0138] It should be noted that the number of rows in the query results refers to the number of records in the query results, that is, how many data records are returned in the result set; the number of columns in the query results refers to the number of fields in the query results, that is, how many different attributes or dimensions are contained in the returned data structure.
[0139] Understandably, comparing the number of rows and columns in the query results ensures the objectivity and accuracy of the evaluation results, thus accurately obtaining the second score.
[0140] In one feasible implementation, the step of evaluating the performance of the large language model based on the first query row count, the first query column count, the second query row count, and the second query column count to obtain a second score includes: performing a consistency comparison based on the first query row count, the first query column count, the second query row count, and the second query column count; when the first query row count and the second query column count are consistent and the first query column count and the second query row count are consistent, using a preset score as the second score; when the first query row count and the second query column count are inconsistent and / or the first query column count and the second query row count are inconsistent, determining a second error type of the actual database query statement based on the reference query result and the actual query result, and determining a second score based on the second error type.
[0141] It should be noted that if the number of rows and columns in the query result is exactly the same as the reference query result, it means that the query statement generated by the large language model can accurately obtain the required data, that is, it means that the SQL statement generated by the large language model is consistent with the standard SQL statement. In this case, the preset full score can be used as the second score.
[0142] Understandably, if there is an inconsistency in the number of rows or columns, a second error type is determined based on the difference, and a second score is assigned based on this error type. For example, the error type could be determined based on the difference in query result generation speed, as generation speed reflects performance issues. The second score is then obtained by subtracting the score corresponding to the performance issue from the preset maximum score. This evaluation method ensures the objectivity and accuracy of the evaluation results while reflecting the model's efficiency in processing queries.
[0143] It is worth noting that in this implementation, a score of 10 is also used as the maximum score. Similarly, the errors that may exist in the SLQ statements generated by the large language model are categorized, such as performance issues, missing metrics, syntax errors, and missing sorting.
[0144] Specifically, when the number of rows in the first query is inconsistent with the number of columns in the second query and / or the number of columns in the first query is inconsistent with the number of rows in the second query, the query result dimension can be disregarded, and the model performance score can be determined solely by the consistency of metadata. This embodiment does not impose specific restrictions on this.
[0145] Step S403: Determine the model performance score based on the first score and the second score.
[0146] It should be noted that the first score and the second score are the scores for the database query statement and the query result dimension, respectively. The final model performance score can be obtained by weighting the first score and the second score. For example, the score weight for the database query statement can be set to 60%, and the score weight for the query result dimension can be set to 40%.
[0147] like Figure 3 As shown, Figure 3The overall flowchart for large-scale model performance evaluation is as follows: After the dataset construction process begins, dataset construction is carried out, including constructing complex scenario questions and answers. The large model determines whether the questions are ambiguous; if so, the complex scenario questions and answers are reconstructed; if not, the large model expands the questions and uses an SQL parser to form an AST tree, and performs metadata parsing on the AST tree. After the dataset construction is completed, SQL evaluation begins. The large model converts the questions in the dataset into SQL statements, executes the SQL statements generated by the large model and the standard SQL statements in the dataset, obtains the execution results and compares them. At the same time, question classification and quantification standards are constructed to determine whether the results are consistent. If the results are consistent, performance evaluation is performed to obtain the final score. If the results are inconsistent, the metadata of the SQL statements generated by the large model and the standard SQL statements in the dataset is compared to determine whether the metadata is consistent. If the metadata is consistent, performance evaluation is performed to obtain the final score; if the metadata is inconsistent, the differences are quantified based on the metadata comparison to obtain the final score.
[0148] In this embodiment, the performance of the large language model is evaluated from two dimensions: the database query statement and the query result. The model performance score is then determined by comprehensively considering the scores of different dimensions. By evaluating the performance of the large language model from multiple dimensions, the accuracy of the performance evaluation is effectively improved.
[0149] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the performance optimization method of the model in this application. Any simple modifications based on this technical concept are within the protection scope of this application.
[0150] This application also provides a model performance optimization device; please refer to... Figure 4 The model performance optimization device includes:
[0151] The expansion module 10 is used to obtain an initial dataset and expand the initial dataset into a target dataset using a large language model. The target dataset consists of a question and a corresponding reference database query statement.
[0152] The conversion module 20 is used to convert the problem into an actual database query statement through the large language model.
[0153] The query module 30 is used to perform data queries based on the actual database query statement and the reference database query statement to obtain the actual query results and the reference query results.
[0154] Evaluation module 40 is used to evaluate the performance of the large language model based on the reference database query statement, the actual database query statement, the reference query result, and the actual query result, and obtain a model performance score.
[0155] The optimization module 50 is used to optimize the large language model based on the model performance score and the target dataset to obtain the optimized large language model.
[0156] This embodiment provides a model performance optimization device. It acquires an initial dataset and expands the initial dataset into a target dataset using a large language model. The target dataset consists of a question and a corresponding reference database query statement. The large language model converts the question into an actual database query statement. Data queries are performed based on the actual and reference database query statements to obtain actual query results and reference query results. The performance of the large language model is evaluated based on the reference query statement, the actual query statement, the reference query results, and the actual query results to obtain a model performance score. The large language model is optimized based on the model performance score and the target dataset to obtain an optimized large language model. By increasing the data richness of the dataset, the performance of the large language model can be accurately evaluated, thereby effectively improving the accuracy of SQL statement conversion in the large language model.
[0157] In summary, this embodiment expands the initial dataset using a large language model to obtain a target dataset consisting of the question and the corresponding reference database query statement. This effectively improves the data richness of the dataset. Furthermore, the large language model converts the question into an actual database query statement, and combines this with the reference database query statement to perform result queries. Based on the actual query results and the reference query results, combined with the corresponding actual and reference database query statements, the performance of the large language model can be accurately evaluated. Therefore, the large language model can be optimized based on its performance score and the target dataset, effectively improving the accuracy of its SQL statement conversion. This overcomes the shortcomings of traditional datasets, such as incomplete data and incomplete coverage of business scenarios, which prevent accurate judgment of the accuracy of the large model's SQL conversion results. By increasing the data richness of the dataset, the performance of the large language model can be accurately evaluated, thereby effectively improving the accuracy of the large language model's SQL statement conversion.
[0158] Optionally, the evaluation module 40 is further configured to perform performance evaluation on the large language model based on the reference database query statement and the actual database query statement to obtain a first score; perform performance evaluation on the large language model based on the reference query result and the actual query result to obtain a second score; and determine the model performance score based on the first score and the second score.
[0159] Optionally, the evaluation module 40 is further configured to obtain first metadata of the reference database query statement; generate second metadata based on the actual database query statement; and perform performance evaluation on the large language model based on the first metadata and the second metadata to obtain a first score.
[0160] Optionally, the evaluation module 40 is further configured to perform a consistency comparison based on the first metadata and the second metadata; when the first metadata and the second metadata are consistent, a preset score is used as the first score; when the first metadata and the second metadata are inconsistent, difference data between the first metadata and the second metadata is obtained, and the first score is determined based on the difference data.
[0161] Optionally, the evaluation module 40 is further configured to determine a first error type of the actual database query statement based on the difference data; obtain a score corresponding to the first error type; and determine a first score based on the score corresponding to the first error type and the preset score.
[0162] Optionally, the evaluation module 40 is further configured to parse the reference database query statement to generate an abstract syntax tree; and to decompose the abstract syntax tree into metadata to obtain the first metadata of the reference database query statement.
[0163] Optionally, the evaluation module 40 is further configured to determine the first number of query rows and the first number of query columns based on the reference query results, and determine the second number of query rows and the second number of query columns based on the actual query results; and to perform performance evaluation on the large language model based on the first number of query rows, the first number of query columns, the second number of query rows, and the second number of query columns to obtain a second score.
[0164] Optionally, the evaluation module 40 is further configured to perform a consistency comparison based on the first query row count, the first query column count, the second query row count, and the second query column count; when the first query row count is consistent with the second query column count and the first query column count is consistent with the second query row count, a preset score is used as a second score; when the first query row count is inconsistent with the second query column count and / or the first query column count is inconsistent with the second query row count, a second error type of the actual database query statement is determined based on the reference query result and the actual query result, and a second score is determined based on the second error type.
[0165] Optionally, the expansion module 10 is further configured to perform ambiguity analysis on the questions in the initial dataset using a large language model to obtain ambiguity analysis results; when the ambiguity analysis results indicate that the questions are ambiguous, remove the questions and their corresponding answers from the initial dataset and re-execute the step of performing ambiguity analysis on the questions in the initial dataset to obtain ambiguity analysis results; when the ambiguity analysis results indicate that the questions are unambiguous, expand the questions using a large language model to obtain new questions; obtain the reference database query statement corresponding to the new questions; and update the initial dataset according to the new questions and the corresponding reference database query statement to obtain the expanded initial dataset.
[0166] Optionally, the conversion module 20 is further configured to parse the question using a large language model to obtain question keywords and question structure; and to perform SQL conversion on the question using the large language model based on the question keywords and question structure to obtain an actual database query statement.
[0167] The model performance optimization device provided in this application, employing the model performance optimization method described in the above embodiments, can solve the technical problem that traditional datasets suffer from incomplete data and incomplete coverage of business scenarios, leading to the inability to accurately determine the accuracy of SQL transformation results for large models. Compared with the prior art, the beneficial effects of the model performance optimization device provided in this application are the same as those of the model performance optimization method provided in the above embodiments, and other technical features in the model performance optimization device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0168] This application provides a model performance optimization device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the model performance optimization method in Embodiment 1 above.
[0169] The following is for reference. Figure 5The diagram illustrates a structural schematic of a model performance optimization device suitable for implementing embodiments of this application. The model performance optimization device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The model performance optimization device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0170] like Figure 5 As shown, the model performance optimization device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the model performance optimization device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. The communication device 1009 allows the model performance optimization device to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows a model performance optimization device with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0171] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0172] The model performance optimization device provided in this application, employing the model performance optimization method described in the above embodiments, can solve the technical problem that traditional datasets suffer from incomplete data and insufficient coverage of business scenarios, leading to the inability to accurately determine the accuracy of SQL transformation results for large models. Compared with the prior art, the beneficial effects of the model performance optimization device provided in this application are the same as those of the model performance optimization method provided in the above embodiments, and other technical features of this model performance optimization device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0173] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0174] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0175] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the model performance optimization method in the above embodiments.
[0176] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0177] The aforementioned computer-readable storage medium may be included in the model performance optimization device; or it may exist independently and not be assembled into the model performance optimization device.
[0178] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by a model performance optimization device, the model performance optimization device performs the following actions: It acquires an initial dataset and expands the initial dataset into a target dataset using a large language model, wherein the target dataset consists of a question and a corresponding reference database query statement; it converts the question into an actual database query statement using the large language model; it performs a data query based on the actual database query statement and the reference database query statement to obtain actual query results and reference query results; it evaluates the performance of the large language model based on the reference database query statement, the actual database query statement, the reference query results, and the actual query results to obtain a model performance score; and it optimizes the large language model based on the model performance score and the target dataset to obtain an optimized large language model.
[0179] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0180] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0181] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0182] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., computer programs) for executing the above-described model performance optimization method. This solves the technical problem that traditional datasets suffer from incomplete data and incomplete coverage of business scenarios, leading to the inability to accurately determine the accuracy of SQL transformation results for large models. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the model performance optimization method provided in the above embodiments, and will not be elaborated upon here.
[0183] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the model performance optimization method described above.
[0184] The computer program product provided in this application can solve the technical problem that traditional datasets have deficiencies such as incomplete data and insufficient coverage of business scenarios, which makes it impossible to accurately judge the accuracy of SQL transformation results for large models. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the model performance optimization method provided in the above embodiments, and will not be repeated here.
[0185] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
[0186] This invention discloses A1. A model performance optimization method, the method comprising:
[0187] An initial dataset is obtained, and the initial dataset is expanded into a target dataset by using a large language model. The target dataset consists of a question and a corresponding reference database query statement.
[0188] The problem is then transformed into a practical database query statement using the large language model.
[0189] Data is queried based on the actual database query statement and the reference database query statement to obtain the actual query result and the reference query result;
[0190] The performance of the large language model is evaluated based on the reference database query statement, the actual database query statement, the reference query result, and the actual query result to obtain the model performance score.
[0191] The large language model is optimized based on the model performance score and the target dataset to obtain the optimized large language model.
[0192] A2. As described in A1, the step of evaluating the performance of the large language model based on the reference database query statement, the actual database query statement, the reference query result, and the actual query result to obtain a model performance score includes:
[0193] The performance of the large language model is evaluated based on the reference database query statement and the actual database query statement to obtain a first score.
[0194] The performance of the large language model is evaluated based on the reference query results and the actual query results to obtain a second score.
[0195] The model performance score is determined based on the first score and the second score.
[0196] A3. As described in A2, the step of evaluating the performance of the large language model based on the reference database query statement and the actual database query statement to obtain a first score includes:
[0197] Obtain the first metadata of the query statement in the reference database;
[0198] Generate second metadata based on the actual database query statement;
[0199] The performance of the large language model is evaluated based on the first metadata and the second metadata to obtain a first score.
[0200] A4. As described in A3, the step of evaluating the performance of the large language model based on the first metadata and the second metadata to obtain a first score includes:
[0201] A consistency comparison is performed based on the first metadata and the second metadata;
[0202] When the first metadata and the second metadata are consistent, the preset score will be used as the first score;
[0203] When the first metadata and the second metadata are inconsistent, the difference data between the first metadata and the second metadata is obtained, and a first score is determined based on the difference data.
[0204] A5. As described in A4, the step of determining the first score based on the difference data includes:
[0205] Based on the discrepancy data, determine the first error type of the actual database query statement;
[0206] Obtain the score corresponding to the first error type;
[0207] The first score is determined based on the score corresponding to the first error type and the preset score.
[0208] A6. As described in A3, before obtaining the first metadata of the reference database query statement, the method further includes:
[0209] The query statement from the reference database is parsed to generate an abstract syntax tree;
[0210] Metadata decomposition is performed on the abstract syntax tree to obtain the first metadata of the reference database query statement.
[0211] A7. As described in A2, the step of evaluating the performance of the large language model based on the reference query results and the actual query results to obtain a second score includes:
[0212] The number of first query rows and the number of first query columns are determined based on the reference query results, and the number of second query rows and the number of second query columns are determined based on the actual query results.
[0213] The performance of the large language model is evaluated based on the number of rows in the first query, the number of columns in the first query, the number of rows in the second query, and the number of columns in the second query, to obtain a second score.
[0214] A8. As described in A6, the step of evaluating the performance of the large language model based on the first query row count, the first query column count, the second query row count, and the second query column count to obtain a second score includes:
[0215] A consistency comparison is performed based on the number of rows in the first query, the number of columns in the first query, the number of rows in the second query, and the number of columns in the second query.
[0216] When the number of rows in the first query is the same as the number of columns in the second query, and the number of columns in the first query is the same as the number of rows in the second query, the preset score will be used as the second score.
[0217] When the number of rows in the first query is inconsistent with the number of columns in the second query and / or the number of columns in the first query is inconsistent with the number of rows in the second query, the second error type of the actual database query statement is determined based on the reference query result and the actual query result, and the second score is determined based on the second error type.
[0218] A9. As described in A1, the step of expanding the initial dataset using a large language model to obtain the target dataset includes:
[0219] The questions in the initial dataset are subjected to ambiguity analysis using a large language model, and the ambiguity analysis results are obtained.
[0220] When the ambiguity analysis result indicates that the question is ambiguous, the question and its corresponding answer are removed from the initial dataset, and the step of performing ambiguity analysis on the questions in the initial dataset to obtain the ambiguity analysis result is re-executed.
[0221] When the ambiguity analysis result indicates that the question is unambiguous, the question is expanded using a large language model to obtain a new question;
[0222] Obtain the reference database query statement corresponding to the new problem;
[0223] The initial dataset is updated based on the new problem and the corresponding reference database query statement to obtain the expanded initial dataset.
[0224] A10. As described in A1, the step of converting the problem into an actual database query statement through the large language model includes:
[0225] The problem is analyzed using a large language model to obtain the problem keywords and problem structure;
[0226] The question is transformed into an SQL query statement by using a large language model based on the question keywords and the question structure.
[0227] The present invention also discloses B11. A model performance optimization device, the model performance optimization device comprising:
[0228] The expansion module is used to obtain an initial dataset and expand the initial dataset into a target dataset using a large language model. The target dataset consists of a question and a corresponding reference database query statement.
[0229] The conversion module is used to convert the problem into an actual database query statement using the large language model;
[0230] The query module is used to perform data queries based on the actual database query statement and the reference database query statement to obtain the actual query results and the reference query results;
[0231] The evaluation module is used to evaluate the performance of the large language model based on the reference database query statement, the actual database query statement, the reference query result, and the actual query result, and obtain the model performance score.
[0232] An optimization module is used to optimize the large language model based on the model performance score and the target dataset to obtain an optimized large language model.
[0233] B12. The apparatus as described in B11, wherein the evaluation module is further configured to perform performance evaluation on the large language model based on the reference database query statement and the actual database query statement, and obtain a first score;
[0234] The performance of the large language model is evaluated based on the reference query results and the actual query results to obtain a second score.
[0235] The model performance score is determined based on the first score and the second score.
[0236] B13. The apparatus as described in B12, wherein the evaluation module is further configured to obtain first metadata of the reference database query statement;
[0237] Generate second metadata based on the actual database query statement;
[0238] The performance of the large language model is evaluated based on the first metadata and the second metadata to obtain a first score.
[0239] B14. The apparatus as described in B13, wherein the evaluation module is further configured to perform a consistency comparison based on the first metadata and the second metadata;
[0240] When the first metadata and the second metadata are consistent, the preset score will be used as the first score;
[0241] When the first metadata and the second metadata are inconsistent, the difference data between the first metadata and the second metadata is obtained, and a first score is determined based on the difference data.
[0242] B15. The apparatus as described in B14, wherein the evaluation module is further configured to determine a first error type of the actual database query statement based on the difference data;
[0243] Obtain the score corresponding to the first error type;
[0244] The first score is determined based on the score corresponding to the first error type and the preset score.
[0245] B16. The apparatus as described in B13, wherein the evaluation module is further configured to parse the query statement of the reference database and generate an abstract syntax tree;
[0246] Metadata decomposition is performed on the abstract syntax tree to obtain the first metadata of the reference database query statement.
[0247] B17. The apparatus as described in B12, wherein the evaluation module is further configured to determine the first number of query rows and the first number of query columns based on the reference query result, and to determine the second number of query rows and the second number of query columns based on the actual query result;
[0248] The performance of the large language model is evaluated based on the number of rows in the first query, the number of columns in the first query, the number of rows in the second query, and the number of columns in the second query, to obtain a second score.
[0249] B18. The apparatus as described in B16, wherein the evaluation module is further configured to perform a consistency comparison based on the first query row count, the first query column count, the second query row count, and the second query column count;
[0250] When the number of rows in the first query is the same as the number of columns in the second query, and the number of columns in the first query is the same as the number of rows in the second query, the preset score will be used as the second score.
[0251] When the number of rows in the first query is inconsistent with the number of columns in the second query and / or the number of columns in the first query is inconsistent with the number of rows in the second query, the second error type of the actual database query statement is determined based on the reference query result and the actual query result, and the second score is determined based on the second error type.
[0252] The present invention also discloses C19. A model performance optimization device, the model performance optimization device comprising: a memory, a processor, and a model performance optimization program stored in the memory and executable on the processor, the model performance optimization program being configured to implement the model performance optimization method as described above.
[0253] The present invention also discloses D20. A storage medium storing a model performance optimization program, wherein the model performance optimization program, when executed by a processor, implements the model performance optimization method as described above.
Claims
1. A method for optimizing model performance, characterized in that, The method includes: An initial dataset is obtained, and the initial dataset is expanded into a target dataset by using a large language model. The target dataset consists of a question and a corresponding reference database query statement. The problem is then transformed into a practical database query statement using the large language model. Data is queried based on the actual database query statement and the reference database query statement to obtain the actual query result and the reference query result; The performance of the large language model is evaluated based on the reference database query statement, the actual database query statement, the reference query result, and the actual query result to obtain the model performance score. The large language model is optimized based on the model performance score and the target dataset to obtain the optimized large language model.
2. The method as described in claim 1, characterized in that, The performance evaluation of the large language model based on the reference database query statement, the actual database query statement, the reference query result, and the actual query result, to obtain a model performance score, includes: The performance of the large language model is evaluated based on the reference database query statement and the actual database query statement to obtain a first score. The performance of the large language model is evaluated based on the reference query results and the actual query results to obtain a second score. The model performance score is determined based on the first score and the second score.
3. The method as described in claim 2, characterized in that, The performance evaluation of the large language model based on the reference database query statement and the actual database query statement to obtain a first score includes: Obtain the first metadata of the query statement in the reference database; Generate second metadata based on the actual database query statement; The performance of the large language model is evaluated based on the first metadata and the second metadata to obtain a first score.
4. The method as described in claim 3, characterized in that, The step of evaluating the performance of the large language model based on the first metadata and the second metadata to obtain a first score includes: A consistency comparison is performed based on the first metadata and the second metadata; When the first metadata and the second metadata are consistent, the preset score will be used as the first score; When the first metadata and the second metadata are inconsistent, the difference data between the first metadata and the second metadata is obtained, and a first score is determined based on the difference data.
5. The method as described in claim 4, characterized in that, The step of determining the first score based on the difference data includes: Based on the discrepancy data, determine the first error type of the actual database query statement; Obtain the score corresponding to the first error type; The first score is determined based on the score corresponding to the first error type and the preset score.
6. The method as described in claim 3, characterized in that, Before obtaining the first metadata of the reference database query statement, the process also includes: The query statement from the reference database is parsed to generate an abstract syntax tree; Metadata decomposition is performed on the abstract syntax tree to obtain the first metadata of the reference database query statement.
7. The method as described in claim 2, characterized in that, The process of evaluating the performance of the large language model based on the reference query results and the actual query results to obtain a second score includes: The number of first query rows and the number of first query columns are determined based on the reference query results, and the number of second query rows and the number of second query columns are determined based on the actual query results. The performance of the large language model is evaluated based on the number of rows in the first query, the number of columns in the first query, the number of rows in the second query, and the number of columns in the second query, to obtain a second score.
8. A model performance optimization device, characterized in that, The model performance optimization device includes: The expansion module is used to obtain an initial dataset and expand the initial dataset into a target dataset using a large language model. The target dataset consists of a question and a corresponding reference database query statement. The conversion module is used to convert the problem into an actual database query statement using the large language model; The query module is used to perform data queries based on the actual database query statement and the reference database query statement to obtain the actual query results and the reference query results; The evaluation module is used to evaluate the performance of the large language model based on the reference database query statement, the actual database query statement, the reference query result, and the actual query result, and obtain the model performance score. An optimization module is used to optimize the large language model based on the model performance score and the target dataset to obtain an optimized large language model.
9. A model performance optimization device, characterized in that, The model performance optimization device includes: a memory, a processor, and a model performance optimization program stored in the memory and executable on the processor, the model performance optimization program being configured to implement the model performance optimization method as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium stores a model performance optimization program, which, when executed by a processor, implements the model performance optimization method as described in any one of claims 1 to 7.