Language conversion model training method, conversion method, device, apparatus and medium

By decomposing the prediction task of the NL2SQL model into the prediction of selection clauses and conditional clauses, and using a shared decoder and multi-task learning method, the problem of high model training difficulty is solved, and more efficient NL2SQL conversion is achieved.

CN116028527BActive Publication Date: 2026-07-03CHINA UNITED NETWORK COMM GRP CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA UNITED NETWORK COMM GRP CO LTD
Filing Date
2023-01-30
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing NL2SQL models have complex structures, making them difficult to train and hindering their ability to effectively learn the relationship between natural language queries and database query languages.

Method used

The natural language query sequence and column name information in the associated table are concatenated into a long sequence information. Two decoders are used to process the features of the selection clause and the conditional clause respectively. Multi-task learning and shared decoder are used to reduce model complexity, and a loss function is constructed to adjust the model parameters.

Benefits of technology

It reduces the structural complexity and number of parameters of the model, improves the ease and accuracy of model training, and enhances the efficiency of NL2SQL conversion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116028527B_ABST
    Figure CN116028527B_ABST
Patent Text Reader

Abstract

This invention discloses a training method, conversion method, apparatus, device, and medium for a language conversion model, belonging to the field of computer technology, and solves the problem of high training difficulty caused by the complexity of the model structure. The method includes: concatenating column name information from a natural language query sequence and a semantic matching association table into a long sequence; training a pre-constructed language conversion model based on the long sequence information to obtain a trained language conversion model. The language conversion model is used to determine the correspondence between the natural language sequence and the structured query language sequence, which includes selection clauses and conditional clauses. During the model training process, a first decoder is used to determine the prediction result of the selection clause based on its features, and a second decoder is used to obtain the prediction result of the conditional clause based on its features. This method can reduce the difficulty of model training.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and specifically to a training method, conversion method, apparatus, device, and medium for a language conversion model. Background Technology

[0002] Structured Query Language (SQL) is the standard query language for databases. The method of converting natural language (NL) into computer-executable structured query language (NL To SQL, NL2SQL), also known as the NL2SQL method, is essentially a process of converting natural language sequences into SQL sequences.

[0003] Because SQL statements need to meet strict syntactic constraints, NL2SQL methods are usually implemented based on deep learning models. Currently, the model structures for implementing NL2SQL are quite complex, making model training difficult. Summary of the Invention

[0004] To address this issue, the present invention provides a training method, conversion method, apparatus, device, and medium for a language conversion model, thereby solving the problem of high training difficulty caused by the complex model structure in the prior art.

[0005] To achieve the above objectives, a first aspect of the present invention provides a training method for a language conversion model. The method includes: concatenating a natural language query sequence and column name information from an association table used for semantic matching into a long sequence; training a pre-constructed language conversion model based on the long sequence information to obtain a trained language conversion model; wherein the language conversion model is used to determine the correspondence between a natural language sequence and a structured query language sequence, the structured query language sequence including a selection clause and a conditional clause, and the network structure of the language conversion model including a first decoder and a second decoder; during the model training process of the language conversion model, the first decoder is used to determine the prediction result of the selection clause based on the features of the selection clause, and the second decoder is used to obtain the prediction result of the conditional clause based on the features of the conditional clause.

[0006] The step of training a pre-constructed language conversion model based on the long sequence information to obtain a trained language conversion model includes: extracting features from the long sequence information to obtain feature encodings of the long sequence information; processing the feature encodings of the long sequence information using a first decoder to obtain a prediction result for a selection clause; processing the feature encodings of the long sequence information using a second decoder to obtain a prediction result for a conditional clause; constructing a loss function based on the prediction result of the selection clause, the annotation result of the selection clause, the prediction result of the conditional clause, and the annotation result of the conditional clause; and adjusting the model parameters of the language conversion model using the loss function to obtain the trained language conversion model using the adjusted model parameters.

[0007] The selection clause includes a column name selection clause and an aggregation function selection clause; the step of using the feature encoding of the long sequence information processed by the first decoder to obtain the prediction result of the selection clause includes:

[0008] The feature encoding of the long sequence information is input into the first decoder for processing to obtain a first natural language query feature vector and a first column name feature vector corresponding to the selection clause. The first natural language query feature vector and the first column name feature vector are then processed by a preset first fully connected layer to obtain the prediction result of the selection column name clause. The first fully connected layer is used to determine the correspondence between the prediction result of the selection column name clause and the first natural language query feature vector and the first column name feature vector. The first natural language query feature vector and the first column name feature vector are then processed by a preset second fully connected layer to obtain the prediction result of the selection aggregation function clause. The second fully connected layer is used to determine the correspondence between the prediction result of the selection aggregation function clause and the first natural language query feature vector and the first column name feature vector. The prediction results of the selection column name clause and the selection aggregation function clause are used as the prediction result of the selection clause.

[0009] The conditional clause includes the number of conditions, the column name selected for each condition, an operator, and the corresponding value of the operator. The step of processing the feature encoding of the long sequence information using the second decoder to obtain the prediction result of the conditional clause includes: inputting the feature encoding of the long sequence information into the second decoder for processing to obtain a second natural language query feature vector and a second column name feature vector corresponding to the conditional clause; processing the second natural language query feature vector through a preset third fully connected layer to obtain the prediction result of the number of conditions, wherein the third fully connected layer is used to determine the correspondence between the prediction result of the number of conditions and the second natural language query feature vector; processing the second natural language query feature vector and the second column name feature vector through a preset fourth fully connected layer to obtain the prediction result of the column name selected for each condition, wherein the fourth fully connected layer is used to determine the correspondence between the prediction result of the column name selected for each condition and the second natural language query feature vector and the second column name feature vector; and processing the second natural language query feature vector and the second column name feature vector through a preset fifth fully connected layer to obtain the prediction result of the operator. The first layer is used to determine the correspondence between the prediction result of the operator and the second natural language query feature vector and the second column name feature vector; the second natural language query feature vector and the second column name feature vector are processed by a preset sixth fully connected layer to obtain the prediction result of the first position, where the first position is the starting position of the value corresponding to the operator in the natural language query sequence, and the sixth fully connected layer is used to determine the correspondence between the prediction result of the first position and the second natural language query feature vector and the second column name feature vector; the second natural language query feature vector and the second column name feature vector are processed by a preset seventh fully connected layer to obtain the prediction result of the second position, where the second position is the ending position of the value corresponding to the operator in the natural language query sequence, and the seventh fully connected layer is used to determine the correspondence between the prediction result of the second position and the second natural language query feature vector and the second column name feature vector; the prediction result of the number of conditions, the prediction result of the column name selected for each condition, the prediction result of the operator, the prediction result of the first position, and the prediction result of the second position are used as the prediction result of the conditional clause.

[0010] The step of constructing a loss function based on the prediction result of the selection clause, the annotation result of the selection clause, the prediction result of the conditional clause, and the annotation result of the conditional clause includes: constructing a first loss function based on the prediction result of the selection clause and the annotation result of the selection clause; constructing a second loss function based on the prediction result of the conditional clause and the annotation result of the conditional clause; and performing a weighted summation of the first loss function and the second loss function, using the weighted summation result as the constructed loss function.

[0011] The step of concatenating the natural language query sequence and column name information in the association table used for semantic matching into a long sequence information includes: using a bidirectional long short-term memory model to obtain the semantic vector of the natural language query sequence as a first semantic representation vector; using the bidirectional long short-term memory model to obtain the semantic representation vector of at least one set of column association information in the association table, each set of column association information including a column name and a corresponding column type; calculating the cosine similarity between the first semantic representation vector and the semantic representation vector of each set of column association information, as the corresponding semantic matching degree; obtaining a predetermined number of cosine similarities in descending order, and using the set of column association information to which the predetermined number of cosine similarities belong as the filtered set of column association information; and concatenating the natural language query sequence and the filtered set of column association information into the long sequence information.

[0012] A second aspect of the present invention provides a language conversion method, the language conversion method comprising: acquiring a natural language query sequence; inputting the natural language query sequence into a preset language conversion model for language conversion to obtain a corresponding structured query language; wherein the language conversion model is a model trained according to any of the language conversion model training methods of the first aspect.

[0013] A third aspect of the present invention provides a training apparatus for a language conversion model, comprising: a concatenation module for concatenating a natural language query sequence and column name information in an association table used for semantic matching into a long sequence of information; and a training module for training a pre-constructed language conversion model based on the long sequence of information to obtain a trained language conversion model; wherein the language conversion model is used to determine the correspondence between a natural language sequence and a structured query language sequence, the structured query language sequence including a selection clause and a conditional clause, and the network structure of the language conversion model including a first decoder and a second decoder; during the model training process of the language conversion model, the first decoder is used to determine the prediction result of the selection clause based on the features of the selection clause, and the second decoder is used to obtain the prediction result of the conditional clause based on the features of the conditional clause.

[0014] A fourth aspect of the present invention provides a language conversion device, the language conversion device comprising: an acquisition module for acquiring a natural language query sequence; and a conversion module for inputting the natural language query sequence into a preset language conversion model for language conversion to obtain a corresponding structured query language; wherein the language conversion model is a model trained by the training method of any of the language conversion models in the second aspect above.

[0015] A fifth aspect of the present invention provides an electronic device, comprising: one or more processors; a memory storing one or more programs thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement a training method for a language conversion model of the first aspect of the present invention or a language conversion method of the second aspect; and one or more I / O interfaces connected between the processors and the memory, configured to enable information interaction between the processors and the memory.

[0016] The fifth aspect of the present invention provides a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements a training method for a language conversion model according to the first aspect of the present invention or a language conversion method according to the second aspect.

[0017] According to the training method of the language conversion model of the present invention, the prediction of NL2SQL can be decomposed into the prediction of the selection clause and the prediction of the condition clause. In this way, only two encoders are used for prediction. The first decoder is used to determine the prediction result of the selection clause based on the features of the selection clause, and the second decoder is used to obtain the prediction result of the condition clause based on the features of the condition clause. In related technologies, different decoders are used to complete the prediction of different contents such as query target and aggregation function contained in the selection clause, and different decoders are used to predict different contents in the limiting conditions. Compared with related technologies, in the present invention, the prediction of different contents in the selection clause can be achieved by sharing the first decoder, and the prediction of different contents in the condition clause can be achieved by sharing the second decoder. By sharing the decoders, the number of decoders used is reduced, thereby reducing the structural complexity of the model, which is beneficial to reducing the number of model parameters and reducing the difficulty of model training. Attached Figure Description

[0018] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the following detailed description to explain the invention, but do not constitute a limitation thereof.

[0019] Figure 1 A flowchart illustrating a training method for a language conversion model provided in an embodiment of the present invention;

[0020] Figure 2A schematic diagram illustrating the components of an SQL statement provided in an embodiment of the present invention;

[0021] Figure 3 This is a schematic diagram of the language conversion model structure provided in an embodiment of the present invention;

[0022] Figure 4a This is a schematic diagram of the decoder for each subtask in the prediction task in related technologies;

[0023] Figure 4b A comparative schematic diagram of the structure of the shared decoder provided in the embodiments of the present invention;

[0024] Figure 5 A flowchart of a language conversion method provided in an embodiment of the present invention;

[0025] Figure 6 This diagram illustrates the structure of a training device for a language conversion model provided in an embodiment of the present invention.

[0026] Figure 7 This is a schematic diagram of the structure of the language conversion device provided in an embodiment of the present invention;

[0027] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0028] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.

[0029] As used in this invention, the term "and / or" includes any and all combinations of one or more of the associated enumerated entries.

[0030] The terminology used in this invention is for describing particular embodiments only and is not intended to limit the invention. As used herein, the singular forms "a" and "the" are also intended to include the plural forms, unless the context clearly indicates otherwise.

[0031] When the terms “comprising” and / or “made of” are used in this invention, they specify the presence of features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or groups thereof.

[0032] Embodiments of the present invention can be described with reference to plan views and / or cross-sectional views using the ideal schematic diagrams of the invention. Therefore, the example illustrations may be modified according to manufacturing techniques and / or tolerances.

[0033] Unless otherwise specified, all terms used in this invention (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in common dictionaries should be interpreted as having the meaning consistent with their meaning in the context of the relevant art and the invention, and will not be interpreted as having an idealized or overly formal meaning unless expressly so defined by the invention.

[0034] Current deep learning-based NL2SQL methods require various decoders to predict the query target, aggregation function, and constraints. When the table has many long column names, the input sequence becomes very long, making it difficult for the model to learn the relationship between natural language queries and column names. Furthermore, using multiple decoders not only increases the model's structural complexity and number of parameters, making training more difficult, but also prevents the decoders from learning the relationships between different subtasks.

[0035] In a first aspect, embodiments of the present invention provide a method for training a language conversion model.

[0036] Figure 1 This is a flowchart illustrating a training method for a language conversion model according to an embodiment of the present invention. Figure 1 As shown, the training method for the language conversion model in this embodiment of the invention includes the following steps.

[0037] Step S110: Concatenate the natural language query sequence and the column name information in the association table used for semantic matching into a long sequence information.

[0038] Text2SQL can solve the problem of mapping natural language to the database query language SQL by using tables involved in database query statements to perform semantic matching in the mapping process from natural language to database query language.

[0039] In this step, the association table is used for semantic matching. The association table can be a table schema in a relational database. For example, for querying employee information, the association table could be named "Employee Information Table," and the column names could include: Employee ID, Name, Age, Department, and Length of Service.

[0040] Step S120: Train the pre-built language conversion model based on long sequence information to obtain the trained language conversion model.

[0041] The language conversion model is used to determine the correspondence between natural language sequences and structured query language sequences. The structured query language sequences include selection clauses and conditional clauses. The network structure of the language conversion model includes a first decoder and a second decoder. During the training process of the language conversion model, the first decoder is used to determine the prediction result of the selection clause based on the features of the selection clause, and the second decoder is used to obtain the prediction result of the conditional clause based on the features of the conditional clause.

[0042] In this step, the Select and WHERE clauses are sentence segments from a sequence of sentences in the Structured Query Language (SMQ) statement. The Select clause is used to select data from the associated table that meets certain conditions, and the WHERE clause is used to specify the selection criteria. In other words, if you need to select data from the table conditionally, you can add a WHERE clause to the SELECT statement.

[0043] According to the training method of the language conversion model of the present invention, the prediction of NL2SQL is decomposed into the prediction of the selection clause and the prediction of the condition clause. In this way, only two encoders are used for prediction. The first decoder is used to determine the prediction result of the selection clause based on the features of the selection clause, and the second decoder is used to obtain the prediction result of the condition clause based on the features of the condition clause. In related technologies, different decoders are used to complete the prediction of different contents such as query target and aggregation function contained in the selection clause, and different decoders are used to predict different contents in the limiting conditions. Compared with related technologies, in the present invention, the prediction of different contents in the selection clause can be achieved by sharing the first decoder, and the prediction of different contents in the condition clause can be achieved by sharing the second decoder. By sharing the decoder, the number of decoders used is reduced, thereby reducing the structural complexity of the model, which is beneficial to reducing the number of model parameters and reducing the difficulty of model training.

[0044] Figure 2 A schematic diagram illustrating the components of an SQL statement provided in an embodiment of the present invention.

[0045] pass Figure 2As can be seen, an SQL statement consists of a SELECT clause and a WHERE clause. The task of predicting the sequence of Structured Query Language (SCL) statements can be broken down into six sub-tasks: predicting the column names selected in the SELECT clause (Select-Column, SC or S-COL), predicting the aggregate functions selected in the SELECT clause (Select-Aggregation, SA or S-AGG), predicting the number of conditions in the WHERE clause (Where-Numbe, WN or W-NUM), and predicting the columns selected for each condition in the WHERE clause (Where-Column, WC or W-COL), operators (Where-Operators, WO or W-OP), and values ​​(Where-Value, WV or W-VAL).

[0046] Figure 3 This is a schematic diagram of the language conversion model structure provided in an embodiment of the present invention. In the following description of the embodiments, the language conversion model will be referred to as the NL2SQL model. Figure 3 As can be seen, the NL2SQL model structure includes an encoder, a decoder, and an output layer.

[0047] In step S110 above, the natural language query sequence Q and the column used for semantic matching are concatenated into a long sequence. The information of the concatenated long sequence is as follows:

[0048]

[0049] In this context, the [CLS] flag in the long sequence information X is located at the beginning of the first sentence, and the representation vector obtained after the encoder can be used for subsequent classification tasks; the [SEP] flag is located after the natural language query sequence Q and between the column association information. This represents the column name of the i-th column used for semantic matching. This indicates the column type of the i-th column, where i is an integer greater than or equal to 1 and less than or equal to k, and k is the total number of columns in the associated table.

[0050] In some embodiments, the NL2SQL model can use a pre-trained language model (Bidirectional Encoder Representation from Transformers, BERT) as the encoder, or other deep learning models such as the Long Short-Term Memory (LSTM) model or the pre-trained language representation with iNformatIve Entities (ERNIE) model as the encoder.

[0051] The concatenated long sequence information can be input into the NL2SQL model, and after feature extraction by the encoder based on the BERT model, the feature code corresponding to each element in the long sequence information X can be obtained:

[0052]

[0053] Among them, H X H is the feature encoding set. X Each element in the sequence is a feature encoding of an element in the long sequence information.

[0054] refer to Figure 3 The BERT model is used as the encoder in the NL2SQL model. Each input of the encoder is a word embedding, which is a vector that a single word is mapped to in a predefined vector space. The encoder encodes the input word embeddings to obtain the feature code corresponding to each word embedding.

[0055] For example, the encoder encodes the vector of the [CLS] flag bits, outputting the feature code h. [CLS] The encoder encodes each word in the natural language query sequence Q, such as q1, q2, and q3, outputting their corresponding feature codes h1, h2, and h3. The encoder also encodes the vector of the [SEP] flag bits, outputting the feature code h. [SEP] The encoder encodes the i-th column (col_i) and column type (col_i_type), and outputs their respective feature codes h. col_i and h col_i_type .

[0056] Continue to refer to Figure 3 In the NL2SQL model, an LSTM model can be used as a decoder. For example, the decoder processes the input feature encoding and decodes it, resulting in the corresponding output sequence (natural language query feature vector W). emb_n and column name eigenvector r ci The output sequence is processed through a fully connected output layer to predict the column names selected in the SELECT clause, the aggregate functions selected in the SELECT clause, the number of conditions in the WHERE clause, and the columns, operators, and values ​​selected for each condition in the WHERE clause.

[0057] In some embodiments, step S120 may specifically include the following steps:

[0058] S11, extract the features of the long sequence information to obtain the feature encoding of the long sequence information.

[0059] S12, the feature encoding of the long sequence information is processed by the first decoder to obtain the prediction result of the selection clause.

[0060] S13, the feature encoding of long sequence information is processed by the second decoder to obtain the prediction result of the conditional clause.

[0061] In steps S11-S13, both the first decoder and the second decoder are used to reconstruct the corresponding SQL statement from the encoded features; wherein, the first decoder is used to process the feature encoding of long sequence information to obtain the prediction result of the selection clause in the SQL statement, and the second decoder is used to process the feature encoding of long sequence information to obtain the prediction result of the condition clause in the SQL statement.

[0062] S14, construct a loss function based on the prediction results, annotation results, and conditional clause results of the selection clause, respectively. In step S14, the loss function of the selection clause is calculated using the prediction and annotation results of the selection clause; the loss function of the conditional clause is calculated using the prediction and annotation results of the conditional clause; the loss functions of the selection clause and the conditional clause are added together to obtain the total loss function, which is then used as the constructed loss function.

[0063] S15. Using the loss function, adjust the model parameters of the language conversion model to obtain the trained language conversion model using the adjusted model parameters.

[0064] In step S15, the gradient corresponding to the loss function can be determined, and the model parameters of the language conversion model can be adjusted according to the gradient corresponding to the loss function.

[0065] Through the above steps S11-S15, the prediction of different contents in the selection clause can be achieved by sharing the first decoder, and the prediction of different contents in the conditional clause can be achieved by sharing the second decoder. By sharing the decoders, the number of decoders used is reduced, thereby reducing the structural complexity of the model, which is beneficial to reducing the number of model parameters and reducing the difficulty of model training.

[0066] In some embodiments, the selection clause includes a column name selection clause and an aggregate function selection clause; the condition clause includes the number of conditions, the column name selected for each condition, the operator, and the corresponding value of the operator.

[0067] Figure 4a A schematic diagram of the decoder for each subtask of the prediction task in the related technology; Figure 4b This is a schematic diagram comparing the structure of the shared decoder for the subtasks of the prediction task in an embodiment of the present invention.

[0068] pass Figure 4aAs can be seen, in related technologies, the prediction task of the structured query language sequence is decomposed into multiple subtasks, each corresponding to a decoder. For example, the SA decoder is used to predict the column names (SC) selected in the SELECT clause, the SC decoder is used to predict the aggregate functions (SA) selected in the SELECT clause, and so on. The WV decoder is used to predict the filter values ​​corresponding to the selected columns of each condition in the WHERE clause.

[0069] pass Figure 4b As can be seen, in this invention, the decoder is divided into a SELECT decoder and a WHERE decoder. The prediction of the column name (SC) selected in the SELECT clause and the prediction of the aggregate function (SA) selected in the SELECT clause can share the SELECT decoder. The prediction of the column (WC) selected for each condition in the WHERE clause, the prediction of the operator (WO), and the prediction of the filter value (WV) can share the WHERE decoder.

[0070] Therefore, the training method of the language conversion model in this embodiment of the invention can use a shared decoder based on a multi-task learning method to reduce the structural complexity and number of parameters of the model, making the model easier to train and converge. Furthermore, the shared decoder enables the decoder to learn the correlation between different sub-tasks, thereby improving the conversion accuracy of the model.

[0071] The following example uses a Bi-directional Long Short-Term Memory (Bi-LSTM) network as the decoder, where the SA and SC tasks of the SELECT clause share a single decoder, and the WN, WC, WO, and WV tasks of the WHERE clause share a single decoder, to describe the specific process of training the language conversion model.

[0072] In some embodiments, step S12 may specifically include:

[0073] S21, the feature encoding of the long sequence information is input into the first decoder for processing to obtain the first natural language query feature vector and the first column name feature vector corresponding to the selection clause.

[0074] In this step, the first decoder is... Figure 4b The SELECT decoder in [the context of the original text].

[0075] Specifically, the natural language query and column name representations output by the SELECT clause decoder are as follows: h Q Feature encoding of natural language query sequences in long sequence information; This is the feature encoding of the column name and column type of the i-th column in the long sequence information. In other words, the first natural language query feature vector is obtained by decoding the natural language query sequence feature encoding in the long sequence information using Bi-LSTM. The first column name feature vector is obtained by decoding the feature encoding of the column name and column type of the i-th column in the long sequence information using Bi-LSTM.

[0076] S22, the first natural language query feature vector and the first column name feature vector are processed by the preset first fully connected layer to obtain the prediction result of the column name selection clause. The first fully connected layer is used to determine the correspondence between the prediction result of the column name selection clause and the first natural language query feature vector and the first column name feature vector.

[0077] S23, the first natural language query feature vector and the first column name feature vector are processed by the preset second fully connected layer to obtain the prediction result of the selection aggregation function clause. The second fully connected layer is used to determine the correspondence between the prediction result of the selection aggregation function clause and the first natural language query feature vector and the first column name feature vector.

[0078] In this step, according to and Two fully connected output layers are used to predict SC and SA, and the specific calculation formulas include the following formulas (1) and (2):

[0079]

[0080]

[0081] Among them, W SC and W SA Let P represent the trainable parameter matrix, Softmax represent the Softmax function, and P represent the obtained probability. SC P represents the probability of the predicted result for the column names selected in the SELECT clause. SA A represents the probability of the predicted result of the aggregate function selected in the SELECT clause; j ∈A={NONE,MAX,MIN,SUM,COUNT,AVERAGE}; A is a set of aggregate functions, A j Let [:j] represent the k-th aggregate function in A, and let [:j] represent W. SA The first j matrices.

[0082] S24. The prediction results of the select column name clause and the select aggregate function clause are used as the prediction results of the select clause.

[0083] Through the above steps S21-S24, the prediction of the SELECT clause is decomposed into: the prediction of the column name (SC) selected in the SELECT clause and the prediction of the aggregation function (SA) selected in the SELECT clause. The two predictions share the first decoder (also known as the SELECT decoder), which helps to reduce the structural complexity and number of parameters of the model, making the model easier to train and converge. Furthermore, the shared decoder enables the decoder to learn the correlation between different subtasks, thereby improving the conversion accuracy of the model.

[0084] In some embodiments, step S13 may specifically include the following steps:

[0085] S31, input the feature encoding of the long sequence information into the second decoder for processing to obtain the second natural language query feature vector and the second column name feature vector corresponding to the conditional clause;

[0086] S32, the second natural language query feature vector is processed through a preset third fully connected layer to obtain the prediction result of the number of conditions. The third fully connected layer is used to determine the correspondence between the prediction result of the number of conditions and the second natural language query feature vector.

[0087] S33, the second natural language query feature vector and the second column name feature vector are processed by the preset fourth fully connected layer to obtain the prediction result of the column name selected for each condition. The fourth fully connected layer is used to determine the correspondence between the prediction result of the column name selected for each condition and the second natural language query feature vector and the second column name feature vector.

[0088] S34, the second natural language query feature vector and the second column name feature vector are processed through the preset fifth fully connected layer to obtain the prediction result of the operator. The fifth fully connected layer is used to determine the correspondence between the prediction result of the operator and the second natural language query feature vector and the second column name feature vector.

[0089] S35, the second natural language query feature vector and the second column name feature vector are processed by the preset sixth fully connected layer to obtain the prediction result of the first position. The first position is the starting position of the value of the operator in the natural language query sequence. The sixth fully connected layer is used to determine the correspondence between the prediction result of the first position and the second natural language query feature vector and the second column name feature vector.

[0090] S37, the second natural language query feature vector and the second column name feature vector are processed by the preset seventh fully connected layer to obtain the prediction result of the second position. The second position is the termination position of the value of the operator in the natural language query sequence. The seventh fully connected layer is used to determine the correspondence between the prediction result of the second position and the second natural language query feature vector and the second column name feature vector.

[0091] S38 uses the prediction results of the number of conditions, the prediction results of the column names selected for each condition, the prediction results of the operators, the prediction results of the first position, and the prediction results of the second position as the prediction results of the conditional clause.

[0092] As an example, the natural language query and column name representations of the WHERE clause decoder output are as follows:

[0093] Among them, h Q Feature encoding of natural language query sequences in long sequence information; This is the feature encoding of the column name and column type of the i-th column in the long sequence information. In other words, the first natural language query feature vector is obtained by decoding the natural language query sequence feature encoding in the long sequence information using Bi-LSTM. The first column name feature vector is obtained by decoding the feature encoding of the column name and column type of the i-th column in the long sequence information using Bi-LSTM.

[0094] according to and Four output layers are used to predict the number of conditions in the WHERE clause, the selected columns, operators, and values ​​for each condition in the WHERE clause. The WV task selects a segment from the natural language query as the prediction result. The method for selecting the segment is to predict the start and end positions of the segment in the natural language query. The specific calculation formula is as follows:

[0095]

[0096]

[0097]

[0098]

[0099]

[0100] Among them, W WN W WC W WO U start V start U end and V end All are trainable parameters, and P represents the obtained probability. Specifically, P WN P is the probability of predicting the number of conditions in the WHERE clause, where l can take values ​​such as 0, 1, 2, 3, 4 in this embodiment, but the range of l can be scaled according to the actual situation; WCThe predicted probability, P, of each column selected for each condition in the WHERE clause. WO Let Oj∈O={>,<,=,≥,≤,≠},[:j] denote the first j matrices of WWO; This represents the probability of predicting the starting position of a segment in a natural language query. This indicates the probability of predicting the termination position of a segment in a natural language query; This represents the output representation of the WHERE clause decoder corresponding to the j-th character in the natural language query sequence.

[0101] Through the above steps S31-S38, the prediction of the WHERE clause is decomposed into: the prediction of the number of conditions (WN) in the WHERE clause, the prediction of the selected columns, operators and values ​​for each condition in the WHERE clause, and these predictions share the second decoder (also known as the WHERE decoder), which helps to reduce the structural complexity and number of parameters of the model, making the model easier to train and converge. Furthermore, sharing the decoder enables the decoder to learn the correlation between different subtasks, thereby improving the conversion accuracy of the model.

[0102] In some embodiments, when testing the trained model, the saved trained model parameters θ are... * Load the data into the NL2SQL model, use the steps above to obtain the prediction results for the six sub-tasks, and then populate the complete SQL as follows: SELECT {SA}{SC}FROM TableName WHERE ({WC}{WO}{WV})*

[0103] In this context, {} represents the slot that needs to be filled (for example, slot SA needs to be filled with the specific content of the aggregate function selected by the SELECT clause), * indicates that the component in the brackets can appear 0 or more times, and TableName represents the name of the associated table, thus completing the prediction of the complete SQL statement.

[0104] In some embodiments, step S14 may specifically include: constructing a first loss function based on the prediction result and the annotation result of the selection clause; constructing a second loss function based on the prediction result and the annotation result of the condition clause; performing a weighted summation on the first loss function and the second loss function, and using the weighted summation result as the constructed loss function.

[0105] For example, during the training phase, based on the model's prediction results, the loss function for each subtask is calculated using the cross-entropy loss function. Taking the SC task as an example, the specific formula for calculating the loss is as follows: in, The labels representing SC tasks can be obtained from the target SQL statement. This represents the prediction results for the SC task.

[0106] For example, the formula for calculating the total loss during training of a language conversion model is: L = L SC +L SA +L WN +L WC +L WO +L WV Where L is the total loss function, L SC L is the loss function for the prediction results of the select column name clause in the SELECT clause. SA The SELECT clause selects the loss function of the aggregate function's prediction result, L WN L is the loss function for predicting the number of conditions in the WHERE clause. WC L WO and L WV The loss function is the prediction result of the selected columns, operators, and values ​​for each condition in the WHERE clause, in that order.

[0107] In some embodiments, step S110 may specifically include: S41, using a bidirectional long short-term memory model to obtain the semantic vector of the natural language query sequence as the first semantic representation vector; S42, using a bidirectional long short-term memory model to obtain the semantic representation vector of at least one set of column association information in the association table, each set of column association information including a column name and a corresponding column type; S43, calculating the cosine similarity between the first semantic representation vector and the semantic representation vector of each set of column association information, as the corresponding semantic matching degree; S44, obtaining the first predetermined number of cosine similarities in descending order, and using the set of column association information to which the predetermined number of cosine similarities belong as the filtered set of column association information; S45, concatenating the natural language query sequence and the filtered set of column association information into a long sequence information.

[0108] As an example, the pre-similarity between the semantic vector of the natural language query sequence and the semantic representation vector of each set of column association information can be calculated using the following formula (3):

[0109]

[0110] Wherein, for the preset natural language query sequence Q = {q1, q2, ... q n}, and the sequence C = {c1, c2, ..., c} of all the column names of the associated tables. m}, and column type c i_type Bi-LSTM networks can be used to obtain the semantic representation E of a natural language query sequence Q. Q And each (ci ,c i_type semantic representation of ) And calculate each and E Q cosine similarity s i As a semantic matching degree.

[0111] In this embodiment, only the k columns with the highest semantic matching degree to the current natural language query can be retained as input to the NL2SQL model, where k is an integer greater than or equal to 1. Through this method, columns in the associated table can be pre-filtered based on semantic matching to reduce the input complexity of the NL2SQL model.

[0112] The training method for the language conversion model according to embodiments of the present invention reduces the length of the input sequence by using a semantic matching-based method to filter column names in the association table, retaining only a predetermined number of columns that semantically match the current natural language query, thus making it easier for the model to learn the relationship between the natural language query and column names in the input sequence; and by using a shared decoder based on a multi-task learning method to reduce the structural complexity and number of parameters of the model, making the model easier to train and converge, and the shared decoder enables the decoder to learn the association between different sub-tasks, thereby improving the conversion accuracy of the model.

[0113] Figure 5 A flowchart of a language conversion method provided by an embodiment of the present invention is shown. In some embodiments, the language conversion method includes: S510, obtaining a natural language query sequence; S520, inputting the natural language query sequence into a preset language conversion model for language conversion to obtain a corresponding structured query language; wherein, the language conversion model is a model trained according to any of the language conversion model training methods of the above embodiments.

[0114] According to the language conversion method of the present invention, the language conversion model used is a pre-trained model. During the training process of this model, the prediction of NL2SQL can be decomposed into the prediction of the selection clause and the prediction of the condition clause. In this way, only two encoders are used for prediction. The first decoder is used to determine the prediction result of the selection clause based on the features of the selection clause, and the second decoder is used to obtain the prediction result of the condition clause based on the features of the condition clause. In related technologies, different decoders are used to complete the prediction of different contents such as query target and aggregation function contained in the selection clause, and different decoders are also used to predict different contents in the limiting conditions. By sharing the decoders, the number of decoders used is reduced, thereby reducing the structural complexity of the model, which is beneficial to reducing the number of model parameters and reducing the difficulty of model training.

[0115] In this embodiment of the disclosure, using a semantic matching-based method to filter column names in the associated table can reduce the length of the input sequence. During model training, a multi-task learning method is used, and a shared decoder is used to predict the query target, aggregation function, and limiting conditions. This can effectively reduce the structural complexity and number of parameters of the model, and enable the decoder to learn the relationship between different sub-tasks.

[0116] The steps of the various methods described above are only for clarity. In practice, they can be combined into one step or some steps can be split into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent. Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but without changing the core design of the algorithm and process, are also within the scope of protection of this patent.

[0117] Figure 6 A schematic diagram of the structure of a training device for a language conversion model according to an embodiment of the present invention is shown. Figure 6 As shown, the training device 600 for the language conversion model may specifically include:

[0118] The splicing module 610 is used to splice the natural language query sequence and the column name information in the association table used for semantic matching into a long sequence information;

[0119] Training module 620 is used to train a pre-built language conversion model based on long sequence information to obtain the trained language conversion model. The language conversion model is used to determine the correspondence between natural language sequences and structured query language sequences. The structured query language sequences include selection clauses and conditional clauses. The network structure of the language conversion model includes a first decoder and a second decoder. During the training process of the language conversion model, the first decoder is used to determine the prediction result of the selection clause based on the features of the selection clause, and the second decoder is used to obtain the prediction result of the conditional clause based on the features of the conditional clause.

[0120] In some embodiments, the training module 620 includes: an extraction unit for extracting features from long sequence information to obtain feature encoding of the long sequence information; a first decoding unit for processing the feature encoding of the long sequence information using a first decoder to obtain a prediction result of the selection clause; a second decoding unit for processing the feature encoding of the long sequence information using a second decoder to obtain a prediction result of the conditional clause; a loss function construction unit for constructing a loss function based on the prediction result of the selection clause, the annotation result of the selection clause, the prediction result of the conditional clause, and the annotation result of the conditional clause; and a parameter adjustment unit for adjusting the model parameters of the language conversion model using the loss function, so as to obtain a trained language conversion model using the adjusted model parameters.

[0121] In some embodiments, the selection clause includes a selection column name clause and a selection aggregation function clause; the first decoding unit is specifically used to: input the feature encoding of long sequence information into a first decoder for processing to obtain a first natural language query feature vector and a first column name feature vector corresponding to the selection clause; process the first natural language query feature vector and the first column name feature vector through a preset first fully connected layer to obtain a prediction result of the selection column name clause, wherein the first fully connected layer is used to determine the correspondence between the prediction result of the selection column name clause and the first natural language query feature vector and the first column name feature vector; process the first natural language query feature vector and the first column name feature vector through a preset second fully connected layer to obtain a prediction result of the selection aggregation function clause, wherein the second fully connected layer is used to determine the correspondence between the prediction result of the selection aggregation function clause and the first natural language query feature vector and the first column name feature vector; and use the prediction result of the selection column name clause and the prediction result of the selection aggregation function clause as the prediction result of the selection clause.

[0122] In some embodiments, the conditional clause includes the number of conditions, the column name selected for each condition, an operator, and the corresponding value of the operator. The second decoding unit is specifically used to: input the feature encoding of the long sequence information into the second decoder for processing, to obtain a second natural language query feature vector and a second column name feature vector corresponding to the conditional clause; process the second natural language query feature vector through a preset third fully connected layer to obtain a prediction result of the number of conditions, the third fully connected layer being used to determine the correspondence between the prediction result of the number of conditions and the second natural language query feature vector; process the second natural language query feature vector and the second column name feature vector through a preset fourth fully connected layer to obtain a prediction result of the column name selected for each condition, the fourth fully connected layer being used to determine the correspondence between the prediction result of the column name selected for each condition and the second natural language query feature vector and the second column name feature vector; process the second natural language query feature vector and the second column name feature vector through a preset fifth fully connected layer to obtain a prediction result of the operator, the fifth fully connected layer being used to determine the operator's value. The prediction results of the operator are correlated with the second natural language query feature vector and the second column name feature vector. A pre-defined sixth fully connected layer processes the second natural language query feature vector and the second column name feature vector to obtain the prediction result for the first position, where the first position is the starting position of the operator's value in the natural language query sequence. The sixth fully connected layer is used to determine the correspondence between the prediction result for the first position and the second natural language query feature vector and the second column name feature vector. A pre-defined seventh fully connected layer processes the second natural language query feature vector and the second column name feature vector to obtain the prediction result for the second position, where the second position is the ending position of the operator's value in the natural language query sequence. The seventh fully connected layer is used to determine the correspondence between the prediction result for the second position and the second natural language query feature vector and the second column name feature vector. The prediction results for the number of conditions, the prediction results for the column names selected for each condition, the prediction results for the operator, the prediction results for the first position, and the prediction results for the second position are used as the prediction results for the conditional clause.

[0123] In some embodiments, the loss function construction unit is specifically used to: construct a first loss function based on the prediction result and the annotation result of the selection clause; construct a second loss function based on the prediction result and the annotation result of the condition clause; perform a weighted summation of the first loss function and the second loss function, and use the weighted summation result as the constructed loss function.

[0124] In some embodiments, the splicing module 610 is specifically used to: obtain the semantic vector of the natural language query sequence as a first semantic representation vector using a bidirectional long short-term memory model; obtain the semantic representation vector of at least one set of column association information in the association table using a bidirectional long short-term memory model, wherein each set of column association information includes a column name and a corresponding column type; calculate the cosine similarity between the first semantic representation vector and the semantic representation vector of each set of column association information, respectively, as the corresponding semantic matching degree; obtain the first predetermined number of cosine similarities in descending order, and use the set of column association information to which the predetermined number of cosine similarities belong as the filtered set of column association information; and splice the natural language query sequence and the filtered set of column association information into a long sequence information.

[0125] This invention decomposes the prediction of NL2SQL into prediction of the selection clause and prediction of the conditional clause. This allows the use of only two encoders for prediction. The first decoder determines the prediction result of the selection clause based on its features, and the second decoder obtains the prediction result of the conditional clause based on its features. Related technologies use different decoders to predict different elements within the selection clause, such as the query target and aggregation functions, and also use different decoders to predict different elements within the conditional clause. Compared to related technologies, this invention allows the prediction of different elements within the selection clause to be achieved by sharing the first decoder, and the prediction of different elements within the conditional clause to be achieved by sharing the second decoder. Sharing decoders reduces the number of decoders used, thereby reducing the structural complexity of the model and helping to reduce the number of model parameters and the difficulty of model training.

[0126] Figure 7 This is a schematic diagram of the structure of a language conversion device provided in an embodiment of the present invention. Figure 7 As shown, the language conversion device 700 may specifically include: an acquisition module 710 for acquiring a natural language query sequence; and a conversion module 720 for inputting the natural language query sequence into a preset language conversion model for language conversion to obtain the corresponding structured query language; wherein the language conversion model is a model trained according to any of the language conversion model training methods described in the above embodiments.

[0127] According to the language conversion apparatus of the present invention, the language conversion model used is a pre-trained model. During the training process of this model, the prediction of NL2SQL can be decomposed into the prediction of the selection clause and the prediction of the condition clause. In this way, only two encoders are used for prediction. The first decoder is used to determine the prediction result of the selection clause based on the features of the selection clause, and the second decoder is used to obtain the prediction result of the condition clause based on the features of the condition clause. In related technologies, different decoders are used to complete the prediction of different contents such as query targets and aggregation functions contained in the selection clause, and different decoders are also used to predict different contents in the limiting conditions. By sharing the decoders, the number of decoders used is reduced, thereby reducing the structural complexity of the model, which is beneficial to reducing the number of model parameters and reducing the difficulty of model training.

[0128] It should be clarified that the present invention is not limited to the specific configurations and processes described in the above embodiments and shown in the figures. For the sake of convenience and brevity, detailed descriptions of known methods are omitted here, and the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, which will not be repeated here.

[0129] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention; see reference. Figure 8 This invention provides an electronic device comprising:

[0130] One or more processors 801;

[0131] The memory 802 stores one or more programs, which, when executed by one or more processors, enable the one or more processors to implement any of the methods described above; one or more I / O interfaces 803 are connected between the processor 801 and the memory 802 and configured to enable information interaction between the processor 801 and the memory 802.

[0132] Among them, processor 801 is a device with data processing capabilities, including but not limited to central processing unit (CPU); memory 802 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH); I / O interface (read-write interface) 803 is connected between processor 801 and memory 802, and can realize information interaction between processor 801 and memory 802, including but not limited to data bus (Bus).

[0133] In some embodiments, the processor 801, memory 802, and I / O interface 803 are interconnected via a bus, and thus connected to other components of the computing device.

[0134] This embodiment also provides a computer-readable medium storing a computer program. When the program is executed by a processor, it implements the training method or language conversion method of the language conversion model provided in this embodiment. To avoid repetition, the specific steps of the method in this embodiment will not be repeated here.

[0135] Those skilled in the art will understand that all or some of the steps, systems, or apparatuses in the methods, systems, and apparatuses described above can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

[0136] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0137] Those skilled in the art will understand that although some embodiments described herein include certain features that are included in other embodiments but not others, combinations of features from different embodiments are meant to be within the scope of this embodiment and form different embodiments.

[0138] It is understood that the above embodiments are merely exemplary implementations used to illustrate the principles of the present invention, and the present invention is not limited thereto. For those skilled in the art, various modifications and improvements can be made without departing from the spirit and essence of the present invention, and these modifications and improvements are also considered to be within the scope of protection of the present invention.

Claims

1. A training method for a language conversion model, characterized in that, The method includes: The natural language query sequence and the column name information in the association table used for semantic matching are concatenated into a long sequence of information; The pre-constructed language conversion model is trained based on the long sequence information to obtain the trained language conversion model; The language conversion model is used to determine the correspondence between natural language sequences and structured query language sequences. The structured query language sequences include selection clauses and conditional clauses. The network structure of the language conversion model includes a first decoder and a second decoder. During the training process of the language conversion model, the first decoder is used to determine the prediction result of the selection clause based on the features of the selection clause, and the second decoder is used to obtain the prediction result of the conditional clause based on the features of the conditional clause. The process of training a pre-constructed language conversion model based on the long sequence information to obtain a trained language conversion model includes: Extract the features of the long sequence information to obtain the feature encoding of the long sequence information; The feature encoding of the long sequence information is processed using the first decoder to obtain the prediction result of the selection clause; The feature encoding of the long sequence information is processed using the second decoder to obtain the prediction result of the conditional clause; Based on the prediction results of the selection clause, the annotation results of the selection clause, the prediction results of the conditional clause, and the annotation results of the conditional clause, a loss function is constructed; The loss function is used to adjust the model parameters of the language conversion model, so that the trained language conversion model can be obtained using the adjusted model parameters.

2. The method according to claim 1, characterized in that, The selection clauses include the column name selection clause and the aggregate function selection clause; The step of using the first decoder to process the feature encoding of the long sequence information to obtain the prediction result of the selection clause includes: The feature encoding of the long sequence information is input into the first decoder for processing to obtain the first natural language query feature vector and the first column name feature vector corresponding to the selection clause; The first natural language query feature vector and the first column name feature vector are processed by a preset first fully connected layer to obtain the prediction result of the column name selection clause. The first fully connected layer is used to determine the correspondence between the prediction result of the column name selection clause and the first natural language query feature vector and the first column name feature vector. The first natural language query feature vector and the first column name feature vector are processed by a preset second fully connected layer to obtain the prediction result of the selection aggregation function clause. The second fully connected layer is used to determine the correspondence between the prediction result of the selection aggregation function clause and the first natural language query feature vector and the first column name feature vector. The prediction results of the selected column name clause and the selected aggregation function clause are used as the prediction result of the selected clause.

3. The method according to claim 1, characterized in that, The conditional clause includes the number of conditions, the column name selected for each condition, the operator, and the corresponding value of the operator; the step of using the second decoder to process the feature encoding of the long sequence information to obtain the prediction result of the conditional clause includes: The feature encoding of the long sequence information is input into the second decoder for processing to obtain the second natural language query feature vector and the second column name feature vector corresponding to the conditional clause; The second natural language query feature vector is processed by a preset third fully connected layer to obtain the prediction result of the number of conditions. The third fully connected layer is used to determine the correspondence between the prediction result of the number of conditions and the second natural language query feature vector. The second natural language query feature vector and the second column name feature vector are processed by a preset fourth fully connected layer to obtain the prediction result of the column name selected for each condition. The fourth fully connected layer is used to determine the correspondence between the prediction result of the column name selected for each condition and the second natural language query feature vector and the second column name feature vector. The second natural language query feature vector and the second column name feature vector are processed by a preset fifth fully connected layer to obtain the prediction result of the operator. The fifth fully connected layer is used to determine the correspondence between the prediction result of the operator and the second natural language query feature vector and the second column name feature vector. The second natural language query feature vector and the second column name feature vector are processed by a preset sixth fully connected layer to obtain the prediction result of the first position, where the first position is the starting position of the value of the operator in the natural language query sequence. The sixth fully connected layer is used to determine the correspondence between the prediction result of the first position and the second natural language query feature vector and the second column name feature vector. The second natural language query feature vector and the second column name feature vector are processed by a preset seventh fully connected layer to obtain the prediction result of the second position. The second position is the termination position of the value of the operator in the natural language query sequence. The seventh fully connected layer is used to determine the correspondence between the prediction result of the second position and the second natural language query feature vector and the second column name feature vector. The prediction results of the number of conditions, the prediction results of the column names selected for each condition, the prediction results of the operators, the prediction results of the first position, and the prediction results of the second position are used as the prediction results of the conditional clause.

4. The method according to claim 1, characterized in that, The step of constructing a loss function based on the prediction results of the selection clause, the annotation results of the selection clause, the prediction results of the conditional clause, and the annotation results of the conditional clause includes: Based on the prediction results and annotation results of the selection clause, a first loss function is constructed; Based on the prediction results and annotation results of the conditional clauses, a second loss function is constructed; The first loss function and the second loss function are weighted and summed, and the resulting weighted summation loss function is used as the constructed loss function.

5. The method according to claim 1, characterized in that, The step of concatenating the natural language query sequence and the column name information in the association table used for semantic matching into a long sequence includes: The semantic vector of the natural language query sequence is obtained using a bidirectional long short-term memory model as the first semantic representation vector; The bidirectional long short-term memory model is used to obtain the semantic representation vector of at least one set of column association information in the association table, and each set of column association information includes a column name and a corresponding column type; Calculate the cosine similarity between the first semantic representation vector and the semantic representation vector of each group of column-related information, and use it as the corresponding semantic matching degree; Obtain a predetermined number of cosine similarities in descending order, and use the association information of each group of columns to which the predetermined number of cosine similarities belong as the filtered association information of each group of columns. The natural language query sequence and the filtered column association information are concatenated to form the long sequence information.

6. A language conversion method, characterized in that, The method includes: Obtain the natural language query sequence; The natural language query sequence is input into a preset language conversion model for language conversion to obtain the corresponding structured query language; wherein, the language conversion model is a model trained by the training method of the language conversion model according to any one of claims 1-5.

7. A training device for a language conversion model, characterized in that, The device includes: The concatenation module is used to concatenate the natural language query sequence and the column name information in the associated table used for semantic matching into a long sequence of information; The training module is used to train a pre-constructed language conversion model based on the long sequence information to obtain the trained language conversion model; The language conversion model is used to determine the correspondence between natural language sequences and structured query language sequences. The structured query language sequences include selection clauses and conditional clauses. The network structure of the language conversion model includes a first decoder and a second decoder. During the training process of the language conversion model, the first decoder is used to determine the prediction result of the selection clause based on the features of the selection clause, and the second decoder is used to obtain the prediction result of the conditional clause based on the features of the conditional clause. The process of training a pre-constructed language conversion model based on the long sequence information to obtain a trained language conversion model includes: Extract the features of the long sequence information to obtain the feature encoding of the long sequence information; The feature encoding of the long sequence information is processed using the first decoder to obtain the prediction result of the selection clause; The feature encoding of the long sequence information is processed using the second decoder to obtain the prediction result of the conditional clause; Based on the prediction results of the selection clause, the annotation results of the selection clause, the prediction results of the conditional clause, and the annotation results of the conditional clause, a loss function is constructed; The loss function is used to adjust the model parameters of the language conversion model, so that the trained language conversion model can be obtained using the adjusted model parameters.

8. A language conversion device, characterized in that, The device includes: The acquisition module is used to acquire natural language query sequences; The conversion module is used to input the natural language query sequence into a preset language conversion model for language conversion to obtain the corresponding structured query language; wherein, the language conversion model is a model trained by the training method of the language conversion model according to any one of claims 1-5.

9. An electronic device, characterized in that, include: One or more processors; A memory having stored one or more programs thereon, which, when executed by the one or more processors, cause the one or more processors to perform the method according to any one of claims 1-5 or claim 6; One or more I / O interfaces are connected between the processor and the memory and configured to enable information interaction between the processor and the memory.

10. A computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the method according to any one of claims 1-5 or claim 6.