Structured query language statement processing method and system, device, and medium

By using a distillation training method, the computational load and memory requirements of the structured query language statement processing model are reduced, thereby improving accuracy and precision. This solves the problems of low accuracy and low deployment efficiency in generating structured query language statements in existing technologies.

CN114610743BActive Publication Date: 2026-03-03JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210158516.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-21
Publication Date
2026-03-03
Estimated Expiration
2042-02-21

AI Technical Summary

Technical Problem

Existing methods for generating structured query language statements suffer from low accuracy and face problems such as insufficient memory and slow inference time when deployed online with limited computing resources.

Method used

The distillation training method is adopted. The first training sample is input into the first teacher model and the first student model respectively to obtain the second student model. Then, the second training sample is input into the second teacher model and the second student model to train the structured query language statement processing model, which reduces the computational load and memory requirements of the model, while retaining the semantic information of the table question and answer.

Benefits of technology

It significantly reduces the computational load and memory requirements of the model, while improving the accuracy and precision of the structured query language statements, thus solving the problems of insufficient memory and slow inference time during online deployment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114610743B_ABST
    Figure CN114610743B_ABST
Patent Text Reader

Abstract

The present disclosure provides a structured query language sentence processing method and system, device and medium, the structured query language sentence processing method comprises: obtaining table information, inputting the table information into a structured query language sentence processing model, and outputting a structured query language sentence, wherein a first training sample is input into a first teacher model and a first student model respectively for distillation training to obtain a second student model; a second training sample is input into a second teacher model and a second student model respectively for distillation training to obtain a trained second student model; the structured query language sentence processing model is obtained by training based on the trained second student model, table samples and predetermined language labels, so that the accuracy and precision of the structured query language sentence can be ensured, and the defects of insufficient memory and slow inference time during online deployment can be overcome.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of natural language processing technology, and in particular to a method and system for processing structured query language statements, an electronic device, and a storage medium. Background Technology

[0002] Table-based question answering (CQA) converts human natural language into machine-understandable structured query language statements based on table information, retrieving the desired answers from a database. Currently, one approach to generating CQA statements is rule-based generation. This method first sets up fields and table description entries; then populates the description information corresponding to these entries to generate a data dictionary; finally, it generates the CQA statement based on the data dictionary and CQA generation rules. However, this method has relatively low accuracy. Another approach is model-based generation, typically using pre-trained models to generate CQA statements. Pre-trained table-based CQA has an advantage in accuracy; however, this approach requires a pre-trained model, which is not only large but also slow inference. On online deployments with limited computing resources, this can lead to memory shortages and slow inference times. Summary of the Invention

[0003] This disclosure provides a method and system for processing structured query language statements, an electronic device, and a storage medium to address the technical deficiencies existing in the prior art.

[0004] This disclosure provides a method for processing Structured Query Language statements, including:

[0005] Obtain table information, input the table information into the structured query language statement processing model, and output a structured query language statement;

[0006] Specifically, the first training sample is input into the first teacher model and the first student model respectively for distillation training to obtain the second student model. The first teacher model is obtained by pre-training based on the first training sample.

[0007] The second training sample is input into the second teacher model and the second student model respectively for distillation training to obtain the trained second student model. The second teacher model is obtained by pre-training based on the second training sample.

[0008] The structured query language statement processing model is obtained by training a pre-trained second student model, table samples, and pre-determined language labels.

[0009] According to the structured query language statement processing method provided in this disclosure, the first training sample includes unlabeled Chinese training corpus samples and pre-determined sentence representation labels, and the loss function used by the first student model during training is:

[0010]

[0011] in, This represents a pre-determined sentence representation label. This represents the output result during the training of the first student model, where n1 represents the number of categories in the output result of the first student model.

[0012] According to the structured query language statement processing method provided in this disclosure, the second training sample includes labeled text and structured query language statement samples, as well as pre-determined representation pair labels. The loss function used by the first student model and the second student model during training is:

[0013]

[0014] in, This indicates a pre-determined pair of character labels. This represents the output result during the training of the second student model, and n2 represents the number of categories in the output result of the second student model.

[0015] According to the structured query language statement processing method provided in this disclosure, the method for constructing the second training sample includes:

[0016] Get the tagged text;

[0017] Based on the labeled text, a first normal form containing the table headers, operations, and table values ​​of the dataset table is constructed, and the first normal form is rewritten into a positive structured query language statement sample.

[0018] The labels that match the tagged text with the positive structured query language statement samples are used as labels representing successful pairings;

[0019] The other table headers and values ​​in the dataset table, along with the operations, are constructed into a second normal form, and the second normal form is rewritten into a negative structured query language statement sample.

[0020] Labels that do not match the marked text with negative structured query language statement samples are used as labels representing failed pairings.

[0021] According to the structured query language statement processing method provided in this disclosure, the step of obtaining table information, inputting the table information into the structured query language statement processing model, and outputting a structured query language statement includes:

[0022] The table information is input into the structured query language statement processing model, and the structured query language statements corresponding to several sub-tasks are output.

[0023] The step of inputting the table information into the structured query language statement processing model and outputting structured query language statements corresponding to several sub-tasks includes:

[0024] The structured query language statements corresponding to several subtasks are concatenated to form the target structured query language statement.

[0025] According to the structured query language statement processing method provided in this disclosure, the loss function used by the structured query language statement processing model during training is:

[0026]

[0027] Among them, y i This indicates a pre-determined language label. This represents the output Structured Query Language (SCL) statement, where n represents the number of categories of the output SCL statement.

[0028] This disclosure also provides a structured query language statement processing system, including:

[0029] The Structured Query Language (SCL) statement processing module is used to obtain table information, input the table information into the SCL statement processing model, and output a SCL statement.

[0030] The system further includes: a first distillation training module, used to input the first training sample into the first teacher model and the first student model respectively for distillation training to obtain the second student model, wherein the first teacher model is obtained by pre-training based on the first training sample;

[0031] The second distillation training module is used to input the second training samples into the second teacher model and the second student model respectively for distillation training to obtain the trained second student model. The second teacher model is obtained by pre-training based on the second training samples.

[0032] The structured query language statement processing model is obtained by training a pre-trained second student model, table samples, and pre-determined language labels.

[0033] According to the structured query language statement processing system provided in this disclosure, the structured query language statement processing module is further configured to:

[0034] The table information is input into the structured query language statement processing model, and the structured query language statements corresponding to several sub-tasks are output.

[0035] The system further includes a splicing module, which splices the structured query language statements corresponding to several sub-tasks together to form a target structured query language statement after outputting the structured query language statements corresponding to several sub-tasks.

[0036] This disclosure also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of any of the structured query language statement processing methods described above.

[0037] This disclosure also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the structured query language statement processing method described above.

[0038] The structured query language (SCL) statement processing method disclosed herein involves distilling a first training sample into a first teacher model and a first student model to obtain a pre-trained second student model. The second training sample is then input into the second teacher model and the second student model for distillation training to obtain a trained second student model. A SCL statement processing model is then trained based on this trained second student model. Since the second student model is a model obtained through distillation training, it significantly reduces the computational load and memory requirements of traditional table-based question-and-answer statement processing models compared to traditional models. Furthermore, training the SCL statement processing model using the distilled second student model allows the trained model to retain as much semantic information as possible from the table-based question-and-answer dataset. This overcomes the shortcomings of insufficient memory and slow inference time during online deployment while ensuring the accuracy and precision of the SCL statements. Attached Figure Description

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

[0040] Figure 1 This is one of the flowcharts illustrating the structured query language statement processing method provided in this embodiment of the disclosure;

[0041] Figure 2This is a second flowchart illustrating the structured query language statement processing method provided in this embodiment of the disclosure;

[0042] Figure 3 This is a schematic diagram of the semantic matching training data method in the structured query language statement processing method provided in this embodiment of the disclosure;

[0043] Figure 4 This is a schematic diagram of the structured query language statement processing system provided in this publication;

[0044] Figure 5 This is a schematic diagram of the structure of the electronic device provided in this disclosure. Detailed Implementation

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

[0046] This disclosure provides a method for processing structured query language statements. See also... Figure 1 The structured query language statement processing method includes:

[0047] S1: Obtain table information, input the table information into the structured query language statement processing model, and output structured query language statement.

[0048] Here, Structured Query Language (SQL) statements refer to SQL statements. Structured Query Language (SQL) is a special-purpose programming language, a database query and programming language used to access, query, update, and manage relational database systems.

[0049] In this embodiment of the disclosure, the first training sample is input into the first teacher model and the first student model respectively for distillation training to obtain the second student model; wherein, the first teacher model is obtained by pre-training based on the first training sample;

[0050] Model distillation is a technique for miniaturizing models. It typically involves a teacher model and a student model. During distillation, the teacher model's predictions serve as labels to supervise learning in the student model. Unlike traditional offline distillation, before training the student model, a portion of unlabeled data is input. The teacher model's output labels are then used as supervision information and fed into the student model. The distillation process is iterated through a series of samples, allowing for the use of a smaller dataset while improving model accuracy.

[0051] Before distillation, it's necessary to obtain the first training samples. This is to enable the first teacher model (which can use a 12-layer BERT) and the first student model (which can use a 4-layer Transformer) to acquire rich semantic representations. This can be achieved by inputting a massive amount of unlabeled data (which, because it's not business-related, is also called general data). Here, the output of the first teacher model is used as supervision information to control the learning of the first student model. This method mainly combines several well-known Chinese datasets and a large amount of data crawled from the internet to form a general training corpus, completing the general training of the 12-layer BERT and 4-layer Transformer models.

[0052] Then, the second training samples are input into the second teacher model and the second student model respectively for distillation training to obtain the trained second student model; wherein, the second teacher model is obtained by pre-training based on the second training samples;

[0053] The training process for the second student model and the second teacher model is the same as that for the first teacher model and the first student model, employing model distillation training, which is a pre-learning process involving distillation. Specifically, the second teacher model is obtained through pre-training based on the second training samples.

[0054] Finally, a structured query language statement processing model is obtained after training based on the trained second student model, table samples, and pre-determined language labels.

[0055] It should be explained that this disclosure obtains the final structured query language statement processing model by supervising the training of the second student model through table samples and pre-determined language labels.

[0056] The structured query language (SCL) statement processing method provided in this disclosure involves distilling a first training sample into a first teacher model and a first student model to obtain a pre-trained second student model. Then, the second training sample is input into the second teacher model and the second student model for distillation training to obtain a trained second student model. Finally, a SCL statement processing model is trained based on this trained second student model. Since the second student model is a model obtained through distillation training, it significantly reduces the computational load and memory requirements of table-based question-and-answer (CPA) models compared to traditional CPA-based statement processing models. Furthermore, training the SCL statement processing model using the distilled second student model allows the trained model to retain as much semantic information as possible from the CPA dataset. This overcomes the shortcomings of insufficient memory and slow inference time during online deployment while ensuring the accuracy and precision of the SCL statements.

[0057] According to the structured query language statement processing method provided in this disclosure, the first training sample includes unlabeled Chinese training corpus samples and pre-determined sentence representation labels, and the loss function used by the first student model during training is:

[0058]

[0059] in, This represents a pre-determined sentence representation label. This represents the output of the first student model during training, where n1 represents the number of categories in the first student model's output. During this training process, the output has two categories: the first category is paired sentence representations, and the second category is unpaired sentence representations. In this case, n1 is 2.

[0060] The first training sample uses a large-scale Chinese training corpus to achieve pre-training, allowing the model to be exposed to a wide variety of sentences and acquire rich Chinese knowledge. The first student model is trained by distillation through multiple iterations. The current iteration operation can be determined based on the loss function used by the first student model during training to determine whether the preset convergence condition has been met. If the convergence condition is met, the iteration can be stopped. The iteration is to supervise and ensure that the outputs of the first teacher model and the first student model are consistent.

[0061] According to the structured query language statement processing method provided in this disclosure, the second training sample includes labeled text and structured query language statement samples, as well as pre-determined representation pair labels. The loss function used by the second student model during training is:

[0062]

[0063] in, This indicates a pre-determined pair of character labels. This represents the output of the second student model during training, where n2 represents the number of categories in the second student model's output. During this training process, the output has two categories: successful sentence representation pairing and unsuccessful sentence representation pairing. In this case, n2 is 2.

[0064] It's important to note that SQL statements themselves cannot be directly input into the pre-trained model for learning. The SQL statement needs to be converted into a text statement, resulting in a (text statement, SQL statement) representation—this is the positive sample. Substituting the components of the SQL statement to create a different sentence creates the negative sample, which can then be learned using the second student model. This is to enable the model to learn domain-specific content, such as knowledge of SQL statements and text statements. By performing multiple iterations to distill the second student model, the convergence condition can be determined based on the loss function used during training. If the convergence condition is met, the iteration can be stopped.

[0065] According to the structured query language statement processing method provided in this disclosure, the method for constructing the second training sample includes:

[0066] Get the tagged text;

[0067] Based on the labeled text, a first normal form containing the table headers, operations, and table values ​​of the dataset table is constructed, and the first normal form is rewritten into a positive structured query language statement sample.

[0068] The labels that match the tagged text with the positive structured query language statement samples are used as labels representing successful pairings;

[0069] The other table headers and values ​​in the dataset table, along with the operations, are constructed into a second normal form, and the second normal form is rewritten into a negative structured query language statement sample.

[0070] Labels that do not match the marked text with negative structured query language statement samples are used as labels representing failed pairings.

[0071] The dataset table is a list of datasets presented in tabular form. Matching requires positive and negative samples. Positive samples are the SQL statements themselves; that is, the SQL statements are rewritten into natural language and paired with the original natural language for training. Negative samples are replaced with other values ​​from the table, where a mismatch occurs. The labels indicating that the tagged text does not match the negative structured query language statement samples are used as labels representing the pairing failure. The advantage of this construction is that it allows the model to focus on the information in the table headers and values, and by using operators to write it into a short sentence, it is also beneficial for obtaining longer semantic information.

[0072] According to the structured query language statement processing method provided in this disclosure embodiment, the step of obtaining table information, inputting the table information into the structured query language statement processing model, and outputting a structured query language statement includes:

[0073] The table information is input into the structured query language statement processing model, which outputs structured query language statements corresponding to several sub-tasks.

[0074] Multiple subtasks are generated by the Structured Query Language (SQL) statement processing model, meaning that each clause of the SQL statement is generated separately. The input of the SQL statement processing model is table information, and the final output is the SQL statement corresponding to several subtasks.

[0075] The step of inputting the table information into the structured query language statement processing model and outputting structured query language statements corresponding to several sub-tasks includes:

[0076] The structured query language statements corresponding to several subtasks are concatenated to form the target structured query language statement.

[0077] In other words, by connecting multiple structured query language statements corresponding to several sub-tasks, an SQL statement is formed.

[0078] According to the structured query language statement processing method provided in this disclosure embodiment, the first teacher model and the second teacher model each include a BERT (Bidirectional Encoder Representations from Transformers) layer, and the first student model and the second student model each include a transformer layer; the number of BERT layers is greater than the number of transformer layers.

[0079] BERT's network architecture uses a multi-layer Transformer structure. Its most significant feature is that it abandons traditional RNNs and CNNs, using an Attention mechanism to convert the distance between two words at any position into 1, effectively solving the thorny long-term dependency problem in NLP. The Transformer is an encoder-decoder structure, formed by stacking several encoders and decoders. The encoder consists of Multi-Head Attention and a fully connected layer, used to transform the input corpus into feature vectors. The decoder takes the encoder's output and the predicted result as input, and consists of Masked Multi-Head Attention, Multi-Head Attention, and a fully connected layer, used to output the conditional probability of the final result.

[0080] According to the structured query language statement processing method provided in this disclosure, for a single sample, taking SQL statement operators as an example, the loss function used by the structured query language statement processing model during training is:

[0081]

[0082] Among them, y i This indicates a pre-determined language label. This represents the output Structured Query Language (SCL) statement, where n represents the number of categories in the output SCL statement. If there are 7 categories, then n can be 7. During the training process of the SCL statement processing model, there are multiple tasks, and the number of n corresponding to each task may be different. If there are two fields, max and min, it is called binary classification; if there are 5 fields, it is called pentathlon.

[0083] The training samples include table samples and pre-determined language labels. The structured query language statement processing model is trained by performing multiple iterations. The current iteration operation can be determined based on the loss function used by the structured query language statement processing model during training to determine whether the preset convergence condition has been met. If the convergence condition is met, the iteration can be stopped. The iteration improves the accuracy of the structured query language statement processing model through deep learning.

[0084] To further understand the method of this embodiment, such as Figure 2 As shown, in a specific instance, the structured query language statement processing method of this embodiment includes:

[0085] S21, General Distillation:

[0086] Before distillation, to obtain rich semantic representations for the first teacher model (12-layer BERT model) and the first student model (4-layer Transformer model), a massive amount of unlabeled data (also called general data because it is not business-related) is input. The output of the first teacher model is used as supervisory information to control the learning of the first student model. This embodiment primarily uses several well-known Chinese datasets such as JDDC and a large amount of data crawled from the internet to form a general training corpus, completing the general training of the 12-layer BERT model and the 4-layer Transformer model.

[0087] S22. Matching task integration: Distillation of SQL statement semantics

[0088] Since the original distillation method uses a matching task for distillation, because its ultimate task is matching, and there is no direct relationship between table-based question-and-answer and matching tasks, the key to learning this task lies in how to construct a matching task from table-based question-and-answer data for distillation learning. To allow the model to learn query and SQL statement information in advance, distillation learning must consider both query and SQL statement information simultaneously. Furthermore, SQL statements contain both table header and value information; using only query or only value information is not conducive to the model comprehensively learning the semantic information in table-based question-and-answer data.

[0089] To address this, this disclosure presents a training method based on SQL statement semantics. First, the WHERE clause of the SQL statement is constructed into a normal form [header, operation, value]. Then, the normal form is rewritten into a short sentence. Matching training requires positive and negative samples; here, other table headers and values ​​are used to replace the headers and values ​​in the normal form to construct negative samples. For example, such as... Figure 3 The WHERE clause paradigm [time, =, October 1st] can be rewritten as the correct short sentence: "Time is October 1st". Replacing the time or October 1st with other information from the table will produce negative samples. The advantage of this construction is that it not only allows the model to focus on the information in the table header and values, but also, by using operators to write it into a short sentence, it is beneficial to obtain longer semantic information.

[0090] After obtaining the matching corpus, pairs of data are input into the second teacher model (BERT model) and the second student model (4-layer Transformer model). It is required that the inputs to each layer of the BERT and Transformer models be consistent; therefore, constraints are applied to the output of each layer. CrossEntropy loss is used to ensure consistency between the outputs of the second teacher and second student models. Once training is complete, a distillation model incorporating the semantics of SQL statements is obtained.

[0091] S22, Training of the table-based question-and-answer model:

[0092] After obtaining the distilled model that incorporates the semantics of SQL statements, the distilled model is used as a pre-training model to train multiple sub-tasks of table-based question answering. The model can be divided into the following 7 sub-tasks. When the model outputs these sub-tasks, concatenating them yields the final SQL statement. For example:

[0093] s_sum: How many items were selected;

[0094] w_sum: The number of columns in the WHERE clause;

[0095] order: Does the order by exist?

[0096] agg: What is the agg(max,min,count) operation for the current column?

[0097] What are the operators (>, <, =) for the current column and value in conn_op?

[0098] conns_op: What is the connector (AND, OR) of the current SQL statement?

[0099] w_value: What is the value in the WHERE clause?

[0100] Detailed Explanation: A basic SQL statement consists of multiple parts, such as `select agg sel_column from table wherewhere_column1 op1 value1 conn where_colnum2 op2 value2`. Therefore, it is extremely difficult for a model to directly and automatically convert natural language into such a complex SQL statement and execute it correctly. This patent decomposes the SQL statement generation problem into multiple subtasks, as shown in the modules above, each representing a subtask. The model obtains the result of each subtask, and finally, the various parts are concatenated to form the output SQL statement.

[0101] To verify the effectiveness of the distilled model, quantitative analysis was also conducted in the embodiments disclosed herein. Performance analysis in Table 1 shows that, compared to the original BERT model, the distilled model of this patent is nearly twice as fast, processing only 6.46 seconds per 100 data points; and its size is only 45MB, approximately 1 / 9 of the original. This not only significantly improves response efficiency but also reduces the demand for computer memory, saving considerable computing resources.

[0102] Table 1

[0103] Model Model size Runtime (per 100 records) BERT 45M 6.46s The 4-layer Transformer after distillation 393M 11.59s

[0104] Table 2 shows the accuracy analysis. Compared with the general 4-layer Transformer model, the distillation training method that integrates SQL statement semantics proposed in this disclosure improves the accuracy of the model by 5%.

[0105] Table 2

[0106]

[0107] This disclosure provides an embodiment of a structured query language statement processing system, see [link to documentation]. Figure 4 The structured query language statement processing system includes:

[0108] The Structured Query Language (SCL) statement processing module 401 is used to obtain table information, input the table information into the SCL statement processing model, and output a structured query language statement.

[0109] The system further includes: a first distillation training module 402, used to input the first training sample into the first teacher model and the first student model respectively for distillation training to obtain the second student model, wherein the first teacher model is obtained by pre-training based on the first training sample;

[0110] The second distillation training module 403 is used to input the second training samples into the second teacher model and the second student model respectively for distillation training to obtain the trained second student model. The second teacher model is obtained by pre-training based on the second training samples.

[0111] The structured query language statement processing model is obtained by training a pre-trained second student model, table samples, and pre-determined language labels.

[0112] According to the structured query language sentence processing system provided in this disclosure, the first training sample includes unlabeled Chinese training corpus samples and pre-determined sentence representation labels, and the loss function used by the first student model during training is:

[0113]

[0114] in, This represents a pre-determined sentence representation label. This represents the output of the first student model during training, where n1 represents the number of categories in the first student model's output. During this training process, the output has two categories: the first category is paired sentence representations, and the second category is unpaired sentence representations. In this case, n1 is 2.

[0115] The first training sample uses a large-scale Chinese training corpus to achieve pre-training, allowing the model to be exposed to a wide variety of sentences and acquire rich Chinese knowledge. The first student model is trained by distillation through multiple iterations. The current iteration operation can be determined based on the loss function used by the first student model during training to determine whether the preset convergence condition has been met. If the convergence condition is met, the iteration can be stopped. The iteration is for supervision to ensure that the outputs of the teacher and student are consistent.

[0116] According to the structured query language statement processing system provided in this disclosure, the second training sample includes labeled text and structured query language statement samples, as well as pre-determined representation pair labels. The loss function used by the second student model during training is:

[0117]

[0118] in, This indicates a pre-determined pair of character labels. This represents the output of the second student model during training, where n2 represents the number of categories in the second student model's output. During this training process, the output has two categories: successful sentence representation pairing and unsuccessful sentence representation pairing. In this case, n2 is 2.

[0119] The structured query language statement processing system provided according to embodiments of this disclosure further includes a second training sample construction module, used for:

[0120] Get the tagged text;

[0121] Based on the labeled text, a first normal form containing the table headers, operations, and table values ​​of the dataset table is constructed, and the first normal form is rewritten into a positive structured query language statement sample.

[0122] The labels that match the tagged text with the positive structured query language statement samples are used as labels representing successful pairings;

[0123] The other table headers and values ​​in the dataset table, along with the operations, are constructed into a second normal form, and the second normal form is rewritten into a negative structured query language statement sample.

[0124] Labels that do not match the marked text with negative structured query language statement samples are used as labels representing failed pairings.

[0125] According to the structured query language statement processing system provided in this disclosure embodiment, the structured query language statement processing module 401 is specifically used to: input the table information into the structured query language statement processing model, and output structured query language statements corresponding to several sub-tasks.

[0126] Multiple subtasks are generated by the Structured Query Language (SQL) statement processing model, meaning that each clause of the SQL is generated separately. The input to the SQL statement processing model is table information, and the final output is the SQL statement corresponding to several subtasks.

[0127] The system further includes a splicing module, which splices the structured query language statements corresponding to several sub-tasks together to form a target structured query language statement after outputting the structured query language statements corresponding to several sub-tasks.

[0128] According to the structured query language statement processing system provided in this disclosure embodiment, for a single sample, taking SQL operators as an example, the loss function used by the structured query language statement processing model during training is:

[0129]

[0130] Among them, y i This indicates a pre-determined language label. This represents the output Structured Query Language (SCL) statement, where n represents the number of categories in the output SCL statement. If there are 7 categories, then n can be 7. During the training process of the SCL statement processing model, there are multiple tasks, and the number of n corresponding to each task may be different. If there are two fields, max and min, it is called binary classification; if there are 5 fields, it is called pentathlon.

[0131] The training samples include table samples and pre-determined language labels. The structured query language statement processing model is trained by performing multiple iterations. The current iteration operation can be determined based on the loss function used by the structured query language statement processing model during training to determine whether the preset convergence condition has been met. If the convergence condition is met, the iteration can be stopped. The iteration improves the accuracy of the structured query language statement processing model through deep learning.

[0132] Figure 5 A schematic diagram of the physical structure of an electronic device is provided. This electronic device may include: a processor 510, a communication interface 520, a memory 530, and a communication bus 540. The processor 510, communication interface 520, and memory 530 communicate with each other via the communication bus 540. The processor 510 can invoke logical instructions from the memory 530 to execute a structured query language statement processing method, which includes:

[0133] Obtain table information, input the table information into the structured query language statement processing model, and output a structured query language statement;

[0134] Specifically, the first training sample is input into the first teacher model and the first student model respectively for distillation training to obtain the second student model. The first teacher model is obtained by pre-training based on the first training sample.

[0135] The second training sample is input into the second teacher model and the second student model respectively for distillation training to obtain the trained second student model. The second teacher model is obtained by pre-training based on the second training sample.

[0136] The structured query language statement processing model is obtained by training a pre-trained second student model, table samples, and pre-determined language labels.

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

[0138] On the other hand, embodiments of this disclosure also provide a computer program product, the computer program product including a computer program stored on a non-transitory computer-readable storage medium, the computer program including program instructions, and when the program instructions are executed by a computer, the computer is able to execute a structured query language statement processing method, the method including:

[0139] Obtain table information, input the table information into the structured query language statement processing model, and output a structured query language statement;

[0140] Specifically, the first training sample is input into the first teacher model and the first student model respectively for distillation training to obtain the second student model. The first teacher model is obtained by pre-training based on the first training sample.

[0141] The second training sample is input into the second teacher model and the second student model respectively for distillation training to obtain the trained second student model. The second teacher model is obtained by pre-training based on the second training sample.

[0142] The structured query language statement processing model is obtained by training a pre-trained second student model, table samples, and pre-determined language labels.

[0143] In another aspect, embodiments of this disclosure also provide a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform a structured query language statement processing method, the method comprising:

[0144] Obtain table information, input the table information into the structured query language statement processing model, and output a structured query language statement;

[0145] Specifically, the first training sample is input into the first teacher model and the first student model respectively for distillation training to obtain the second student model. The first teacher model is obtained by pre-training based on the first training sample.

[0146] The second training sample is input into the second teacher model and the second student model respectively for distillation training to obtain the trained second student model. The second teacher model is obtained by pre-training based on the second training sample.

[0147] The structured query language statement processing model is obtained by training a pre-trained second student model, table samples, and pre-determined language labels.

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

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

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

Claims

1. A method of processing structured query language statements, the method comprising: The method comprises: obtaining table information, inputting the table information into a structured query language statement processing model, and outputting a structured query language statement; wherein the first training sample is input into a first teacher model and a first student model respectively for distillation training to obtain a second student model, and the first teacher model is obtained based on the first training sample through pre-training; the second training sample is input into a second teacher model and the second student model respectively for distillation training to obtain a trained second student model, and the second teacher model is obtained based on the second training sample through pre-training; the structured query language statement processing model is obtained based on the trained second student model, a table sample, and a predetermined language label through training; the construction method of the second training sample comprises: obtaining a marked text; based on the marked text, constructing a first normal form containing table headers, operations and table values in a data set table, rewriting the first normal form into a positive structured query language statement sample; a label matched with the positive structured query language statement sample is taken as a representation pairing success label; other table headers and table values in the data set table and the operation are constructed into a second normal form, and the second normal form is rewritten into a negative structured query language statement sample; a label not matched with the negative structured query language statement sample is taken as a representation pairing failure label.

2. The method of claim 1, wherein, The first training sample comprises an unlabeled Chinese training corpus sample and a predetermined sentence representation label, and a loss function adopted by the first student model in the training process is: wherein, represents a predetermined sentence representation label, represents an output result of the first student model training, and n1 represents a classification number of the first student model output result.

3. The method of claim 1, wherein, The second training sample comprises a marked text and a structured query language statement sample and a predetermined representation pairing label, and a loss function adopted by the second student model in the training process is: wherein, represents a predetermined pair of labels, represents an output result of the second student model training, and n2 represents a classification number of the second student model output result.

4. The method of claim 1, wherein, The method of obtaining table information, inputting the table information into the structured query language statement processing model, and outputting a structured query language statement comprises: inputting the table information into the structured query language statement processing model to output structured query language statements corresponding to a plurality of subtasks; after outputting the structured query language statements corresponding to the plurality of subtasks, the method comprises: splicing the structured query language statements corresponding to the plurality of subtasks to form a target structured query language statement.

5. The method of claim 1, wherein, The loss function adopted by the structured query language statement processing model in the training process is: wherein y i represents a predetermined language tag, represents an output structured query language sentence, and n represents the number of categories of the output structured query language sentence.

6. A structured query language statement processing system, characterized by, The system comprises: a structured query language statement processing module, configured to obtain table information, input the table information into a structured query language statement processing model, and output a structured query language statement; wherein the system further comprises a first distillation training module, configured to input a first training sample into a first teacher model and a first student model respectively for distillation training to obtain a second student model, and the first teacher model is obtained based on the first training sample through pre-training; a second distillation training module, configured to input the second training sample into a second teacher model and the second student model respectively for distillation training, to obtain a trained second student model, the second teacher model being obtained based on the second training sample and pre-training; the structured query language sentence processing model is obtained based on the trained second student model, a table sample, and a predetermined language label after training; a second training sample construction module, configured to: obtain a marked text; based on the marked text, construct a first normal form containing table headers, operations, and table values in a data set table, rewrite the first normal form into a positive structured query language sentence sample; match a label of the marked text with the positive structured query language sentence sample as a representation of a successful pairing label; construct other table headers and table values in the data set table and the operations into a second normal form, rewrite the second normal form into a negative structured query language sentence sample; match a label of the marked text with the negative structured query language sentence sample as a representation of a failed pairing label.

7. The structured query language statement processing system of claim 6, wherein, the structured query language sentence processing module is further configured to: input the table information into the structured query language sentence processing model, and output structured query language sentences corresponding to a plurality of subtasks; the system further includes a splicing module configured to splice the structured query language sentences corresponding to the plurality of subtasks to form a target structured query language sentence after outputting the structured query language sentences corresponding to the plurality of subtasks.

8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, the processor executes the program to implement the steps of the structured query language sentence processing method according to any one of claims 1 to 5. 9.A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, the computer program is executed by the processor to implement the steps of the structured query language sentence processing method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method for generating structured query statement based on natural language

    CN111813802A

  • Method and apparatus for outputting structured query sentence

    US20210200763A1