SQL statement conversion model generation method and device
The SQL statement conversion model, utilizing a BERT and LSTM model, addresses inefficiencies and inaccuracies in banking data queries by converting natural language to SQL statements, enhancing query accuracy and efficiency.
Patent Information
- Application Number
- CN202110423435.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-20
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2041-04-20
AI Technical Summary
Banking personnel face inefficiencies and low accuracy in data queries due to the complexity of writing SQL statements and the difficulty of existing Text-to-SQL technologies in accurately identifying financial scenario vocabulary.
A method and device for generating a SQL statement conversion model using a BERT model and an LSTM model, trained with high-precision training data derived from frequent item sets of historical queries and financial scenario vocabulary, to automatically convert natural language into SQL statements.
Improves the efficiency and accuracy of data queries by enabling automatic conversion of natural language to SQL statements, facilitating banking business operations and enhancing office efficiency.
Smart Images

Figure CN113051286B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method and device for generating a SQL statement conversion model. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the invention recited in the claims. No admission is made that the description herein is prior art by inclusion in this section.
[0003] In real life, there are many databases storing information from all walks of life, such as school course selection information, grade information, company account information, personnel flow information, etc. Banking staff often need to obtain various types of data in the business system for business analysis in their daily work. The current mainstream method is to reserve an SQL query function on the business system, and bank staff submit SQL statements for data query.
[0004] SQL is a database query language with great flexibility and powerful functions, but it requires high skills from banking personnel. Banking personnel are required to write a large number of SQL statements with guaranteed accuracy to implement data queries for different databases and application scenarios. It is highly complex and has poor scalability, which makes data query inefficient.
[0005] Text-to-SQL is a technology that converts natural language descriptions into SQL query statements. For example, when we ask the smart assistant "Where was director Jia Zhangke born?", the Text-to-SQL model will first parse the SQL statement "SELECT birth_city FROM director WHERE name="Jia Zhangke"" based on the question, then execute the command on the database, and finally return the query result "Fenyang City, Shanxi Province" to the user.
[0006] Since banking business involves various types of financial scenarios, existing Text-to-SQL technology is difficult to accurately identify financial scenario vocabulary, resulting in low accuracy of data query.
[0007] Currently, no effective solution has been proposed to the above problems. Summary of the invention
[0008] An embodiment of the present invention provides a method for generating a SQL statement conversion model to improve the efficiency and accuracy of data query, the method comprising:
[0009] According to the SQL statements of historical queries by banking personnel, determine the frequent item sets of the SQL statements of historical queries;
[0010] According to the frequent item sets of SQL statements in historical queries, determine the text statements of frequent item sets;
[0011] Match the text sentences of the frequent item sets with the financial scenario vocabulary and perform word segmentation on the text sentences of the frequent item sets;
[0012] The SQL statements of historical queries and the word segmentation processing results of the text statements of frequent itemsets are used as training data to train the SQL statement conversion model to obtain a trained SQL statement conversion model, wherein the SQL statement conversion model includes: a BERT model and an LSTM model. The SQL statement conversion model is used to output the SQL statement corresponding to any text statement when a banking staff inputs the text statement.
[0013] An embodiment of the present invention provides a device for generating a SQL statement conversion model, which is used to improve the efficiency and accuracy of data query. The device includes:
[0014] A frequent item set determination module is used to determine the frequent item sets of historical query SQL statements based on the SQL statements of historical queries by banking personnel;
[0015] A text statement determination module is used to determine text statements of frequent item sets based on frequent item sets of SQL statements in historical queries;
[0016] The word segmentation processing module is used to match the text sentences of the frequent item sets with the financial scenario vocabulary and perform word segmentation processing on the text sentences of the frequent item sets;
[0017] The training module is used to train the SQL statement conversion model by taking the SQL statements of historical queries and the word segmentation processing results of the text statements of the frequent item sets as training data, and obtain the trained SQL statement conversion model, wherein the SQL statement conversion model includes: a BERT model and an LSTM model. The SQL statement conversion model is used to output the SQL statement corresponding to any text statement when the banking staff inputs the text statement.
[0018] An embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method for generating a SQL statement conversion model when executing the computer program.
[0019] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program for executing the method for generating a SQL statement conversion model.
[0020] In an embodiment of the present invention, according to the SQL statements of historical queries by bank business personnel, a frequent item set of the SQL statements of historical queries is determined; according to the frequent item set of the SQL statements of historical queries, a text statement of the frequent item set is determined; the text statement of the frequent item set is matched with the financial scenario vocabulary, and the text statement of the frequent item set is segmented, and then through the frequent item set extraction and financial scenario vocabulary matching, high-precision training data that can reflect the characteristics of the financial scenario is extracted; the SQL statements of historical queries and the word segmentation processing results of the text statements of the frequent item set are used as training data to train the SQL statement conversion model to obtain a trained SQL statement conversion model, the SQL statement conversion model includes: a BERT model and an LSTM model, the SQL statement conversion model is used to output the SQL statement corresponding to the arbitrary text statement when the bank business personnel inputs the arbitrary text statement, the BERT model and the LSTM model are trained based on the high-precision training data that can reflect the characteristics of the financial scenario, the automatic conversion of natural language to SQL statements is realized, and the efficiency and accuracy of data query are improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0022] Figure 1 A schematic diagram of a method for generating a SQL statement conversion model according to an embodiment of the present invention;
[0023] Figure 2 for Figure 1 Schematic diagram of the specific process of step 101;
[0024] Figure 3 for Figure 1 A schematic diagram of the specific process of step 103;
[0025] Figure 4 for Figure 1 A schematic diagram of the specific process of step 104;
[0026] Figure 5 A schematic diagram of the structure of a device for generating a SQL statement conversion model according to an embodiment of the present invention;
[0027] Figure 6 for Figure 5 Schematic diagram of the specific structure of the frequent itemset determination module;
[0028] Figure 7 for Figure 5 Schematic diagram of the specific structure of the word segmentation processing module;
[0029] Figure 8 for Figure 5 Schematic diagram of the specific structure of the training module. DETAILED DESCRIPTION
[0030] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0031] Those skilled in the art will appreciate that the embodiments of the present invention may be implemented as a system, device, method or computer program product. Therefore, the present invention may be implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.
[0032] The embodiment of the present invention provides a method for generating a SQL statement conversion model to improve the efficiency and accuracy of data query. Figure 1 FIG. 1 is a schematic diagram of a method for generating a SQL statement conversion model in an embodiment of the present invention. Figure 1 As shown, the method includes:
[0033] Step 101: determining frequent item sets of SQL statements of historical queries according to SQL statements of historical queries by banking personnel;
[0034] Step 102: Determine text statements of frequent item sets according to the frequent item sets of the SQL statements of the historical queries;
[0035] Step 103: Match the text sentences of the frequent item sets with the financial scenario vocabulary, and perform word segmentation processing on the text sentences of the frequent item sets;
[0036] Step 104: Use the SQL statements of historical queries and the word segmentation processing results of the text statements of the frequent item sets as training data to train the SQL statement conversion model to obtain a trained SQL statement conversion model, wherein the SQL statement conversion model includes: a BERT model and an LSTM model. The SQL statement conversion model is used to output the SQL statement corresponding to any text statement when the banking staff inputs the text statement.
[0037] like Figure 1As shown, in an embodiment of the present invention, according to the SQL statements of historical queries by bank business personnel, the frequent item sets of the SQL statements of historical queries are determined; according to the frequent item sets of the SQL statements of historical queries, the text statements of the frequent item sets are determined; the text statements of the frequent item sets are matched with the financial scenario vocabulary, and the text statements of the frequent item sets are segmented, and then through the frequent item set extraction and financial scenario vocabulary matching, high-precision training data that can reflect the characteristics of the financial scenario is extracted; the SQL statements of historical queries and the word segmentation results of the text statements of the frequent item sets are used as training data to train the SQL statement conversion model to obtain a trained SQL statement conversion model, the SQL statement conversion model includes: a BERT model and an LSTM model, the SQL statement conversion model is used to output the SQL statement corresponding to any text statement when the bank business personnel input the text statement, the BERT model and the LSTM model are trained based on the high-precision training data that can reflect the characteristics of the financial scenario, and the automatic conversion of natural language to SQL statements is realized, and the efficiency and accuracy of data query are improved.
[0038] Figure 2 for Figure 1 A schematic diagram of the specific process of step 101 is shown in FIG. Figure 2 As shown, in one embodiment, in step 101, determining the frequent item sets of the SQL statements of the historical queries according to the SQL statements of the historical queries of the banking staff may include:
[0039] Step 201: clustering the SQL statements of historical queries by banking staff based on a Gaussian mixture model;
[0040] Step 202: Based on the Gaussian Naive Bayes model, classify the SQL statements of the historical queries after clustering;
[0041] Step 203: determining frequent item sets of the historical query SQL statements based on the FP-Growth algorithm according to the classified historical query SQL statements.
[0042] In the specific implementation, in step 101, first, the SQL statements of the historical queries of the bank staff can be obtained from the bank's production environment database (such as Mysql), which can be the query history of the past three years. Then, based on the Gaussian Mixture Model, the SQL statements of the historical queries of the bank staff are clustered. Then, based on the Gaussian Naive Bayes model, the SQL statements of the historical queries after clustering are classified. Finally, based on the FP-Growth algorithm (frequent pattern mining), the frequent item sets of the SQL statements of the historical queries after classification are extracted. When determining the frequent item sets of the SQL statements of the historical queries, a threshold can be set, such as 1000 items. In this way, through clustering processing, classification processing and extraction of frequent item sets, frequent item sets with higher accuracy can be obtained.
[0043] In step 102, the frequent item sets of the SQL statements of the historical queries are automatically matched and annotated or manually annotated by database technicians based on SQL grammar rules to form a series of text statements in natural language form, and the text statements are sent to bank business personnel for verification.
[0044] Figure 3 for Figure 1 The schematic diagram of the specific process of step 103 is as follows: Figure 3 As shown, in one embodiment, in step 103, matching the text sentences of the frequent item sets with the financial scenario vocabulary and performing word segmentation processing on the text sentences of the frequent item sets may include:
[0045] Step 301: inputting the text sentences of the frequent item sets into a financial scenario vocabulary library, and outputting the financial scenario vocabulary contained in the text sentences of the frequent item sets, wherein the financial scenario vocabulary library stores vocabulary of multiple financial scenarios;
[0046] Step 302: According to the financial scenario vocabulary contained in the text sentences of the frequent item sets, based on the hidden Markov model, the text sentences of the frequent item sets are segmented.
[0047] In specific implementation, we can first establish a financial scenario vocabulary library based on the vocabulary of various financial scenarios in the industry standard financial vocabulary library, a named entity data set with banking business characteristics (such as "Inclusive Zone") and a banking business database-related data dictionary (related to the basic information of the database table structure). Then, we can input the text sentences of frequent item sets into the financial scenario vocabulary library, match them with the financial scenario vocabulary, and output the financial scenario vocabulary contained in the text sentences of the frequent item sets. Next, we can use the Hidden Markov Model to perform word segmentation on the text sentences of the frequent item sets. In this way, we can obtain training data reflecting the characteristics of financial scenarios and provide a reliable data foundation for subsequent training models.
[0048] Figure 4 for Figure 1 The schematic diagram of the specific process of step 104 is as follows: Figure 4 As shown, in one embodiment, in step 104, the SQL statements of historical queries and the word segmentation processing results of the text statements of the frequent itemsets are used as training data to train the SQL statement conversion model, and the trained SQL statement conversion model is obtained, which may include:
[0049] Step 401: setting the initialization values of various parameters in the BERT model and the LSTM model and the conditions for stopping iteration;
[0050] Step 402: Loop through the following steps until the iteration stop condition is met to obtain a trained SQL statement conversion model:
[0051] Step 403: input the word segmentation processing result of the text sentence of the frequent item set into the BERT model, and output the encoding vector of the word segmentation processing result of the text sentence of the frequent item set;
[0052] Step 404: input the encoding vector of the word segmentation processing result of the text sentence of the frequent item set into the LSTM model, and output the SQL sentence corresponding to the encoding vector based on the SQL grammar;
[0053] Step 405: Compare the SQL statement corresponding to the encoding vector with the SQL statement of the historical query;
[0054] Step 406: Update the parameter values in the BERT model and the LSTM model according to the comparison result;
[0055] Step 407: re-input the word segmentation processing results of the text sentences of the frequent itemsets to the BERT model and the LSTM model after the parameter values are updated.
[0056] In one embodiment, the SQL grammar includes at least: Mysql grammar, Oracle grammar and PostgreSql grammar.
[0057] In specific implementation, the Text-to-SQL system can convert natural language descriptions into corresponding SQL query statements. This technology can effectively assist people in querying massive databases. Therefore, this research has attracted widespread attention from industry and academia. BERT is a language representation model that is trained with super large data, huge models, and huge computational overhead, and has achieved the best (state-of-the-art, SOTA) results in 11 natural language processing tasks. BERT is a new language representation model, which represents the bidirectional encoder representation of Transformer. Unlike other recent language representation models, BERT aims to pre-train deep bidirectional representations by jointly adjusting the context in all layers. Therefore, the pre-trained BERT representation can be fine-tuned with an additional output layer, which is suitable for the construction of state-of-the-art models for a wide range of tasks, such as question-answering tasks and language reasoning, without making major architectural modifications for specific tasks.
[0058] In an embodiment of the present invention, it is first necessary to set the initialization values of various parameters in the BERT model and the LSTM model and the conditions for stopping iteration, and then start training the model. The specific training process is: inputting the word segmentation processing results of the text sentences of the frequent item sets into the BERT model, outputting the encoding vector of the word segmentation processing results of the text sentences of the frequent item sets, loading the encoding vector and SQL grammar into the LSTM model, and outputting the SQL statement corresponding to the encoding vector. The SQL grammar may include: Mysql grammar, Oracle grammar and PostgreSql grammar, and may also include other database grammars. The present invention is not limited to this. By configuring multiple SQL grammars, the scope of application of the SQL statement conversion model can be expanded, and it has high scalability.
[0059] After the LSTM model outputs the SQL statement corresponding to the encoding vector, the SQL statement corresponding to the encoding vector can be compared and verified with the SQL statement of the historical query, the comparison result can be analyzed, and the parameter values in the BERT model and the LSTM model can be updated. Finally, the word segmentation processing results of the text sentences of the frequent itemsets are re-input into the BERT model and the LSTM model after the parameter values are updated, and the above training process is executed repeatedly until the stop iteration condition is met to obtain the trained SQL statement conversion model.
[0060] The SQL statements of historical queries can also be used as test data and verification data. The trained SQL statement conversion model can be tested using the test data, and the tested SQL statement conversion model can be verified using the verification data to obtain the final SQL statement conversion model.
[0061] When banking personnel input any text statement, the SQL statement conversion model can output the SQL statement corresponding to the arbitrary text statement, execute and return the query results, thereby realizing the automatic conversion of natural language to SQL statements and automatic data query, improving the efficiency and accuracy of data query, greatly facilitating banking business work and improving office efficiency.
[0062] It should be noted that although the operations of the method of the present invention are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0063] Based on the same inventive concept, an embodiment of the present invention also provides a device for generating a SQL statement conversion model, such as the following embodiment. Since the principle of solving the problem by the device for generating a SQL statement conversion model is similar to that of the method for generating a SQL statement conversion model, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0064] The embodiment of the present invention provides a device for generating a SQL statement conversion model, which is used to improve the efficiency and accuracy of data query. Figure 5 FIG. 1 is a schematic diagram of a structure of a generating device for a SQL statement conversion model according to an embodiment of the present invention. Figure 5 As shown, the device comprises:
[0065] The frequent item set determination module 01 is used to determine the frequent item sets of the SQL statements of the historical queries according to the SQL statements of the historical queries of the banking staff;
[0066] The text statement determination module 02 is used to determine the text statements of the frequent item sets according to the frequent item sets of the SQL statements of the historical query;
[0067] The word segmentation processing module 03 is used to match the text sentences of the frequent item sets with the financial scenario vocabulary and perform word segmentation processing on the text sentences of the frequent item sets;
[0068] The training module 04 is used to train the SQL statement conversion model using the SQL statements of historical queries and the word segmentation processing results of the text statements of the frequent item sets as training data, and obtain a trained SQL statement conversion model, wherein the SQL statement conversion model includes: a BERT model and an LSTM model. The SQL statement conversion model is used to output the SQL statement corresponding to any text statement when the banking staff inputs the text statement.
[0069] Figure 6 for Figure 5 The schematic diagram of the specific structure of the frequent item set determination module is as follows: Figure 6 As shown, in one embodiment, the frequent item set determination module 01 includes:
[0070] The cluster processing unit 011 is used to perform cluster processing on the SQL statements of the historical queries of the banking staff based on the Gaussian mixture model;
[0071] A classification processing unit 012 is used to classify the SQL statements of the historical queries after clustering based on a Gaussian naive Bayes model;
[0072] The frequent item set extraction unit 013 is used to determine the frequent item sets of the historical query SQL statements based on the classified historical query SQL statements and the FP-Growth algorithm.
[0073] Figure 7 for Figure 5 The schematic diagram of the specific structure of the word segmentation processing module is as follows: Figure 7 As shown, the word segmentation processing module 03 includes:
[0074] The financial scenario vocabulary matching unit 031 is used to input the text sentences of the frequent item sets into the financial scenario vocabulary library, and output the financial scenario vocabulary contained in the text sentences of the frequent item sets, wherein the financial scenario vocabulary library stores vocabulary of multiple financial scenarios;
[0075] The word segmentation processing unit 032 is used to perform word segmentation processing on the text sentences of the frequent item sets based on the hidden Markov model according to the financial scenario vocabulary contained in the text sentences of the frequent item sets.
[0076] Figure 8 for Figure 5 The schematic diagram of the specific structure of the training module is as follows: Figure 8 As shown, in one embodiment, the training module 04 includes:
[0077] Initialization unit 041, used to set initialization values of various parameters in the BERT model and the LSTM model and stop iteration conditions;
[0078] The judgment unit 042 is used to loop through the following steps until the iteration stop condition is met to obtain a trained SQL statement conversion model:
[0079] The BERT model unit 043 is used to input the word segmentation processing result of the text sentence of the frequent item set into the BERT model, and output the encoding vector of the word segmentation processing result of the text sentence of the frequent item set;
[0080] The LSTM model unit 044 is used to input the encoding vector of the word segmentation processing result of the text sentence of the frequent item set into the LSTM model, and output the SQL statement corresponding to the encoding vector based on the SQL grammar;
[0081] A comparison unit 045, used to compare the SQL statement corresponding to the encoding vector with the SQL statement of the historical query;
[0082] An updating unit 046, used to update each parameter value in the BERT model and the LSTM model according to the comparison result;
[0083] The iteration unit 047 is used to re-input the word segmentation processing results of the text sentences of the frequent itemsets into the BERT model and the LSTM model after the parameter values are updated.
[0084] In one embodiment, the SQL grammar includes at least: Mysql grammar, Oracle grammar and PostgreSql grammar.
[0085] An embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method for generating a SQL statement conversion model when executing the computer program.
[0086] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program for executing the method for generating a SQL statement conversion model.
[0087] A specific example is given below to facilitate understanding of how to implement the present invention.
[0088] Step 1: Obtain the SQL statements of the bank's business personnel's historical queries in the past three years from the bank's production environment database MySQL;
[0089] Step 2: Based on the Gaussian mixture model, cluster the SQL statements of historical queries by banking staff;
[0090] Step 3: Based on the Gaussian Naive Bayes model, classify the SQL statements of historical queries after clustering;
[0091] Step 4: Extract frequent item sets of historical query SQL statements after classification based on the FP-Growth algorithm;
[0092] Step 5: Based on SQL grammar rules, the frequent item sets of SQL statements of historical queries are automatically matched and annotated or manually annotated by database technicians to form a series of text statements in natural language form, and the text statements are sent to bank business personnel for verification;
[0093] Step 6: Establish a financial scenario vocabulary library in advance based on the vocabulary of various financial scenarios in the industry standard financial vocabulary library, the named entity dataset with banking business characteristics, and the data dictionary related to the banking business database, input the text sentences of the frequent item sets into the financial scenario vocabulary library, match them with the financial scenario vocabulary, and output the financial scenario vocabulary contained in the text sentences of the frequent item sets;
[0094] Step 7: Segment the text sentences of frequent item sets based on the hidden Markov model;
[0095] Step 8: Set the initialization values of each parameter in the BERT model and LSTM model and the conditions for stopping iteration;
[0096] Step 9: Input the word segmentation processing results of the text sentences of the frequent item sets into the BERT model, and output the encoding vector of the word segmentation processing results of the text sentences of the frequent item sets;
[0097] Step 10: The LSTM model loads the encoding vector and SQL syntax, and outputs the SQL statement corresponding to the encoding vector;
[0098] Step 11: Compare and verify the SQL statement corresponding to the encoding vector with the SQL statement of the historical query to determine whether the stop iteration condition is met. If the stop iteration condition is met, the process ends. If the stop iteration condition is not met, execute step 12:
[0099] Step 12: Analyze the comparison results and update the parameter values in the BERT model and LSTM model;
[0100] Step 13: After updating the parameter values of the BERT model and LSTM model, re-input the word segmentation processing results of the text sentences of the frequent itemsets and repeat the above steps 9 to 11.
[0101] In summary, the method and device for generating a SQL statement conversion model provided by the embodiment of the present invention have the following advantages:
[0102] (1) Based on the SQL statements of historical queries by banking personnel, the frequent item sets of the SQL statements of historical queries are determined; based on the frequent item sets of the SQL statements of historical queries, the text statements of the frequent item sets are determined, and through clustering processing, classification processing and extraction of frequent item sets, a high-precision frequent item set can be obtained; the text statements of the frequent item sets are matched with financial scenario vocabulary, and the text statements of the frequent item sets are segmented to extract high-precision training data that can reflect the characteristics of financial scenarios, providing a reliable data foundation for subsequent training models;
[0103] (2) The SQL statements of historical queries and the word segmentation results of the text statements of frequent itemsets are used as training data to train the SQL statement conversion model to obtain a trained SQL statement conversion model. The SQL statement conversion model includes a BERT model and an LSTM model. The SQL statement conversion model is used to output the SQL statement corresponding to any text statement when a banking staff inputs the arbitrary text statement. The BERT model and the LSTM model are trained based on high-precision training data that can reflect the characteristics of financial scenarios, and the financial scenario vocabulary and SQL syntax are integrated to realize the automatic conversion of natural language into SQL statements, thereby improving the efficiency and accuracy of data query.
[0104] (3) By configuring multiple SQL syntaxes, the application scope of the SQL statement conversion model is expanded, and it has high scalability.
[0105] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0106] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0107] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0108] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0109] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for generating a SQL statement conversion model, characterized in that: include: According to the SQL statements of historical queries by banking personnel, determine the frequent item sets of the SQL statements of historical queries; According to the frequent item sets of SQL statements in historical queries, determine the text statements of frequent item sets; Match the text sentences of the frequent item sets with the financial scenario vocabulary and perform word segmentation on the text sentences of the frequent item sets; The SQL statements of historical queries and the word segmentation processing results of the text statements of the frequent itemsets are used as training data to train the SQL statement conversion model to obtain a trained SQL statement conversion model, wherein the SQL statement conversion model includes: a BERT model and an LSTM model. The SQL statement conversion model is used to output the SQL statement corresponding to any text statement when the banking staff inputs the text statement; The SQL statements of historical queries and the word segmentation results of the text statements of frequent itemsets are used as training data to train the SQL statement conversion model, and a trained SQL statement conversion model is obtained, including: Set the initialization values of various parameters in the BERT model and LSTM model and the conditions for stopping iteration; The following steps are executed repeatedly until the iteration stop condition is met to obtain the trained SQL statement conversion model: Input the word segmentation processing results of the text sentences of the frequent item sets into the BERT model, and output the encoding vector of the word segmentation processing results of the text sentences of the frequent item sets; Input the encoding vector of the word segmentation processing result of the text sentence of the frequent item set into the LSTM model, and output the SQL statement corresponding to the encoding vector based on the SQL grammar; Compare the SQL statement corresponding to the encoding vector with the SQL statement of the historical query; According to the comparison results, update the parameter values in the BERT model and LSTM model; For the BERT model and LSTM model after updating the parameter values, re-input the word segmentation processing results of the text sentences of the frequent item sets.
2. The method according to claim 1, characterized in that The SQL grammar includes at least: Mysql grammar, Oracle grammar and PostgreSql grammar.
3. The method according to claim 1, characterized in that According to the SQL statements of historical queries by banking personnel, the frequent item sets of the SQL statements of historical queries are determined, including: Based on Gaussian mixture model, clustering is performed on SQL statements of historical queries by banking staff; Based on the Gaussian Naive Bayes model, the SQL statements of historical queries after clustering are classified; According to the classified historical query SQL statements, the frequent item sets of the historical query SQL statements are determined based on the FP-Growth algorithm.
4. The method according to claim 1, characterized in that Match the text sentences of the frequent item sets with the financial scenario vocabulary and perform word segmentation on the text sentences of the frequent item sets, including: Inputting the text sentences of the frequent item sets into a financial scenario vocabulary library, and outputting the financial scenario vocabulary contained in the text sentences of the frequent item sets, wherein the financial scenario vocabulary library stores vocabulary of multiple financial scenarios; According to the financial scenario vocabulary contained in the text sentences of the frequent item sets, the text sentences of the frequent item sets are segmented based on the hidden Markov model.
5. A device for generating a SQL statement conversion model, characterized in that: include: A frequent item set determination module is used to determine the frequent item sets of historical query SQL statements based on the SQL statements of historical queries by banking personnel; A text statement determination module is used to determine text statements of frequent item sets based on frequent item sets of SQL statements in historical queries; The word segmentation processing module is used to match the text sentences of the frequent item sets with the financial scenario vocabulary and perform word segmentation processing on the text sentences of the frequent item sets; A training module is used to train the SQL statement conversion model using the SQL statements of historical queries and the word segmentation processing results of the text statements of the frequent itemsets as training data, and obtain a trained SQL statement conversion model, wherein the SQL statement conversion model includes: a BERT model and an LSTM model, and the SQL statement conversion model is used to output the SQL statement corresponding to any text statement when the banking staff inputs the text statement; The training modules include: Initialization unit, used to set the initialization values of various parameters in the BERT model and LSTM model and the conditions for stopping iteration; The judgment unit is used to loop through the following steps until the iteration stop condition is met to obtain a trained SQL statement conversion model: A BERT model unit, used to input the word segmentation processing result of the text sentence of the frequent item set into the BERT model, and output the encoding vector of the word segmentation processing result of the text sentence of the frequent item set; The LSTM model unit is used to input the encoding vector of the word segmentation processing result of the text sentence of the frequent item set into the LSTM model, and output the SQL statement corresponding to the encoding vector based on the SQL grammar; A comparison unit, used to compare the SQL statement corresponding to the encoding vector with the SQL statement of the historical query; An updating unit, used to update the parameter values in the BERT model and the LSTM model according to the comparison results; The iteration unit is used to re-input the word segmentation processing results of the text sentences of the frequent itemsets into the BERT model and the LSTM model after the parameter values are updated.
6. The device according to claim 5, characterized in that The word segmentation processing module includes: A financial scenario vocabulary matching unit, used for inputting the text sentences of the frequent item sets into the financial scenario vocabulary library, and outputting the financial scenario vocabulary contained in the text sentences of the frequent item sets, wherein the financial scenario vocabulary library stores vocabulary of multiple financial scenarios; The word segmentation processing unit is used to perform word segmentation processing on the text sentences of the frequent item sets based on the hidden Markov model according to the financial scenario vocabulary contained in the text sentences of the frequent item sets.
7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 4 is implemented.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program for executing the method according to any one of claims 1 to 4.
