Query statement generation method and device, storage medium and electronic device
By determining the corresponding link relationship and label data between data tables and text information in NL2SQL technology and generating structured query statements, the problem of poor accuracy in the existing technology is solved and the accuracy of query results is improved.
Patent Information
- Application Number
- CN202110306766.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-23
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2041-03-23
AI Technical Summary
The existing NL2SQL technology has poor accuracy in converting natural language into SQL query statements, resulting in a low accuracy rate in querying the database.
By determining the corresponding link relationship between the data table and the text information, generating label data, and inputting the text information, table header information and its label data into the language model for conversion task learning, the structured relationship between the text information and the data table is integrated to generate structured query statements.
The expression logic accuracy of SQL structured query statements has been improved, and the accuracy of query results in query scenarios has been enhanced.
Smart Images

Figure CN115114281B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of natural language processing, and more particularly to a method and apparatus for generating query statements. The present application also relates to an intelligent dialogue service method, a computer storage medium, and an electronic device. Background Art
[0002] Tables are a widely used data storage method for storing and displaying structured data. Because tabular data is clearly structured, easy to maintain, and highly timely, they are often an important source of answers for search engines and intelligent conversational systems.
[0003] In the era of massive big data, storing big data in tables in databases has become a common data storage method. Everyday data interactions, such as online shopping, ticket booking, and restaurant ordering, are often implemented using pre-set SQL templates. However, pre-set SQL templates lack flexibility, limiting interactions to the SQL template's functionality.
[0004] NL2SQL technology, which converts natural language into SQL queries, can address the aforementioned issue of inflexibility in SQL templates. However, existing NL2SQL technology suffers from poor accuracy in parsing natural language to generate SQL queries. Furthermore, in specific application scenarios, this results in low accuracy in SQL queries when querying databases. Summary of the Invention
[0005] The present application provides a method for generating a query statement to solve the problem of poor accuracy of SQL query statements in the prior art.
[0006] This application provides a method for generating a query statement, comprising:
[0007] Determine the label data of the words in the text information according to the data information in the data table;
[0008] Determining label data of the header information of the data table according to the data information of the data table and the text information;
[0009] Inputting the text information, the header information, the label data of the text information, and the label data of the header information into a language model to perform conversion task learning, and obtaining subtask data for converting the text information into the query statement;
[0010] The query statement is generated according to the subtask data.
[0011] In some embodiments, determining the label data of the words in the text information based on the data information in the data table includes:
[0012] Establishing a corresponding link relationship between the data information and the text information;
[0013] According to the corresponding link relationship, label data of the words in the text information is determined.
[0014] In some embodiments, establishing a corresponding link relationship between the data information and the text information includes:
[0015] Performing word segmentation processing on the text information to obtain vocabulary;
[0016] Matching the vocabulary with the data information in the data table to determine a matching relationship between the vocabulary and the data information;
[0017] The matching relationship is determined as a corresponding link relationship between the data information and the text information.
[0018] In some embodiments, determining the label data of the words in the text information according to the corresponding link relationship includes:
[0019] The type information used to characterize the corresponding link relationship between the word and the data information is determined as the label data of the text information.
[0020] In some embodiments, determining the label data of the header information of the data table according to the data information of the data table and the text information includes:
[0021] determining whether the data information appears in the text information;
[0022] If so, the identification information used to characterize the appearance state of the data information in the text information is determined as the label data of the data table header information.
[0023] In some embodiments, inputting the text information, the header information, the label data of the text information, and the label data of the header information into a language model to perform conversion task learning, and obtaining subtask data for converting the text information into the query statement, includes:
[0024] Inputting the text information and the header information into the encoding layer of the language model for encoding processing to obtain encoded data of the text information and encoded data of the header information;
[0025] The encoded data of the text information, the label data of the text information, the encoded data of the header information, and the text information are input as input parameters for learning the conversion task, and are input into the interaction layer of the language model for data interaction to obtain interaction data;
[0026] The feature interaction data is input into the conversion task parsing layer of the language model for parsing to obtain subtask data for converting the text information into the structured query statement.
[0027] In some embodiments, inputting the encoded data of the text information, the tag data of the text information, the encoded data of the header information, and the text information as input parameters into the interaction layer of the language model for data interaction to obtain interaction data includes:
[0028] Inputting the encoded data of the text information and the encoded data of the header information into the first neural network of the interaction layer for data interaction to obtain first interaction data;
[0029] Splicing the first interaction data with the label data of the text information to obtain first spliced data;
[0030] Inputting the sequence encoding data of the text information and the encoding data of the header information into the second neural network of the interaction layer for data interaction to obtain second interaction data;
[0031] The second interaction data, the tag data of the header information, and the first interaction data are spliced together to obtain second spliced data.
[0032] In some embodiments, inputting the data interaction features into the task parsing layer of the language model for parsing to obtain subtask data for converting the text information into the structured query statement includes:
[0033] The first concatenated data and the second concatenated data are used as the interaction data and input into the task parsing layer of the language model for parsing to obtain subtask data for converting the text information into the structured query statement.
[0034] In some embodiments, further comprising:
[0035] Determining a probability value of the subtask data;
[0036] determining whether the probability value satisfies a generation condition for generating the query statement;
[0037] If not, the model parameters in the language model are adjusted according to the probability value.
[0038] In some embodiments, further comprising:
[0039] The text information and the header information are input into a language model for learning a query statement of a dependency relationship between the text information and the header information, and dependency relationship task learning is performed to obtain data representing the dependency relationship between the text information and the header information.
[0040] In some embodiments, inputting the text information and the header information into a language model for learning the dependency relationship between the text information and the header information to perform dependency task learning, and obtaining data for representing the dependency relationship between the text information and the header information, includes:
[0041] Using the encoded data of the text information and the encoded data of the header information as input parameters for the dependency relationship task learning, inputting them into the interaction layer of the language model to perform dependency data interaction, and obtaining interactive dependency data;
[0042] The interactive dependency data is input into the dependency task parsing layer of the language model for parsing to obtain dependency relationship data for representing the dependency relationship between the text information and the header information.
[0043] In some embodiments, inputting the interactive dependency data into the dependency task parsing layer of the language model for parsing to obtain dependency relationship data representing the dependency relationship between the text information and the header information includes:
[0044] The dependency task parsing layer parses the dependency data to determine the correspondence between words in the text information and the header information;
[0045] The label data of the word relative to the header information is determined according to the corresponding relationship, and the label data is dependency relationship data representing the dependency relationship between the text information and the header information.
[0046] In some embodiments, generating the structured query statement for the text information based on the subtask data further includes:
[0047] The structured query statement for the text information is generated according to the subtask data and the dependency relationship data.
[0048] In some embodiments, generating the structured query statement for the text information based on the subtask data and the dependency data includes:
[0049] The subtask data and the dependency relationship data are integrated to obtain the structured query statement for the text information.
[0050] In some embodiments, further comprising:
[0051] determining a probability value of the dependency relationship data;
[0052] Determining whether the probability value satisfies a generation condition for the query statement generated by the dependency data and the subtask data;
[0053] If not, the probability value is used as an input parameter and input into the language model to adjust the model parameters.
[0054] The present application also provides a query statement generation device, comprising:
[0055] A first determining unit, configured to determine label data of the text information according to a corresponding link relationship between the data information in the data table and the text information;
[0056] a second determining unit, configured to determine label data of header information of the data table according to the data information of the data table and the text information;
[0057] a conversion unit, configured to input the text information, the header information, the label data of the text information, and the label data of the header information into a language model for converting the text information into a structured query statement, perform conversion task learning, and obtain subtask data for converting the text information into the structured query statement;
[0058] A generating unit is configured to generate the structured query statement for the text information according to the subtask data.
[0059] This application also provides an intelligent dialogue service method, including:
[0060] Based on the intelligent dialogue service platform, obtain question information in the question request and data information of the data table to be queried for querying the question information;
[0061] Generate a query statement for the question information according to the above query statement generation method;
[0062] Query the data table to be queried according to the query statement to determine the query data that matches the question information;
[0063] The query data is output to the intelligent dialogue service platform.
[0064] The present application also provides a computer storage medium for storing data generated by a network platform and a program for processing the data generated by the network platform;
[0065] When the program is read and executed, the following steps are performed:
[0066] Determining label data of the text information according to data information in the data table;
[0067] Determining label data of header information of the data table according to the data information of the data table and the text information;
[0068] Inputting the text information, the header information, the label data of the text information, and the label data of the header information into a language model to perform conversion task learning, and obtaining subtask data for converting the text information into the query statement;
[0069] generating the query statement according to the subtask data;
[0070] Alternatively, when the program is read and executed, the following steps are performed:
[0071] Based on the intelligent dialogue service platform, obtain question information in the question request and data information of the data table to be queried for querying the question information;
[0072] Generate a query statement for the question information according to the above query statement generation method;
[0073] Query the data table to be queried according to the query statement to determine the query data that matches the question information;
[0074] The query data is output to the intelligent dialogue service platform.
[0075] The present application also provides an electronic device, comprising:
[0076] processor;
[0077] The memory is used to store a program for processing data generated by the network platform, and when the program is read and executed by the processor, the program performs the following steps:
[0078] Determining label data of the text information according to data information in the data table;
[0079] Determining label data of header information of the data table according to the data information of the data table and the text information;
[0080] Inputting the text information, the header information, the label data of the text information, and the label data of the header information into a language model to perform conversion task learning, and obtaining subtask data for converting the text information into the query statement;
[0081] generating the query statement according to the subtask data;
[0082] Alternatively, perform the following steps:
[0083] Based on the intelligent dialogue service platform, obtain question information in the question request and data information of the data table to be queried for querying the question information;
[0084] Generate a query statement for the question information according to the above query statement generation method;
[0085] Query the data table to be queried according to the query statement to determine the query data that matches the question information;
[0086] The query data is output to the intelligent dialogue service platform.
[0087] Compared with the prior art, this application has the following advantages:
[0088] The present application provides an embodiment of a method for generating a query statement. The method comprises determining label data for words in text information based on data information in a data table; determining label data for table header information in the data table based on the data information in the data table and the text information; inputting the text information, the table header information, the label data for the text information, and the label data for the table header information into a language model for conversion task learning to obtain subtask data for converting the text information into the query statement; and generating the query statement based on the subtask data. This method integrates the structured relationship of semantic dependencies between the text information and the data table into the generated SQL structured query statement, thereby enhancing the expression logic accuracy of the SQL structured query statement and further improving the accuracy of query results in query scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] Figure 1 This is a flowchart of an embodiment of a method for generating a query statement provided by the present application;
[0090] Figure 2 This is a structural diagram of establishing corresponding link relationships in an embodiment of a method for generating a query statement provided by the present application;
[0091] Figure 3 This is a schematic diagram of the structure of label data for determining header information in an embodiment of a method for generating a query statement provided by the present application;
[0092] Figure 4 This is a schematic diagram of a language model structure for performing a conversion learning task in an embodiment of a query statement generation method provided by the present application;
[0093] Figure 5 This is a schematic diagram of the structure of dependency data in an embodiment of a method for generating a query statement provided by the present application;
[0094] Figure 6 1 is a schematic diagram of a language model structure in an embodiment of a query statement generation method provided by the present application, including performing conversion task learning and dependency task learning;
[0095] Figure 7 This is a schematic diagram of the structure of an embodiment of a query statement generation device provided by the present application;
[0096] Figure 8 This is a flowchart of an embodiment of an intelligent dialogue service method provided by this application;
[0097] Figure 9 It is a structural diagram of an electronic device embodiment provided by this application. DETAILED DESCRIPTION
[0098] The following description sets forth many specific details to facilitate a thorough understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of the present application. Therefore, the present application is not limited to the specific implementations disclosed below.
[0099] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. Descriptive terms such as "a," "a," "a first," and "a second," etc., used in this application and the appended claims, are not intended to limit quantity or sequence, but are used to distinguish information of the same type from one another.
[0100] As can be seen from the description of the above background technology, the concept of an embodiment of a method for generating a query statement provided in this application is based on the fact that when using NL2SQL in the prior art, there is a lack of information in the data table in the database, which leads to difficulties in executing SQL statements. So, what is NL2SQL and why is NL2SQL technology needed in the data processing process? The following will explain one by one.
[0101] With the rapid development and mutual integration of artificial intelligence and Internet of Things technologies, more and more devices will be implanted with question-answering AI, such as: question-answering of intelligent robots, intelligent services of application software, etc. In order to realize intelligent question-answering, the terminal device needs to convert the input language information into SQL query statements that can be operated by the database, so as to realize question-answering. NL2SQL is Natural Language to SQL, which converts the user's natural statements into executable SQL query statements. This process can be regarded as a Text-to-SQL task, that is, a semantic parsing task. The Text-to-SQL task includes: a Text-to-SQL task parser and an SQL executor. The input of the parser is a given database and a question (natural language) for the database, and the output is the SQL query statement corresponding to the question. The SQL executor executes the SQL query statement on the database and gives an answer to the question.
[0102] The Text-to-SQL task can be performed similarly to a sequence-to-sequence generation task using a language model with a neural network. Currently, there are two mainstream approaches:
[0103] 1. Utilize the Seq2Seq model. The Seq2Seq model, short for Sequence to Sequence, consists of two parts: an encoder and a decoder, each of which is an RNNCell (RNN, LSTM, GRU, etc.) structure. The encoder encodes a sequence into a fixed-length semantic vector, and the decoder decodes this semantic vector into another sequence, converting the SQL query generation task into a sequence-to-sequence generation task. Therefore, the seq2seq model has extremely strict requirements on the order of sequences, while SQL queries have no strict ordering requirements. This results in poor accuracy on multi-domain datasets. Currently, mainstream datasets are multi-domain datasets, such as WikiSQL, Spider, CSpider, and CoSQL; single-domain datasets include ATIS, GeoQuery, and Scholar.
[0104] 2. Using the SQLNet model, SQL consists of SELECT and WHRER parts, which are converted into a classification problem. The so-called SQLNet model can be a Sequence-to-set model, which predicts whether all sequences belong to Select or Where. However, this method only uses the text information input to the model and the table header information in the data table, lacking information within the table. SQL query statements are structured queries with structural information between words. However, the existing SQLNet model lacks this structured information, which affects the accuracy of querying the database based on the generated SQL query statement.
[0105] Based on the above technical background, the present application provides a method for generating a query statement. This method incorporates structured information between table information and text information in a data table during the process of generating an SQL query statement. The specific content is as follows.
[0106] like Figure 1 As shown, Figure 1 This is a flowchart of an embodiment of a method for generating a query statement provided by the present application, which includes:
[0107] Step S101: determining label data of text information according to data information in the data table;
[0108] Currently, a large amount of information is stored in structured and semi-structured knowledge bases, such as databases. A database may include one or more data tables. When there are multiple data tables, the relationships between them can be determined through foreign keys. Therefore, in this embodiment, there is no limit on the number of data tables in step S101.
[0109] A data table generally includes a table header and table data in the table. The table header may be row header information or column header information. In this embodiment, the column header information of a table column is taken as an example for description.
[0110] The data information of the data table in step S101 may include column header information and table data in the table; the text information may be input natural language, that is, the expression of the information to be queried.
[0111] The tag data of the text information (utterance) in step S101 can be determined based on the corresponding link relationship between the data information in the data table and the text information. Therefore, this embodiment includes:
[0112] Step S101-1: establishing a corresponding link relationship between the data information and the text information;
[0113] Step S102-2: Determine the label data of the words in the text information according to the corresponding link relationship.
[0114] Please refer to Figure 2 As shown, Figure 2 This is a schematic diagram of a structure for establishing a corresponding link relationship in an embodiment of a method for generating a query statement provided by the present application. The specific process of establishing the corresponding link relationship may include:
[0115] Step S101-11: performing word segmentation processing on the text information to obtain words;
[0116] Step S101-12: matching the word with the data information in the data table to determine a matching relationship between the word and the data information;
[0117] Step S101 - 13 : Determine the matching relationship as a corresponding link relationship between the data information and the text information.
[0118] like Figure 2 As shown, the text information in step S001-1 may be "What are the financial products with a yield greater than 5%?" Text information is also natural language, and natural language usually needs to be converted into text information that can be recognized and processed by a computer during the processing process.
[0119] In the step S101-11, the text information "Which financial products have a yield greater than 5%?" is segmented, and the obtained words may be yield, greater than, 5%, of, financial products, have, and which ones.
[0120] The specific implementation process of step S101-12 can refer to Figure 2 As shown, the data table includes column header information, namely, product name, annualized return, and term. The table data corresponds to the content of each column header information, such as data content under product name AAA001, BBB, CCC, etc.; data content under annualized return 4.3%, 5%, 5.2%, etc.; data content under term 365, 181, 190, etc. It can be understood that the word "yield" in the text information matches the "annual return" in the column header information; the "financial product" in the text information matches the "product name" in the column header information, thereby obtaining a matching relationship between each word and the data information in the data table.
[0121] The step S101 - 13 determines a corresponding linking relationship (schema linking) between the column header information and the word according to the matching relationship in the step S101 - 12 .
[0122] Based on the above content, the specific implementation process of step S101-2 may include:
[0123] Step S101 - 21 : Determine the type information used to characterize the corresponding link relationship between the word and the data information as label data of the text information.
[0124] The type information can be understood as the column header to which the word belongs and the data content corresponding to the column header. Generally, different column headers have different meanings, such as column name (column), operator (op), value (value), null (null), and aggregate (agg). Figure 2 The example shown shows that the label data for each word in the text information is:
[0125] Yield -- column name; greater than -- operator; 5% -- value; of -- null; financial product -- column name; has -- null; which -- null. 5% belongs to the data content in the "Annualized Return" column header of the data table and is of numeric type, i.e., value.
[0126] Step S102: determining label data of the header information of the data table according to the data information of the data table and the text information;
[0127] For easier understanding of step S102, please refer to Figure 3 As shown, Figure 3 This is a structural diagram of label data for determining header information in an embodiment of a query statement generation method provided by the present application.
[0128] In this embodiment, the specific implementation process of step S102 may include:
[0129] Step S002-1: Determine whether the data information appears in the text information;
[0130] Step S002-2: If yes, the identification information used to characterize the appearance state of the data information in the text information is determined as the label data of the data table header information.
[0131] The step S002-1 can be specifically understood as whether the table information (data content in the table) and column header information in the data table appear in the text information.
[0132] In step S002-2, if the data information in the data table appears in the text information, the label data of the header information is determined according to the appearance. The identification information can be represented by Arabic numerals or by English letters, Chinese numerals or other methods. In this embodiment, Arabic numerals are used for explanation, "0" represents null; "1" represents that the column name appears in the text information (utterance); "2" represents that the value appears in the text information (utterance); "3" represents that the column name and value appear in the text information (utterance). Then the label data of the header information can be represented in the form of 0, 1, 2, 3...N. For example Figure 3 As shown, because the "Product Name" in the data table corresponds to the names of financial products such as AAA001 and BBB, it appears in the text information "What financial products have a yield greater than 5%?" but the specific financial product name does not appear. Therefore, the label data of the product name header information is 1; the "Annualized Return" in the data table corresponds to numerical information such as 4.3% and 5%, and the text information "What financial products have a yield greater than 5%?" contains numerical values and the column name - yield. Therefore, the label data of the annualized return header information is 2; the "Term" in the data table does not appear in either the header or the content in the text information, so the label data of the term header information is 0.
[0133] It should be noted that the above steps S101 and S102 are for determining the tag data of the text information and the tag data of the data table header information respectively, and there is no particular order between the two. They can be determined simultaneously or in any order.
[0134] Through the above steps S101 and S102 , the structured information between the data table and the text information can be obtained.
[0135] Step S103: Inputting the text information, the header information, the tag data of the text information, and the tag data of the header information into a language model for converting the text information into a structured query statement to perform a conversion task (NL2SQL Task) learning, thereby obtaining subtask data for converting the text information into the structured query statement;
[0136] The purpose of step S103 is to obtain subtask data. In this embodiment, the subtask data can be understood as components of SQL query statements, that is, subtask data corresponding to Select and Where, such as: select-column (query column, i.e. S-col), select-aggregation (query aggregation operation, i.e. S-agg), select-number (query number, i.e. S-num), where-number (condition number, i.e. W-num), where-column (condition corresponding column, i.e. W-col), where-operator (condition operator, i.e. W-op), where-value (condition target value, i.e. W-val), Conn (connector), etc.
[0137] The specific implementation process of step S103 can refer to Figure 4 As shown, Figure 4 : is a schematic diagram of a language model structure in an embodiment of a method for generating a query statement provided by this application. Step S103 may include:
[0138] Step S103-1: Inputting the text information and the header information into the encoding layer of the language model for encoding processing to obtain encoded data of the text information and encoded data of the header information;
[0139] Step S103-2: The encoded data of the text information, the label data of the text information, the encoded data of the header information, and the text information are input as input parameters for learning the conversion task, and are input into the interaction layer of the language model for data interaction to obtain interaction data;
[0140] Step S103 - 3 : inputting the interaction data into the conversion task parsing layer of the language model for parsing to obtain subtask data for converting the text information into the structured query statement.
[0141] In this embodiment, the language model may employ a hybrid network model, such as a BERT model, an LSTM model, and an ATT (Attention) model. Step S103-1 encodes each word or character in the text information and data table header information input into the BERT model encoding layer. In other words, the encoding layer employs the BERT model. In this embodiment, encoding processing is primarily performed on each character and each character in the data table header information, thereby obtaining encoded data for the text information and the header information.
[0142] The specific implementation process of step S103-2 may include:
[0143] Step S103-21: Inputting the encoded data of the text information and the encoded data of the header information into the first neural network of the interaction layer for data interaction to obtain first interaction data;
[0144] Step S103-22: Splicing the first interaction data with the tag data of the text information to obtain first spliced data;
[0145] Step S103-23: Inputting the encoded data of the text information and the header information into the second neural network of the interaction layer for data interaction to obtain second interaction data;
[0146] Step S103 - 24 : splicing the second interaction data, the tag data of the header information, and the first data interaction feature to obtain second spliced data.
[0147] Among them, the encoded data of the text information in step S103-21 and the encoded data of the header information can be understood as the word vector of each word in the text information and the word vector of each word in the header information. The first neural network adopts Bi-LSTM (Bi-directional Long Short-Term Memory, i.e. bidirectional long short-term memory network). Bi-LSTM is an extension or improvement of recurrent neural network (RNN), including forward LSTM and backward LSTM. It is used for sequence labeling tasks that are related to each other, so it is often used to model contextual information in NLP. The Bi-LSTM neural network will output sequence labeling data information for the input data, i.e. the first interactive data. In other words, the interactive layer is a Bi-LSTM model.
[0148] The specific implementation process of step S103 - 22 may be to concatenate the tag data of the text information determined in step S101 and the first interaction data to obtain first concatenated data.
[0149] Step S103-23 belongs to another branch in the language model, that is, inputting the encoded data (Hctx) of the text information and the encoded data of the header information into the second neural network. The second neural network is an attention (ATT) neural network (also called an attention mechanism) in this embodiment. The attention mechanism can increase a range of attention, so that when outputting word vectors, it is necessary to focus on which parts of the input sequence, and then generate the next output based on the area of attention. The purpose of the step S103-23 is to interact the encoded data of the text information and the header information through the second neural network to obtain second interaction data. In this embodiment, this process is completed by the attention neural network. The attention neural network can also be understood as the interaction layer.
[0150] The purpose of step S103 - 24 is to concatenate the second interaction data output in step S103 - 23 and the tag data of the header information determined in step S102 to obtain second concatenated data.
[0151] Based on the specific implementation process of step S103-2 above, the specific implementation process of step S103-3 may include:
[0152] The first concatenated data and the second concatenated data are used as the interaction data and input into the task parsing layer of the language model for parsing to obtain subtask data for converting the text information into the structured query statement.
[0153] In this embodiment, the task parsing layer parses the first and second concatenated data to obtain the subtask data, such as the select-column (query column, i.e., S-col), select-aggregation (query aggregation operation, i.e., S-agg), select-number (query number, i.e., S-num), where-number (condition number, i.e., W-num), where-column (condition corresponding column, i.e., W-col), where-operator (condition operator, i.e., W-op), where-value (condition target value, i.e., W-val), Conn (connector), etc. Because SQL query statements primarily involve select and where, the subtask data described above is primarily for these two query statements, but this does not preclude the possibility of parsing other subtask data. The above is merely an example.
[0154] After obtaining the subtask data, step S104 may be executed.
[0155] Step S104: generating the structured query statement for the text information according to the subtask data.
[0156] The specific implementation process of step S104 may be to generate an SQL structured query statement from the subtask data through an ensemble algorithm.
[0157] Therefore, before generating SQL structured query statements, to ensure that subtask data is more accurate, you can also include:
[0158] Step S003-1: Determine the probability value of the subtask data;
[0159] Step S003-2: Determine whether the probability value satisfies the generation condition for generating the query statement;
[0160] Step S003-3: If not, adjusting the model parameters in the language model according to the probability value.
[0161] The probability value of step S003-1 can be obtained by calculating the loss function, which belongs to the prior art and will not be described here.
[0162] The generation condition of step S003-2 can be a probability threshold. That is, when the probability value approaches the set probability threshold of 1, it indicates that the loss is small, and the SQL structured query statement can be directly generated based on the subtask data. Conversely, when the probability value approaches 0, it indicates that the loss is large, the subtask data output by the language model is not ideal, and the language model needs to be adjusted. In this case, step S003-3 can be executed to adjust the model parameters of the language model using the probability value as reference data so that the output of the language model approaches 1.
[0163] The data input into the language model include label data of text information, label data of header information, header information of data table, text information, etc., and the label data of text information and label data of header information can represent the structured relationship between text information and data table, that is, the corresponding matching relationship between header information and table cell information (content of data table) and text information, so that the semantic dependency relationship between text information and data table can be integrated into the generated SQL structured query statement, so that the SQL structured query statement can have better expression logic, that is, the expression logic accuracy of SQL structured query statement is improved, further improving the accuracy of query results in query scenarios.
[0164] Please refer to Figure 5 and Figure 6As shown, to further enhance the structured information in the language model, this embodiment may also add semantic dependency task learning. The learning results of the dependency task (Schema dependency Task) and the conversion task (NL2SQL Task) are integrated into an algorithm to obtain an SQL structured query statement. The dependency task learning may specifically include:
[0165] Step S004: input the text information and the header information into a language model for learning a query statement of the dependency relationship between the text information and the header information, perform dependency task learning, and obtain data representing the dependency relationship between the text information and the header information.
[0166] In this embodiment, the dependency task (Schema dependency task) and the transformation task (NL2SQL task) share the underlying encoding layer, namely the BERT model, to obtain the encoded data of the text information and the encoded data of the data table header information. Then, step S004 may specifically include:
[0167] Step S004-1: Using the encoded data of the text information and the encoded data of the header information as input parameters for the dependency relationship learning task, inputting them into the interaction layer of the language model to perform dependency data interaction, thereby obtaining interactive dependency data. The language model herein is a model for learning the dependency relationship between the text information and the header information.
[0168] Step S004-2: inputting the interactive dependency data into the dependency task parsing layer of the language model for parsing to obtain dependency relationship data for representing the dependency relationship between the text information and the header information.
[0169] The interactive layer of the language model in step S004-1 may be an MLP neural network (Multi Layer Perceptron multi-layer perception neural network) so as to obtain the interactive dependency data between the text information and the header information. Figure 5 As shown, Figure 5 This is a schematic diagram of the dependency data structure in an embodiment of a query statement generation method provided by this application. The product name in the column header of the data table has a dependency relationship with the financial product in the text information; the annualized return in the column header of the data table has a dependency relationship with the yield, greater than, and 5% in the text information; and the term in the column header of the data table has no dependency relationship with the text information.
[0170] When parsing the interactive dependency data, step S004-2 may be performed using dependency analysis (biaffine). Applying MLP to the recursive output state before biaffine helps remove redundant information. i It only needs to carry enough information to identify the head of word i, find all its dependencies, assign the correct label to word i, and assign the correct labels to all its dependencies. Therefore, the specific implementation process of step S004-2 may include:
[0171] Step S004-21: the dependency task parsing layer parses the dependency relationship data to determine the correspondence between the words in the text information and the header information;
[0172] Step S004-22: determining the label data of the word relative to the header information according to the corresponding relationship, wherein the label data is dependency relationship data representing the dependency relationship between the text information and the header information.
[0173] like Figure 5 As shown, the text information "yield," "greater than," and "5%" correspond to the "annualized return" column in the data table header. Therefore, the label data corresponding to 1 (yield) is Wcol (condition column header, where column), the label data corresponding to 1 (greater than) is op, and the label data corresponding to 1 (5%) is val. The "of" in the text information is null, representing 0. The text information "financial product" corresponds to the "product name" in the data table header. Therefore, the label data corresponding to 2 (financial product) is Scol (query column header, select column). All other information in the text information is null, representing 0. The obtained dependency data can be the text information's representation sequence, such as 1, 1, 1, 0, 2, 0, 0; and the label data corresponding to the sequence number or each word in the text information, such as Wcol, op, val, null, Scol, null, null.
[0174] Based on the above, if Figure 6 As shown, Figure 6 This is a schematic diagram of a language model structure in an embodiment of a query statement generation method provided by the present application, including performing conversion task learning and dependency task learning. The step S104 of generating the structured query statement for the text information based on the subtask data may also include:
[0175] The structured query statement for the text information is generated based on the subtask data and the dependency data. That is, the subtask data obtained by the NL2SQL Task and the dependency data obtained by the Schema dependency Task are integrated into an SQL structured query statement for the text information.
[0176] It is understandable that the process of generating the SQL structured query statement for the text information may further include:
[0177] determining a probability value of the dependency relationship data;
[0178] Determining whether the probability value satisfies a generation condition for the query statement generated by the dependency data and the subtask data;
[0179] If not, the probability value is used as an input parameter and input into the language model to adjust the model parameters.
[0180] In the face of bidirectional hybrid network models, such as BERT and Bi-LSTM, after forward output, backward input is also required based on the loss function to adjust the model, which has reached higher requirements.
[0181] The above is a detailed description of an embodiment of a method for generating a query statement provided by the present application. Corresponding to the embodiment of the method for generating a query statement provided above, the present application also discloses an embodiment of a device for generating a query statement. Figure 7 Since the device embodiment is basically similar to the method embodiment, the description is relatively simple. For relevant details, please refer to the partial description of the method embodiment. The device embodiment described below is only illustrative.
[0182] like Figure 7 As shown, an embodiment of a query statement generation device provided by the present application includes:
[0183] The first determining unit 701 is configured to determine label data of the text information according to the data information in the data table;
[0184] A second determining unit 702 is configured to determine label data of the header information of the data table according to the data information of the data table and the text information;
[0185] a conversion unit 703, configured to input the text information, the header information, the label data of the text information, and the label data of the header information into a language model to perform conversion task learning, and obtain subtask data for converting the text information into the query statement;
[0186] The generating unit 704 is configured to generate the query statement according to the subtask data.
[0187] The first determining unit 701 includes:
[0188] An establishing subunit, configured to establish a corresponding link relationship between the data information and the text information;
[0189] The label determination subunit is used to determine the label data of the words in the text information according to the corresponding link relationship.
[0190] The establishment subunit may specifically include: a word segmentation subunit, a matching subunit, and a relationship determination subunit;
[0191] The word segmentation subunit is used to perform word segmentation processing on the text information to obtain words;
[0192] The matching subunit is configured to match the word with the data information in the data table to determine a matching relationship between the word and the data information;
[0193] The relationship determination subunit is configured to determine the matching relationship as a corresponding link relationship between the data information and the text information.
[0194] The first determination unit 701 is specifically configured to determine the type information representing the corresponding link relationship between the word and the data information as the label data of the text information. The specific implementation process includes: a first determination subunit and a second determination subunit. The first determination subunit is configured to determine whether the data information appears in the text information; and the second determination subunit is configured to determine, if the determination result of the first determination subunit is yes, identification information representing the appearance of the data information in the text information as the label data of the data table header information.
[0195] The conversion unit 703 includes: an encoding subunit, an interaction subunit and a parsing subunit;
[0196] The encoding subunit is configured to input the text information and the header information into the encoding layer of the language model for encoding processing to obtain the encoded data of the text information and the encoded data of the header information;
[0197] The interaction subunit is configured to input the encoded data of the text information, the label data of the text information, the encoded data of the header information, and the text information as input parameters for learning the conversion task, and input them into the interaction layer of the language model to perform data interaction and obtain interaction data;
[0198] The parsing subunit is used to input the feature interaction data into the conversion task parsing layer of the language model for parsing, and obtain subtask data for converting the text information into the structured query statement.
[0199] The interaction subunit may include: a first interaction subunit, a first splicing subunit, a second interaction subunit and a second splicing subunit;
[0200] The first interaction subunit is configured to input the encoded data of the text information and the encoded data of the header information into the first neural network of the interaction layer to perform data interaction and obtain first interaction data;
[0201] The first splicing subunit is configured to splice the first interaction data with the tag data of the text information to obtain first spliced data;
[0202] The second interaction sub-unit is configured to input the sequence encoding data of the text information and the encoding data of the header information into the second neural network of the interaction layer to perform data interaction and obtain second interaction data;
[0203] The second splicing subunit is configured to splice the second interaction data, the tag data of the header information, and the first interaction data to obtain second spliced data.
[0204] The parsing subunit is specifically configured to input the first concatenated data and the second concatenated data as the interaction data into the task parsing layer of the language model for parsing, and obtain subtask data for converting the text information into the structured query statement.
[0205] Also includes:
[0206] A probability determination unit, configured to determine a probability value of the subtask data;
[0207] a condition determination unit, configured to determine whether the probability value satisfies a generation condition for generating the query statement;
[0208] An adjusting unit is configured to adjust model parameters in the language model according to the probability value when a determination result in the condition determining unit is negative.
[0209] To enhance the language model's ability to parse SQL query structured information, this embodiment further includes:
[0210] A dependency unit is used to input the text information and the header information into a language model for learning a dependency query statement between the text information and the header information, and to perform dependency task learning to obtain data representing the dependency relationship between the text information and the header information.
[0211] The dependency unit may specifically include: an interaction subunit and a parsing subunit.
[0212] It should be noted that the dependency unit and the conversion unit 703 share the encoding subunit, so the encoding subunit is not described again here.
[0213] The interaction subunit is configured to input the encoded data of the text information and the encoded data of the header information as input parameters for the dependency relationship task learning, and input them into the interaction layer of the language model to perform dependency data interaction and obtain interaction dependency data;
[0214] The parsing subunit is used to input the interactive dependency data into the dependency task parsing layer of the language model for parsing, and obtain dependency relationship data for representing the dependency relationship between the text information and the header information.
[0215] The parsing subunit includes: a relationship parsing subunit and a relationship determining subunit.
[0216] The relationship parsing subunit is configured to parse the dependency relationship data, the corresponding relationship between the words in the text information and the header information, at the dependency task parsing layer;
[0217] The relationship determination subunit is used to determine the label data of the word relative to the header information based on the corresponding relationship, and the label data is dependency relationship data representing the dependency relationship between the text information and the header information.
[0218] The generating unit 701 may be configured to generate the structured query statement for the text information based on the subtask data and the dependency data. Specifically, the subtask data and the dependency data may be integrated to obtain the structured query statement for the text information.
[0219] Furthermore, this embodiment may also include:
[0220] a probability determination unit, configured to determine a probability value of the dependency relationship data;
[0221] a condition determination unit, configured to determine whether the probability value satisfies a generation condition for generating the query statement by the dependency data and the subtask data;
[0222] The adjustment unit is configured to, when the determination result of the condition determination unit is yes or no, input the probability value as an input parameter into the language model to adjust the model parameters. If the determination result is yes, it means that the probability value meets the requirements and can be output.
[0223] The above content is a description of an embodiment of a query statement generation device provided in this application. The description process is relatively brief. For specific content, please refer to the description of steps S101 to S104 in the above query statement generation method embodiment.
[0224] Based on the above content, this application also provides an intelligent dialogue service method, such as Figure 8 As shown, the embodiment of the intelligent dialogue service method includes:
[0225] Step S801: Based on the intelligent dialogue service platform, obtain question information in the question request and data information of the data table to be queried for querying the question information;
[0226] Step S802: Generate a query statement for the question information according to the query statement generation method provided above;
[0227] Step S803: querying the to-be-queried data table according to the query statement to determine query data matching the question information;
[0228] Step S803: Output the query data to the intelligent dialogue service platform.
[0229] The generation method involved in step S802 may be the contents described in steps S101 to S104 in the embodiment of the method for generating a query statement provided in this application, and will not be repeated here.
[0230] With the continuous development and advancement of Internet technology, human-computer interaction services are gradually becoming part of people's work and life, bringing great convenience to people. People can obtain the information they need by communicating with smart products (such as smart robots, smart speakers, or other smart electronic products).
[0231] During the human-computer interaction process, the intelligent product, through deep learning and natural language processing technology, can incorporate the table information (table content) in the data table when generating SQL structured query statements, and incorporate the structured information between the data table and the question information, so that the generated SQL structured query statements can more accurately query the database, and the accuracy of the query results is further improved, so that the information people need can be output on the human-computer interaction platform, thereby completing the dialogue interaction process between the human and the computer. The fields involved in human-computer interaction are very broad. The embodiments of the intelligent dialogue service method provided by this application can include: e-commerce, telecommunications, government affairs, finance, education, entertainment, health, tourism and many other industries.
[0232] For example, in the e-commerce industry, users can conduct human-computer dialogues with intelligent customer service to achieve functions such as: issuing invoices, urging shipments, checking logistics, changing addresses, receiving express deliveries, etc. Alternatively, in the telecommunications industry or the entire operator industry, users can conduct human-computer dialogues with intelligent customer service to achieve functions such as checking phone charges, checking traffic, buying packages, reporting faults, and changing passwords. Regardless of the industry, the query statement generation method embodiment provided by the present application incorporates table information (table content) in the data table when generating SQL structured query statements, and incorporates structured information between the data table and the question information, so that the generated SQL structured query statement can more accurately query the database. On the basis of improving the accuracy of the query results, the output of reply information to user queries or inquiries is also correspondingly more accurate.
[0233] Of course, during human-computer dialogue, in order to ensure that smart products can accurately serve users, that is, to improve service quality, smart products need to accurately identify user intentions during the dialogue process, and then give correct feedback based on user intentions, thereby providing the information required by users or performing corresponding actions.
[0234] Specifically, when applying human-computer interaction services in the financial industry, a user inputs information about financial products. A query statement is generated according to the query statement generation method embodiment described above. The query statement is used to query a database to obtain the information the user requested, and the smart device provides the obtained feedback information to the user. For example, a user may call a financial service institution to inquire about financial products, or the user may query relevant service information through an online customer service center dialogue platform. The content of the corresponding service information obtained based on natural language processing is fed back to the user through the online customer service center dialogue platform.
[0235] In the process of human-computer dialogue, intelligent customer service specifically converts the voice of the customer's query into text information and analyzes the text information, thereby integrating the structured relationship of semantic dependencies between text information and data tables into the generated SQL structured query statement, thereby enhancing the expression logic accuracy of the SQL structured query statement. That is, based on the specific information required under the specific query business category entered by the user, the intelligent customer service can obtain the information content under the corresponding business category and that meets the user's requirements through database query, and then feedback the information content to the user or feedback the information required by the user through corresponding operations. In this way, the user only needs to input voice or text to provide the query requirements to the intelligent customer service in the form of human-computer dialogue, and the intelligent customer service will provide the queried information to the user through the above method.
[0236] Based on the above content, the present application also provides a computer storage medium for storing data generated by a network platform and a program for processing the data generated by the network platform;
[0237] When the program is read and executed, the following steps are performed:
[0238] Determining label data of the text information according to a corresponding link relationship between the data information in the data table and the text information;
[0239] Determining label data of header information of the data table according to the data information of the data table and the text information;
[0240] Inputting the text information, the header information, the label data of the text information, and the label data of the header information into a language model for converting the text information into a structured query statement to perform conversion task learning, and obtaining subtask data for converting the text information into the structured query statement;
[0241] generating the structured query statement for the text information according to the subtask data;
[0242] Alternatively, when the program is read and executed, the following steps are performed:
[0243] Based on the intelligent dialogue service platform, obtain question information in the question request and data information of the data table to be queried for querying the question information;
[0244] Generate a structured query statement for the question information according to the query statement generation method above;
[0245] Querying the to-be-queried data table according to the structured query statement to determine query data matching the question information;
[0246] The query data is output to the intelligent dialogue service platform.
[0247] Based on the above, if Figure 9 As shown, the present application also provides an electronic device, including:
[0248] Processor 901;
[0249] The memory 902 is used to store a program for processing data generated by the network platform. When the program is read and executed by the processor, the program performs the following steps:
[0250] Determining label data of the text information according to a corresponding link relationship between the data information in the data table and the text information;
[0251] Determining label data of header information of the data table according to the data information of the data table and the text information;
[0252] Inputting the text information, the header information, the label data of the text information, and the label data of the header information into a language model for converting the text information into a structured query statement to perform conversion task learning, and obtaining subtask data for converting the text information into the structured query statement;
[0253] generating the structured query statement for the text information according to the subtask data;
[0254] Alternatively, perform the following steps:
[0255] Based on the intelligent dialogue service platform, obtain question information in the question request and data information of the data table to be queried for querying the question information;
[0256] Generate a structured query statement for the question information according to the query statement generation method above;
[0257] Querying the to-be-queried data table according to the structured query statement to determine query data matching the question information;
[0258] The query data is output to the intelligent dialogue service platform.
[0259] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0260] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0261] 1. Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include non-transitory media such as modulated data signals and carrier waves.
[0262] 2. Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0263] Although the present application is disclosed as above with the preferred embodiments, it is not intended to limit the present application. Any person skilled in the art may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.
Claims
1. A method for generating a query statement, characterized in that: include: Determine the label data of the words in the text information according to the data information in the data table; Determining label data of the header information of the data table according to the data information of the data table and the text information; Inputting the text information, the header information, the label data of the text information, and the label data of the header information into a language model to perform conversion task learning, and obtaining subtask data for converting the text information into a structured query statement; Generating the structured query statement according to the subtask data; Determining the label data of the words in the text information based on the data information in the data table includes: determining the matching relationship between the vocabulary of the text information and the data information as the corresponding link relationship between the data information and the text information; and determining the type information used to characterize the corresponding link relationship between the words and the data information as the label data; The step of inputting the text information, the header information, the label data of the text information, and the label data of the header information into a language model for conversion task learning to obtain subtask data for converting the text information into the structured query statement includes: inputting the text information and the header information into the language model for encoding processing to obtain the encoded data of the text information and the encoded data of the header information; using the encoded data of the text information, the label data of the text information, the encoded data of the header information, and the text information as input parameters for the conversion task learning, inputting them into the language model for data interaction to obtain interaction data; and inputting the interaction data into the language model for parsing to obtain the subtask data.
2. The method for generating a query statement according to claim 1, wherein: Determining the matching relationship between the vocabulary of the text information and the data information as a corresponding link relationship between the data information and the text information includes: Performing word segmentation processing on the text information to obtain the vocabulary; Matching the vocabulary with the data information in the data table to determine the matching relationship between the vocabulary and the data information; The matching relationship is determined as a corresponding link relationship between the data information and the text information.
3. The method for generating a query statement according to claim 1, wherein: The step of determining the label data of the header information of the data table according to the data information of the data table and the text information includes: determining whether the data information appears in the text information; If so, the identification information used to characterize the appearance state of the data information in the text information is determined as the label data of the data table header information.
4. The method for generating a query statement according to claim 1, wherein: The step of inputting the text information and the header information into the language model for encoding to obtain the encoded data of the text information and the encoded data of the header information includes: Inputting the text information and the header information into the encoding layer of the language model for encoding processing to obtain encoded data of the text information and encoded data of the header information; The step of inputting the encoded data of the text information, the label data of the text information, the encoded data of the header information, and the text information as input parameters for learning the conversion task into the language model for data interaction to obtain interaction data includes: The encoded data of the text information, the label data of the text information, the encoded data of the header information, and the text information are input as input parameters for learning the conversion task, and are input into the interaction layer of the language model for data interaction to obtain the interaction data; Inputting the interaction data into the language model for parsing to obtain the subtask data includes: The interaction data is input into the conversion task parsing layer of the language model for parsing to obtain the subtask data for converting the text information into the structured query statement.
5. The method for generating a query statement according to claim 4, wherein: The step of inputting the encoded data of the text information, the tag data of the text information, the encoded data of the header information, and the text information as input parameters into the interaction layer of the language model for data interaction to obtain interaction data includes: Inputting the encoded data of the text information and the encoded data of the header information into the first neural network of the interaction layer for data interaction to obtain first interaction data; Splicing the first interaction data with the label data of the text information to obtain first spliced data; Inputting the sequence encoding data of the text information and the encoding data of the header information into the second neural network of the interaction layer for data interaction to obtain second interaction data; The second interaction data, the tag data of the header information, and the first interaction data are spliced together to obtain second spliced data.
6. The method for generating a query statement according to claim 5, wherein: Inputting the interaction data into the task parsing layer of the language model for parsing to obtain subtask data for converting the text information into the structured query statement includes: The first concatenated data and the second concatenated data are used as the interaction data and input into the task parsing layer of the language model for parsing to obtain subtask data for converting the text information into the structured query statement.
7. The method for generating a query statement according to claim 6, wherein: Also includes: Determining a probability value of the subtask data; Determining whether the probability value satisfies a generation condition for generating the structured query statement; If not, the model parameters in the language model are adjusted according to the probability value.
8. The method for generating a query statement according to claim 4, wherein: Also includes: The text information and the header information are input into a language model for learning a query statement of a dependency relationship between the text information and the header information, and dependency relationship task learning is performed to obtain data representing the dependency relationship between the text information and the header information.
9. The method for generating a query statement according to claim 8, wherein: The step of inputting the text information and the header information into a language model for learning the dependency relationship between the text information and the header information, performing dependency relationship task learning, and obtaining data for representing the dependency relationship between the text information and the header information, includes: Using the encoded data of the text information and the encoded data of the header information as input parameters for the dependency relationship task learning, inputting them into the interaction layer of the language model to perform dependency data interaction, and obtaining interactive dependency data; The interactive dependency data is input into the dependency task parsing layer of the language model for parsing to obtain dependency relationship data for representing the dependency relationship between the text information and the header information.
10. The method for generating a query statement according to claim 9, wherein: Inputting the interactive dependency data into the dependency task parsing layer of the language model for parsing to obtain dependency relationship data for representing the dependency relationship between the text information and the header information includes: The dependency task parsing layer parses the dependency data to determine the correspondence between words in the text information and the header information; The label data of the word relative to the header information is determined according to the corresponding relationship, and the label data is dependency relationship data representing the dependency relationship between the text information and the header information.
11. The method for generating a query statement according to claim 9, wherein: Generating the structured query statement for the text information according to the subtask data further includes: The structured query statement for the text information is generated according to the subtask data and the dependency relationship data.
12. The method for generating a query statement according to claim 11, wherein: Generating the structured query statement for the text information based on the subtask data and the dependency relationship data includes: The subtask data and the dependency relationship data are integrated to obtain the structured query statement for the text information.
13. The method for generating a query statement according to claim 9, wherein: Also includes: determining a probability value of the dependency relationship data; Determining whether the probability value satisfies a generation condition for generating the query statement from the dependency data and the subtask data; If not, the probability value is used as an input parameter and input into the language model to adjust the model parameters.
14. A query statement generating device, characterized in that: include: A first determining unit, configured to determine label data of the text information according to data information in the data table; a second determining unit, configured to determine label data of header information of the data table according to the data information of the data table and the text information; a conversion unit, configured to input the text information, the header information, the label data of the text information, and the label data of the header information into a language model for converting the text information into a structured query statement, perform conversion task learning, and obtain subtask data for converting the text information into the structured query statement; A generating unit, configured to generate the structured query statement for the text information according to the subtask data; The first determining unit is further configured to determine label data of a word in the text information based on the data information in the data table by: determining a matching relationship between the vocabulary of the text information and the data information as a corresponding link relationship between the data information and the text information; and determining type information representing the corresponding link relationship between the word and the data information as the label data; The conversion unit is further configured to input the text information, the header information, the label data of the text information, and the label data of the header information into a language model for conversion task learning, thereby obtaining subtask data for converting the text information into the structured query statement through the following steps: inputting the text information and the header information into the language model for encoding processing, thereby obtaining the encoded data of the text information and the encoded data of the header information; using the encoded data of the text information, the label data of the text information, the encoded data of the header information, and the text information as input parameters for the conversion task learning, and inputting them into the language model for data interaction, thereby obtaining interaction data; and inputting the interaction data into the language model for parsing, thereby obtaining the subtask data.
15. An intelligent dialogue service method, characterized in that: include: Based on the intelligent dialogue service platform, obtain question information in the question request and data information of the data table to be queried for querying the question information; Generate a query statement for the question information according to any one of the query statement generation methods of claims 1 to 13; query the data table to be queried according to the query statement to determine query data that matches the question information; The query data is output to the intelligent dialogue service platform.
16. A computer storage medium for storing data generated by a network platform and a program for processing the data generated by the network platform; When the program is read and executed, the following steps are performed: Determining label data of the text information according to data information in the data table; Determining label data of header information of the data table according to the data information of the data table and the text information; Inputting the text information, the header information, the label data of the text information, and the label data of the header information into a language model to perform conversion task learning, and obtaining subtask data for converting the text information into the query statement; generating the query statement according to the subtask data; Determining the label data of the words in the text information based on the data information in the data table includes: determining the matching relationship between the vocabulary of the text information and the data information as the corresponding link relationship between the data information and the text information; and determining the type information used to characterize the corresponding link relationship between the words and the data information as the label data; The step of inputting the text information, the header information, the label data of the text information, and the label data of the header information into a language model for conversion task learning to obtain subtask data for converting the text information into the structured query statement includes: inputting the text information and the header information into the language model for encoding processing to obtain the encoded data of the text information and the encoded data of the header information; using the encoded data of the text information, the label data of the text information, the encoded data of the header information, and the text information as input parameters for the conversion task learning, inputting them into the language model for data interaction to obtain interaction data; and inputting the interaction data into the language model for parsing to obtain the subtask data. Alternatively, when the program is read and executed, the following steps are performed: Based on the intelligent dialogue service platform, obtain question information in the question request and data information of the data table to be queried for querying the question information; Generate a query statement for the question information according to any one of the query statement generation methods in claims 1-13 above; Query the data table to be queried according to the query statement to determine the query data that matches the question information; The query data is output to the intelligent dialogue service platform.
17. An electronic device comprising: processor; The memory is used to store a program for processing data generated by the network platform, and when the program is read and executed by the processor, the program performs the following steps: Determining label data of the text information according to data information in the data table; Determining label data of header information of the data table according to the data information of the data table and the text information; Inputting the text information, the header information, the label data of the text information, and the label data of the header information into a language model to perform conversion task learning, and obtaining subtask data for converting the text information into the query statement; generating the query statement according to the subtask data; Determining the label data of the words in the text information based on the data information in the data table includes: determining the matching relationship between the vocabulary of the text information and the data information as the corresponding link relationship between the data information and the text information; and determining the type information used to characterize the corresponding link relationship between the words and the data information as the label data; The step of inputting the text information, the header information, the label data of the text information, and the label data of the header information into a language model for conversion task learning to obtain subtask data for converting the text information into the structured query statement includes: inputting the text information and the header information into the language model for encoding processing to obtain the encoded data of the text information and the encoded data of the header information; using the encoded data of the text information, the label data of the text information, the encoded data of the header information, and the text information as input parameters for the conversion task learning, inputting them into the language model for data interaction to obtain interaction data; and inputting the interaction data into the language model for parsing to obtain the subtask data. Alternatively, perform the following steps: Based on the intelligent dialogue service platform, obtain question information in the question request and data information of the data table to be queried for querying the question information; Generate a query statement for the question information according to any one of the query statement generation methods in claims 1-13 above; Query the data table to be queried according to the query statement to determine the query data that matches the question information; The query data is output to the intelligent dialogue service platform.
Citation Information
Patent Citations
Structured query language conversion method based on natural language, and related equipment thereof
CN111177184A
Predicting query language statements from natural language analytic questions
US20200210525A1