Query statement generation model processing method and device and computer equipment

By training and optimizing the query statement generation model, the problem of low accuracy in converting natural language text into query statements is solved, achieving higher accuracy and efficiency, and is suitable for data generation in fields such as financial assistance.

CN118568202APending Publication Date: 2024-08-30CHINA CONSTRUCTION BANK +1

Patent Information

Application Number
CN202410825155.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

The existing large language models that convert natural language text into query statements have low accuracy and are difficult to meet the needs of practical applications.

Method used

By obtaining training samples and test samples, the query statement generation model is trained, and the quality of the predicted query statements is evaluated. When the preset quality conditions are not met, optimization is performed, model parameters are adjusted, and a target query statement generation model is built to improve accuracy.

Benefits of technology

It significantly improves the accuracy of converting natural language text into query statements, improves the performance and efficiency of the model, and is suitable for data generation scenarios in fields such as financial assistance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118568202A
    Figure CN118568202A
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence, and particularly discloses a query statement generation model processing method and device and computer equipment. The method comprises the steps of obtaining a first training sample and a test sample, wherein the first training sample comprises a natural language training text and a first target query statement; the test sample comprises a natural language test text; training a query statement generation model by using the first training sample, and generating a prediction query statement for the test sample by using an initial query statement generation model obtained by training; performing quality evaluation on the prediction query statement to obtain quality evaluation information; when the quality evaluation information does not meet the preset quality condition, optimizing the predicted query statement to obtain a second target query statement; and constructing a second training sample by utilizing the natural language test text and the second target query statement so as to adjust model parameters of the initial query statement generation model. By adopting the method, the accuracy of converting the natural language text into the query statement can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a query statement generation model processing method, device and computer equipment. Background Art

[0002] With the rapid development of artificial intelligence and big data technologies, the new generation of artificial intelligence technology represented by large language models has brought revolutionary breakthroughs. How to reconstruct and upgrade traditional products and businesses based on large language models has become a hot research topic.

[0003] Converting natural language text to query statements is one of the hottest research directions in natural language processing. The diversity of human natural language expressions is very large, and traditional methods are difficult to deal with well. Large language models have powerful emergent capabilities, a universal understanding of natural language, and extremely high cross-domain capabilities and flexibility. Therefore, the method of converting natural language text to query statements based on large language models has become a hot research direction.

[0004] However, in the related art, large language models used to convert natural language text into query statements often have the problem of low accuracy. Summary of the invention

[0005] Based on this, it is necessary to provide a query statement generation model processing method, device, computer equipment, computer-readable storage medium and computer program product that can improve the accuracy of converting natural language text into query statements in response to the above technical problems.

[0006] In a first aspect, the present application provides a query statement generation model processing method, comprising:

[0007] Obtaining a first training sample and a test sample, wherein the first training sample includes a natural language training text and a first target query sentence corresponding to the natural language training text; and the test sample includes a natural language test text;

[0008] Using the first training sample to train a query statement generation model, and using the initial query statement generation model obtained through training to generate a predicted query statement for the test sample;

[0009] Performing a quality assessment on the predicted query statement to obtain quality assessment information corresponding to the predicted query statement;

[0010] When the quality assessment information corresponding to the predicted query statement does not meet the preset quality condition, optimizing the predicted query statement to obtain a second target query statement corresponding to the natural language test text;

[0011] A second training sample is constructed using the natural language test text and the second target query statement, and a model parameter of the initial query statement generation model is adjusted using the second training sample to obtain a target query statement generation model.

[0012] In one embodiment, the natural language training text is a historical assistance letter text, and the first target query statement is a query statement obtained by manually converting the historical assistance letter text into a query statement.

[0013] In one embodiment, the using the first training sample to train a query statement generation model includes:

[0014] Optimizing the first target query statement to obtain an optimized first target query statement;

[0015] Inputting the natural language training text into a query statement generation model to be trained to obtain a predicted query statement corresponding to the natural language training text;

[0016] The query statement generation model is trained based on the predicted query statement corresponding to the natural language training text and the optimized first target query statement.

[0017] In one embodiment, the test sample also includes a test query statement corresponding to the natural language test text; and the quality assessment of the predicted query statement to obtain quality assessment information corresponding to the predicted query statement includes:

[0018] Querying a preset database using the test query statement to obtain a first query result;

[0019] Querying the preset database using the prediction query statement to obtain a second query result;

[0020] The first query result and the second query result are compared, and quality evaluation information of the predicted query statement is determined according to the obtained comparison result.

[0021] In one embodiment, the performing quality assessment on the predicted query statement to obtain quality assessment information corresponding to the predicted query statement includes:

[0022] Inputting the prediction query sentence into a trained natural language generation model to obtain a generated natural language prediction text;

[0023] Determining text similarity between the natural language prediction text and the natural language test text;

[0024] Based on the text similarity between the natural language prediction text and the natural language test text, quality assessment information of the predicted query statement is determined.

[0025] In one embodiment, the performing quality assessment on the predicted query statement to obtain quality assessment information corresponding to the predicted query statement includes:

[0026] Sending the test sample and the prediction query statement to multiple expert terminals;

[0027] receiving quality assessment scores returned by the plurality of expert terminals;

[0028] An average value of multiple quality assessment scores is calculated, and an average value of multiple quality assessment scores is calculated, and the calculated average value of the quality assessment scores is determined as the quality assessment information corresponding to the predicted query statement.

[0029] In one embodiment, the method further comprises:

[0030] Acquire the text of the to-be-processed assistance letter, input the text of the assistance letter into the target query statement generation model, and obtain a conversion query statement corresponding to the text of the assistance letter;

[0031] Based on the conversion query statement, a preset database is queried to obtain the reporting data corresponding to the text of the cooperative investigation letter.

[0032] In a second aspect, the present application also provides a query statement generation model processing device, comprising:

[0033] A sample acquisition module, configured to acquire a first training sample and a test sample, wherein the first training sample includes a natural language training text and a first target query sentence corresponding to the natural language training text; and the test sample includes a natural language test text;

[0034] A model training module, used to train a query statement generation model using the first training sample, and to generate a prediction query statement for the test sample using an initial query statement generation model obtained through training;

[0035] A quality assessment module, used to perform quality assessment on the prediction query statement and obtain quality assessment information corresponding to the prediction query statement;

[0036] A query statement optimization module, configured to optimize the predicted query statement when the quality evaluation information corresponding to the predicted query statement does not meet a preset quality condition, and obtain a second target query statement corresponding to the natural language test text;

[0037] The parameter adjustment module is used to construct a second training sample using the natural language test text and the second target query statement, and adjust the model parameters of the initial query statement generation model using the second training sample to obtain a target query statement generation model.

[0038] In one embodiment, the natural language training text is a historical assistance letter text, and the first target query statement is a query statement obtained by manually converting the historical assistance letter text into a query statement.

[0039] In one of the embodiments, the model training module is also used to optimize the first target query statement to obtain an optimized first target query statement; input the natural language training text into the query statement generation model to be trained to obtain a predicted query statement corresponding to the natural language training text; and train the query statement generation model based on the predicted query statement corresponding to the natural language training text and the optimized first target query statement.

[0040] In one of the embodiments, the test sample also includes a test query statement corresponding to the natural language test text; the quality assessment module is further used to: use the test query statement to query a preset database to obtain a first query result; use the prediction query statement to query the preset database to obtain a second query result; compare the first query result and the second query result, and determine the quality assessment information of the prediction query statement based on the comparison result obtained.

[0041] In one of the embodiments, the quality assessment module is further used to: input the predicted query statement into a trained natural language generation model to obtain a generated natural language predicted text; determine the text similarity between the natural language predicted text and the natural language test text; and determine quality assessment information of the predicted query statement based on the text similarity between the natural language predicted text and the natural language test text.

[0042] In one of the embodiments, the quality assessment module is further used to: send the test sample and the predictive query statement to multiple expert terminals; receive quality assessment scores returned by the multiple expert terminals; calculate the average of the multiple quality assessment scores, and determine the calculated average of the quality assessment scores as the quality assessment information corresponding to the predictive query statement.

[0043] In one of the embodiments, the device also includes: a letter text conversion module, which is used to obtain the cooperation letter text to be processed, input the cooperation letter text into the target query statement generation model, and obtain a conversion query statement corresponding to the cooperation letter text; based on the conversion query statement, query a preset database to obtain the reporting data corresponding to the cooperation letter text.

[0044] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned query statement generation model processing method when executing the computer program.

[0045] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the above-mentioned query statement generation model processing method are implemented.

[0046] In a fifth aspect, the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the above-mentioned query statement generation model processing method.

[0047] The query statement generation model processing method, device, computer equipment, storage medium and computer program product described above, after obtaining the first training sample and the test sample, first use the training sample to train the query statement generation model, after obtaining the initial query statement generation model, the initial query statement generation model can be used to generate a predicted query statement for the test sample, and then the predicted query statement is quality evaluated to obtain quality evaluation information corresponding to the predicted query statement, the quality evaluation information can reflect the accuracy of the initial query statement generation model, when the quality evaluation information corresponding to the predicted query statement does not meet the preset quality conditions, it means that the accuracy of the initial query statement generation model is low, the predicted query statement can be further optimized to obtain a second target query statement corresponding to the natural language test text, and then the natural language test text and the second target query statement can be used to construct a second training sample, so as to obtain a second training sample with better quality, and the model parameters of the initial query statement generation model can be adjusted by using the second training sample, so as to improve the accuracy of the model, thereby obtaining a target query statement generation model with higher accuracy, and when the natural language text is converted into a query statement by using the target query statement generation model, the accuracy of the generated query statement can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0049] FIG1 is an application environment diagram of a query statement generation model processing method according to an embodiment;

[0050] Figure 2 A flowchart of a query statement generation model processing method in one embodiment;

[0051] Figure 3 A schematic diagram of a flow chart of steps for training a query statement generation model using a first training sample in one embodiment;

[0052] Figure 4 A schematic diagram of a flow chart of steps for performing quality assessment on a predicted query statement in one embodiment;

[0053] Figure 5 A schematic diagram of a process of training a model in one embodiment;

[0054] Figure 6 A schematic diagram of a process of model tuning in one embodiment;

[0055] Figure 7 A schematic diagram of a process for generating SQL statements in one embodiment;

[0056] FIG8 is a structural block diagram of a query statement generation model processing device in one embodiment;

[0057] FIG9 is a diagram showing the internal structure of a computer device in one embodiment;

[0058] FIG. 10 is a diagram showing the internal structure of a computer device in another embodiment. DETAILED DESCRIPTION

[0059] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0060] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the acquisition, transmission, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.

[0061] It should also be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.

[0062] The query statement generation model processing method provided in the embodiment of the present application can be applied to the application environment shown in Figure 1. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, the terminal 102 can be but is not limited to various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.

[0063] In the query statement generation model processing method provided in the embodiment of the present application, the execution subject of each step can be a computer device, and a computer device refers to an electronic device with data calculation, processing and storage capabilities. Taking the application environment shown in Figure 1 as an example, the query statement generation model processing method can be executed by the terminal 102 alone, or by the server 104 alone, or by the terminal 102 and the server 104 interacting and cooperating to execute, and this application does not limit this.

[0064] Taking the server 104 executing alone as an example, the server can obtain a first training sample and a test sample, the first training sample includes a natural language training text and a first target query statement corresponding to the natural language training text; the test sample includes a natural language test text, the first training sample is used to train a query statement generation model, and the initial query statement generation model obtained by training is used to generate a predictive query statement for the test sample, and the predictive query statement is quality evaluated to obtain quality evaluation information corresponding to the predictive query statement. When the quality evaluation information corresponding to the predictive query statement does not meet the preset quality conditions, the predictive query statement is optimized to obtain a second target query statement corresponding to the natural language test text, the natural language test text and the second target query statement are used to construct a second training sample, the second training sample is used to adjust the model parameters of the initial query statement generation model, and the target query statement generation model is obtained.

[0065] In an exemplary embodiment, Figure 2 As shown, a query statement generation model processing method is provided, and the method is applied to the server 104 in FIG. 1 as an example for description, including the following steps 202 to 210. Among them:

[0066] Step 202: Obtain a first training sample and a test sample.

[0067] The first training sample includes a natural language training text and a first target query statement corresponding to the natural language training text. The test sample includes a natural language test text. The natural language training text is a natural language text included in the first training sample. The natural language text may be a text that describes the query requirement in natural language. For example, the natural language text may be a financial investigation text. The first target query statement is an SQL (Structured Query Language) statement obtained by converting the natural language training text. The SQL statement is a database query and programming language used to access data and query, update and manage database systems. The natural language test text is the natural language text included in the test sample. For example, the test sample may only include the natural language test text. Or in some other embodiments, the test sample may also include a query statement corresponding to the natural language test text, that is, an SQL statement obtained by converting the natural language test text.

[0068] Specifically, the server can obtain a first training sample and a test sample, and then use the first training sample and the test sample to process the query statement generation model. It is understandable that the number of the first training sample and the test sample can be set as needed.

[0069] Exemplarily, the server may obtain the first training sample and the test sample from a database. Alternatively, in some other embodiments, the server may also obtain the first training sample and the test sample from other computer devices.

[0070] Exemplarily, the test sample may be a natural language text that actually needs to be converted.

[0071] Step 204: Use the first training sample to train the query statement generation model, and use the initial query statement generation model obtained through the training to generate a predicted query statement for the test sample.

[0072] Among them, the query statement generation model can be a machine learning model for converting natural language text into query statements. The machine learning model can be a large language model (LLM). Large language models (English: Large Language Models) are one of the applications of computer deep learning. It attempts to simulate the working method of the human brain and create artificial neural networks to process data. There is no need to directly program the computer to complete the task, but to find hidden patterns or rules through learning the data, and then use these rules to predict new and unknown data. It has great advantages in the fields of image recognition, speech recognition and natural language processing, and greatly improves the processing efficiency of such unstructured data. Exemplarily, the query statement generation model can be a large language model based on the transformer architecture. The transformer architecture is an encoder-decoder model for seq2seq (sequence to sequence), which is mainly composed of input embedding, position encoding, multiple encoder and decoder layers, and output linear layers and softmax layers.

[0073] Specifically, the server can input the natural language training text in the first training sample into the query statement generation model to be trained, output the query statement through the query language generation model, and then train the query statement generation model based on the difference between the query statement output by the query language generation model and the first target query statement included in the first training sample. When the training is completed, the initial query statement generation model is obtained.

[0074] Furthermore, the server can use the initial query statement generation model to generate a predicted query statement for the test sample, that is, convert the natural language test text contained in the test sample to obtain a predicted query statement corresponding to the natural language test text, which is also a SQL statement.

[0075] Step 206: perform quality assessment on the predicted query statement to obtain quality assessment information corresponding to the predicted query statement.

[0076] The quality assessment information is information used to characterize the quality of the predicted query statement, and the quality assessment information may specifically be a quality grade or a quality score.

[0077] Specifically, the server may perform a quality assessment on the predicted query statement, thereby obtaining quality assessment information corresponding to the predicted query statement.

[0078] Step 208: When the quality evaluation information corresponding to the predicted query statement does not meet the preset quality condition, the predicted query statement is optimized to obtain a second target query statement corresponding to the natural language test text.

[0079] The preset quality condition is a condition used to determine whether the quality meets the requirements, for example, the quality level can reach a preset level or the quality score is greater than a preset score threshold.

[0080] Specifically, after obtaining the quality assessment information corresponding to the predicted query statement, the server determines whether the quality assessment information meets the preset quality conditions. If so, it can be said that the quality of the predicted query statement is good. If not, it can be said that the quality of the predicted query statement is poor. The quality of the predicted query statement can indirectly indicate that the quality of the initial query statement generation model obtained through training is good.

[0081] Furthermore, the server may optimize the predicted query statement that does not meet the preset quality condition, and obtain a second target query statement corresponding to the natural language test text corresponding to the predicted query statement. Exemplarily, the optimization of the predicted query statement may be that the server may send the predicted query statement that does not meet the preset quality condition and its corresponding natural language test text to a preset terminal, and a technician at the preset terminal may manually modify the predicted query statement according to the natural language test text.

[0082] For example, when the proportion of predicted query statements that meet preset quality conditions in the predicted query statements generated for multiple test samples exceeds the proportion threshold, it can be said that the quality of the initial query statement generation model obtained through training is good. At this time, the server can directly use the initial query statement generation model obtained through training as the target query statement generation model. The target query statement generation model can be applied to actual business scenarios to convert the natural language text to be processed to obtain the corresponding SQL statement.

[0083] Step 210: construct a second training sample using the natural language test text and the second target query statement, and adjust the model parameters of the initial query statement generation model using the second training sample to obtain the target query statement generation model.

[0084] Specifically, the server can use the natural language test text and the second target query statement to construct a second training sample, and then input the natural language test text in the second training sample into the initial query statement generation model to obtain the query statement output by the initial query statement generation model, and then adjust the model parameters of the initial query statement generation model according to the difference between the query statement and the second target query statement, so as to obtain the target query statement generation model.

[0085] Exemplarily, the model parameters can be adjusted multiple times during the training process until the stop condition is met to obtain the optimal target query statement generation model. The model parameter adjustment is an iterative process. Specifically, after each parameter adjustment, the query statement generation model obtained by the adjustment can be used to obtain test samples again, and then the query statement generation model obtained by the adjustment can be used to generate prediction query statements for these test samples, and then the prediction query statements are again evaluated for quality to obtain quality evaluation information corresponding to the prediction query statements. When the quality evaluation information corresponding to the prediction query statements does not meet the preset quality conditions, the prediction query statements are optimized, and the training samples are constructed by the optimized prediction query statements to adjust the model parameters again. The stopping condition can be that the number of iterations reaches the preset number, or the quality evaluation information of the prediction sample no longer changes.

[0086] In the above-mentioned query statement generation model processing method, after obtaining the first training sample and the test sample, the query statement generation model is first trained using the training sample. After obtaining the initial query statement generation model, the initial query statement generation model can be used to generate a predicted query statement for the test sample, and then the predicted query statement is quality evaluated to obtain quality evaluation information corresponding to the predicted query statement. The quality evaluation information can reflect the accuracy of the initial query statement generation model. When the quality evaluation information corresponding to the predicted query statement does not meet the preset quality conditions, it means that the accuracy of the initial query statement generation model is low. The predicted query statement can be further optimized to obtain a second target query statement corresponding to the natural language test text. Then, the natural language test text and the second target query statement can be used to construct a second training sample, so as to obtain a second training sample with better quality. The model parameters of the initial query statement generation model can be adjusted using the second training sample to improve the accuracy of the model, thereby obtaining a target query statement generation model with higher accuracy. When the natural language text is converted into a query statement using the target query statement generation model, the accuracy of the generated query statement can be improved.

[0087] In an exemplary embodiment, the natural language training text is a historical assistance letter text, and the first target query statement is a query statement obtained by manually converting the historical assistance letter text into a query statement.

[0088] Specifically, the text of historical investigation letters refers to the text of investigation letters within the historical time period. The text of investigation letters is a financial institution's response to the financial investigation notice of the competent national authority. It extracts customer data and transaction data that meet specific characteristics according to the content of the notice, and promptly feeds back the data to the competent authority. It has higher requirements for the accuracy of extracted data and the timeliness of reported data, and is the main means for financial institutions at all levels to meet local regulatory requirements. The first target query statement is a query statement obtained by manually converting the historical investigation letter text into a query statement, that is, the first target query statement is a query statement manually generated after manually analyzing the investigation letter text.

[0089] In the above embodiment, the natural language training text is the text of historical cooperative investigation letters, so the query statement generation model processing method of the present application can be used in the financial cooperative investigation data generation scenario to improve the generation efficiency and accuracy of financial cooperative investigation data.

[0090] In an exemplary embodiment, the method also includes: obtaining the text of the cooperation letter to be processed, inputting the cooperation letter text into the target query statement generation model, and obtaining a conversion query statement corresponding to the cooperation letter text; querying a preset database based on the conversion query statement to obtain the reporting data corresponding to the cooperation letter text.

[0091] The data submitted to the investigation letter are the financial investigation data submitted to the competent national authorities. The competent national authorities here can be the financial regulatory agencies at all levels stationed in the local areas by the People's Bank of China and the State Financial Supervision and Administration Bureau, as well as the public security, procuratorate, courts and other political and legal institutions at all levels.

[0092] Specifically, in the present application, since the natural language training text in the first training sample is a historical cooperation letter text, the target query statement generation model obtained through training can be used to generate query statements for the cooperation letter text to be processed. Specifically, the server can input the cooperation letter text to be processed into the target query statement generation model to obtain the conversion query statement corresponding to the cooperation letter text, and then execute the conversion query statement to obtain the reporting data corresponding to the cooperation letter text.

[0093] In the above embodiment, the content of the cooperation letter can be directly understood through big language artificial intelligence technology, without organizing a large number of professionals to conduct analysis, thereby improving the efficiency of generating reported data.

[0094] In an exemplary embodiment, Figure 3 As shown, in the above step S204, using the first training sample to train the query statement generation model includes:

[0095] Step 302: Optimize the first target query statement to obtain an optimized first target query statement.

[0096] Specifically, optimizing SQL statements is essentially to reduce the execution time of SQL statements, thereby improving query efficiency. In this embodiment, in order to further improve the performance of the model and make the generated SQL statements of better quality, the first target query statement included in the first training sample can be optimized to obtain an optimized first target query statement, and the optimized first target query statement is used for model training.

[0097] Exemplarily, the SQL statement is optimized, including but not limited to the following methods:

[0098] 1. Find the SQL statements that take a long time to execute and consume a lot of resources. For example, for MySQL database, you can obtain them from the slow query log, and for Oracle database, you can view the AWR report.

[0099] 2. Analyze the execution plans of the SQL statements with poor performance obtained above, find the parts with high overhead in the execution plans, and evaluate whether the execution plans are reasonable and whether they need to be adjusted.

[0100] 3. For the parts of the execution plan with high overhead, take corresponding measures to reduce the execution overhead and shorten the execution time, such as the following:

[0101] (1) If an incorrect execution plan is generated due to inaccurate statistical information, you need to collect the statistical information again first;

[0102] (2) If there is a problem with the SQL statement, the SQL statement can be appropriately rewritten without changing the business logic;

[0103] (3) For unnecessary full table scans or sorts, you can eliminate them by creating appropriate indexes;

[0104] (4) If the execution plan of the SQL statement is unstable for some reason, use a hint to fix the execution plan of the SQL statement if conditions permit;

[0105] (5) If the execution overhead is high and the execution time is long due to unreasonable table or index settings, the table or index should be redesigned. For example, if the number of records in the table is too large, exceeding 100 million, you should consider splitting the table into separate databases.

[0106] (6) Consider adopting parallel execution for parts that can be executed in parallel;

[0107] (7) If the inefficient execution of SQL statements is caused by unreasonable business design, you should consider modifying the business logic.

[0108] Step 304: input the natural language training text into the query statement generation model to be trained to obtain a predicted query statement corresponding to the natural language training text.

[0109] Step 306 , training a query statement generation model based on the predicted query statement corresponding to the natural language training text and the optimized first target query statement.

[0110] Specifically, the server can input the natural language training text in the first training sample into the query statement generation model to be trained, obtain the predicted query statement corresponding to the natural language training text, and then perform supervised training on the query statement generation model to be trained based on the difference between the predicted query statement and the optimized first target query statement. When the training is completed, the initial query statement generation model is obtained.

[0111] In this embodiment, by optimizing the first target query statement in the first training sample, a training sample with better quality can be obtained, so that the performance of the query statement generation model obtained through training is better, and the generated query statement is more efficient when used for query.

[0112] In an exemplary embodiment, the test sample also includes a test query statement corresponding to the natural language test text; a quality assessment is performed on the predicted query statement to obtain quality assessment information corresponding to the predicted query statement, including: using the test query statement to query a preset database to obtain a first query result; using the predicted query statement to query the preset database to obtain a second query result; comparing the first query result and the second query result, and determining the quality assessment information of the predicted query statement based on the comparison result obtained.

[0113] The preset database is the database where the data to be queried when executing the query statement is located.

[0114] Specifically, in this embodiment, the server can execute the test query statement and the prediction query statement respectively, that is, use the test query statement and the prediction query statement to query the preset database respectively, and obtain the first query result corresponding to the test query statement and the second query result corresponding to the prediction query statement respectively, and then compare the two query results to obtain a comparison result. The comparison result can indicate the difference data of the second query result corresponding to the prediction query statement relative to the first query result, and then determine the quality assessment information of the prediction query statement based on the difference data.

[0115] Exemplarily, the server may further determine the proportion of the difference data in the second query result, and determine the quality assessment information of the predicted query statement according to the proportion. Specifically, the proportion may be divided into multiple numerical ranges in advance, each numerical range corresponds to a different quality level, and the larger the numerical value of the proportion, the lower the quality level. After obtaining the proportion of the difference data in the second query result, the server may determine the numerical range to which the proportion belongs, and determine the quality level corresponding to the numerical range as the quality assessment information of the predicted query statement.

[0116] In the above embodiment, since the test sample also includes a test query statement corresponding to the natural language test text, the test query statement and the prediction query statement can be used to query the preset database respectively, and the quality assessment information can be determined by comparing the query results, which can improve the efficiency and accuracy of quality assessment.

[0117] In an exemplary embodiment, referring to Figure 4 , perform quality assessment on the predicted query statement, and obtain quality assessment information corresponding to the predicted query statement, including:

[0118] Step 402: input the prediction query statement into the trained natural language generation model to obtain the generated natural language prediction text.

[0119] The natural language generation model is a machine learning model that can generate corresponding natural language text according to the query statement. The trained natural language generation model can be obtained by supervised training. The trained natural language generation model can be a large language model.

[0120] Specifically, the server may input the predicted query statement into a trained natural language generation model, and generate a natural language prediction text corresponding to the predicted query statement through the natural language generation model.

[0121] Step 404, determining the text similarity between the natural language prediction text and the natural language test text.

[0122] Step 406: Determine quality assessment information of the predicted query statement based on the text similarity between the natural language prediction text and the natural language test text.

[0123] Specifically, the server can calculate the text similarity between the natural language prediction text and the natural language test text, and then determine the quality assessment information of the predicted query sentence based on the conversion relationship between the text similarity and the quality assessment information. The text similarity calculation can adopt the existing text similarity calculation method, for example, the edit distance can be calculated, and this application does not limit the text similarity calculation method.

[0124] Exemplarily, the server can directly determine the quality score based on the text similarity, and the quality score is positively correlated with the text similarity. Or in some other embodiments, the server can pre-divide the possible values ​​of the text similarity into multiple value ranges, and set a corresponding quality level for each value range, and the larger the value of the value range, the higher the corresponding quality level, so that when determining the quality evaluation information of the predicted query statement, the server can first determine the value range to which the text similarity between the natural language predicted text and the natural language test text belongs, and then determine the quality level corresponding to the value range as the quality evaluation information of the predicted query statement.

[0125] In the above embodiment, by inputting the predicted query statement into the trained natural language generation model, a generated natural language predicted text is obtained, and then based on the text similarity between the natural language predicted text and the natural language test text, the quality assessment information of the predicted query statement can be determined, thereby improving the quality assessment efficiency and accuracy.

[0126] In an exemplary embodiment, a quality assessment is performed on a predictive query statement to obtain quality assessment information corresponding to the predictive query statement, including: sending a test sample and a predictive query statement to multiple expert terminals; receiving quality assessment scores returned by the multiple expert terminals; calculating an average of the multiple quality assessment scores, and determining the calculated average of the quality assessment scores as the quality assessment information corresponding to the predictive query statement.

[0127] Specifically, in this embodiment, the predictive query statement generated by the model can be submitted to experts for evaluation and scoring, that is, the server can send test samples and predictive query statements to multiple expert terminals. After the experts at each expert terminal score the corresponding predictive query statement based on the test samples, the server can return the quality assessment score to the server through the expert terminal. After receiving the quality assessment scores returned by multiple expert terminals, the server calculates the average of the multiple quality assessment scores, and determines the calculated average of the quality assessment scores as the quality assessment information corresponding to the predictive query statement.

[0128] In this embodiment, since the quality assessment scores of multiple expert terminals can be obtained and the average value can be calculated, relatively accurate quality assessment information can be obtained, thereby improving the accuracy of quality assessment.

[0129] In a specific embodiment, the query statement generation model processing method of the present application can be applied to a financial investigation application scenario. In this application scenario, the query statement generation model processing method of the present application specifically includes:

[0130] 1) Train the model. Reference Figure 5, which is a schematic diagram of the model training process. Bank staff can submit cooperative investigation letters, SQL statements and data for model training to the server. The server can be deployed with an artificial intelligence system. A large language model with an open source transformer architecture is built in the system. The system can use the received data to perform supervised learning on the large language model to obtain a trained model that can process cooperative investigation letters (i.e., the initial query statement generation model mentioned above).

[0131] 2) Model tuning. Reference Figure 6 , is a schematic diagram of the model tuning process. Bank staff submit the inquiry letter for model tuning to the server. The artificial intelligence system inputs the inquiry letter into the trained transformer model, generates the corresponding SQL statement, and then submits the SQL statement to the expert terminal. The experts at the expert terminal score the SQL. If the score fails, the SQL statement is modified and the model is trained again and the parameters are adjusted. If the score passes, the expert review model can be further used to determine whether the model meets the standards. If so, the trained and adjusted transformer model can be obtained.

[0132] 3) Generate SQL statements through the model. Figure 7 , which is a schematic diagram of the process of generating SQL statements. Bank staff can submit pending cooperative investigation letters to the server. The artificial intelligence system can input the pending cooperative investigation letters into the trained and adjusted transformer model to generate SQL statements, and then execute the SQL statements to obtain financial cooperative investigation data.

[0133] In this embodiment, the content of the cooperation letter can be directly understood through big language artificial intelligence technology without organizing a large number of professionals to analyze it. In addition, the SQL statements generated by the big model trained based on historical data can directly adapt to the data model of a specific bank, and can be directly run to obtain the data to be reported. The SQL generated by the big model to extract data can maintain consistency with the data reported historically, ensuring that each report has a unified caliber. In addition, the use of a big language model can also significantly shorten the reporting cycle and improve the quality of the reported data.

[0134] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0135] Based on the same inventive concept, the embodiment of the present application also provides a query statement generation model processing device for implementing the query statement generation model processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more query statement generation model processing device embodiments provided below can refer to the limitations of the query statement generation model processing method above, and will not be repeated here.

[0136] In an exemplary embodiment, as shown in FIG8 , a query statement generation model processing device 800 is provided, comprising:

[0137] The sample acquisition module 802 is used to acquire a first training sample and a test sample, wherein the first training sample includes a natural language training text and a first target query sentence corresponding to the natural language training text; and the test sample includes a natural language test text;

[0138] A model training module 804 is used to train a query statement generation model using the first training sample, and to generate a prediction query statement for a test sample using the initial query statement generation model obtained through training;

[0139] The quality assessment module 806 is used to perform quality assessment on the predicted query statement and obtain quality assessment information corresponding to the predicted query statement;

[0140] A query statement optimization module 808, configured to optimize the predicted query statement when the quality evaluation information corresponding to the predicted query statement does not meet the preset quality condition, and obtain a second target query statement corresponding to the natural language test text;

[0141] The parameter adjustment module 810 is used to construct a second training sample using the natural language test text and the second target query statement, and adjust the model parameters of the initial query statement generation model using the second training sample to obtain the target query statement generation model.

[0142] In the above-mentioned query statement generation model processing device, after obtaining the first training sample and the test sample, the query statement generation model is first trained using the training sample. After obtaining the initial query statement generation model, the initial query statement generation model can be used to generate a predicted query statement for the test sample, and then the predicted query statement is quality evaluated to obtain quality evaluation information corresponding to the predicted query statement. The quality evaluation information can reflect the accuracy of the initial query statement generation model. When the quality evaluation information corresponding to the predicted query statement does not meet the preset quality conditions, it means that the accuracy of the initial query statement generation model is low. The predicted query statement can be further optimized to obtain a second target query statement corresponding to the natural language test text. Then, the natural language test text and the second target query statement can be used to construct a second training sample, so as to obtain a second training sample with better quality. The model parameters of the initial query statement generation model can be adjusted using the second training sample to improve the accuracy of the model, thereby obtaining a target query statement generation model with higher accuracy. When the natural language text is converted into a query statement using the target query statement generation model, the accuracy of the generated query statement can be improved.

[0143] In one embodiment, the natural language training text is a historical assistance letter text, and the first target query statement is a query statement obtained by manually converting the historical assistance letter text into a query statement.

[0144] In one of the embodiments, the model training module is also used to optimize the first target query statement to obtain an optimized first target query statement; input the natural language training text into the query statement generation model to be trained to obtain a predicted query statement corresponding to the natural language training text; and train the query statement generation model based on the predicted query statement corresponding to the natural language training text and the optimized first target query statement.

[0145] In one of the embodiments, the test sample also includes a test query statement corresponding to the natural language test text; the quality assessment module is further used to: use the test query statement to query a preset database to obtain a first query result; use the predicted query statement to query the preset database to obtain a second query result; compare the first query result and the second query result, and determine the quality assessment information of the predicted query statement based on the comparison result obtained.

[0146] In one of the embodiments, the quality assessment module is further used to: input the predicted query statement into a trained natural language generation model to obtain a generated natural language predicted text; determine the text similarity between the natural language predicted text and the natural language test text; and determine quality assessment information of the predicted query statement based on the text similarity between the natural language predicted text and the natural language test text.

[0147] In one of the embodiments, the quality assessment module is further used to: send test samples and prediction query statements to multiple expert terminals; receive quality assessment scores returned by multiple expert terminals; calculate the average of multiple quality assessment scores, and determine the calculated average of the quality assessment scores as the quality assessment information corresponding to the prediction query statement.

[0148] In one of the embodiments, the device also includes: a letter text conversion module, which is used to obtain the cooperation letter text to be processed, input the cooperation letter text into the target query statement generation model, and obtain the conversion query statement corresponding to the cooperation letter text; query the preset database based on the conversion query statement to obtain the reporting data corresponding to the cooperation letter text.

[0149] Each module in the query statement generation model processing device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.

[0150] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG9. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data such as training samples and test samples. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the query statement generation model processing method provided in the embodiment of the present application is implemented.

[0151] In an exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be shown in FIG10. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, the memory, and the input / output interface are connected via a system bus, and the communication interface, the display unit, and the input device are connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner may be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, the query statement generation model processing method provided in the embodiment of the present application is implemented. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0152] Those skilled in the art will understand that the structures shown in FIGS. 9 and 10 are merely block diagrams of partial structures related to the scheme of the present application, and do not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device may include more or fewer components than those shown in the figures, or combine certain components, or have a different arrangement of components.

[0153] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of the query statement generation model processing method in any of the above embodiments are implemented.

[0154] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the query statement generation model processing method in any of the above embodiments are implemented.

[0155] In one embodiment, a computer program product is provided, including a computer program, which, when executed by a processor, implements the steps of the query statement generation model processing method in any of the above embodiments.

[0156] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0157] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0158] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A query statement generation model processing method, characterized in that: The method comprises: Obtaining a first training sample and a test sample, wherein the first training sample includes a natural language training text and a first target query sentence corresponding to the natural language training text; and the test sample includes a natural language test text; Using the first training sample to train a query statement generation model, and using the initial query statement generation model obtained through training to generate a predicted query statement for the test sample; Performing a quality assessment on the predicted query statement to obtain quality assessment information corresponding to the predicted query statement; When the quality assessment information corresponding to the predicted query statement does not meet the preset quality condition, optimizing the predicted query statement to obtain a second target query statement corresponding to the natural language test text; A second training sample is constructed using the natural language test text and the second target query statement, and a model parameter of the initial query statement generation model is adjusted using the second training sample to obtain a target query statement generation model.

2. The method according to claim 1, characterized in that The natural language training text is a historical assistance letter text, and the first target query statement is a query statement obtained by manually converting the historical assistance letter text into a query statement.

3. The method according to claim 2, characterized in that The method further comprises: Acquire the text of the to-be-processed assistance letter, input the text of the assistance letter into the target query statement generation model, and obtain a conversion query statement corresponding to the text of the assistance letter; Based on the conversion query statement, a preset database is queried to obtain the reporting data corresponding to the text of the cooperative investigation letter.

4. The method according to claim 1, characterized in that: The using the first training sample to train the query statement generation model includes: Optimizing the first target query statement to obtain an optimized first target query statement; Inputting the natural language training text into a query statement generation model to be trained to obtain a predicted query statement corresponding to the natural language training text; The query statement generation model is trained based on the predicted query statement corresponding to the natural language training text and the optimized first target query statement.

5. The method according to claim 1, characterized in that The test sample also includes a test query statement corresponding to the natural language test text; and the quality assessment of the predicted query statement to obtain quality assessment information corresponding to the predicted query statement includes: Querying a preset database using the test query statement to obtain a first query result; Querying the preset database using the prediction query statement to obtain a second query result; The first query result and the second query result are compared, and quality evaluation information of the predicted query statement is determined according to the obtained comparison result.

6. The method according to any one of claims 1 to 5, characterized in that: The performing quality assessment on the prediction query statement to obtain quality assessment information corresponding to the prediction query statement includes: Inputting the prediction query sentence into a trained natural language generation model to obtain a generated natural language prediction text; Determining text similarity between the natural language prediction text and the natural language test text; Based on the text similarity between the natural language prediction text and the natural language test text, quality assessment information of the predicted query statement is determined.

7. The method according to any one of claims 1 to 5, characterized in that: The performing quality assessment on the prediction query statement to obtain quality assessment information corresponding to the prediction query statement includes: Sending the test sample and the prediction query statement to multiple expert terminals; receiving quality assessment scores returned by the plurality of expert terminals; An average value of the multiple quality assessment scores is calculated, and the calculated average value of the quality assessment scores is determined as the quality assessment information corresponding to the predicted query statement.

8. A query statement generation model processing device, characterized in that: The device comprises: A sample acquisition module, configured to acquire a first training sample and a test sample, wherein the first training sample includes a natural language training text and a first target query sentence corresponding to the natural language training text; and the test sample includes a natural language test text; A model training module, used to train a query statement generation model using the first training sample, and to generate a prediction query statement for the test sample using an initial query statement generation model obtained through training; A quality assessment module, used to perform quality assessment on the prediction query statement and obtain quality assessment information corresponding to the prediction query statement; A query statement optimization module, configured to optimize the predicted query statement when the quality evaluation information corresponding to the predicted query statement does not meet a preset quality condition, and obtain a second target query statement corresponding to the natural language test text; The parameter adjustment module is used to construct a second training sample using the natural language test text and the second target query statement, and adjust the model parameters of the initial query statement generation model using the second training sample to obtain a target query statement generation model.

9. The device according to claim 8, characterized in that The natural language training text is a historical assistance letter text, and the first target query statement is a query statement obtained by manually converting the historical assistance letter text into a query statement.

10. The device according to claim 9, characterized in that The device also includes: a letter text conversion module, which is used to obtain the cooperation letter text to be processed, input the cooperation letter text into the target query statement generation model, and obtain the conversion query statement corresponding to the cooperation letter text; based on the conversion query statement, query the preset database to obtain the reporting data corresponding to the cooperation letter text.

11. The device according to claim 8, characterized in that The model training module is also used to optimize the first target query statement to obtain an optimized first target query statement; input the natural language training text into the query statement generation model to be trained to obtain a predicted query statement corresponding to the natural language training text; and train the query statement generation model based on the predicted query statement corresponding to the natural language training text and the optimized first target query statement.

12. The device according to claim 8, characterized in that The test sample also includes a test query statement corresponding to the natural language test text; the quality assessment module is further used to: query a preset database using the test query statement to obtain a first query result; query the preset database using the prediction query statement to obtain a second query result; The first query result and the second query result are compared, and quality evaluation information of the predicted query statement is determined according to the obtained comparison result.

13. The device according to any one of claims 8 to 12, characterized in that The quality assessment module is also used to: input the predicted query statement into a trained natural language generation model to obtain a generated natural language predicted text; determine the text similarity between the natural language predicted text and the natural language test text; and determine the quality assessment information of the predicted query statement based on the text similarity between the natural language predicted text and the natural language test text.

14. The device according to any one of claims 8 to 12, characterized in that The quality assessment module is also used to: send the test sample and the prediction query statement to multiple expert terminals; receive the quality assessment scores returned by the multiple expert terminals; calculate the average of the multiple quality assessment scores, and determine the calculated average of the quality assessment scores as the quality assessment information corresponding to the prediction query statement.

15. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

16. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

17. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Method and device for outputting structured query statements

    CN111159220A

  • Language transformation model training method and device

    CN114168619A

  • Data information processing method and device, storage medium and electronic equipment

    CN116737904A

  • Approximate query processing optimization method

    CN117216096A

  • Model training method, structured query statement generation method, device and equipment

    CN117435612A

Cited By

  • Quality evaluation method and device for query statements and computer readable storage medium

    CN119226321A

  • SQL statement generation method and device, electronic equipment and storage medium

    CN119311716A

  • Query statement adjustment method and device of relational database based on large model

    CN119988406A