CN116303537A - Data query method and device, electronic equipment and storage medium - Google Patents

Data query method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116303537A
CN116303537A CN202310257937.6A CN202310257937A CN116303537A CN 116303537 A CN116303537 A CN 116303537A CN 202310257937 A CN202310257937 A CN 202310257937A CN 116303537 A CN116303537 A CN 116303537A
Authority
CN
China
Prior art keywords
data
training
question
template
answer
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
Application number
CN202310257937.6A
Other languages
Chinese (zh)
Inventor
袁韶祖
刘瑞雪
祝天刚
陈蒙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jingdong Technology Information Technology Co Ltd
Original Assignee
Jingdong Technology Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Jingdong Technology Information Technology Co Ltd filed Critical Jingdong Technology Information Technology Co Ltd
Priority to CN202310257937.6A priority Critical patent/CN116303537A/en
Publication of CN116303537A publication Critical patent/CN116303537A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The disclosure provides a data query method and device, electronic equipment and a storage medium, and relates to the technical field of artificial intelligence. The data query method comprises the following steps: acquiring problem data; determining form data corresponding to the problem data; matching a target question-answering model corresponding to the problem data; and inputting the question data and the form data into the target question-answer model to generate answer data corresponding to the question data. According to the technical scheme, the pre-trained target question-answering model can quickly inquire answer data of the questions from the form data, so that the inquiry efficiency of the answer data is effectively improved, and the accuracy of the answer data is improved.

Description

Data query method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of artificial intelligence technology, and in particular, to a data query method, a data query device, an electronic apparatus, and a computer readable storage medium.
Background
The form question-answer is a dialogue model that converts human natural language into executable structured query sentences (Structured Query Language, SQL) based on form information, and executes the SQL sentences from the database and returns answers intended by people.
Currently, in the related art, when generating an answer by a form question-answer mode, an SQL statement needs to be generated first, and then the answer is queried by executing the SQL statement, and the generation of the SQL statement needs to take time, so that the query efficiency of the question answer is low.
It should be noted that the information disclosed in the above background section is only for enhancing understanding of the background of the present disclosure and thus may include information that does not constitute prior art known to those of ordinary skill in the art.
Disclosure of Invention
An object of an embodiment of the present disclosure is to provide a data query method, a data query device, an electronic device, and a computer readable storage medium, so as to effectively improve query efficiency of querying answer data in table data.
Other features and advantages of the present disclosure will be apparent from the following detailed description, or may be learned in part by the practice of the disclosure.
According to a first aspect of an embodiment of the present disclosure, there is provided a data query method, including:
acquiring problem data;
determining form data corresponding to the problem data;
matching a target question-answering model corresponding to the problem data;
and inputting the question data and the form data into the target question-answer model to generate answer data corresponding to the question data.
In some example embodiments of the present disclosure, based on the foregoing solution, the matching the target question-answer model corresponding to the question data includes:
determining the service field type corresponding to the problem data;
and matching a target question-answering model corresponding to the problem data according to the service field type, wherein the target question-answering model is obtained by performing directional training on a pre-trained question-answering model.
In some example embodiments of the present disclosure, based on the foregoing approach, the pre-trained question-answering model is obtained through a pre-training process comprising:
obtaining a problem template and a structured query statement template corresponding to the problem template;
generating training triplet data according to preset training form data, the problem template and the structured query statement template;
and carrying out iterative training on the pre-built initial pre-training question-answering model through the training triplet data to obtain a pre-training question-answering model after training is completed.
In some example embodiments of the present disclosure, based on the foregoing solution, before obtaining the question template and the structured query statement template corresponding to the question template, the method further includes:
Extracting sample problem data from a preset data set and sample structured query sentences corresponding to the sample problem data;
fuzzy matching is carried out on the sample question data and the keywords in the sample structured query statement, and a template filling position is determined, wherein the template filling position comprises a data position and a data type;
and generating the problem template and a structured query statement template corresponding to the problem template based on the template filling position, the sample problem data and the sample structured query statement.
In some example embodiments of the present disclosure, based on the foregoing solution, the generating training triplet data according to preset training form data, the problem template, and the structured query statement template includes:
acquiring preset training table data, and disassembling the training table data to obtain training sub-table data;
randomly filling the problem template and the structured query statement template based on the training sub-table data to obtain training problem data and training structured query statements;
inquiring in the training form data according to the training structured inquiry statement to obtain training answer data;
And forming training triplet data by the training form data, the training question data and the training answer data.
In some example embodiments of the present disclosure, based on the foregoing solution, the randomly filling the question template and the structured query term template based on the training sub-table data to obtain training question data and training structured query terms includes:
determining the template type of the structured query statement template, and classifying the problem template and the structured query statement template according to the template type; wherein the template types are partitioned by the complexity of the structured query statement templates;
and randomly filling the problem templates and the structured query sentence templates under different classification results based on the training sub-table data to obtain training problem data and training structured query sentences.
In some example embodiments of the present disclosure, based on the foregoing approach, the target question-answering model is obtained by directional training of a pre-trained question-answering model, comprising:
acquiring sample triplet data belonging to different service field types;
And carrying out directional training on the trained pre-training question-answering model according to the sample triplet data to obtain target question-answering models belonging to different service field types.
According to a second aspect of embodiments of the present disclosure, there is provided a data query apparatus, including:
the problem acquisition module is used for acquiring problem data;
the form determining module is used for determining form data corresponding to the problem data;
the question-answering model matching module is used for matching a target question-answering model corresponding to the question data;
and the answer query module is used for inputting the question data and the form data into the target question-answer model and generating answer data corresponding to the question data.
According to a third aspect of embodiments of the present disclosure, there is provided an electronic device, comprising: a processor; and a memory having stored thereon computer readable instructions which when executed by the processor implement the data query method of any of the above.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements a data query method according to any one of the above.
The technical scheme provided by the embodiment of the disclosure can comprise the following beneficial effects:
according to the data query method in the example embodiment of the disclosure, the question data can be acquired, the form data corresponding to the question data can be determined, then the target question-answer model corresponding to the question data can be matched, and further the question data and the form data can be input into the target question-answer model to generate answer data corresponding to the question data. The method can be matched with the target question-answer model corresponding to the service field of the question data, and then the answer data corresponding to the question data can be quickly inquired from the form data through the target question-answer model, so that the inquiry efficiency of the answer data can be effectively improved, and the accuracy of the answer data can be improved to a certain extent because SQL sentences are not required to be additionally generated for inquiry.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure. It will be apparent to those of ordinary skill in the art that the drawings in the following description are merely examples of the disclosure and that other drawings may be derived from them without undue effort. In the drawings:
FIG. 1 illustrates a schematic diagram of a system architecture of an exemplary application environment in which a data query method and apparatus of embodiments of the present disclosure may be applied;
FIG. 2 schematically illustrates a flow diagram of a data query method according to some embodiments of the present disclosure;
FIG. 3 schematically illustrates a flow diagram for pre-training a pre-trained question-answering model, according to some embodiments of the present disclosure;
FIG. 4 schematically illustrates a schematic diagram of a data querying device according to some embodiments of the present disclosure;
FIG. 5 schematically illustrates a structural schematic diagram of a computer system of an electronic device, in accordance with some embodiments of the present disclosure;
fig. 6 schematically illustrates a schematic diagram of a computer-readable storage medium according to some embodiments of the present disclosure.
In the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
Detailed Description
Example embodiments will now be described more fully with reference to the accompanying drawings. However, the exemplary embodiments may be embodied in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the disclosed aspects may be practiced without one or more of the specific details, or with other methods, components, devices, steps, etc. In other instances, well-known methods, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the disclosure.
Moreover, the drawings are only schematic illustrations and are not necessarily drawn to scale. The block diagrams depicted in the figures are merely functional entities and do not necessarily correspond to physically separate entities. That is, the functional entities may be implemented in software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor devices and/or microcontroller devices.
FIG. 1 illustrates a schematic diagram of a system architecture of an exemplary application environment in which data query methods and apparatus of embodiments of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include one or more of the terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used as a medium to provide communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others. The terminal devices 101, 102, 103 may be various electronic devices having image processing functions including, but not limited to, desktop computers, portable computers, smart phones, tablet computers, and the like. It should be understood that the number of terminal devices, networks and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation. For example, the server 105 may be a server cluster formed by a plurality of servers.
The data query method provided by the embodiments of the present disclosure is generally executed by the terminal devices 101, 102, 103, and accordingly, the data query apparatus is generally disposed in the terminal devices 101, 102, 103. However, it will be readily understood by those skilled in the art that the data query method provided in the embodiment of the present disclosure may be executed by the server 105, and accordingly, the data query device may also be disposed in the server 105, which is not limited in particular in the present exemplary embodiment. For example, in an exemplary embodiment, the user may acquire the question data input in various manners through the terminal devices 101, 102, 103, then upload the question data to the server 105, and after the server generates answer data through the data query method provided by the embodiment of the present disclosure, transmit the answer data to the terminal devices 101, 102, 103 for post-processing.
In the related art, a common practice of a form question-answer method is to convert a natural language of a human into an executable SQL sentence according to form information, execute and return an answer intended by the human from a database. The technology can automatically generate the SQL query statement through the computing device, and a user can quickly query the wanted answer data only through the SQL query statement. The prior proposal mainly adopts a pre-training language model to adopt a plurality of subtasks, generates each part of SQL query sentences, and forms an SQL query sentence to be sent to a database for execution to obtain an answer. For example, it may be expressed as "select agg sel_ column from table where column1 op1 value1 conn where colnum op2value2" for a SQL query statement consisting of multiple parts of "agg", "sel_column", "column1", "op1", "value1", "conn", "colnum2", "op2", "value 2". It is quite difficult to directly and automatically convert natural language into such complex SQL query sentences, so that the classical model often decomposes the generation problem of one SQL query sentence into a plurality of subtasks for processing, and the subtasks correspond to the above parts respectively, and each part corresponds to one subtask. The main body part of the model is usually a pre-training language model BERT, each part of the SQL query statement is generated through at least more than 7 subtasks, and finally each part is spliced together to obtain an output SQL query statement, and then the SQL query statement is sent to a database to be operated to obtain an answer.
In the scheme, because the SQL query statement is needed to be obtained first, the answer is queried through the SQL query statement, and the query efficiency is low; secondly, a plurality of subtasks are required to be designed when the SQL query statement is generated, the complexity of a model is greatly increased, meanwhile, data annotation is extremely difficult, because a data set is required to be marked with a problem, and the SQL statement corresponding to the problem is marked as a supervision signal, the marking of SQL is required to be a talent line familiar with SQL and trained in a professional way, the marking is laborious, and the application range of form questions and answers is greatly limited by the high complexity of the model.
Based on one or more problems in the related art, in the present exemplary embodiment, there is first provided a data query method that can be applied to a terminal device or a server, and a description will be given below taking a server executing the method as an example. Fig. 2 schematically illustrates a schematic diagram of a data query method flow according to some embodiments of the present disclosure. Referring to fig. 2, the data query method may include the steps of:
step S210, acquiring problem data;
step S220, determining form data corresponding to the problem data;
Step S230, matching a target question-answering model corresponding to the question data;
step S240, inputting the question data and the table data into the target question-answer model, and generating answer data corresponding to the question data.
According to the data query method in the embodiment of the invention, the target question-answer model corresponding to the service field of the question data can be matched, and then the answer data corresponding to the question data can be quickly queried from the table data through the target question-answer model, so that the query efficiency of the answer data can be effectively improved, and the accuracy of the answer data can be improved to a certain extent because the query is performed without additionally generating SQL sentences.
Next, a data query method in the present exemplary embodiment will be specifically described.
In step S210, question data is acquired.
In an example embodiment, the problem data refers to a problem characterized by a natural language form input by a user through any manner, for example, the problem data may be a problem characterized by a natural language input by a user through an input tool such as a physical keyboard, a virtual keyboard, etc., or may be a problem voice collected by an intelligent device with a voice collection function, and the problem voice is converted into a problem characterized by a natural language, and of course, the problem data may also be a problem characterized by a natural language obtained by handwriting the problem on a manuscript paper and identifying the problem through optical character recognition (Optical Character Recognition, OCR), which is not limited in this example embodiment.
The problem data may be input in real time by the user in any manner, or may be pre-stored in the storage unit, and the source of the problem data is not limited in any way in this embodiment.
In step S220, table data corresponding to the problem data is determined.
In an exemplary embodiment, the table data refers to a structured table that realizes data storage and data query by combining column data and row data, however, although a data table is taken as an example in this embodiment, it is easily understood by those skilled in the art that the table data in this embodiment may also be other types of structured data, or may be converted into structured data of a table, and the related data may be quickly located by the structured data, for example, the table data in this embodiment may also be log file data, XML document data, or the like, which is not limited to this exemplary embodiment.
Different form data can be divided in advance according to different service field types, the service field type corresponding to the problem data can be determined, and then the form data corresponding to the problem data can be determined according to the service field type; of course, keywords corresponding to the problem data may be extracted, and form data corresponding to the problem data may be determined by the keywords, and the manner of determining form data corresponding to the problem data in this example embodiment is not limited in any way.
By determining the form data of the question data, the data matching amount can be effectively reduced, and the query efficiency of answer data can be improved to a certain extent.
In step S230, a target question-answer model corresponding to the question data is matched.
In an example embodiment, the target question-answering model refers to a question-answering model obtained by performing directional training on a general pre-training question-answering model through training data of different service field types in advance, for example, if the question data is a question of a medical service field, the target question-answering model obtained by performing directional training through the training data of the medical service field can be matched; the question data is assumed to be a question in the customer service domain, and then a target question-answer model obtained through directional training of training data in the customer service domain may be matched, and of course, the target question-answer model may also be a question-answer model obtained through directional training of a general pre-training question-answer model through training data in other service domain types, which is not limited in this example embodiment.
The target question-answering model and the service field type corresponding to the target question-answering model can be stored in the database, so that the service field type of the problem data can be determined first, and then the target question-answering model of the corresponding service field type can be matched and called in the database through the service field type of the problem data; of course, a target question-answer model for any business domain type may also be trained, which is not particularly limited in this example embodiment.
In step S240, the question data and the table data are input into the target question-answer model, and answer data corresponding to the question data is generated.
In an example embodiment, the question data and the corresponding table data may be combined together to serve as input data of the target question-answer model, and answer data corresponding to the question data may be directly output through processing of the target question-answer model.
The method can be matched with the target question-answer model corresponding to the service field of the question data, and then the answer data corresponding to the question data can be quickly inquired from the form data through the target question-answer model, so that the inquiry efficiency of the answer data can be effectively improved, and the accuracy of the answer data can be improved to a certain extent because SQL sentences are not required to be additionally generated for inquiry.
Next, the data query method in step S210 to step S240 will be described in detail.
In one exemplary embodiment of the present disclosure, the target question-answering model corresponding to the question data may be matched by: the method can determine the service field type corresponding to the problem data, and match a target question-answer model corresponding to the problem data according to the service field type, wherein the target question-answer model is obtained by carrying out directional training on the pre-training question-answer model.
The service domain type refers to type data set when data of different service domains are divided, for example, the service domain type can include, but is not limited to, medical service domain, customer service domain and warehouse service domain; specifically, different identifiers may be set for different service domain types, for example, the service domain types may be distinguished by a unique code, or the service domain types may be distinguished by a suggested digital code, or of course, the service domain types may be distinguished by a character string or the like, which is not limited in this example embodiment.
The directional training refers to a process of training a pre-training question-answer model according to training data belonging to different service field types, wherein the pre-training question-answer model refers to a pre-training model which is obtained by pre-selecting a large amount of data training and has table question-answer capability, and is a general model, and after the pre-training question-answer model is directionally trained through the training data belonging to different service field types, the obtained target question-answer model has higher answer query efficiency and higher accuracy rate for the corresponding service field types.
The service field types of the question data are matched with the target question-answering models of the corresponding service field types, so that SQL query sentences are not required to be generated according to the question data, a large amount of manpower and material resources are saved, the query efficiency of answer data corresponding to the question data can be effectively improved by matching the target question-answering models of the corresponding service field types, and the accuracy of the answer data can be effectively improved because the target question-answering models are obtained based on the training data of the service field types.
In an exemplary embodiment of the present disclosure, the pre-training question-answer model may be obtained through a pre-training process, which may be implemented through the steps in fig. 3, and specifically may include:
step S310, obtaining a problem template and a structured query statement template corresponding to the problem template;
step S320, training triplet data is generated according to preset training form data, the problem template and the structured query statement template;
and step S330, performing iterative training on the pre-constructed initial pre-training question-answer model through the training triplet data to obtain a pre-training question-answer model after training.
The problem template refers to a template obtained by carrying out general partial extraction on a large amount of problem data in a training data set in advance, the structured query language template refers to a template obtained by carrying out general partial extraction on a large amount of SQL query language in the training data set, the problem template and the structured query language template comprise data slots which can be used for data filling and are used for filling data content, and each data slot can comprise a data type which can be filled.
For example, what is the 'recruitment' of '2020' for the 'big people' of problem data? "and corresponding SQL query statement" Select ' recruit ' university= people university and year= 2020 ' ", wherein the single quote refers to the replaceable content, by general partial extraction of the question data and SQL query statement, it is how much is < sql_col1> of < cond_value2> of the question template" < cond_value1 >? "and structured query statement templates" Select < sql_col1> where < cond_col1> = < cond_col1> and < cond_col2> = < cond_value2> ", in which" < cond_value1> "," < cond_value2> "," < sql_col1> "," < cond_col1> "," < cond_col2> "are data slots and data types corresponding to the filled data content, the question templates and the corresponding structured query statement templates can be filled by the data slots and data types.
The training form data refers to sample data which is collected in advance and used for training a pre-training question-answer model, and the training form data can be form data of any service field type which is collected in advance; the data content in the training form data can be randomly filled into the question template and the structured query statement template, a large number of training question data and training structured query statements corresponding to the training question data are filled, the training structured query statement template is executed in the training form data to obtain training answer data corresponding to the training question data, and training triplet data can be further obtained according to the training question data, the training structured query statements and the training answer data.
Optionally, if the training structural query sentence obtained by filling cannot obtain the corresponding training answer data after being executed in the training form data, the training structural query sentence and the corresponding training question data may be deleted.
The pre-built initial pre-training question-answering model refers to a pre-training question-answering model which is not started to be trained in advance, for example, the initial pre-training question-answering model can be built based on a Chinese pre-training model T5, can be built based on a pre-training model BERT, and can be built based on other types of pre-training models, and the embodiment is not limited in particular.
Alternatively, the loss function of the pre-training question-answering model in this embodiment may be trained by using a cross entropy loss function, and of course, the pre-training question-answering model may also use other types of loss functions, which, in this example embodiment, is not limited thereto, and the loss function of the initial pre-training question-answering model may be expressed as a relation (1):
Figure BDA0004132212040000111
wherein Loss may represent the total Loss of the pre-trained question-answer model t The loss of each character in the answer data output by the pre-trained question-answering model may be represented,
Figure BDA0004132212040000112
the text generated at time step t may be represented.
The method comprises the steps of randomly filling a question template and a structured query sentence template through training table data, executing a training structured query sentence obtained by filling, obtaining corresponding training answer data, and further forming a plurality of training triplet data, for example, the training triplet data can be represented as { table, query, answer }, wherein table can represent training table data, query can represent training question data, answer can represent training answer data, and further carrying out iterative training on a pre-built initial pre-training question-answer model according to the training triplet data. For example, training table data and training question data may be used as input data of a pre-built initial pre-training question-answer model, e.g., training table data and training question data may be organized to obtain #questin@1 by t-h1|t-c1|t-c2@2:t-h2|t-c1|t-c2@3., where the first "# questin" may represent training question data, @ may represent table contents of training table data, specifically, @1 may represent first row data of training table data, @2 may represent second row data of training table data, and by analogy, t-h may represent a table header (table header) of training table data, t-c may represent table contents (table content) of training table data, such that all required information is organized together and the table data is flattened as input data of the initial pre-training question-answer model; and then, the training answer data can be used as a training label, and iterative training is carried out on the pre-built initial pre-training question-answer model until a pre-training question-answer model with the training completed is obtained.
In one exemplary embodiment of the present disclosure, the question template and the structured query statement template may be obtained by:
sample question data and sample structured query sentences corresponding to the sample question data can be extracted from a preset data set; fuzzy matching is carried out on the sample problem data and the keywords in the sample structured query statement, and the template filling position is determined; the question template and the structured query statement template corresponding to the question template may be generated based on the template filling location and the sample question data and sample structured query statement.
The preset data set refers to an already disclosed SQL related data set, for example, the preset data set may be an NL2SQL data set, a WikiSQL data set, a Spider data set, a chaser data set, etc., and of course, the preset data set may also be other types of SQL related data sets, which is not limited to this example embodiment.
The sample question data refers to question data extracted from a preset data set, and the sample structured query statement refers to a structured query statement extracted from the preset data set and corresponding to the sample question data.
Fuzzy matching can be carried out on the sample problem data and the keywords in the sample structured query statement, and the template filling position is determined; the template filling position refers to sample problem data and data content which can be replaced in the sample structured query statement, the template filling position is a data slot position used for filling the data content in the problem template and the structured query statement template, the template filling position can comprise a data position and a data type, the data type refers to the type of the data content filled in the data position in the template, for example, the data type can comprise a numerical type and a character type, the data filled in the template can be effectively limited through the data type of the template filling position in the template, the accuracy of the sample problem data and the sample structured query statement obtained after filling is ensured, and the quality of the sample data is ensured.
Because some semantic transformations can occur in the problem description of the part in the SQL, such as 'A university' and 'A big', when the problem template and the structured query statement template are generated, sample problem data and template filling positions in the sample structured query statement can be accurately determined in a fuzzy matching mode, and are identified by different characters, so that the accuracy and the universality of the problem template and the structured query statement template can be effectively improved, and the template quality is ensured.
Alternatively, if any data other than the column type in the form data (because the column type is often omitted in the language) cannot be identified from the question, the current sample instance is discarded directly, further ensuring the quality of the question template and the structured query statement template.
Optionally, the training triplet data may be generated according to preset training table data, a problem template and a structured query statement template by the following steps:
the method comprises the steps that preset training table data can be obtained, and the training table data are disassembled to obtain training sub-table data; randomly filling the problem template and the structured query statement template based on the training sub-table data to obtain training problem data and training structured query statements; inquiring in the training form data according to the training structural inquiry statement to obtain training answer data; training triplet data is formed by training form data, training question data and training answer data.
The training sub-table data refers to a table with a smaller data size obtained by disassembling the training table data, for example, the table may be disassembled according to a column type in the training table data to obtain the training sub-table data, or the training table data may be disassembled according to a size of the training table data and a preset table size to obtain the training sub-table data, or of course, the training table data may be disassembled in other manners, which is not limited in this example embodiment.
The question template and the structured query statement template can be randomly filled through the training sub-table data to obtain training question data and training structured query statements, the training structured query statements can be further executed in the training table data, the training answer data is obtained through query, and training triplet data is formed through the training table data, the training question data and the training answer data. The quantity of training triplet data can be effectively improved through the problem template and the structured query statement template, meanwhile, a large amount of manpower and material resources can be saved because manual labeling is not needed, the coverage range of the training triplet data can be effectively improved through random filling of the template, the generalization capability of a pre-training question-answer model is improved, and the accuracy of the pre-training question-answer model is improved.
Optionally, the random population of the question templates and the structured query statement templates may be achieved by:
the template type of the structured query sentence template can be determined, and the problem template and the structured query sentence template are classified according to the template type; and randomly filling the problem templates and the structured query statement templates under different classification results based on the training sub-table data to obtain training problem data and training structured query statements.
The template types may be divided by the complexity of the structured query sentence template, specifically, the complexity of the structured query sentence template may be determined by the number of clauses of the structured query sentence template, for example, only one structured query sentence template with the number of clauses may be divided into one template type, two structured query sentence templates with the number of clauses may be divided into one template type, and so on, so as to obtain structured query sentence templates with different template types.
The method has the advantages that the structured query statement templates and the corresponding problem templates can be classified according to the template types, the problem templates and the structured query statement templates under different classification results are randomly filled based on training sub-table data, sample structured query statements with different complexity degrees can be obtained, the obtained training triplet data can cover the problem statements and the structured query statements under all scenes as much as possible, the richness of the training triplet data is ensured, the generalization capability of the pre-training question-answer model is further improved, and the accuracy of the pre-training question-answer model is improved.
In one exemplary embodiment of the present disclosure, the pre-trained question-answering model may be directionally trained by: sample triplet data belonging to different service field types can be obtained, and then the trained pre-training question-answering model can be directionally trained according to the sample triplet data, so that the pre-training question-answering model belonging to different service field types can be obtained.
After the trained pre-training question-answering model is obtained, the pre-training question-answering model only has the capability of form question-answering, namely a general model, so that the trained pre-training question-answering model can be further trained according to sample triplet data belonging to different service field types, target question-answering models applied to different service field types can be obtained, and the accuracy of the target question-answering models of the service field types can be effectively guaranteed.
Compared with the traditional method for generating SQL query statement query answer data, the accuracy is effectively improved by evaluating the pre-training mode provided in the embodiment through the existing public data set, for example, the data of table 1 can be obtained through implementation:
table 1 accuracy evaluation
Evaluating a dataset Whether to use the pretraining mode of the present embodiment Accuracy rate of
Zhuiyi (Chinese character) Whether or not 68.8%
Zhuiyi (Chinese character) Is that 78.9%
SDCUP Whether or not 69.7%
SDCUP Is that 81.8%
Therefore, the pre-training mode provided in this embodiment is adopted, that is, the pre-training question-answer model is obtained by training the training triplet data generated by the question template and the structured query statement template, then the target question-answer model is obtained by performing directional training on the pre-training question-answer model according to sample data of different service field types, and the question data and the table data are input into the target question-answer model to output answer data.
It should be noted that although the steps of the methods of the present disclosure are illustrated in the accompanying drawings in a particular order, this does not require or imply that the steps must be performed in that particular order or that all of the illustrated steps be performed in order to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step to perform, and/or one step decomposed into multiple steps to perform, etc.
In addition, in the present exemplary embodiment, a data query apparatus is also provided. Referring to fig. 4, the data query apparatus 400 includes:
the problem acquisition module 410 is configured to acquire problem data;
the table determining module 420 is configured to determine table data corresponding to the problem data;
the question-answer model matching module 430 is configured to match a target question-answer model corresponding to the question data;
the answer query module 440 is configured to input the question data and the table data into the target question-answer model, and generate answer data corresponding to the question data.
In one exemplary embodiment of the present disclosure, based on the foregoing scheme, the question-answer model matching module may be configured to:
determining the service field type corresponding to the problem data;
and matching a target question-answering model corresponding to the problem data according to the service field type, wherein the target question-answering model is obtained by performing directional training on a pre-trained question-answering model.
In an exemplary embodiment of the present disclosure, based on the foregoing scheme, the data query device may include a pre-training module, which may be used to:
obtaining a problem template and a structured query statement template corresponding to the problem template;
Generating training triplet data according to preset training form data, the problem template and the structured query statement template;
and carrying out iterative training on the pre-built initial pre-training question-answering model through the training triplet data to obtain a pre-training question-answering model after training is completed.
In one exemplary embodiment of the present disclosure, based on the foregoing scheme, the pre-training module may be configured to:
extracting sample problem data from a preset data set and sample structured query sentences corresponding to the sample problem data;
fuzzy matching is carried out on the sample question data and the keywords in the sample structured query statement, and a template filling position is determined, wherein the template filling position comprises a data position and a data type;
and generating the problem template and a structured query statement template corresponding to the problem template based on the template filling position, the sample problem data and the sample structured query statement.
In one exemplary embodiment of the present disclosure, based on the foregoing scheme, the pre-training module may be configured to:
acquiring preset training table data, and disassembling the training table data to obtain training sub-table data;
Randomly filling the problem template and the structured query statement template based on the training sub-table data to obtain training problem data and training structured query statements;
inquiring in the training form data according to the training structured inquiry statement to obtain training answer data;
and forming training triplet data by the training form data, the training question data and the training answer data.
In one exemplary embodiment of the present disclosure, based on the foregoing scheme, the pre-training module may be configured to:
determining the template type of the structured query statement template, and classifying the problem template and the structured query statement template according to the template type; wherein the template types are partitioned by the complexity of the structured query statement templates;
and randomly filling the problem templates and the structured query sentence templates under different classification results based on the training sub-table data to obtain training problem data and training structured query sentences.
In one exemplary embodiment of the present disclosure, based on the foregoing scheme, the pre-training module may be configured to:
acquiring sample triplet data belonging to different service field types;
And carrying out directional training on the trained pre-training question-answering model according to the sample triplet data to obtain target question-answering models belonging to different service field types.
The specific details of each module of the data query device are described in detail in the corresponding data query method, so that the details are not repeated here.
It should be noted that although in the above detailed description several modules or units of the data querying device are mentioned, this division is not mandatory. Indeed, the features and functionality of two or more modules or units described above may be embodied in one module or unit in accordance with embodiments of the present disclosure. Conversely, the features and functions of one module or unit described above may be further divided into a plurality of modules or units to be embodied.
In addition, in the exemplary embodiment of the present disclosure, an electronic device capable of implementing the above data query method is also provided.
Those skilled in the art will appreciate that the various aspects of the present disclosure may be implemented as a system, method, or program product. Accordingly, various aspects of the disclosure may be embodied in the following forms, namely: an entirely hardware embodiment, an entirely software embodiment (including firmware, micro-code, etc.) or an embodiment combining hardware and software aspects may be referred to herein as a "circuit," module "or" system.
An electronic device 500 according to such an embodiment of the present disclosure is described below with reference to fig. 5. The electronic device 500 shown in fig. 5 is merely an example and should not be construed as limiting the functionality and scope of use of the disclosed embodiments.
As shown in fig. 5, the electronic device 500 is embodied in the form of a general purpose computing device. The components of electronic device 500 may include, but are not limited to: the at least one processing unit 510, the at least one memory unit 520, a bus 530 connecting the different system components (including the memory unit 520 and the processing unit 510), and a display unit 540.
Wherein the storage unit stores program code that is executable by the processing unit 510 such that the processing unit 510 performs steps according to various exemplary embodiments of the present disclosure described in the above-mentioned "exemplary methods" section of the present specification. For example, the processing unit 510 may perform step S210 shown in fig. 1 to acquire problem data; step S220, determining form data corresponding to the problem data; step S230, matching a target question-answering model corresponding to the question data; step S240, inputting the question data and the table data into the target question-answer model, and generating answer data corresponding to the question data.
The storage unit 520 may include readable media in the form of volatile storage units, such as Random Access Memory (RAM) 521 and/or cache memory 522, and may further include Read Only Memory (ROM) 523.
The storage unit 520 may also include a program/utility 524 having a set (at least one) of program modules 525, such program modules 525 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment.
Bus 530 may be one or more of several types of bus structures including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
The electronic device 500 may also communicate with one or more external devices 570 (e.g., keyboard, pointing device, bluetooth device, etc.), with one or more devices that enable a user to interact with the electronic device 500, and/or with any device (e.g., router, modem, etc.) that enables the electronic device 500 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 550. Also, electronic device 500 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet, through network adapter 560. As shown, network adapter 560 communicates with other modules of electronic device 500 over bus 530. It should be appreciated that although not shown, other hardware and/or software modules may be used in connection with electronic device 500, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.) or on a network, and includes several instructions to cause a computing device (may be a personal computer, a server, a terminal device, or a network device, etc.) to perform the method according to the embodiments of the present disclosure.
In an exemplary embodiment of the present disclosure, a computer-readable storage medium having stored thereon a program product capable of implementing the method described above in the present specification is also provided. In some possible embodiments, the various aspects of the present disclosure may also be implemented in the form of a program product comprising program code for causing a terminal device to carry out the steps according to the various exemplary embodiments of the disclosure as described in the "exemplary methods" section of this specification, when the program product is run on the terminal device.
Referring to fig. 6, a program product 600 for implementing the above-described data query method, which may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer, is described according to an embodiment of the present disclosure. However, the program product of the present disclosure is not limited thereto, and in this document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium would include the following: an electrical connection having one or more wires, a portable disk, a hard disk, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
The computer readable signal medium may include a data signal propagated in baseband or as part of a carrier wave with readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server. In the case of remote computing devices, the remote computing device may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., connected via the Internet using an Internet service provider).
Furthermore, the above-described figures are only schematic illustrations of processes included in the method according to the exemplary embodiments of the present disclosure, and are not intended to be limiting. It will be readily appreciated that the processes shown in the above figures do not indicate or limit the temporal order of these processes. In addition, it is also readily understood that these processes may be performed synchronously or asynchronously, for example, among a plurality of modules.
From the above description of embodiments, those skilled in the art will readily appreciate that the example embodiments described herein may be implemented in software, or in combination with the necessary hardware. Thus, the technical solution according to the embodiments of the present disclosure may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (may be a CD-ROM, a U-disk, a mobile hard disk, etc.) or on a network, and includes several instructions to cause a computing device (may be a personal computer, a server, a touch terminal, or a network device, etc.) to perform the method according to the embodiments of the present disclosure.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any adaptations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It is to be understood that the present disclosure is not limited to the precise arrangements and instrumentalities shown in the drawings, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A method of querying data, comprising:
acquiring problem data;
determining form data corresponding to the problem data;
matching a target question-answering model corresponding to the problem data;
and inputting the question data and the form data into the target question-answer model to generate answer data corresponding to the question data.
2. The data query method of claim 1, wherein said matching the target question-answer model corresponding to the question data comprises:
determining the service field type corresponding to the problem data;
and matching a target question-answering model corresponding to the problem data according to the service field type, wherein the target question-answering model is obtained by performing directional training on a pre-trained question-answering model.
3. The data query method of claim 2, wherein the pre-trained question-answering model is obtained through a pre-training process comprising:
Obtaining a problem template and a structured query statement template corresponding to the problem template;
generating training triplet data according to preset training form data, the problem template and the structured query statement template;
and carrying out iterative training on the pre-built initial pre-training question-answering model through the training triplet data to obtain a pre-training question-answering model after training is completed.
4. A data query method as claimed in claim 3, wherein prior to obtaining a question template and a structured query statement template corresponding to the question template, the method further comprises:
extracting sample problem data from a preset data set and sample structured query sentences corresponding to the sample problem data;
fuzzy matching is carried out on the sample question data and the keywords in the sample structured query statement, and a template filling position is determined, wherein the template filling position comprises a data position and a data type;
and generating the problem template and a structured query statement template corresponding to the problem template based on the template filling position, the sample problem data and the sample structured query statement.
5. The data query method of claim 3, wherein generating training triplet data from preset training form data, the question template and the structured query term template comprises:
Acquiring preset training table data, and disassembling the training table data to obtain training sub-table data;
randomly filling the problem template and the structured query statement template based on the training sub-table data to obtain training problem data and training structured query statements;
inquiring in the training form data according to the training structured inquiry statement to obtain training answer data;
and forming training triplet data by the training form data, the training question data and the training answer data.
6. The data query method of claim 5, wherein randomly filling the question template and the structured query term template based on the training sub-table data to obtain training question data and training structured query terms, comprises:
determining the template type of the structured query statement template, and classifying the problem template and the structured query statement template according to the template type; wherein the template types are partitioned by the complexity of the structured query statement templates;
and randomly filling the problem templates and the structured query sentence templates under different classification results based on the training sub-table data to obtain training problem data and training structured query sentences.
7. The data query method of claim 2, wherein the target question-answering model is obtained by directional training of a pre-trained question-answering model, comprising:
acquiring sample triplet data belonging to different service field types;
and carrying out directional training on the trained pre-training question-answering model according to the sample triplet data to obtain target question-answering models belonging to different service field types.
8. A data query device, comprising:
the problem acquisition module is used for acquiring problem data;
the form determining module is used for determining form data corresponding to the problem data;
the question-answering model matching module is used for matching a target question-answering model corresponding to the question data;
and the answer query module is used for inputting the question data and the form data into the target question-answer model and generating answer data corresponding to the question data.
9. An electronic device, comprising:
a processor; and
a memory having stored thereon computer readable instructions which when executed by the processor implement the data query method of any of claims 1 to 7.
10. A computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the data query method of any of claims 1 to 7.
CN202310257937.6A 2023-03-10 2023-03-10 Data query method and device, electronic equipment and storage medium Pending CN116303537A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310257937.6A CN116303537A (en) 2023-03-10 2023-03-10 Data query method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310257937.6A CN116303537A (en) 2023-03-10 2023-03-10 Data query method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116303537A true CN116303537A (en) 2023-06-23

Family

ID=86821951

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310257937.6A Pending CN116303537A (en) 2023-03-10 2023-03-10 Data query method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116303537A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116483982A (en) * 2023-06-25 2023-07-25 北京中关村科金技术有限公司 Knowledge question-answering method, knowledge question-answering device, electronic equipment and readable storage medium
CN116821696A (en) * 2023-08-30 2023-09-29 腾讯科技(深圳)有限公司 Training method, device, equipment and storage medium for form question-answer model

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116483982A (en) * 2023-06-25 2023-07-25 北京中关村科金技术有限公司 Knowledge question-answering method, knowledge question-answering device, electronic equipment and readable storage medium
CN116483982B (en) * 2023-06-25 2023-10-13 北京中关村科金技术有限公司 Knowledge question-answering method, knowledge question-answering device, electronic equipment and readable storage medium
CN116821696A (en) * 2023-08-30 2023-09-29 腾讯科技(深圳)有限公司 Training method, device, equipment and storage medium for form question-answer model
CN116821696B (en) * 2023-08-30 2023-11-24 腾讯科技(深圳)有限公司 Training method, device, equipment and storage medium for form question-answer model

Similar Documents

Publication Publication Date Title
US11651236B2 (en) Method for question-and-answer service, question-and-answer service system and storage medium
CN108363790B (en) Method, device, equipment and storage medium for evaluating comments
US20180341698A1 (en) Method and apparatus for parsing query based on artificial intelligence, and storage medium
CN107861954B (en) Information output method and device based on artificial intelligence
CN108628830B (en) Semantic recognition method and device
CN112256860A (en) Semantic retrieval method, system, equipment and storage medium for customer service conversation content
CN116303537A (en) Data query method and device, electronic equipment and storage medium
CN111143556B (en) Automatic counting method and device for software function points, medium and electronic equipment
CN111552766B (en) Using machine learning to characterize reference relationships applied on reference graphs
CN110555205B (en) Negative semantic recognition method and device, electronic equipment and storage medium
WO2022174496A1 (en) Data annotation method and apparatus based on generative model, and device and storage medium
CN114840671A (en) Dialogue generation method, model training method, device, equipment and medium
EP4035024A1 (en) Semantic parsing of natural language query
WO2020149959A1 (en) Conversion of natural language query
CN114141384A (en) Method, apparatus and medium for retrieving medical data
CN112036186A (en) Corpus labeling method and device, computer storage medium and electronic equipment
CN114842982B (en) Knowledge expression method, device and system for medical information system
CN111831624A (en) Data table creating method and device, computer equipment and storage medium
US20230081015A1 (en) Method and apparatus for acquiring information, electronic device and storage medium
CN114625889A (en) Semantic disambiguation method and device, electronic equipment and storage medium
CN112347196B (en) Entity relation extraction method and device based on neural network
CN112148751A (en) Method and device for querying data
CN116755683B (en) Data processing method and related device
CN114330345B (en) Named entity recognition method, training method, device, electronic equipment and medium
US20240061761A1 (en) Device, system, and method for text semantic analysis using source code analysis, and chatbot question-answer service providing method using same

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