Natural language processing model, method, electronic device and computer storage medium
By adding the pool layer to compress the data table information by adding the pool layer before the encoding layer of the NL2SQL model, it solves the performance problem caused by the length of the input data, and achieves more efficient natural language processing performance. It is suitable for multi -table -related query scenarios.
Patent Information
- Application Number
- CN202210606848.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-31
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2042-05-31
AI Technical Summary
When the existing NL2SQL model deals with multi-table and multi-round table Q&A scenarios, due to the length of input data, the calculation amount increases and the calculation efficiency decreases, which affects performance.
Add the pool layer before the encoding layer of the natural language processing model, compress the column information of the retrieved data table through the pooling layer, generate the setting data of the set length, and construct it with the problem statement to enter the input data, so as to thus input data, thereby Reduce the length of the input data and reduce the amount of data processing calculation of the encoding layer.
Through the compression of the column information through the pooling layer, the length of the input data is reduced, the performance of the natural language processing model is improved, the scenes of multi -table -associated query can be better applied, and the reasoning performance is 2.3 times.
Smart Images

Figure CN115017283B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of intelligent dialogue technology, and in particular to a natural language processing model, method, electronic device and computer storage medium. Background Art
[0002] Tables are a widely used data storage method that is widely used to store and display structured data. Since table data has a clear structure, is easy to maintain, and has strong timeliness, they are usually an important source of answers for search engines and intelligent dialogue systems. In the process of regular interaction with databases (such as online shopping, ticket booking, meal ordering, etc.), most operations are performed through SQL templates encapsulated in the background. This means that operations are often limited to pre-set SQL templates, lack flexibility, and are difficult to meet the needs of intelligent dialogue systems.
[0003] To solve this problem, the NL2SQL (natural language to SQL statement) technical solution can be used. Users only need to express their intentions through natural language, and NL2SQL will convert them into structured question statements SQL, which will greatly shorten the distance between users and the database.
[0004] TableQA is an effective application of this technology. TableQA is a type of intelligent dialogue, which can automatically convert user natural language into SQL statements and automatically reply to queries. In actual application scenarios, since data is generally stored in a database, in order to represent complex table relationships, it is necessary to involve multiple tables, and tables are associated through foreign keys. In addition, the contextual information of natural language must be considered during the question-answering process, and multiple tables and multiple rounds of table question-answering are required. As a result, the input data of the NL2SQL model is very long, which seriously affects the overall performance of the NL2SQL model. Summary of the invention
[0005] In view of this, an embodiment of the present application provides a natural language processing solution to at least partially solve the above-mentioned problems.
[0006] According to a first aspect of an embodiment of the present application, a natural language processing model is provided, wherein the natural language processing model is used to convert natural language question statements in multiple rounds of dialogue into SQL statements, and the model comprises: a pooling layer, wherein the pooling layer is used to compress the column information of a data table to be retrieved into encoded data of a set length; an encoding layer, wherein the encoding layer is used to construct input data based on the natural language question statement and the encoded data containing the column information, and predict the parameters of the SQL statement of the current round and the intention of the question statement based on the input data; and an output layer, wherein the output layer is used to generate an SQL statement corresponding to the question statement based on the predicted intention and the parameters of the SQL statement of the current round.
[0007] According to a second aspect of an embodiment of the present application, a natural language processing method is provided, comprising: compressing column information of a data table to be retrieved into encoded data of a set length; constructing input data based at least on the encoded data containing the column information and a question statement of a current round of dialogue; processing the input data using a natural language processing model to predict parameters of an SQL statement corresponding to the question statement and the intent of the question statement; and generating an SQL statement corresponding to the question statement based on the predicted parameters of the SQL statement corresponding to the question statement and the intent of the question statement.
[0008] According to the third aspect of an embodiment of the present application, there is provided an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the aforementioned method.
[0009] According to a fourth aspect of an embodiment of the present application, a computer storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method as described above is implemented.
[0010] According to a fifth aspect of an embodiment of the present application, a computer program product is provided, comprising computer instructions, wherein the computer instructions instruct a computing device to perform operations corresponding to the above-mentioned method.
[0011] According to the method provided in the embodiment of the present application, in the process of the natural language processing model processing the question statement to obtain the SQL statement, the column information (such as column name, etc.) of the data table to be retrieved needs to be input. Because the column information of the data table is long, the length of the input data input into the natural language processing model is long, resulting in an increase in the amount of calculation of the natural language processing model and a decrease in the calculation efficiency, which affects the performance. In this embodiment, by adding a pooling layer before the encoding layer of the natural language processing model, the pooling layer is used to compress the column information, so that the column information with a long length is compressed into the encoded data of a set length, and the column information is still retained in the encoded data, and the encoded data containing the column information and the question statement are constructed into input data, so that the length of the input data of the natural language processing model is reduced, thereby reducing the amount of calculation of the data processing of the encoding layer and improving the performance. The encoding layer can predict the intention of the question statement and the parameters of the SQL statement corresponding to the question statement by processing the input data, and then the output layer can generate the corresponding SQL statement according to the intention and the parameters of the SQL statement. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0013] Figure 1 A schematic diagram of the structure of a natural language processing model according to the first embodiment of the present application;
[0014] Figure 2 A schematic diagram of a natural language processing method according to Embodiment 2 of the present application;
[0015] Figure 3 is a structural block diagram of a natural language processing device according to Embodiment 3 of the present application;
[0016] Figure 4 This is a schematic diagram of the structure of an electronic device according to Embodiment 5 of the present application. DETAILED DESCRIPTION
[0017] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the embodiments of the present application should fall within the scope of protection of the embodiments of the present application.
[0018] The specific implementation of the embodiment of the present application is further explained below in conjunction with the accompanying drawings of the embodiment of the present application.
[0019] Embodiment 1
[0020] For ease of understanding, before describing in detail the implementation process of the method of the present application, an exemplary use scenario of the method is described, but the method of the present application is not limited to this use scenario, and it can also be applied to other appropriate scenarios.
[0021] In the embodiment of the present application, an intelligent robot based on tableQA is used as an example for explanation. The intelligent dialogue robot can dialogue with the user based on the data in the data table (table), and during the dialogue process, the intelligent dialogue robot can understand the question statement entered by the user in natural language, and convert the question statement into an SQL statement that the database can understand, and then use the SQL statement to search the data table in the database to obtain the required information, and convert the required information into a reply statement expressed in natural language and return it to the user. For example, the user asks "How long is the investment time of product A?" The intelligent dialogue robot converts the question statement into an SQL statement based on the user's question statement, queries the data table through the SQL statement, obtains the information about the investment time of product A (such as 5 days), and generates a reply statement in natural language from the information, and feeds it back to the user, so that the user and the intelligent dialogue robot can interact in a way similar to a conversation between people.
[0022] In this process, it is necessary to be able to accurately convert the natural language question statements into the corresponding SQL statements that can be recognized by the database. In this embodiment, a natural language processing model is provided to realize this function. The natural language processing model is used to convert the natural language question statements in multiple rounds of dialogue into SQL statements, which includes a pooling layer, an encoding layer and an output layer. Among them, the pooling layer is used to compress the column information of the data table to be retrieved into encoded data of a set length; the encoding layer is used to construct input data based on the natural language question statement and the encoded data containing the column information, and predict the parameters of the current round of SQL statements and the intention of the question statement based on the input data; the output layer is used to generate an SQL statement corresponding to the question statement based on the predicted intention and the parameters of the current round of SQL statements.
[0023] In the process of the natural language processing model processing the question statement to obtain the SQL statement, the column information of the data table to be retrieved (such as column name, column unit and column value type, etc.) needs to be input. Because the column information of the data table is long, the length of the input data input into the natural language processing model is long, resulting in an increase in the amount of calculation of the natural language processing model and a decrease in the calculation efficiency, which affects the performance. In this embodiment, by adding a pooling layer before the encoding layer of the natural language processing model, the pooling layer is used to compress the column information, so that the column information with a long length is compressed into the encoding data of the set length, and the column information is still retained in the encoding data, and the encoding data and the question statement are constructed as input data, so that the length of the input data of the natural language processing model is reduced, thereby reducing the amount of calculation of the encoding layer data processing, improving the performance, and the column information is retained in the encoding data, so that the accuracy of the subsequent prediction of the SQL statement can still be guaranteed. The encoding layer can predict the intention of the question statement and the parameters of the SQL statement corresponding to the question statement by processing the input data, and then the output layer can generate the corresponding SQL statement according to the intention and the parameters of the SQL statement.
[0024] Combine the following Figure 1 The natural language processing model is described in detail as follows:
[0025] like Figure 1 As shown, the natural language processing model includes a pooling layer, an encoding layer, and an output layer.
[0026] Among them, the pooling layer can be a max-pooling (maximum pooling) pooling layer or an avg-pooling (average pooling) pooling layer, which is not limited. Different from the ordinary pooling layer, the pooling layer in the present application is set before the encoder, and the pooling layer can encode the column information (schema) of the associated data table separately to output the encoded data of a set length, which can be determined as needed and is not limited.
[0027] Usually, the set length is less than or equal to the length of the column information of any column in the data after being directly spliced. Column information includes but is not limited to: column name (such as rate of return, product name, investment time, etc.), column value type (such as text, number, etc.) and column unit (such as day, %, ten thousand yuan, etc.).
[0028] Under normal circumstances, if the column information only includes the column name, and each character of the column name will be converted into an N-dimensional vector (also called a token), taking the column name as the rate of return as an example, the column name needs to be represented by a 3XN-dimensional vector. In the present application, the column name is processed by a pooling layer so that the compressed encoded data is an N-dimensional vector. For the case where there are many columns in the data table, the length of the constructed input data can be greatly reduced by processing the column information through a pooling layer. Of course, in other examples, the column information may include column names (such as rate of return), column units (such as %), and column value types (such as number), without limitation. Experiments have shown that the richer the column information, the better the accuracy of subsequent predictions.
[0029] The encoded data output by the pooling layer and the question statement (which can be represented by a vector) together constitute the input data. For example, when the encoding layer constructs the input data according to the question statement of natural language and the encoded data, it includes: according to the question statement, the historical information of the multi-round dialogue ( Figure 1 The input data is constructed by using the historical SQL statements shown in the figure), the encoding data and the initialized SQL structure data (SQL-sketch data).
[0030] In this example, the input data includes not only the encoded data and question statements, but also the historical information of multiple rounds of conversations and the initialized SQL structure data. Because it includes the historical information of multiple rounds of conversations, the natural language processing model is compatible with the scenarios of multiple rounds of conversations, so that it can combine the contextual information of historical conversations to improve the accuracy of predictions.
[0031] In this example, the historical information of the multi-round dialogue includes the SQL statement corresponding to the question statement in the previous round of dialogue. Since the input data of each round of the natural language processing model contains historical information, the SQL statement of the previous round of dialogue actually integrates the context information of all historical rounds of dialogue. In this way, the SQL statement of the previous round of dialogue ensures that all historical information can be retained and the length of input data is short, which helps to improve performance.
[0032] In addition to the historical information of multiple rounds of dialogue, the input data also includes the initialized SQL structure data, which includes the parameters of the initialized SQL statement (such as Figure 1 s-num, agg, etc.) and the initialization intention (such as Figure 1 action shown in ), so that the encoding layer can directly predict the parameters of the current round of SQL statements and the intention expressed by the question statement entered by the user, so that the subsequent output layer does not need to perform complex processing on the data output by the encoding layer, thereby simplifying the output layer and improving performance.
[0033] The encoding layer can use the BERT neural network model, and the model can be initialized using the BERT-Base method during training. Of course, in other embodiments, the encoding layer can use other models as long as the accuracy of the prediction can be guaranteed.
[0034] The parameters of the predicted SQL statement may include query parameters for indicating a query target (such as select-related parameters) and filter parameters for indicating filter conditions.
[0035] The query parameters include query quantity parameters, query column parameters and aggregate function parameters, but are not limited thereto.
[0036] The query quantity parameter (select number, Figure 1 The s-number shown in is used to indicate the number of query operations included in the SQL statement of the current round, which may indicate that the SQL statement includes several queries.
[0037] The query column parameter (select column) is used to indicate the column corresponding to each query operation, such as the column of "product name".
[0038] The aggregation function parameter (Select-Aggregation) is used to indicate the aggregation function used by the query operation, such as the max function, the min function, and the like.
[0039] The filtering parameters include a filtering condition quantity parameter, a filtering condition target column parameter, a filtering condition operator and a filtering condition value, and may also include a filtering connector.
[0040] The filtering condition number parameter (where number) is used to indicate the number of filtering conditions included in the SQL statement of the current round.
[0041] The target column parameter (where column) of the filtering condition is used to indicate the column filtered by the filtering condition, such as "yield rate".
[0042] The where operator of the filter condition is used to indicate which operator to use, such as greater than, equal to, less than, or not equal to.
[0043] The value of the filter condition (where value) is used to indicate the filter value.
[0044] In one example, in the SQL statement: select max(col_1) where col_2 > 2, max() is an aggregation function, col_1 is the value of the query column parameter, col_2 is the value of the target column parameter of the filtering condition, > is the operator of the filtering condition, and 2 is the value of the filtering condition.
[0045] When there are multiple filtering conditions, the filtering connector is used to indicate the connection relationship between the filtering conditions, such as "and" or "or", etc.
[0046] When there is only one filtering condition or no filtering condition exists, there is no filtering connector.
[0047] In addition to the parameters of these SQL statements, the encoding layer can also predict the intention of the problem statement, which can indicate adjusting the SQL statement of the previous round of conversation to obtain the SQL statement of the current round; or, indicating whether to use this data table to answer the problem statement; or, indicating to start a new SQL statement.
[0048] The output layer can generate the SQL statement corresponding to the problem statement of the current round of conversation based on the intention predicted by the encoding layer and the parameters of the SQL statement, so as to query the data table by executing the SQL statement, thereby obtaining the required information.
[0049] For example, when the intention is to add a condition, modify a condition, delete a condition, modify a query, modify an aggregation function, delete a query, etc., it means adjusting the SQL statement of the previous round of conversation to obtain the SQL statement of the current round. In this case, the output layer uses the predicted parameters of the SQL statement to adjust the SQL statement in the previous round of conversation to generate the SQL statement corresponding to the problem statement.
[0050] Specifically, for example, when the intention is to add a condition, the parameters of the SQL statement include the number of filtering condition parameters (for example, 2), the target column parameter of the filtering condition (for example, col_5), the operator of the filtering condition (for example, less than), the filtering condition value (for example, value1), and the filtering connector (for example, and). A new filtering condition: col_5 < value1 can be added on the basis of the previous round of SQL statement. The relationship between the newly added filtering condition and the filtering conditions of the original SQL statement is and. Thus, the number of filtering conditions of the generated SQL statement of the current round is 2.
[0051] When the intention is to modify the conditions, the parameters of the SQL statement can include the target column parameter (for example, col_2). Other parameters that do not need to be changed are not repeated. The target column in the filter condition in the previous round of SQL statements can be modified to col_2, thereby generating the SQL statement for the current round. When there are multiple filter conditions, the target column of each filter condition can be modified in the order of the output target column parameters. For example, there are 3 filter conditions, and the previous target column parameters in the SQL statement of the previous round of dialogue are col_3, col_5, and col_6. The target column parameters output by the coding layer are col_2, col_5, and col_6, which means that col_3 is changed to col_2.
[0052] When the intention is to delete a condition, the parameters of the SQL statement can be parameters corresponding to the filtering conditions that need to be deleted or parameters of the filtering conditions that need to be retained. There is no restriction on this. The output layer only needs to delete the unnecessary filtering conditions in the SQL statement of the previous round of dialogue according to the intention.
[0053] When the intention is to modify the query, the parameters of the SQL statement include the parameters of the query column that needs to be modified. For example, if the column to be queried changes from "product name" to "yield", the output layer modifies the SQL statement of the previous round of dialogue based on the parameters of the SQL statement to obtain the SQL statement of the current round.
[0054] When the intention is to modify an aggregate function, the parameters of the SQL statement contain the aggregate function that needs to be replaced, such as changing max() to min(). The modification process is similar to the above, so it will not be repeated here.
[0055] When the intention is to delete a query, the parameters of the SQL statement include the parameters of the query to be deleted, and the modification process is similar to the above, so it will not be repeated.
[0056] It should be noted that one or more of the aforementioned intentions and their corresponding parameters may be output in one prediction, without limitation.
[0057] If the intention in the prediction result indicates to start a new SQL statement, a SQL statement corresponding to the question statement is generated according to the predicted parameters of the SQL statement.
[0058] When the intent indicates starting a new SQL statement, it may mean that the previous conversation has been completed and a new topic has been started, so a new SQL statement can be generated based on the parameters of the SQL statement.
[0059] If the intent in the prediction result indicates that the data table to be retrieved is not used to answer the question statement, it is a rejection, indicating that the data table to be retrieved and the question statement are not closely related, and the question statement cannot be answered through the data table to be retrieved. For example, the question statement queries the yield of a certain product, and the retrieved data table stores information such as the release year of film and television works. Since the two are unrelated, the intent is expressed as a rejection.
[0060] Through this natural language processing model, the column information (Schema) in the data table can be encoded to obtain encoded data (schema embedding). Since the column information is encoded, it is suitable for multi-table multi-round TableQA question-answering systems. This solves the problem of splicing the table schema to the question statement for unified parsing, which makes the model input very long and seriously affects the overall performance of the model. Compared with the existing model, the model of this embodiment supports more than 300 columns from 60 columns, with a 5-fold increase in column name capacity and a 2.3-fold increase in the model's reasoning performance, which can be better applied to multi-table association query scenarios.
[0061] Embodiment 2
[0062] Reference Figure 2 , showing a schematic diagram of the step flow of the natural language processing method of Example 2 of the present application.
[0063] The method may use the natural language processing model of the aforementioned embodiment, and the method comprises the following steps:
[0064] Step S202: compressing the column information of the data table to be retrieved into coded data of a set length.
[0065] For example, if the data table to be retrieved includes 10 columns, the column information of each column can be compressed to obtain coded data of a set length. The column information includes at least the column name, but is not limited to this, and can also include column units, etc. In this way, the column information can be used as the input of the encoding layer of the natural language processing model, and the length of the input data can be minimized to improve the reasoning performance.
[0066] Step S204: construct input data at least based on the encoded data including the column information and the question statement of the current round of dialogue.
[0067] In one feasible manner, step S204 can be implemented as follows: constructing the input data according to the coded data, the question statement of the current round of dialogue, the SQL statement of the previous round of dialogue, and the SQL structure data. By including the SQL statement of the previous round of dialogue in the input data, the input data can carry the context information of the historical dialogue in multiple rounds of dialogue, thereby improving the adaptability to the multi-round dialogue scenario.
[0068] By including SQL structure data (SQL sketch) in the input data, and the SQL structure data includes the intent of the question statement and the parameters of the SQL statement, the subsequent encoding layer can directly predict the intent and the parameters of the SQL statement. In this way, the output layer does not need to perform complex processing on the data output by the encoding layer to obtain the intent and the parameters of the SQL statement, reducing the burden of data processing.
[0069] Step S206: Process the input data using a natural language processing model to predict parameters of an SQL statement corresponding to the question statement and the intent of the question statement.
[0070] By inputting the input data into the trained encoding layer and processing it using the encoding layer, the intent output by the encoding layer and the parameters of the SQL statement are obtained.
[0071] Step S208: Generate an SQL statement corresponding to the question statement according to the predicted parameters of the SQL statement corresponding to the question statement and the intention of the question statement.
[0072] The intention of the question statement may include adding conditions, modifying conditions, deleting conditions, modifying queries, modifying aggregate functions, deleting queries, reopening, rejecting, etc. Among them, adding conditions, modifying conditions, deleting conditions, modifying queries, modifying aggregate functions, deleting queries, etc. indicate that corresponding operations are performed on the basis of the SQL statements of the previous round of dialogue to generate the SQL statements corresponding to the question statement of the current round of dialogue.
[0073] For example, the SQL statement in the previous round of dialogue is: select investment time where product name = A, and the question statement in the current round is "What is its rate of return". The corresponding intention is to modify the query. The parameters of the SQL statement include the query column parameter "rate of return". After adjustment, the SQL statement in the current round of dialogue is: select rate of return where product name = A.
[0074] Through this method, users only need to express their intentions through natural language question statements. This method will perform NL2SQL (Natural Language to SQL) based on the question statements and convert them into structured query statements SQL, thus achieving intelligent responses. In addition, because the column information of each column in the data table is compressed to form encoded data as input, the length of the input data is reduced, thereby improving the reasoning performance of the natural language processing model, and it can be compatible with data tables with more columns.
[0075] The effect of this method is evaluated on a general industry dataset. Compared with the sketch-base model, the overall effect is basically the same, and the inference performance is improved by 2.3 times. Specifically, the test set effect of the sketch-base model is 86.6%, the test set effect is 85.4% when max-pooling is performed on the column names, the test set effect is 85.8% when avg-pooling is performed on the column names, the test set effect is 86.1% when avg-pooling is performed on the column names and combined with column value type encoding, and the test set effect is 86.3% when avg-pooling is performed on the column names and combined with column value type and column unit encoding.
[0076] This method can support multi-table and multi-round database question-answering scenarios, and solves the problem that the sketch-base model splices the column information of the data table into the question statement for unified parsing, resulting in very long input data for the model, which seriously affects the overall performance of the model. This method effectively reduces the input data length by compressing the column information and obtaining encoded data. Compared with the sketch-base model, the number of column names supported is increased from 60 to more than 300, the column name capacity is increased by 5 times, and the inference performance is improved by 2.3 times, which can be better applied to multi-table association query scenarios.
[0077] The method of this embodiment can be executed by any appropriate electronic device with data processing capability, including but not limited to: a server, a mobile terminal (such as a mobile phone, a PAD, etc.) and a PC, etc.
[0078] Embodiment 3
[0079] Reference Figure 3 , showing a structural block diagram of the natural language processing device of Example 3 of the present application.
[0080] In this embodiment, the device includes:
[0081] A compression module 302, used to compress the column information of the data table to be retrieved into coded data of a set length;
[0082] A construction module 304, configured to construct input data based on at least the encoded data including the column information and a question statement of a current round of dialogue;
[0083] A prediction module 306, configured to process the input data using a natural language processing model to predict parameters of an SQL statement corresponding to the question statement and the intent of the question statement;
[0084] The generation module 308 is used to generate a SQL statement corresponding to the question statement according to the predicted parameters of the SQL statement corresponding to the question statement and the intention of the question statement.
[0085] Optionally, the construction module 304 is used to construct the input data according to the encoded data, the question statement of the current round of dialogue, the SQL statement of the previous round of dialogue and the SQL structure data.
[0086] The device of this embodiment is used to implement the corresponding methods in the aforementioned multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here. In addition, the functional implementation of each module in the device of this embodiment can refer to the description of the corresponding parts in the aforementioned method embodiments, which will not be repeated here.
[0087] Embodiment 4
[0088] Reference Figure 4 , shows a schematic diagram of the structure of an electronic device according to the fourth embodiment of the present application. The specific embodiment of the present application does not limit the specific implementation of the electronic device.
[0089] like Figure 4 As shown, the electronic device may include: a processor (processor) 402 , a communication interface (Communications Interface) 404 , a memory (memory) 406 , and a communication bus 408 .
[0090] in:
[0091] The processor 402 , the communication interface 404 , and the memory 406 communicate with each other via a communication bus 408 .
[0092] The communication interface 404 is used to communicate with other electronic devices or servers.
[0093] The processor 402 is used to execute the program 410, and specifically can execute the relevant steps in the above method embodiment.
[0094] Specifically, the program 410 may include program codes, which include computer operation instructions.
[0095] The processor 402 may be a processor CPU, or an application specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0096] The memory 406 is used to store the program 410. The memory 406 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0097] The program 410 may be specifically used to enable the processor 402 to execute operations corresponding to the aforementioned method.
[0098] The specific implementation of each step in program 410 can refer to the corresponding description of the corresponding steps and units in the above method embodiment, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above method embodiment, which will not be repeated here.
[0099] An embodiment of the present application also provides a computer program product, including computer instructions, which instruct a computing device to execute operations corresponding to any one of the above-mentioned multiple method embodiments.
[0100] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present application can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present application.
[0101] The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as a CD ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as a computer code originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and to be stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a special-purpose processor or programmable or special-purpose hardware (such as an ASIC or FPGA). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the method shown here, the execution of the code converts the general-purpose computer into a special-purpose computer for executing the method shown here.
[0102] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present application.
[0103] The above implementation methods are only used to illustrate the embodiments of the present application, and are not limitations on the embodiments of the present application. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the spirit and scope of the embodiments of the present application. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present application. The scope of patent protection of the embodiments of the present application should be limited by the claims.
Claims
1. A natural language processing model, the natural language processing model is used to convert natural language question statements in multi-round dialogues into SQL statements, the model comprising: A pooling layer, the pooling layer is used to compress the column information of the data table to be retrieved into encoded data of a set length; An encoding layer, the encoding layer is used to construct input data according to the question statement in natural language and the encoded data containing the column information, and predict the parameters of the SQL statement of the current round and the intention of the question statement based on the input data; The output layer is used to generate an SQL statement corresponding to the question statement according to the predicted intent and the parameters of the SQL statement of the current round.
2. The model according to claim 1, wherein: When the encoding layer constructs input data according to the question statement of the natural language and the encoded data, it includes: The input data is constructed according to the question statement, the historical information of the multiple rounds of dialogue, the encoded data and the initialized SQL structure data.
3. The model according to claim 2, wherein: The historical information of the multiple rounds of dialogues includes the SQL statements corresponding to the question statements in the previous round of dialogues.
4. The model according to claim 1, wherein: The parameters of the current round of SQL statements include query parameters for indicating the query target, and the query parameters include a query quantity parameter, a query column parameter and an aggregate function parameter. The query quantity parameter is used to indicate the number of query operations included in the current round of SQL statements, the query column parameter is used to indicate the column corresponding to each query operation, and the aggregate function parameter is used to indicate the aggregate function used by the query operation.
5. The model according to claim 1, wherein: The parameters of the SQL statement of the current round include filtering parameters for indicating filtering conditions, and the filtering parameters include a filtering condition quantity parameter, a target column parameter of the filtering condition, an operator of the filtering condition and a filtering condition value. The filtering condition quantity parameter is used to indicate the number of filtering conditions included in the SQL statement of the current round, and the filtering condition target column parameter is used to indicate the column filtered by the filtering condition.
6. The model according to claim 1, wherein: When the output layer generates an SQL statement corresponding to the question statement according to the prediction result, it includes: If the intention in the prediction result indicates that the SQL statement in the previous round of dialogue is to be adjusted, the SQL statement in the previous round of dialogue is adjusted using the predicted parameters of the SQL statement to generate an SQL statement corresponding to the question statement; or, If the intention in the prediction result indicates to start a new SQL statement, a SQL statement corresponding to the question statement is generated according to the predicted parameters of the SQL statement.
7. A natural language processing method, comprising: Compressing the column information of the data table to be retrieved into coded data of a set length; constructing input data based on at least the encoded data including the column information and the question sentence of the current round of dialogue; Processing the input data using a natural language processing model to predict parameters of an SQL statement corresponding to the question statement and the intent of the question statement; The SQL statement corresponding to the question statement is generated according to the predicted parameters of the SQL statement corresponding to the question statement and the intention of the question statement.
8. The method according to claim 7, wherein: The step of constructing input data at least according to the encoded data and the question statement of the current round of dialogue includes: The input data is constructed according to the encoded data, the question statement of the current round of dialogue, the SQL statement of the previous round of dialogue and the SQL structure data.
9. An electronic device, comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the method according to claim 7 or 8.
10. A computer storage medium having a computer program stored thereon, which implements the method according to claim 7 or 8 when executed by a processor.
11. A computer program product, comprising computer instructions, wherein the computer instructions instruct a computing device to perform operations corresponding to the method according to claim 7 or 8.
Citation Information
Patent Citations
Management database connecting method and system
CN101334778A
Method for automatically switching between SQL search result column titles and codes
CN107943995A