CN115146040A - Data query method, device, equipment and storage medium - Google Patents
Data query method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN115146040A CN115146040A CN202210553946.5A CN202210553946A CN115146040A CN 115146040 A CN115146040 A CN 115146040A CN 202210553946 A CN202210553946 A CN 202210553946A CN 115146040 A CN115146040 A CN 115146040A
- Authority
- CN
- China
- Prior art keywords
- query
- identification information
- current
- historical
- operators
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/332—Query formulation
- G06F16/3329—Natural language query formulation or dialogue systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/31—Indexing; Data structures therefor; Storage structures
- G06F16/313—Selection or weighting of terms for indexing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/332—Query formulation
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Mathematical Physics (AREA)
- Computational Linguistics (AREA)
- Software Systems (AREA)
- Artificial Intelligence (AREA)
- Human Computer Interaction (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The disclosure relates to a data query method, device, equipment and storage medium. The method comprises the steps of obtaining one or more historical query requests and historical query sentences corresponding to the last query request, and predicting operators corresponding to one or more identification information in the current query sentences according to one or more historical query requests, the current query request and operators corresponding to one or more identification information in the historical query sentences. The operator corresponding to the one or more identification information in the historical query statement helps to accurately predict the operator corresponding to the one or more identification information in the current query statement. Therefore, the current query statement corresponding to the current query request can be generated more accurately according to the one or more operators respectively corresponding to the one or more identification information in the current query statement. Thereby improving the accuracy of data query and the accuracy of the intelligent question-answering system.
Description
Technical Field
The present disclosure relates to the field of information technologies, and in particular, to a data query method, apparatus, device, and storage medium.
Background
With the continuous development of science and technology, the application of the intelligent question-answering system is more and more extensive. For example, after inputting a user question into the smart question-answering system, the smart question-answering system may feed back the answer that the user wants.
However, the inventors of the present application have found that the prior art cannot convert a user question into a precise Structured Query Language (SQL) statement, and thus cannot obtain an accurate answer.
Disclosure of Invention
To solve the above technical problem or at least partially solve the above technical problem, the present disclosure provides a data query method, apparatus, device, and storage medium to improve accuracy of data query and accuracy of an intelligent question-answering system.
In a first aspect, an embodiment of the present disclosure provides a data query method, including:
acquiring one or more historical query requests and historical query sentences corresponding to the last query request;
predicting the operators corresponding to the one or more identification information in the current query statement according to one or more historical query requests, the current query request and the operators corresponding to the one or more identification information in the historical query statement respectively, wherein each identification information is used for identifying one subset in a data set, and the current query request corresponds to the current query statement;
generating the current query statement according to the one or more operators respectively corresponding to the identification information in the current query statement;
and inquiring target data matched with the current inquiry request from the data set according to the current inquiry statement.
In a second aspect, an embodiment of the present disclosure provides a data query apparatus, including:
the system comprises an acquisition module, a query module and a query module, wherein the acquisition module is used for acquiring one or more historical query requests and historical query statements corresponding to the last query request;
the prediction module is used for predicting the operators corresponding to the one or more identification information in the current query statement according to the operators corresponding to the one or more historical query requests, the current query request and the one or more identification information in the historical query statement respectively, wherein each identification information is used for identifying one subset in a data set, and the current query request corresponds to the current query statement;
the generating module is used for generating the current query statement according to the one or more corresponding operational characters of the identification information in the current query statement;
and the query module is used for querying the target data matched with the current query request from the data set according to the current query statement.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
a memory;
a processor; and
a computer program;
wherein the computer program is stored in the memory and configured to be executed by the processor to implement the method of the first aspect.
In a fourth aspect, the present disclosure provides a computer-readable storage medium, on which a computer program is stored, the computer program being executed by a processor to implement the method of the first aspect.
According to the data query method, the data query device, the data query equipment and the storage medium, one or more historical query requests and historical query sentences corresponding to the last query request are obtained, and operators corresponding to one or more identification information in the historical query sentences are predicted according to the one or more historical query requests, the current query request and one or more corresponding operators of the identification information in the historical query sentences. The operator corresponding to the one or more identification information in the historical query statement helps to accurately predict the operator corresponding to the one or more identification information in the current query statement. Therefore, the current query statement corresponding to the current query request can be generated more accurately according to the operators respectively corresponding to the one or more identification information in the current query statement. Therefore, when the current query statement is executed, more accurate target data can be acquired, and the accuracy of data query and the accuracy of the intelligent question-answering system are improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments or technical solutions in the prior art of the present disclosure, the drawings used in the description of the embodiments or prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a flowchart of a data query method provided by an embodiment of the present disclosure;
fig. 2 is a schematic diagram of an application scenario provided by an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a multi-turn dialog provided by an embodiment of the present disclosure;
FIG. 4 is a flowchart of a data query method according to another embodiment of the disclosure;
FIG. 5 is a schematic diagram of the inference phase of a multi-round pre-training model according to another embodiment of the disclosure;
FIG. 6 is a diagram illustrating the inference phase of a multi-round pre-training model and a text-to-SQL model according to another embodiment of the present disclosure;
FIG. 7 is a flow diagram of a training phase of a machine learning model provided by another embodiment of the present disclosure;
fig. 8 is a schematic structural diagram of a data query device according to an embodiment of the present disclosure;
fig. 9 is a schematic structural diagram of an embodiment of an electronic device provided in the embodiment of the present disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, aspects of the present disclosure will be further described below. It should be noted that the embodiments and features of the embodiments of the present disclosure may be combined with each other without conflict.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced in other ways than those described herein; it is to be understood that the embodiments disclosed in the specification are only a few embodiments of the present disclosure, and not all embodiments.
In general, the smart question-answering system may output answers desired by the user according to user question sentences. However, the prior art cannot convert the user question into an accurate Structured Query Language (SQL) statement, and thus cannot obtain an accurate answer. To address this problem, embodiments of the present disclosure provide a data query method, which is described below with reference to specific embodiments.
Fig. 1 is a flowchart of a data query method provided in an embodiment of the present disclosure. The method can be executed by a data query device, which can be implemented in software and/or hardware, and the device can be configured in an electronic device, such as a server or a terminal, where the terminal specifically includes a mobile phone, a computer, or a tablet computer. In addition, the data query method provided in this embodiment may be applied to the application scenario shown in fig. 2, where the application scenario includes the terminal 21 and the server 22, and in a possible implementation manner, the terminal 21 may send a question of the user to the server 22, and the server 22 queries target data matched with the question from a database and sends the target data to the terminal 21, so that the terminal 21 may display the target data to the user. Or, in another possible implementation manner, the terminal 21 may directly query, locally according to a question of the user, target data matched with the question, and present the target data to the user. The data query method performed by the server 22 is schematically described below. As shown in fig. 1, the method comprises the following specific steps:
s101, one or more historical query requests and historical query sentences corresponding to the last query request are obtained.
As shown in FIG. 3, "xxxxxx", "zzzzzz", and "nnnnnnnn" are user questions, respectively. "yyyyy" and "mmmm" are respectively the reply of the intelligent question-answering system, i.e. the system reply. Where "yyyy" is a reversion to "xxxxxx" and "mmmmmm" is a reversion to "zzzzzz". "xxxxxx" and "yyyy" may constitute a pair of dialog data 31. "zzzzzzz" and "mmmm" constitute another set of dialog data 32. Assuming that "nnnnnnnnnn" is the current question of the user, then "xxxxxx" and "zzzzzz" are the historical questions of the user, respectively. The user's history question or the user's current question may be abbreviated as a user question, which may be a natural language sentence, for example, "how like today weather? ", in some embodiments, the user question may be written as query. In addition, in the present embodiment, the forms of the user question and the system reply are not limited, and for example, the user question may be text information, voice information, or other forms of information. Similarly, the system reply may be a text message, a voice message, or other form of information.
In this embodiment, each time the server 22 receives a user question, the server may convert the user question into a Query statement, where the Query statement may be, for example, a Structured Query Language (SQL) statement, and the Query statement is an executable statement. Further, the server 22 may execute the query statement, for example, query the database for data that can satisfy the query condition defined by the query statement according to the query statement, and generate a system reply according to the queried data. That is, server 22 may generate respective query statements "xxxxxx", "zzzzzzzz", and "nnnnnnnn" and then execute respective query statements "xxxxxx", "zzzzzz", and "nnnnnnnn" to generate respective system replies "xxxxxx", "zzzz", and "nnnnnnnn". Assuming that "nnnnnnnnnn" is the current question of the user, the query statement corresponding to "nnnnnnnn" can be recorded as the current query statement, and the query statements corresponding to "xxxxxxxx" and "zzzzzz" are recorded as the historical query statements, respectively. The historical query statement has a certain help or influence on the generation of the current query statement, for example, the current query statement may be obtained by modifying and expanding the current query statement based on the historical query statement. Thus, the server 22 may generate the current query statement with the historical query statement.
Specifically, the server 22 may obtain one or more historical query requests and the historical query statement corresponding to the previous query request. For example, the plurality of historical query requests may be "xxxxxx", "zzzzzzzz". If "nnnnnnnnnn" is the current query, then "zzzzzz" may be marked as the last query.
Optionally, obtaining one or more historical query requests includes: and acquiring historical query requests respectively included in one or more rounds of historical dialogue data. The last query request is a historical query request in the last session data.
For example, 31 and 32 shown in fig. 3 represent multiple rounds of historical dialogue data. In acquiring a plurality of historical query requests, historical query requests respectively included in a plurality of rounds of historical dialogue data may be acquired. In other embodiments, server 22 may obtain a historical query request, for example, from a round of historical session data. Taking multiple historical query requests as an example, assuming that "nnnnnnnnn" is the current query request in the current round of session data, then "zzzzz" is the historical query request in the previous round of session data.
S102, according to one or more historical query requests, a current query request and one or more operators corresponding to the identification information in the historical query statement, predicting the operators corresponding to the identification information in the current query statement, wherein each identification information is used for identifying one subset in a data set, and the current query request corresponds to the current query statement.
For example, one or more data tables, which may be referred to as a data set, are included in a database local to the server 22 or corresponding to the server 22. Each data table may correspond to a table name. One data area in each data table may be denoted as a subset, for example, each column of data in each data table may be a subset, and each column of data may correspond to a column name. Each column name may be referred to herein as an identification information, that is, an identification information may identify a subset of the data set. In this embodiment, the server 22 may select one or more column names, i.e., one or more identification information, from the data set. Further, the server 22 may predict the corresponding operator of the one or more identification information in the current query statement according to the corresponding operator of the one or more historical query requests, the current query request, and the one or more identification information in the historical query statement, where the historical query statement may be the historical query statement corresponding to the previous query request.
For example, the plurality of historical query requests retrieved by the server 22 are "xxxxxx" and "zzzzzzzz", and the current query request is "nnnnnnnn". The plurality of identification information are schema item 1, schema item 2, schema item 3, and when the data set includes a plurality of data tables, schema item 1, schema item 2, schema item 3 include a table name and a column name, respectively. When the data set includes one data table, the schema item 1, the schema item 2, and the schema item 3 are column names, respectively. Taking a data table as an example, for example, the mode item 1 may be a column name of a first column in the data table, the mode item 2 is a column name of a second column in the data table, and the mode item 3 is a column name of a third column in the data table. In other embodiments, the total number of pattern entries may be the same as the total number of columns included in the data table, i.e., several columns of data are included in the data table and several pattern entries. For example, "zzzzzzz" is the last query request of "nnnnnnnn", and the historical query statement corresponding to "zzzzzzzzzzzzz" is, for example, "SELECT pattern item 1FROM pattern item 2", it indicates that the operator corresponding to pattern item 1 in the historical query statement is "SELECT" and the operator corresponding to pattern item 2 in the historical query statement is "FROM". The corresponding operator of pattern item 3 in the historical query statement is "None".
For example, the server 22 may predict the operators corresponding to the pattern item 1, the pattern item 2, and the pattern item 3 in the current query statement according to "xxxxxx", "zzzzzzzz", "nnnnnnnnnn", the operator "SELECT" corresponding to the pattern item 1 in the historical query statement, the operator "FROM" corresponding to the pattern item 2 in the historical query statement, and the operator "None" corresponding to the pattern item 3 in the historical query statement.
S103, generating the current query statement according to the operators which are respectively corresponding to the one or more identification information in the current query statement.
Assuming that the server 22 predicts that the operator corresponding to the pattern item 1 in the current query statement is "SELECT", the operator corresponding to the pattern item 2 in the current query statement is "FROM", and the operator corresponding to the pattern item 3 in the current query statement is "WHERE", the server 22 may generate the current query statement, for example, "SELECT pattern item 1FROM pattern item 2WHERE pattern item 3" according to the operators corresponding to the pattern item 1, the pattern item 2, and the pattern item 3, respectively, in the current query statement.
And S104, inquiring target data matched with the current inquiry request from the data set according to the current inquiry statement.
For example, the server 22 may execute "SELECT mode item 1FROM mode item 2WHERE mode item 3", e.g., query the data set for target data that can satisfy the query condition defined by "SELECT mode item 1FROM mode item 2WHERE mode item 3", i.e., the target data is the target data that matches the current query request "nnnnn". Further, a system reply corresponding to "nnnnnnnn" is generated from the target data.
The embodiment of the disclosure predicts the operators respectively corresponding to the one or more identification information in the current query statement by acquiring the one or more historical query requests and the historical query statement corresponding to the last query request and according to the one or more historical query requests, the current query request and the operators respectively corresponding to the one or more identification information in the historical query statement. The operator corresponding to the one or more identification information in the historical query statement helps to accurately predict the operator corresponding to the one or more identification information in the current query statement. Therefore, the current query statement corresponding to the current query request can be generated more accurately according to the one or more operators respectively corresponding to the one or more identification information in the current query statement. Therefore, when the current query statement is executed, more accurate target data can be acquired, and the accuracy of data query and the accuracy of the intelligent question answering system are improved.
Fig. 4 is a flowchart of a data query method according to another embodiment of the disclosure. The method comprises the following specific steps:
s401, one or more historical query requests and historical query sentences corresponding to the last query request are obtained.
Specifically, the implementation manner of S401 and S101 is consistent with a specific principle, and is not described herein again.
S402, predicting the operators corresponding to the one or more identification information in the current query statement according to the one or more historical query requests, the current query request, the one or more identification information, the slot corresponding to the one or more identification information respectively, and the operators corresponding to the one or more identification information in the historical query statement respectively, wherein the slot corresponding to the identification information corresponds to the operator corresponding to the identification information in the current query statement.
As shown in FIG. 5, the server 22 may be deployed with multiple rounds of pre-training models, 51 representing inputs to the multiple rounds of pre-training models. For example, the inputs to the multi-round pre-trained model include a first round of queries, such as "xxxxxx", a second round of queries, such as "zzzzzz", and a third round of queries, such as "nnnnnn". For example, starting with the character [ S ], a distinction is made between different rounds using the character [/S ], i.e., the character [/S ] can be distinguished as a round. In addition, the input of the multi-round pre-training model further includes mode item 1, mode item 2, and mode item 3, for example, 3 column names. Each pattern entry is followed by a character slot representing a slot, i.e., each pattern entry corresponds to a slot. In addition, each slot is followed by a character, which indicates that the mode item corresponding to the slot is an operator in the SQL statement corresponding to the last query, for example, the character after the slot corresponding to mode item 1 is [ SELECT ], and indicates that the operator in the SQL statement corresponding to the last query (for example, "zzzzzzz") of mode item 1 is [ SELECT ]. The character after the slot corresponding to schema item 2 is [ FROM ], which indicates that the operator in the SQL statement corresponding to the last query (e.g., "zzzzzzzz") of schema item 2 is [ FROM ]. The character after the slot corresponding to the mode item 3 is [ None ], which indicates that the mode item 3 has no corresponding operator in the SQL statement corresponding to the last query (e.g., "zzzzzzz"). Furthermore, the characters [/S ] can be used to distinguish between different pattern items. It can be understood that the SQL statement corresponding to the previous query may also be denoted as the previous SQL statement.
Further, the multi-round pre-training model may predict operators corresponding to the pattern item 1, the pattern item 2, and the pattern item 3 in the current query statement according to the input shown in fig. 5. For example, as shown in FIG. 5, the multi-round pre-training model predicts that the operator corresponding to mode item 1 in the current query statement is [ SELECT ], the operator corresponding to mode item 2 in the current query statement is [ FROM ], and the operator corresponding to mode item 3 in the current query statement is [ WHERE ]. Specifically, the operator [ SELECT ] corresponding to the mode item 1 in the current query statement corresponds to the slot of the mode item 1, the operator [ FROM ] corresponding to the mode item 2 in the current query statement corresponds to the slot of the mode item 2, and the operator [ WHERE ] corresponding to the mode item 3 in the current query statement corresponds to the slot of the mode item 3.
Optionally, predicting the operators corresponding to the one or more identification information in the current query statement according to the one or more historical query requests, the current query request, the one or more identification information, the slots corresponding to the one or more identification information respectively, and the operators corresponding to the one or more identification information in the historical query statement respectively, includes: inputting one or more historical query requests, the current query request, the one or more identification information, slots corresponding to the one or more identification information respectively, and operators corresponding to the one or more identification information in the historical query sentence respectively into a trained machine learning model, wherein output information of the machine learning model comprises the operators corresponding to the one or more slots respectively, and the operators corresponding to the slots are the operators corresponding to the identification information corresponding to the slots in the current query sentence.
As shown in fig. 5, a plurality of historical query requests (e.g., a first round of query, a second round of query), a current query request (e.g., a third round of query), a plurality of identification information (e.g., a pattern item 1, a pattern item 2, and a pattern item 3), a slot (e.g., [ slot ]), to which the plurality of identification information respectively corresponds, and an operator (e.g., [ SELECT ], [ FROM ], [ None ]), to which the plurality of identification information respectively corresponds in a previous SQL statement are input into a trained multi-round pre-training model, output information of the multi-round pre-training model includes operators to which the plurality of slots respectively correspond, and an operator corresponding to a slot is an operator to which the identification information corresponding to the slot corresponds in the current query statement. The multi-round pre-training model is specifically a machine learning model.
Optionally, an operator corresponding to the identification information in the historical query statement is a slot value, and the slot value is located after the slot corresponding to the identification information.
As shown in fig. 5, the operator corresponding to each pattern item in the previous SQL statement may be marked as a slot value, and the slot value corresponding to a certain pattern item may be located after the slot corresponding to the pattern item. In some embodiments, the operators may also be written as SQL operators.
Specifically, in this embodiment, the server 22 or multiple rounds of pre-training models may convert each character in the input information 51 shown in fig. 6 into a representation vector. For example, the start character [ S ] may be converted to a representation vector. The first, second, or third round of queries may include one or more characters, each of which may be converted to a representation vector, and thus the first, second, or third round of queries may be converted to one or more representation vectors, respectively. Each character [/S ] used to distinguish the different parts can be converted into a representation vector. Mode item 1, mode item 2, or mode item 3 may include one or more characters, and thus, mode item 1, mode item 2, and mode item 3 may be converted into one or more representation vectors, respectively. In addition, characters such as [ slot ], [ SELECT ], [ FROM ], [ None ] and the like can be converted into one expression vector respectively. Assuming that the input information 51 can be converted into 68 representation vectors in total, in some other embodiments, the representation vectors can also be recorded as characterization information or feature information. The 68 representation vectors may be input to a multi-round pre-training model, and the same number of representation vectors may be output after the 68 representation vectors are processed by the multi-round pre-training model. For example, 3 of the 68 representation vectors output by the multi-round pre-training model may be changed, and the representation vectors 61, 62, and 63 shown in fig. 6 may be changed from their corresponding representation vectors in the input information. Specifically, the indicating vector 61 corresponds to the slot [ slot ] of the pattern item 1, the indicating vector 62 corresponds to the slot [ slot ] of the pattern item 2, and the indicating vector 63 corresponds to the slot [ slot ] of the pattern item 3. The expression vectors 61, 62, and 63 are calculated from 68 expression vectors corresponding to the input information. The character corresponding to the representation vector 61 may represent an operator corresponding to the mode item 1 in the current query statement, for example, SELECT. The character to which representation vector 62 corresponds may represent an operator to which pattern item 2 corresponds in the current query statement, e.g., FROM. The character corresponding to the representation vector 63 may represent the operator corresponding to the pattern item 3 in the current query statement, e.g., [ WHERE ].
In this embodiment, the characters may be denoted as tokens, and in other embodiments, the representation vector may be not only a representation vector corresponding to a character level, but also a representation vector corresponding to a character string, a word, a phrase, a word, a subword, a phrase, a short sentence, or the like.
S403, generating the current query statement according to the operators which are respectively corresponding to the one or more identification information in the current query statement.
As shown in fig. 6, after the 68 representation vectors are output by the multi-round pre-training model, the 68 representation vectors output by the multi-round pre-training model can be used as the input of a text-to-SQL (text-to-SQL) model. Further, the text-to-SQL model may process the 68 representation vectors to generate the current query statement, i.e., the SQL statement corresponding to the current query request. The Text-to-SQL is a core technology of a Table query Answering (Table QA), and particularly, the Text-to-SQL is a language understanding (semantic parsing) mode and can convert a human natural statement (Text) into an SQL Statement (SQL). Table QA is a human-computer interaction system based on expression knowledge.
Optionally, generating the current query statement according to the one or more operators respectively corresponding to the one or more identification information in the current query statement, where the generating includes: and generating the current query statement according to the one or more historical query requests, the current query request, the one or more identification information, operators corresponding to the one or more identification information in the current query statement respectively, and operators corresponding to the one or more identification information in the historical query statement respectively.
As shown in fig. 6, the 68 expression vectors output by the multi-round pre-training model include an expression vector of the start character [ S ], expression vectors corresponding to the first round of query, the second round of query, and the third round of query, expression vectors corresponding to each [/S ], expression vectors corresponding to the pattern item 1, the pattern item 2, and the pattern item 3, expression vectors of operators corresponding to the pattern item 1, the pattern item 2, and the pattern item 3, respectively, predicted by the multi-round pre-training model in the current query statement, and expression vectors of operators corresponding to the pattern item 1, the pattern item 2, and the pattern item 3, respectively, in the last SQL statement. the text-to-SQL model can generate the current query statement according to the 68 expression vectors output by the multi-round pre-training model.
Specifically, the combination of the multi-round pre-training model and the text-to-SQL model shown in fig. 6 may implement a process of generating an SQL statement corresponding to a current query request according to a historical query request, the current query request, and one or more pattern items, where the process may also be referred to as a sequence-to-sequence (seq 2 seq) process. Thereby completing the generation process from the natural language to the SQL statement.
S404, inquiring target data matched with the current inquiry request from the data set according to the current inquiry statement.
Specifically, the implementation manner and specific principle of S404 and S104 are consistent, and are not described herein again.
It is understood that the slot values described in the embodiments of the present disclosure are not limited to the characters such as "SELECT", "FROM", etc. as described above, and may also include characters or character sequences such as "SELECT group _ BY", "SELECT count", "ORDER _ bypass", "SELECT max", etc.
In the embodiment, historical query is spliced at the input end of the multi-round pre-training model, and meanwhile SQL sentences corresponding to the query in the previous round of conversation are spliced. In this embodiment, the SQL statement is not directly spliced at the input end, but the SQL statement corresponding to the query in the previous round of dialog is equivalently replaced by slot filling or slot value pair (e.g., mode entry and its corresponding slot value). Therefore, the problem that the SQL statement is difficult to understand due to the fact that the multi-round pre-training model cannot analyze the format of the SQL statement is solved. In addition, generally, the SQL statement is long, and if the SQL statement is directly added to the input end of the multi-round pre-training model, the input of the multi-round pre-training model is long, and the difficulty in understanding the multi-round pre-training model is increased. Therefore, the longer SQL sentence equivalence is replaced by the slot value pair, and the slot value pair is shorter, so that the input of the multi-round pre-training model is not long, and the understanding difficulty of the multi-round pre-training model is reduced. In addition, the slot value pair equivalent to the SQL sentence corresponding to the query in the previous round of dialogue is input as a part of the multi-round pre-training model, so that the effect of the historical SQL sentence can be fully utilized, the historical SQL sentence can play a great help role in the generation of the SQL sentence in the current round, the historical SQL sentence can be effectively merged into the SQL sentence in the current round, and the accuracy of the SQL sentence in the current round is improved.
In the embodiment of the present disclosure, the multi-round pre-training model may also be recorded as a pre-training Table model or a pre-training language model, the pre-training Table model is an indispensable basic component of Table QA, and a question-answering system with a cold start (i.e., the model can be used without being trained) and a better generalization performance can be realized depending on a strong pre-training Table model. Therefore, statistical rules in mass data can be mined to the greatest extent by designing a more elaborate pre-training table model. In a real scene, a user and a question-answering system can obtain an expected answer after multiple rounds of question-answering, so that multiple rounds of pre-training models are required to have multiple rounds of information capturing capability and context understanding capability.
The process as shown in fig. 5 or fig. 6 may be a use phase or an inference phase of a multi-round pre-training model. The training phase of the multi-round pre-training model is described below.
As shown in fig. 7, the machine learning model, for example, a multi-round pre-training model, is trained by the following steps:
s701, obtaining sample dialogue data of multiple rounds, wherein each round of sample dialogue data respectively comprises a sample query request and a system reply.
For example, the computing device that trains the multiple rounds of pre-training models may be the server 22 as described above, or may be another terminal or server. The following is an example of the server 22 training the multi-round pre-training model. In particular, the server 22 may obtain multiple rounds of sample session data, which may be multiple rounds of session data between the user and the question and answer system. Each round of sample dialogue data respectively comprises a sample query request and a system reply, wherein the sample query request can be a user question. In addition, the SQL sentences corresponding to the sample query requests are not generated by the question-answering system but manually marked, so that the accuracy of the SQL sentences can be ensured, and the accuracy of trained multi-round pre-training models is ensured. In addition, when the question answering system generates the system reply according to the manually marked SQL sentence, the accuracy of the system reply can be improved.
S702, obtaining a sample query statement corresponding to the sample query request in each round of sample dialogue data.
For example, the server 22 may obtain a sample SQL statement corresponding to the sample query request in each round of sample dialog data, where the sample SQL statement is an SQL statement that is manually marked according to the sample query request.
S703, training the machine learning model according to the operator corresponding to the one or more identification information in the previous round of sample query sentences and the operator corresponding to the one or more identification information in the current round of sample query sentences.
For example, the server 22 may parse out the operators corresponding to the plurality of pattern items in the previous round of sample SQL statements, and input the operators corresponding to the plurality of pattern items in the previous round of sample SQL statements to the multiple rounds of pre-training models to be trained, so that the multiple rounds of pre-training models may predict the operators corresponding to the plurality of pattern items in the current round of sample SQL statements according to the operators corresponding to the plurality of pattern items in the previous round of sample SQL statements. Furthermore, training the multi-round pre-training model according to the operators of the plurality of mode items obtained by prediction of the multi-round pre-training model in the sample SQL sentence of the round and the operators of the plurality of mode items analyzed according to the sample SQL sentence of the round.
In the embodiment, the multi-round pre-training model is trained through multi-round sample dialogue data, so that the trained multi-round pre-training model can possibly rely on historical information for context understanding in each round of interaction, and the multi-round pre-training model has the context modeling capability.
Fig. 8 is a schematic structural diagram of a data query apparatus according to an embodiment of the present disclosure. The data query apparatus provided in the embodiment of the present disclosure may perform the processing procedure provided in the embodiment of the data query method, as shown in fig. 8, the data query apparatus 80 includes:
an obtaining module 81, configured to obtain one or more historical query requests and a historical query statement corresponding to a previous query request;
a prediction module 82, configured to predict, according to one or more historical query requests, a current query request, and one or more operators corresponding to the one or more identification information in the historical query statement, the operator corresponding to the one or more identification information in the current query statement, where each identification information is used to identify one subset in a data set, and the current query request corresponds to the current query statement;
a generating module 83, configured to generate the current query statement according to the one or more operators corresponding to the identification information in the current query statement;
and the query module 84 is configured to query, according to the current query statement, the target data matched with the current query request from the data set.
Optionally, the above-mentioned last query request is a historical query request in the previous session data; when the obtaining module 81 obtains one or more historical query requests, it is specifically configured to: and acquiring historical query requests respectively included in one or more rounds of historical dialogue data.
Optionally, the predicting module 82 is specifically configured to, when predicting the operators corresponding to the one or more identification information in the current query statement according to the one or more historical query requests, the current query request, and the one or more corresponding operators corresponding to the one or more identification information in the historical query statement:
and predicting the operators corresponding to the one or more identification information in the current query statement according to the one or more historical query requests, the current query request, the one or more identification information, the slots corresponding to the one or more identification information respectively and the operators corresponding to the one or more identification information in the historical query statement respectively, wherein the slots corresponding to the identification information correspond to the operators corresponding to the identification information in the current query statement.
Optionally, the predicting module 82 is specifically configured to, when predicting the corresponding operators of the one or more identification information in the current query statement according to the one or more historical query requests, the current query request, the one or more identification information, the slots corresponding to the one or more identification information respectively, and the operators corresponding to the one or more identification information respectively in the historical query statement:
inputting one or more historical query requests, the current query request, the one or more identification information, slots corresponding to the one or more identification information respectively, and operators corresponding to the one or more identification information in the historical query sentence respectively into a trained machine learning model, wherein output information of the machine learning model comprises the operators corresponding to the one or more slots respectively, and the operators corresponding to the slots are the operators corresponding to the identification information corresponding to the slots in the current query sentence.
Optionally, an operator corresponding to the identification information in the historical query statement is a slot value, and the slot value is located after the slot corresponding to the identification information.
Optionally, when the generating module 83 generates the current query statement according to the one or more operators respectively corresponding to the identification information in the current query statement, specifically, the generating module is configured to:
and generating the current query statement according to the one or more historical query requests, the current query request, the one or more identification information, operators corresponding to the one or more identification information in the current query statement respectively, and operators corresponding to the one or more identification information in the historical query statement respectively.
Optionally, the data query apparatus 80 further includes a training module 85, and the training module 85 is configured to train the machine learning model, where the machine learning model is obtained by training through the following steps:
acquiring multi-round sample dialogue data, wherein each round of sample dialogue data respectively comprises a sample query request and a system reply;
obtaining a sample query statement corresponding to a sample query request in each round of sample dialogue data;
and training the machine learning model according to the one or more operators corresponding to the identification information in the last round of sample query sentences and the one or more operators corresponding to the identification information in the current round of sample query sentences.
The data query apparatus in the embodiment shown in fig. 8 may be used to implement the technical solution of the method embodiment, and the implementation principle and technical effect are similar, which are not described herein again.
The internal functions and structure of the data inquiry apparatus, which can be implemented as an electronic device, are described above. Fig. 9 is a schematic structural diagram of an embodiment of an electronic device provided in the embodiment of the present disclosure. As shown in fig. 9, the electronic device includes a memory 91 and a processor 92.
The memory 91 is used to store programs. In addition to the above-described programs, the memory 91 may also be configured to store other various data to support operations on the electronic device. Examples of such data include instructions for any application or method operating on the electronic device, contact data, phonebook data, messages, pictures, videos, and so forth.
The memory 91 may be implemented by any type or combination of volatile or non-volatile memory devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The processor 92 is coupled to the memory 91 and executes the programs stored in the memory 91 for:
acquiring one or more historical query requests and historical query statements corresponding to the last query request;
predicting the operators corresponding to the one or more identification information in the current query statement according to one or more historical query requests, the current query request and the operators corresponding to the one or more identification information in the historical query statement respectively, wherein each identification information is used for identifying one subset in a data set, and the current query request corresponds to the current query statement;
generating the current query statement according to the one or more operators respectively corresponding to the identification information in the current query statement;
and inquiring target data matched with the current inquiry request from the data set according to the current inquiry statement.
Further, as shown in fig. 9, the electronic device may further include: communication components 93, power components 94, audio components 95, a display 96, and other components. Only some of the components are schematically shown in fig. 9, and the electronic device is not meant to include only the components shown in fig. 9.
The communication component 93 is configured to facilitate wired or wireless communication between the electronic device and other devices. The electronic device may access a wireless network based on a communication standard, such as WiFi,2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 93 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 93 further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
A power supply assembly 94 provides power to the various components of the electronic device. The power components 94 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for an electronic device.
The audio component 95 is configured to output and/or input an audio signal. For example, the audio component 95 includes a Microphone (MIC) configured to receive external audio signals when the electronic device is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal may further be stored in the memory 91 or transmitted via the communication component 93. In some embodiments, audio assembly 95 also includes a speaker for outputting audio signals.
The display 96 includes a screen, which may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
In addition, the embodiment of the present disclosure also provides a computer readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the data query method described in the above embodiment.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of additional like elements in a process, method, article, or apparatus that comprises the element.
The previous description is only for the purpose of describing particular embodiments of the present disclosure, so as to enable those skilled in the art to understand or implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (10)
1. A method of data query, wherein the method comprises:
acquiring one or more historical query requests and historical query statements corresponding to the last query request;
predicting the operators respectively corresponding to one or more identification information in the current query statement according to one or more historical query requests, the current query request and the operators respectively corresponding to one or more identification information in the historical query statement, wherein each identification information is used for identifying one subset in a data set, and the current query request corresponds to the current query statement;
generating the current query statement according to the one or more operators respectively corresponding to the identification information in the current query statement;
and inquiring target data matched with the current inquiry request from the data set according to the current inquiry statement.
2. The method of claim 1, wherein the previous query request is a historical query request in previous session data;
obtaining one or more historical query requests, comprising:
and acquiring historical query requests respectively included in one or more rounds of historical dialogue data.
3. The method of claim 1, wherein predicting the one or more operators for which the one or more identification information respectively corresponds in the current query statement based on one or more of historical query requests, current query requests, and one or more operators for which the one or more identification information respectively corresponds in the historical query statement comprises:
and predicting the operators corresponding to the one or more identification information in the current query statement according to the one or more historical query requests, the current query request, the one or more identification information, the slots corresponding to the one or more identification information respectively and the operators corresponding to the one or more identification information in the historical query statement respectively, wherein the slots corresponding to the identification information correspond to the operators corresponding to the identification information in the current query statement.
4. The method of claim 3, wherein predicting the operators corresponding to the one or more identification information in the current query statement according to the one or more historical query requests, the current query request, the one or more identification information, the slots corresponding to the one or more identification information, and the operators corresponding to the one or more identification information in the historical query statement, respectively, comprises:
inputting one or more historical query requests, the current query request, the one or more identification information, slots corresponding to the one or more identification information respectively, and operators corresponding to the one or more identification information in the historical query sentence respectively into a trained machine learning model, wherein output information of the machine learning model comprises the operators corresponding to the one or more slots respectively, and the operators corresponding to the slots are the operators corresponding to the identification information corresponding to the slots in the current query sentence.
5. The method of claim 4, wherein the corresponding operator of the identifying information in the historical query statement is a slot value, the slot value being located after the slot to which the identifying information corresponds.
6. The method of claim 1, wherein generating the current query statement according to the one or more operators respectively corresponding to the one or more identification information in the current query statement comprises:
and generating the current query statement according to the one or more historical query requests, the current query request, the one or more identification information, operators corresponding to the one or more identification information in the current query statement respectively, and operators corresponding to the one or more identification information in the historical query statement respectively.
7. The method of claim 4, wherein the machine learning model is trained by:
acquiring multiple turns of sample dialogue data, wherein each turn of sample dialogue data respectively comprises a sample query request and a system reply;
obtaining a sample query statement corresponding to a sample query request in each round of sample dialogue data;
and training the machine learning model according to the one or more operators corresponding to the identification information in the last round of sample query sentences and the one or more operators corresponding to the identification information in the current round of sample query sentences.
8. A data query apparatus, comprising:
the system comprises an acquisition module, a query module and a query module, wherein the acquisition module is used for acquiring one or more historical query requests and historical query statements corresponding to the last query request;
the prediction module is used for predicting the operators corresponding to the one or more identification information in the current query statement according to the operators corresponding to the one or more historical query requests, the current query request and the one or more identification information in the historical query statement respectively, wherein each identification information is used for identifying one subset in a data set, and the current query request corresponds to the current query statement;
the generating module is used for generating the current query statement according to the one or more corresponding operational characters of the identification information in the current query statement;
and the query module is used for querying the target data matched with the current query request from the data set according to the current query statement.
9. An electronic device, comprising:
a memory;
a processor; and
a computer program;
wherein the computer program is stored in the memory and configured to be executed by the processor to implement the method of any one of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the method of any one of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210553946.5A CN115146040A (en) | 2022-05-19 | 2022-05-19 | Data query method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210553946.5A CN115146040A (en) | 2022-05-19 | 2022-05-19 | Data query method, device, equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115146040A true CN115146040A (en) | 2022-10-04 |
Family
ID=83406833
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210553946.5A Pending CN115146040A (en) | 2022-05-19 | 2022-05-19 | Data query method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115146040A (en) |
-
2022
- 2022-05-19 CN CN202210553946.5A patent/CN115146040A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11983638B2 (en) | Example-driven machine learning scheme for dialog system engines | |
US20210232761A1 (en) | Methods and systems for improving machine learning performance | |
CN103035240A (en) | Speech recognition repair using contextual information | |
CN101233559A (en) | Context-sensitive communication and translation methods for enhanced interactions and understanding among speakers of different languages | |
CN108519998B (en) | Problem guiding method and device based on knowledge graph | |
CN109144285A (en) | A kind of input method and device | |
CN112084315A (en) | Question-answer interaction method, device, storage medium and equipment | |
CN111199732A (en) | Emotion-based voice interaction method, storage medium and terminal equipment | |
CN111897915B (en) | Question-answering device and answer information determination method | |
CN112115244B (en) | Dialogue interaction method and device, storage medium and electronic equipment | |
CN111540355B (en) | Personalized setting method and device based on voice assistant | |
CN114186016A (en) | Man-machine conversation method, device, equipment and storage medium | |
CN116701601A (en) | Man-machine interaction method | |
CN109684443B (en) | Intelligent interaction method and device | |
WO2024088039A1 (en) | Man-machine dialogue method, dialogue network model training method and apparatus | |
CN118035392A (en) | Intelligent question-answering system, question-answering interaction method, computer equipment and storage medium | |
CN116069911A (en) | Intelligent question-answering method, device, equipment and storage medium | |
CN115146040A (en) | Data query method, device, equipment and storage medium | |
KR20210050484A (en) | Information processing method, device and storage medium | |
US20220244847A1 (en) | Intelligent Keyboard | |
CN115879440A (en) | Natural language processing method, natural language processing device, natural language model training equipment and storage medium | |
CN114462410A (en) | Entity identification method, device, terminal and storage medium | |
CN113254611A (en) | Question recommendation method and device, electronic equipment and storage medium | |
CN112836023A (en) | Question-answering method and device based on knowledge graph | |
CN117474084B (en) | Bidirectional iteration method, equipment and medium for pre-training model and downstream sequence task |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |