A method, apparatus, electronic device and medium for generating statements

By determining words and fields in natural language description information and using a bidirectional recursive neural network to generate SQL query statements, the problem of insufficient accuracy in SQL query statement generation in the prior art is solved, and a higher accuracy in SQL query statement generation is achieved.

CN115878662BActive Publication Date: 2025-06-24STATE GRID INFORMATION & TELECOMM BRANCH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211358681.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-01
Publication Date
2025-06-24
Estimated Expiration
2042-11-01

AI Technical Summary

Technical Problem

The prior art is difficult to generate accurate SQL query statements at the grammatical and semantic levels, resulting in a decrease in the accuracy of natural language questions being converted to SQL query statements.

Method used

By determining the words and fields corresponding to natural language description information, a two-way recursive neural network is used to determine vector pairs, joint probability density, aggregation operators, columns and aggregation columns, and then the target SQL query statement is generated.

Benefits of technology

The accuracy of SQL query statement generation is improved, and the target compatible pairs and target vector pairs with high correlation relationships are generated, combined with the preset SQL query statement framework, accurate and executable SQL query statements are generated.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115878662B_ABST
    Figure CN115878662B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention discloses a method, apparatus, electronic device, and medium for generating statements. The method includes: determining at least one vector pair, a first joint probability density corresponding to each vector pair, at least one aggregation operator, at least one column, and an aggregation column; determining a target vector pair based on the at least one vector pair and the first joint probability density of each vector pair; determining a target compatibility pair based on the at least one aggregation operator, the at least one column, the aggregation column, and a bidirectional recurrent neural network; generating a target SQL query statement based on each target vector pair, each target compatibility pair, and a preset SQL query statement framework. This method determines a target compatibility pair and a target vector pair with a relatively high correlation based on the obtained vector pairs, the first joint probability density corresponding to the vector pairs, the aggregation operator, the columns, and the aggregation column, and then combines the preset SQL query statement framework to obtain an accurate and executable SQL query statement, improving the accuracy of SQL query statement generation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of databases, and in particular, to a method, apparatus, electronic device, and medium for generating statements. Background Art

[0002] With the development of society and technology, the conversion of natural language questions into accurate and executable Structured Query Language (SQL) query statements has received a lot of attention and has been applied in many fields.

[0003] Currently, although deep learning methods have been introduced into the Natural Language to SQL (NL2SQL) model to realize the conversion of natural language questions into SQL query statements; NL2SQL is a technology that converts users' natural statements into executable SQL query statements to obtain query results from a database. However, the above method cannot generate relatively effective and accurate query SQL statements at the syntax and semantic levels, thereby reducing the accuracy of converting natural language questions into SQL query statements. Summary of the Invention

[0004] The embodiments of the present invention provide a method, apparatus, electronic device, and medium for generating statements to improve the accuracy of generating SQL query statements.

[0005] According to one aspect of the embodiments of the present invention, a method for generating statements is provided, including:

[0006] Determine at least one word and at least one field corresponding to the input natural language description information, and determine the at least one word and the at least one field as information to be processed, where one word corresponds to one piece of information to be processed, one field corresponds to one piece of information to be processed, the word is the smallest semantic unit constituting the natural language description information, and the field is the field corresponding to the natural language description information in a set database table;

[0007] According to each piece of information to be processed and a bidirectional recurrent neural network, determine at least one vector pair, the first joint probability density corresponding to each vector pair, at least one aggregation operator, at least one column, and an aggregation column, where the vector pair is composed of two corresponding decoded vectors, the first joint probability density indicates the degree of association between the two decoded vectors in the corresponding vector pair, the decoded vector is a vector obtained after the information to be processed is encoded and decoded, and the aggregation column is a column composed of the at least one column;

[0008] Determine at least one target vector pair based on the at least one vector pair and the first joint probability density corresponding to each vector pair;

[0009] Determine at least one target compatible pair based on the at least one aggregation operator, the at least one column, the aggregation column, and the bidirectional recurrent neural network, where the target compatible pair indicates an executable compatible pair, and the compatible pair indicates a combined pair composed of an aggregation operator and a column or a combined pair composed of an aggregation operator and an aggregation column;

[0010] Generate a target SQL query statement corresponding to the natural language description information based on each of the target vector pairs, each of the target compatible pairs, and a preset SQL query statement framework.

[0011] According to another aspect of the embodiments of the present invention, there is provided a statement generation device, including:

[0012] A first determination module, configured to determine at least one word and at least one field corresponding to the input natural language description information, and determine the at least one word and the at least one field as information to be processed, where one word corresponds to one piece of information to be processed, one field corresponds to one piece of information to be processed, the word is the smallest semantic unit constituting the natural language description information, and the field is the field corresponding to the natural language description information in a set database table;

[0013] A second determination module, configured to determine at least one vector pair, a first joint probability density corresponding to each of the vector pairs, at least one aggregation operator, at least one column, and an aggregation column according to each of the information to be processed and a bidirectional recurrent neural network, where the vector pair is composed of two corresponding decoded vectors, the first joint probability density indicates the degree of association between the two decoded vectors in the corresponding vector pair, the decoded vector is a vector obtained after the information to be processed is encoded and decoded, and the aggregation column is a column combined by the at least one column;

[0014] A third determination module, configured to determine at least one target vector pair based on at least one vector pair and the first joint probability density corresponding to each of the vector pairs;

[0015] A fourth determination module, configured to determine at least one target compatible pair based on the at least one aggregation operator, the at least one column, the aggregation column, and the bidirectional recurrent neural network, where the target compatible pair indicates an executable compatible pair, and the compatible pair indicates a combined pair composed of an aggregation operator and a column or a combined pair composed of an aggregation operator and an aggregation column;

[0016] A generation module, configured to generate a target SQL query statement corresponding to the natural language description information based on each of the target vector pairs, each of the target compatible pairs, and a preset SQL query statement framework.

[0017] According to another aspect of an embodiment of the present invention, an electronic device is provided, the electronic device comprising:

[0018] at least one processor; and

[0019] a memory communicatively connected to the at least one processor; wherein,

[0020] the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the statement generation method according to any embodiment of the present invention.

[0021] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to implement the statement generation method according to any embodiment of the present invention when executed.

[0022] In the technical solution of the embodiment of the present invention, first, at least one word and at least one field corresponding to the input natural language description information are determined, and the at least one word and the at least one field are determined as the information to be processed. Among them, one word corresponds to one piece of information to be processed, one field corresponds to one piece of information to be processed, the word is the smallest semantic unit constituting the natural language description information, and the field is the field corresponding to the natural language description information in the set database table. Secondly, according to each piece of information to be processed and the bidirectional recurrent neural network, at least one vector pair, the first joint probability density corresponding to each vector pair, at least one aggregation operator, at least one column, and an aggregation column are determined. The vector pair is composed of two corresponding decoded vectors, and the first joint probability density indicates the degree of association between the two decoded vectors in the corresponding vector pair. The decoded vector is the vector obtained after the information to be processed is encoded and decoded. The aggregation column is a column composed of at least one column combined. Then, at least one target vector pair is determined based on at least one vector pair and the first joint probability density corresponding to each vector pair. After that, based on at least one aggregation operator, at least one column, the aggregation column, and the bidirectional recurrent neural network, at least one target compatible pair is determined. The target compatible pair indicates an executable compatible pair, and the compatible pair indicates a combination pair composed of an aggregation operator and a column or a combination pair composed of an aggregation operator and an aggregation column. Finally, based on each target vector pair, each target compatible pair, and the preset SQL query statement framework, the target SQL query statement corresponding to the natural language description information is generated. Through the information to be processed corresponding to the natural language description information and the bidirectional recurrent neural network, this method can obtain vector pairs, the first joint probability density corresponding to the vector pairs, aggregation operators, columns, and aggregation columns. On this basis, target compatible pairs and target vector pairs with a higher degree of association can be obtained, and combined with the preset SQL query statement framework, an accurate and executable SQL query statement corresponding to the natural language description information can be obtained, thereby improving the accuracy of SQL query statement generation.

[0023] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present invention, nor is it used to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0025] Figure 1 It is a schematic flowchart of a statement generation method provided in Embodiment 1 of the present invention;

[0026] Figure 2 A flowchart of a statement generation method provided in the second embodiment of the present invention;

[0027] Figure 3 A structural diagram of a statement generation device provided in the third embodiment of the present invention;

[0028] Figure 4 A structural diagram of an electronic device provided in the fourth embodiment of the present invention. Detailed implementation manners

[0029] In order to enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0030] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.

[0031] Embodiment 1

[0032] Figure 1 A flowchart of a statement generation method provided in the first embodiment of the present invention. This method is applicable to the situation of converting natural language description information into SQL query statements to improve the accuracy of SQL query statement generation. This method can be executed by a statement generation device, where the device can be implemented by software and / or hardware and is generally integrated on an electronic device. In this embodiment, the electronic device includes, but is not limited to: desktop computers, laptop computers, servers, and other devices.

[0033] As Figure 1 shown, a statement generation method provided in the first embodiment of the present invention includes the following steps:

[0034] S110. Determine at least one word and at least one field corresponding to the input natural language description information, and determine the at least one word and the at least one field as the information to be processed.

[0035] In this embodiment, the natural language description information can be understood as the description information in the form of natural language related to data query. Natural language generally refers to a language that naturally evolves with culture. For example, the natural language description information can be a natural language question, specifically, such as a sentence like "Query the C data in Table A and Table B".

[0036] The information to be processed can be understood as the information to be processed. One word corresponds to one piece of information to be processed, that is to say, one word can be used as one piece of information to be processed; one field corresponds to one piece of information to be processed, that is to say, one field can be used as one piece of information to be processed.

[0037] A word can be understood as the smallest semantic unit that constitutes the natural language description information; that is to say, a word can be regarded as each individual word contained in the natural language description information. The natural language description information can include at least one word. For example, "table", "A", and "in" can all be regarded as one word. A field can be understood as the field corresponding to the natural language description information in the set database table. The set database table can be understood as at least one pre-set database table; there is no specific limitation on the set database table here. For example, it can include all the database tables in the queried database, or it can be a part of the database tables in the queried database. In a relational database, a database table is a collection of a series of two-dimensional arrays, used to represent and store the relationships between data objects. It consists of vertical columns and horizontal rows. For example, in a database table about author information, each column contains a specific type of information for all authors, such as "surname", "first name", and "address", etc., and each row contains all the information of a specific author: surname, first name, and address, etc. In the database table, "surname", "first name", and "address" can be regarded as individual fields, and can be located at the column head position of the corresponding column. That is to say, the column head of each column is a field.

[0038] There is no specific limitation on how to determine at least one word corresponding to the natural language description information here; for example, the natural language description information can be segmented to obtain at least one word contained in the natural language description information; on this basis, the at least one word obtained can also be filtered to filter out useless and / or duplicate words, and there is no specific limitation on how to filter here.

[0039] There is no specific limitation on how to determine at least one field corresponding to the natural language description information either. For example, the words associated with the table in the natural language description information can be determined first. These words are regarded as strings, and all the fields included in the database table can also be regarded as strings. Through a string matching algorithm, at least one string corresponding to these words in the natural language description information is found from all the fields included in the set database table, and this at least one string can be regarded as the at least one field determined.

[0040] S120. Determine at least one vector pair, the first joint probability density corresponding to each of the vector pairs, at least one aggregation operator, at least one column, and an aggregation column according to each of the to-be-processed information and the bidirectional recurrent neural network.

[0041] In this embodiment, a vector pair can be composed of two corresponding decoded vectors, that is, it can be regarded as a pair composed of two corresponding decoded vectors. A vector pair can correspond to a first joint probability density. The first joint probability density can indicate the degree of association between the two decoded vectors in the corresponding vector pair. Association can be understood as the association relationship in features between the two decoded vectors. A decoded vector can be understood as a vector obtained after the to-be-processed information is encoded and decoded. An aggregation column can be understood as a column composed of at least one column combination; for example, if there are 2 columns, the aggregation column can be regarded as the combination of these two columns; a column can be understood as a column in the database table or the column header representing the data content included in this column in the database table. An aggregation operator can be understood as an operator used for aggregation operations in an SQL database; aggregation can refer to an operation of forming a single value from the values included in a column, such as the sum or average of each value in the column. For example, the aggregation operator can include but is not limited to SUM (summation operator, used to calculate the sum of each value in a column), AVG (average operator, used to calculate the average of each value in a column), MIN (minimum value operator, used to find the minimum value among each value in a column), and MAX (maximum value operator, used to find the maximum value among each value in a column), etc.

[0042] There is no specific limitation on how to determine at least one vector pair, the first joint probability density corresponding to each vector pair, at least one aggregation operator, at least one column, and an aggregation column according to each to-be-processed information and a bidirectional recurrent neural network (Bi-directional Recurrent Neural Network, BRNN). For example, each to-be-processed information can be used as input data and input into the bidirectional recurrent neural network. Since the bidirectional recurrent neural network is a pre-trained model, at least one vector pair, the first joint probability density corresponding to each vector pair, at least one aggregation operator, at least one column, and an aggregation column can be output.

[0043] S130. Determine at least one target vector pair based on at least one vector pair and a first joint probability density corresponding to each of the vector pairs.

[0044] In this embodiment, the target vector pair can be understood as a vector pair with a high correlation degree between the corresponding two decoding vectors.

[0045] A vector pair corresponds to a first joint probability density. Here, there is no specific limitation on how to determine at least one target vector pair based on at least one vector pair and the first joint probability density corresponding to each vector pair; the first joint probability density is a value, such as first sorting the first joint probability densities from large to small, and then selecting a set number of first joint probability densities with the highest sorting, and determining the vector pairs corresponding to the selected first joint probability densities as the target vector pairs.

[0046] S140. Determine at least one target compatible pair based on the at least one aggregation operator, the at least one column, the aggregation column, and the bidirectional recurrent neural network.

[0047] In this embodiment, the target compatible pair may indicate an executable compatible pair. The compatible pair may indicate a combination pair consisting of an aggregation operator and a column, or a combination pair consisting of an aggregation operator and an aggregation column.

[0048] Here, how to determine at least one target compatible pair based on at least one aggregation operator, at least one column, the aggregation column and the bidirectional recurrent neural network is not specifically limited. For example, it can be determined whether the compatible pair consisting of the aggregation operator and the aggregation column is executable, such as adding the compatible pair to a pre-set SQL statement for testing whether the compatible pair is executable, and determining whether the corresponding compatible pair is executable by executing the SQL statement to determine whether it can be successfully executed. On this basis, the compatible pair consisting of the aggregation operator and the aggregation column that can be successfully executed can be determined as the target compatible pair. It can be pre-inputted into the decoder of the bidirectional recurrent neural network by inputting each compatible pair consisting of the aggregation operator and the column as input data to obtain the joint probability density corresponding to the compatible pair consisting of the aggregation operator and the column, and this joint probability density can indicate the association relationship between the aggregation operator and the column; on this basis, for the unexecutable compatible pair consisting of the aggregation operator and the aggregation column, determine the compatible pair consisting of the aggregation operator and the column corresponding to the aggregation operator, and then select the compatible pair with the largest joint probability density as the target compatible pair.

[0049] S150: Generate a target SQL query statement corresponding to the natural language description information based on each of the target vector pairs, each of the target compatible pairs and a preset SQL query statement framework.

[0050] In this embodiment, the preset SQL query statement framework can be understood as a statement framework that is preset for generating a target SQL query statement. No specific limitation is imposed on the preset SQL query statement framework here. For example, it can include various clauses for querying (such as the SELECT clause, the FROM clause, and the WHERE clause, etc.), where the information related to the query conditions corresponding to each clause is empty and waits to be filled in subsequently to generate the corresponding predicted SQL query statement. The target SQL query statement can be understood as an accurate executable SQL query statement corresponding to the generated natural language description information.

[0051] Here, it describes how to generate a target SQL query statement corresponding to the natural language description information based on each target vector pair, each target compatibility pair, and the preset SQL query statement framework. One target vector pair can correspond to two decoding vectors, and one decoding vector can correspond to one word or field (i.e., the information to be processed). That is to say, one target vector pair can correspond to two pieces of information to be processed. For example, the information to be processed corresponding to each target vector pair and each target compatibility pair can be filled into the preset SQL query statement framework to obtain the target SQL query statement corresponding to the natural language description information.

[0052] A statement generation method provided in Embodiment 1 of the present invention first determines at least one word and at least one field corresponding to the input natural language description information, and determines the at least one word and the at least one field as information to be processed, where one word corresponds to one piece of information to be processed, one field corresponds to one piece of information to be processed, a word is the smallest semantic unit constituting the natural language description information, and a field is the field corresponding to the natural language description information in a set database table; secondly, according to each piece of information to be processed and a bidirectional recurrent neural network, at least one vector pair, the first joint probability density corresponding to each vector pair, at least one aggregation operator, at least one column, and an aggregation column are determined, the vector pair is composed of two corresponding decoded vectors, the first joint probability density indicates the degree of association between the two decoded vectors in the corresponding vector pair, the decoded vector is a vector obtained after the information to be processed is encoded and decoded, and the aggregation column is a column composed of at least one column combined; then at least one target vector pair is determined based on the at least one vector pair and the first joint probability density corresponding to each vector pair; then, based on the at least one aggregation operator, the at least one column, the aggregation column, and the bidirectional recurrent neural network, at least one target compatibility pair is determined, the target compatibility pair indicates an executable compatibility pair, and the compatibility pair indicates a combination pair composed of an aggregation operator and a column or a combination pair composed of an aggregation operator and an aggregation column; finally, based on each target vector pair, each target compatibility pair, and a preset SQL query statement framework, a target SQL query statement corresponding to the natural language description information is generated. Through the information to be processed corresponding to the natural language description information and the bidirectional recurrent neural network, this method can obtain a vector pair, the first joint probability density corresponding to the vector pair, an aggregation operator, a column, and an aggregation column; on this basis, a target compatibility pair and a target vector pair with a relatively high degree of association can be obtained, and then combined with the preset SQL query statement framework, an accurate and executable SQL query statement corresponding to the natural language description information can be obtained, thereby improving the accuracy of SQL query statement generation.

[0053] Optionally, determining at least one word and at least one field corresponding to the input natural language description information includes: performing word segmentation processing on the natural language description information to obtain at least one word; and searching for at least one field corresponding to the natural language description information in the set database table through a semantic parsing algorithm.

[0054] In this embodiment, the word segmentation processing can be understood as a text processing method in natural language processing, that is, classifying the text content at the word level. Taking the natural language description information as a text content, performing word segmentation processing on the natural language description information can obtain at least one word.

[0055] The semantic parsing algorithm can be understood as an algorithm for parsing the semantics and grammar of text content. Here, there is no specific limitation on how to find at least one field of the corresponding natural language description information from the set database table. For example, the natural language description information can be regarded as a text content, and the semantic parsing algorithm is used to parse the natural language description information to obtain information related to table query (such as age), and based on this information, fields associated with and matching these information (such as age, age in Chinese, and years of age, etc.) are found from all the fields included in the set database table as at least one field corresponding to the natural language description information.

[0056] Optionally, based on each target vector pair, each target compatibility pair, and a preset SQL query statement framework, a target SQL query statement corresponding to the natural language description information is generated, including: filling the statement information corresponding to each target vector pair and each target compatibility pair into the preset SQL query statement framework to obtain the target SQL query statement corresponding to the natural language description information, where the statement information indicates the information to be processed corresponding to the two decoded vectors in the corresponding target vector pair.

[0057] In this embodiment, the statement information can indicate the information to be processed corresponding to the two decoded vectors in the corresponding target vector pair. One target vector pair can correspond to one statement information.

[0058] The statement information corresponding to each target vector pair and each target compatibility pair can be filled into the area under each clause in the preset SQL query statement framework for placing information related to query conditions to obtain the target SQL query statement corresponding to the natural language description information. Here, there is no specific limitation on how to fill it under each clause.

[0059] Embodiment 2

[0060] Figure 2 It is a schematic flowchart of a statement generation method provided by Embodiment 2 of the present invention. Embodiment 2 is refined on the basis of the above embodiments. In this embodiment, the process of determining at least one vector pair, the first joint probability density corresponding to each vector pair, at least one aggregation operator, at least one column, and an aggregation column based on each piece of information to be processed and a bidirectional recurrent neural network, the process of determining at least one target vector pair based on at least one vector pair and the first joint probability density corresponding to each vector pair, and the process of determining at least one target compatibility pair based on at least one aggregation operator, at least one column, the aggregation column, and the bidirectional recurrent neural network are specifically described. It should be noted that the technical details not described in detail in this embodiment can be referred to in any of the above embodiments. As Figure 2 shown, the method includes:

[0061] As Figure 2As shown in the figure, an embodiment two of the present invention provides a method, including the following steps:

[0062] S210. Determine at least one word and at least one field corresponding to the input natural language description information, and determine the at least one word and the at least one field as the information to be processed.

[0063] S220. Input each of the information to be processed into the encoder of the bidirectional recurrent neural network to obtain the encoding vectors respectively corresponding to each of the information to be processed.

[0064] In this embodiment, the bidirectional recurrent neural network may include an encoder and a decoder. The encoding vector can be understood as a vector obtained by encoding the information to be processed. One piece of information to be processed can correspond to one encoding vector.

[0065] Taking each piece of information to be processed as input data and inputting it into the encoder of the bidirectional recurrent neural network, the encoding vectors respectively corresponding to each piece of information to be processed can be output.

[0066] S230. Input each of the encoding vectors into the decoder of the bidirectional recurrent neural network to obtain at least one vector pair, the first joint probability density corresponding to each vector pair, at least one aggregation operator, and at least one column sum and aggregation column.

[0067] In this embodiment, taking each encoding vector as input data and inputting it into the decoder of the bidirectional recurrent neural network, at least one vector pair, the first joint probability density corresponding to each vector pair, at least one aggregation operator, and at least one column sum and aggregation column can be output.

[0068] Optionally, inputting each encoding vector into the decoder of the bidirectional recurrent neural network to obtain at least one vector pair and the first joint probability density corresponding to each vector pair includes: obtaining the decoding vectors respectively corresponding to each encoding vector through the decoder of the bidirectional recurrent neural network; selecting any two different decoding vectors from each decoding vector through the decoder, forming a vector pair with the any two different decoding vectors, and determining the first joint probability density corresponding to the vector pair; repeating the operation of selecting any two different decoding vectors from each decoding vector until there are no two decoding vectors in each decoding vector that have not been selected simultaneously.

[0069] In this embodiment, after inputting each encoding vector into the decoder of the bidirectional recurrent neural network, the decoding vectors respectively corresponding to each encoding vector can be obtained. One encoding vector can correspond to one decoding vector. The decoding vector can be understood as a vector obtained by decoding the encoding vector.

[0070] Select any two different decoded vectors from each decoded vector through a decoder, then form a vector pair with the two selected different decoded vectors, and determine the first joint probability density corresponding to the vector pair. Here, there is no specific limitation on how to determine the first joint probability density corresponding to the vector pair, and the output of the first joint probability density corresponding to the vector pair can be realized through a pre-trained decoder. Repeat the operation of selecting any two different decoded vectors from each decoded vector until there are no two decoded vectors that have not been selected simultaneously among all decoded vectors.

[0071] S240. Select a set number of first joint probability densities from each of the first joint probability densities in descending order, and use each selected first joint probability density as the target joint probability density.

[0072] In this embodiment, the set number can be understood as a pre-set number; there is no specific limitation on the set number here, and it can be flexibly set according to actual needs. It can be understood that the set number is less than the number of vector pairs. The target joint probability density can be understood as a joint probability density with a higher value.

[0073] From the obtained first joint probability densities, a set number of first joint probability densities can be selected in descending order, and each selected first joint probability density is used as the target joint probability density.

[0074] S250. Determine the vector pairs corresponding to each of the target joint probability densities as the target vector pairs.

[0075] In this embodiment, the vector pairs corresponding to each of the target joint probability densities are determined as the target vector pairs. One target joint probability density can correspond to one target vector pair.

[0076] S260. For each aggregation operator, form a corresponding first compatible pair with the aggregation operator and the aggregation column, and form corresponding second compatible pairs with the aggregation operator and each column respectively.

[0077] In this embodiment, the first compatible pair can be considered as a compatible pair composed of an aggregation operator and an aggregation column. The second compatible pair can be considered as a compatible pair composed of an aggregation operator and a column.

[0078] For each aggregation operator, the aggregation operator and the aggregation column can form a corresponding first compatible pair, and the aggregation operator and each column can form corresponding second compatible pairs respectively.

[0079] S270. Determine the second joint probability density of each of the second compatible pairs through the decoder of the bidirectional recurrent neural network, where the first compatible pair and the second compatible pair of the same aggregation operator correspond to each other.

[0080] In this embodiment, by performing corresponding parsing processing on each second compatible pair through the decoder of the bidirectional recurrent neural network, the second joint probability density corresponding to each second compatible pair can be obtained. One second-year compatible pair corresponds to one second joint probability density. The second joint probability density can indicate the degree of association between the aggregation operator and the column in the corresponding second compatible pair. Among them, the first compatible pair and the second compatible pair of the same aggregation operator can correspond to each other.

[0081] S280. For each first compatible pair, add the first compatible pair to the selection area of the set SQL statement to obtain the to-be-executed SQL statement corresponding to the first compatible pair.

[0082] In this embodiment, the set SQL statement can be understood as a pre-set SQL statement for testing whether the first compatible pair is executable; no specific limitation is made on the set SQL statement here. For example, the set SQL statement can be "SELECT (selection area) WHERE TRUE". The selection area can be understood as the area in the set SQL statement for placing information related to the query condition. For example, it can be the selection area under the SELECT clause.

[0083] The to-be-executed statement can be understood as a to-be-executed SQL statement for testing whether the first compatible pair is executable. For each first compatible pair, adding the first compatible pair to the selection area of the set SQL statement can obtain the to-be-executed SQL statement corresponding to the first compatible pair. For example, the to-be-executed SQL statement can be expressed as "SELECT (first compatible pair) WHERE TRUE".

[0084] S290. By running the to-be-executed SQL statement corresponding to the first compatible pair, determine whether the to-be-executed SQL statement is executable; if so, execute S2100; otherwise, execute S2110.

[0085] In this embodiment, by running the to-be-executed SQL statement corresponding to the first compatible pair, it can be determined whether the to-be-executed SQL statement is executable. If the to-be-executed SQL statement runs successfully, it indicates that the to-be-executed SQL statement is executable, and at this time, S2100 can be continued to be executed. If the to-be-executed SQL statement runs fails, it indicates that the to-be-executed SQL statement is not executable, and it can also indicate that the first compatible pair is not compatible. At this time, S2110 can be continued to be executed.

[0086] S2100. Determine the first compatible pair as the target compatible pair.

[0087] In this embodiment, if the to-be-executed SQL statement corresponding to the first compatible pair is executable, the first compatible pair can be determined as the target compatible pair.

[0088] S2110. Determine the maximum joint probability density from the second joint probability densities of the second compatible pairs corresponding to each of the first compatible pairs, and determine the second compatible pair corresponding to the maximum joint probability density as the target compatible pair.

[0089] In this embodiment, the maximum joint probability density can be understood as the second joint probability density with the largest value. One first compatible pair can correspond to at least one second compatible pair, and the corresponding second compatible pairs correspond to the same aggregation operator as this first compatible pair.

[0090] If the to-be-executed SQL statement corresponding to the first compatible pair is not executable, then the second joint probability density with the largest value can be determined as the maximum joint probability density from the second joint probability densities of the second compatible pairs corresponding to the first compatible pair, and then the second compatible pair corresponding to the maximum joint probability density is determined as the target compatible pair corresponding to this first compatible pair.

[0091] S2120. Generate the target SQL query statement corresponding to the natural language description information based on each of the target vector pairs, each of the target compatible pairs, and the preset SQL query statement framework.

[0092] A method provided in Embodiment 2 of the present invention specifies the process of determining at least one vector pair, the first joint probability density corresponding to each vector pair, at least one aggregation operator, at least one column, and the aggregation column according to each of the to-be-processed information and the bidirectional recurrent neural network, the process of determining at least one target vector pair based on at least one vector pair and the first joint probability density corresponding to each vector pair, and the process of determining at least one target compatible pair based on at least one aggregation operator, at least one column, the aggregation column, and the bidirectional recurrent neural network. By selecting the first compatible pair corresponding to the executable to-be-executed SQL statement as the target compatible pair, and by selecting the second joint probability density with the largest value to replace the incompatible first compatible pair as the target compatible pair, a relatively reliable compatible pair with a high degree of association can be obtained for generating the target SQL query statement; also, by selecting the vector pair with a relatively high first joint probability density as the target vector pair, relatively reliable to-be-processed information with a high degree of association can be obtained; on this basis, by using the relatively reliable target vector pair and target compatible pair, and combining the preset SQL query statement framework to generate the target SQL query statement, the accuracy of SQL query statement generation can be effectively improved.

[0093] The following is an exemplary description of the present invention.

[0094] In this embodiment, executable guidance decoding, which is an extension of the standard recursive autoregressive decoder, is proposed. It can be regarded as an extension of the standard beam search and is applied to the decoding of the decoder unit of a specific model. The result at the current time period t corresponds to the executable partial program. This process only retains the SQL query statements in the beam that have no execution errors or empty outputs. The frame with the highest probability is selected and the decoding proceeds to the next stage. The decoding aggregation operator f and the aggregation column c are run on the execution engine in the "partial program", f and c are selected from t, and the compatible pair (f; c) with the highest joint probability density is selected. The top k (c1; c2) combinations (i.e., the target vector pairs) with the highest joint probability density ranking can be retained, which can avoid the occurrence of execution errors.

[0095] The executable guidance mechanism can be used as a filtering step at the end of the decoding process. For example, by deleting the result programs that generate execution errors. This also applies to any autoregressive decoder at the end of beam decoding. However, in many application areas (including SQL generation), execution checks can be applied to the partially decoded programs. First, standard beam decoding with a width of k can be performed, and then the generated SQL program with the highest joint probability density ranking is selected to avoid errors at the end of decoding.

[0096] In practice, the execution-guided decoder is parameterized with the beam width k. Instead of calculating all the correct options, only the results that trigger errors are discarded. This method is similar to the standard beam decoder, where the top-k (i.e., the first k) results are not generated in the case of the highest probability, and the results of evaluating and discarding the error programs are additionally used.

[0097] If no valid results are found, backtracking will be performed and different frame results will be issued from the "coarse" model. The coarse model can be regarded as a hybrid model of a template-based model and an end-to-end model. This is a two-stage process for the general text-to-encoding translation model, where the first stage generates a rough "frame" (template) of the target program, and the second stage fills the missing "slots" in its rough frame. The template-based model makes two predictions: (a), which template to use; and (b), which words in the natural language question should be applied to fill the slots in the selected template. A bidirectional RNN is run on the natural language question, and a "used in slot" or "not used in query" signal is output for each token. Then a small fully connected network is used to predict the selected template from the final state of the RNN. The output SQL query statement is constructed by filling the slots from the template with the predicted tokens from the input question.

[0098] The model generates programs through the following three steps. First, the input natural language question can be encoded using a bidirectional RNN encoding long short-term memory (LSTM) cells. Then, the frame generator uses a classifier to select a part of the query frame in the form of "Where()*" from it. The frame determines the number of conditions and comparison operators in the Where clause. Finally, the input and the generated frame can be used to generate a frame, and a complete SQL query statement can be generated by filling in the slots.

[0099] This embodiment can improve the accuracy of semantic parsing of natural language questions, allowing any autoregressive decoder to be adjusted according to the results of non-differentiable parts during inference, thereby eliminating semantically invalid programs from candidate programs.

[0100] Embodiment III

[0101] Figure 3 FIG. 10 is a schematic structural diagram of a statement generation device provided in Embodiment III of the present invention. The device can be implemented by software and / or hardware. As Figure 3 shown, the device includes:

[0102] A first determination module 310, configured to determine at least one word and at least one field corresponding to the input natural language description information, and determine the at least one word and the at least one field as information to be processed, where one word corresponds to one piece of information to be processed, one field corresponds to one piece of information to be processed, the word is the smallest semantic unit constituting the natural language description information, and the field is the field corresponding to the natural language description information in a set database table;

[0103] A second determination module 320, configured to determine at least one vector pair, a first joint probability density corresponding to each vector pair, at least one aggregation operator, at least one column, and an aggregation column according to each piece of information to be processed and a bidirectional recurrent neural network, where the vector pair is composed of two corresponding decoded vectors, the first joint probability density indicates the degree of association between the two decoded vectors in the corresponding vector pair, the decoded vector is a vector obtained after the information to be processed is encoded and decoded, and the aggregation column is a column formed by combining the at least one column;

[0104] A third determination module 330, configured to determine at least one target vector pair based on at least one vector pair and the first joint probability density corresponding to each vector pair;

[0105] A fourth determination module 340, configured to determine at least one target compatible pair based on the at least one aggregation operator, the at least one column, the aggregation column, and the bidirectional recurrent neural network, where the target compatible pair indicates an executable compatible pair, and the compatible pair indicates a combined pair formed by an aggregation operator and a column or a combined pair formed by an aggregation operator and an aggregation column;

[0106] A generation module 350, configured to generate a target SQL query statement corresponding to the natural language description information based on each of the target vector pairs, each of the target compatible pairs, and a preset structured query language (SQL) query statement framework.

[0107] In this embodiment, the apparatus first determines, through a first determination module 310, at least one word and at least one field corresponding to the input natural language description information, and determines the at least one word and the at least one field as information to be processed, where one word corresponds to one piece of information to be processed, one field corresponds to one piece of information to be processed, a word is the smallest semantic unit constituting the natural language description information, and a field is a field corresponding to the natural language description information in a set database table; secondly, through a second determination module 320, according to each piece of information to be processed and the bidirectional recurrent neural network, at least one vector pair, a first joint probability density corresponding to each vector pair, at least one aggregation operator, at least one column, and an aggregation column are determined, the vector pair is composed of two corresponding decoded vectors, the first joint probability density indicates the degree of association between the two decoded vectors in the corresponding vector pair, the decoded vector is a vector obtained after the information to be processed is encoded and decoded, and the aggregation column is a column formed by combining at least one column; then, through a third determination module 330, at least one target vector pair is determined based on the at least one vector pair and the first joint probability density corresponding to each vector pair; afterwards, through a fourth determination module 340, at least one target compatible pair is determined based on the at least one aggregation operator, the at least one column, the aggregation column, and the bidirectional recurrent neural network, the target compatible pair indicates an executable compatible pair, and the compatible pair indicates a combined pair formed by an aggregation operator and a column or a combined pair formed by an aggregation operator and an aggregation column; finally, through a generation module 350, a target SQL query statement corresponding to the natural language description information is generated based on each target vector pair, each target compatible pair, and the preset SQL query statement framework. The apparatus can obtain a vector pair, a first joint probability density corresponding to the vector pair, an aggregation operator, a column, and an aggregation column through the information to be processed corresponding to the natural language description information and the bidirectional recurrent neural network; on this basis, a target compatible pair and a target vector pair with a relatively high degree of association can be obtained, and then an accurate and executable SQL query statement corresponding to the natural language description information can be obtained by combining the preset SQL query statement framework, thereby improving the accuracy of generating the SQL query statement.

[0108] Optionally, the second determination module 320 includes:

[0109] A first input unit, configured to input each of the to-be-processed information into an encoder of a bidirectional recurrent neural network, so as to obtain encoded vectors respectively corresponding to each of the to-be-processed information;

[0110] A second input unit, configured to input each of the encoded vectors into a decoder of the bidirectional recurrent neural network, so as to obtain at least one vector pair, a first joint probability density corresponding to each of the vector pairs, at least one aggregation operator, and at least one column sum aggregation column.

[0111] Optionally, the second input unit includes:

[0112] A decoding subunit, configured to obtain decoded vectors respectively corresponding to each of the encoded vectors through the decoder of the bidirectional recurrent neural network;

[0113] A selection subunit, configured to select any two different decoded vectors from each of the decoded vectors through the decoder, form a vector pair with the any two different decoded vectors, and determine a first joint probability density corresponding to the vector pair;

[0114] An execution subunit, configured to repeatedly execute an operation of selecting any two different decoded vectors from each of the decoded vectors until there are no two decoded vectors that have not been selected simultaneously among each of the decoded vectors.

[0115] Optionally, a third determination module 330 includes:

[0116] A selection unit, configured to select a set number of first joint probability densities from each of the first joint probability densities in descending order, and use each of the selected first joint probability densities as a target joint probability density;

[0117] A vector pair determination unit, configured to determine the vector pairs respectively corresponding to each of the target joint probability densities as target vector pairs.

[0118] Optionally, a fourth determination module 340 includes:

[0119] A composition unit, configured to, for each aggregation operator, form a corresponding first compatibility pair with the aggregation operator and the aggregation column, and form a corresponding second compatibility pair with the aggregation operator and each of the columns;

[0120] A density determination unit, configured to determine a second joint probability density of each of the second compatibility pairs through the decoder of the bidirectional recurrent neural network, where the first compatibility pair and the second compatibility pair of the same aggregation operator correspond to each other;

[0121] An adding unit, configured to add each first compatible pair to a selection area of a set SQL statement to obtain an SQL statement to be executed corresponding to the first compatible pair;

[0122] An operating unit, configured to determine whether the SQL statement to be executed is executable by executing the SQL statement to be executed corresponding to the first compatible pair;

[0123] A first determining unit, configured to, if so, determine the first compatible pair as a target compatible pair;

[0124] A second determining unit, configured to, otherwise, determine a maximum joint probability density from second joint probability densities of each second compatible pair corresponding to the first compatible pair, and determine the second compatible pair corresponding to the maximum joint probability density as the target compatible pair.

[0125] Optionally, the generating module 350 includes:

[0126] A generating unit, configured to fill statement information corresponding to each target vector pair and each of the target compatible pairs into a preset SQL query statement framework to obtain a target SQL query statement corresponding to the natural language description information, where the statement information indicates information to be processed corresponding to two decoded vectors in the corresponding target vector pair.

[0127] Optionally, the first determining module 310 includes:

[0128] A word segmentation unit, configured to perform word segmentation processing on the natural language description information to obtain at least one word;

[0129] A searching unit, configured to search for at least one field corresponding to the natural language description information from a set database table through a semantic parsing algorithm.

[0130] The statement generating device provided by the embodiments of the present invention can execute the statement generating method provided by any embodiment of the present invention, and has corresponding functional modules and beneficial effects for executing the method.

[0131] Embodiment 4

[0132] Figure 4A schematic structural diagram of an electronic device provided in Embodiment 4 of the present invention. The electronic device is intended to represent various forms of digital computers, such as, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, personal digital processors, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described herein and / or claimed.

[0133] As Figure 4 shown, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc. The memory stores a computer program executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. The input / output (I / O) interface 15 is also connected to the bus 14.

[0134] Multiple components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0135] The processor 11 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the statement generation method.

[0136] In some embodiments, the statement generation method may be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the statement generation method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the statement generation method by any other suitable means (e.g., by means of firmware).

[0137] The various embodiments of the systems and techniques described above in this document may be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), systems on a chip (SOC), complex programmable logic devices (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include: implemented in one or more computer programs that may be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a special-purpose or general-purpose programmable processor, that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit the data and instructions to the storage system, the at least one input device, and the at least one output device.

[0138] The computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions / operations specified in the flowchart and / or block diagram to be implemented. The computer programs may be executed entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine, or entirely on the remote machine or server.

[0139] In the context of the present invention, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any suitable combination of the foregoing. Alternatively, the computer-readable storage medium can be a machine-readable signal medium. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0140] To provide for interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can also be used to provide for interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0141] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0142] A computing system may include a client and a server. The client and the server are generally far from each other and usually interact via a communication network. The client-server relationship is created by computer programs running on respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or a cloud host, which is a host product in the cloud computing service system, solving the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services.

[0143] It should be understood that various forms of the processes shown above can be used, steps can be reordered, added or deleted. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and no limitation is made herein.

[0144] The above specific embodiments do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A sentence generation method, characterized in that, The method includes: Determine at least one word and at least one field corresponding to the input natural language description information, and determine the at least one word and the at least one field as the information to be processed. Wherein, one word corresponds to one piece of information to be processed, one field corresponds to one piece of information to be processed, the word is the smallest semantic unit constituting the natural language description information, and the field is the field corresponding to the natural language description information in the set database table; According to each piece of information to be processed and the bidirectional recurrent neural network, determine at least one vector pair, the first joint probability density corresponding to each vector pair, at least one aggregation operator, at least one column, and an aggregation column. The vector pair is composed of two corresponding decoded vectors, the first joint probability density indicates the degree of association between the two decoded vectors in the corresponding vector pair, the decoded vector is the vector obtained after the information to be processed is encoded and decoded, and the aggregation column is a column composed of the at least one column; Based on at least one vector pair and the first joint probability density corresponding to each vector pair, determine at least one target vector pair; Based on the at least one aggregation operator, the at least one column, the aggregation column, and the bidirectional recurrent neural network, determine at least one target compatible pair. The target compatible pair indicates an executable compatible pair, and the compatible pair indicates a combination pair composed of one aggregation operator and one column or a combination pair composed of one aggregation operator and one aggregation column; Based on each target vector pair, each target compatible pair, and the preset structured query language SQL query statement framework, generate the target SQL query statement corresponding to the natural language description information.

2. The method according to claim 1, characterized in that, According to each piece of information to be processed and the bidirectional recurrent neural network, determining at least one vector pair, the first joint probability density corresponding to each vector pair, at least one aggregation operator, at least one column, and an aggregation column includes: Input each piece of information to be processed into the encoder of the bidirectional recurrent neural network to obtain the encoded vector corresponding to each piece of information to be processed; Input each encoded vector into the decoder of the bidirectional recurrent neural network to obtain at least one vector pair, the first joint probability density corresponding to each vector pair, at least one aggregation operator, at least one column, and an aggregation column.

3. The method according to claim 2, wherein Inputting each encoded vector into the decoder of the bidirectional recurrent neural network to obtain at least one vector pair and the first joint probability density corresponding to each vector pair includes: Obtain the decoded vector corresponding to each encoded vector through the decoder of the bidirectional recurrent neural network; Select any two different decoded vectors from each decoded vector through the decoder, form a vector pair with the any two different decoded vectors, and determine the first joint probability density corresponding to the vector pair; Repeat the operation of selecting any two different decoded vectors from each decoded vector until there are no two decoded vectors in each decoded vector that have not been selected simultaneously.

4. The method according to claim 1, wherein Based on at least one vector pair and the first joint probability density corresponding to each vector pair, determining at least one target vector pair includes: From each of the first joint probability densities, a set number of first joint probability densities are selected in descending order, and each of the selected first joint probability densities is used as a target joint probability density; The vector pairs corresponding to the respective target joint probability densities are determined as target vector pairs.

5. The method according to claim 1, characterized in that, Based on the at least one aggregation operator, the at least one column, the aggregation column, and the bidirectional recurrent neural network, determining at least one target compatible pair, including: For each aggregation operator, a corresponding first compatible pair is formed by the aggregation operator and the aggregation column, and a corresponding second compatible pair is formed by the aggregation operator and each of the columns; The second joint probability density of each of the second compatible pairs is determined by the decoder of the bidirectional recurrent neural network, where the first compatible pair and the second compatible pair of the same aggregation operator correspond to each other; For each first compatible pair, the first compatible pair is added to the selection area of a set SQL statement to obtain the to-be-executed SQL statement corresponding to the first compatible pair; By running the to-be-executed SQL statement corresponding to the first compatible pair, it is determined whether the to-be-executed SQL statement is executable; If so, the first compatible pair is determined as a target compatible pair; Otherwise, the maximum joint probability density is determined from the second joint probability densities of the second compatible pairs corresponding to the first compatible pair, and the second compatible pair corresponding to the maximum joint probability density is determined as the target compatible pair.

6. The method according to claim 1, wherein Based on the respective target vector pairs, the respective target compatible pairs, and a preset SQL query statement framework, generating the target SQL query statement corresponding to the natural language description information, including: The statement information corresponding to each target vector pair and the respective target compatible pairs are filled into the preset SQL query statement framework to obtain the target SQL query statement corresponding to the natural language description information, where the statement information indicates the to-be-processed information corresponding to the two decoded vectors in the corresponding target vector pair.

7. The method according to claim 1, characterized in that Determining at least one word and at least one field corresponding to the input natural language description information, including: Performing word segmentation on the natural language description information to obtain at least one word; Through a semantic parsing algorithm, at least one field corresponding to the natural language description information is found from a set database table.

8. A sentence generation device, characterized in that, Including: A first determination module, configured to determine at least one word and at least one field corresponding to the input natural language description information, and determine the at least one word and the at least one field as to-be-processed information, where one word corresponds to one piece of to-be-processed information, one field corresponds to one piece of to-be-processed information, the word is the smallest semantic unit constituting the natural language description information, and the field is the field corresponding to the natural language description information in the set database table; A second determination module, configured to determine at least one vector pair, a first joint probability density corresponding to each of the vector pairs, at least one aggregation operator, at least one column, and an aggregated column according to each of the to-be-processed information and a bidirectional recurrent neural network, where the vector pair is composed of two corresponding decoded vectors, the first joint probability density indicates the degree of association between the two decoded vectors in the corresponding vector pair, the decoded vector is a vector obtained after the to-be-processed information is encoded and decoded, and the aggregated column is a column composed of the at least one column; A third determination module, configured to determine at least one target vector pair based on the at least one vector pair and the first joint probability density corresponding to each of the vector pairs; A fourth determination module, configured to determine at least one target compatibility pair based on the at least one aggregation operator, the at least one column, the aggregated column, and the bidirectional recurrent neural network, where the target compatibility pair indicates an executable compatibility pair, and the compatibility pair indicates a combination pair composed of an aggregation operator and a column or a combination pair composed of an aggregation operator and an aggregated column; A generation module, configured to generate a target SQL query statement corresponding to the natural language description information based on each of the target vector pairs, each of the target compatibility pairs, and a preset structured query language (SQL) query statement framework; 9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the statement generation method according to any one of claims 1-7; 10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions, and the computer instructions are used to implement the statement generation method according to any one of claims 1-7 when executed by a processor.

Citation Information

Patent Citations

  • Complex multi-table SQL generation method and device based on bridging filling

    CN112925794A

  • Semantic analysis method, semantic analysis device, electronic equipment and storage medium

    CN115221288A