A method, apparatus, electronic device, and storage medium for intelligent question answering.

By employing intent recognition, entity recognition, and NL2SQL model processing, the accuracy problem of intelligent question answering systems in complex text processing has been solved, achieving higher text processing accuracy and user experience.

CN115827819BActive Publication Date: 2026-11-17AISINO CORPORATION +2
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202211244937.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-12
Publication Date
2026-11-17
Estimated Expiration
2042-10-12

AI Technical Summary

Technical Problem

Existing intelligent question-answering systems have low accuracy when processing texts with complex semantics or unclear content, making it difficult to effectively improve the accuracy of question text processing.

Method used

The intent and entity information of the question text are determined by intent recognition and entity recognition. The question text is converted into an SQL statement using the NL2SQL model. The target SQL statement is determined by similarity comparison or scoring. Preprocessing operations such as error correction and word segmentation are combined to improve accuracy.

Benefits of technology

It improves the accuracy of problem text processing, ensures the accuracy of output results and user experience, and enhances feature representation capabilities and recognition performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115827819B_ABST
    Figure CN115827819B_ABST
Patent Text Reader

Abstract

This application discloses an intelligent question-answering processing method, apparatus, electronic device, and storage medium, relating to the field of natural language processing technology. The method includes: responding to a user operation inputting question text, performing intent recognition on the question text to determine intent information of the question text; performing entity recognition on the question text to determine entity information of the question text, the entity information including keywords in the question text; determining a first structured query SQL statement for the question text based on the intent information and the keywords of the question text; converting the question text into a second SQL statement based on an NL2SQL model; and determining a target SQL statement for the question text based on the first SQL statement and the second SQL statement, thereby achieving high accuracy in question text processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of natural language processing technology, and in particular to an intelligent question-answering processing method, apparatus, electronic device, and storage medium. Background Technology

[0002] Intelligent question-answering systems organize accumulated, unordered corpora into a structured and scientific framework, establishing knowledge-based classification models. These models guide newly added corpus-based consultation and service information, saving human resources, improving the automation of information processing, and reducing website operating costs. Based on years of accumulated common questions and answers about various industries, these have been compiled into a standardized question-and-answer database to support intelligent question answering for various types of questions. This benefits users, improves efficiency, and enhances the company's image.

[0003] Currently, intelligent question-answering systems typically respond to user-inputted question text by converting it into a corresponding Structured Query Language (SQL) statement. Executing the converted SQL statement then yields the answer data. This approach may have relatively good accuracy for simpler operations, but its accuracy is relatively low when dealing with semantically complex or unclear text.

[0004] Therefore, improving the accuracy of processing user-input question text is a pressing issue that needs to be addressed. Summary of the Invention

[0005] This application provides an intelligent question-answering processing method to improve the accuracy of question text processing.

[0006] Firstly, an intelligent question-answering processing method is provided, including:

[0007] In response to a user's input of question text, the system performs intent recognition on the question text to determine intent information; it then performs entity recognition on the question text to determine entity information, including keywords in the question text; based on the intent information and the keywords in the question text, it determines a first SQL statement for the question text; based on the NL2SQL model, it converts the question text into a second SQL statement; and based on the first SQL statement and the second SQL statement, it determines a target SQL statement for the question text.

[0008] Optionally, the step of performing entity recognition on the question text to determine the entity information of the question text includes:

[0009] Entity recognition is performed on the question text to determine i features of the question text and the position information of the i features, where i is an integer greater than 0; based on the i features and the position information of the i features, the entity information of the question text is determined.

[0010] Optionally, determining the first SQL statement for the question text based on the intent information and keywords in the question text includes:

[0011] Based on the intent information and the keywords, a database is queried to obtain a first information list associated with the question text; wherein, the first information list includes candidate SQL statements related to the intent information and / or the keywords; based on a statistical algorithm, a first SQL statement matching the question text is selected from the candidate SQL statements.

[0012] Optionally, determining the target SQL statement for the problem text based on the first SQL statement and the second SQL statement includes:

[0013] If the similarity between the first SQL statement and the second SQL statement meets the requirements, then either the first SQL statement or the second SQL statement is used as the target SQL statement of the question text; if the similarity between the first SQL statement and the second SQL statement does not meet the requirements, then it is determined whether the score of the first SQL statement is greater than a set threshold. If so, then the first SQL statement is used as the target SQL statement of the question text; otherwise, the second SQL statement is used as the target SQL statement of the question text.

[0014] Optionally, before performing intent recognition on the question text, the method further includes:

[0015] Perform at least one of the following preprocessing operations on the question text:

[0016] The text in the question text is converted into a specified text type; if the question text contains typos, the typos are corrected; if the question text contains time information, the time information is converted into time information in a specified format; the punctuation marks in the question text are converted into English punctuation marks; auxiliary words in the question text are deleted based on the stop word list; and the question text is segmented based on a word segmentation dictionary.

[0017] Optionally, after determining the target SQL statement for the problem text based on the first SQL statement and the second SQL statement, the method further includes:

[0018] Execute the target SQL statement and output the execution result, which indicates the answer to the question text.

[0019] Secondly, an intelligent question-answering processing device is provided, comprising:

[0020] An intent recognition module is used to respond to a user operation that inputs question text, perform intent recognition on the question text, and determine the intent information of the question text; an entity recognition module is used to perform entity recognition on the question text, and determine the entity information of the question text, the entity information including keywords in the question text; a first determination module is used to determine a first SQL statement of the question text based on the intent information and the keywords in the question text; a conversion module is used to convert the question text into a second SQL statement based on the NL2SQL model; and a second determination module is used to determine the target SQL statement of the question text based on the first SQL statement and the second SQL statement.

[0021] Optionally, the first determining module is specifically used for:

[0022] Based on the intent information and the entity information, a database is queried to obtain a first information list associated with the question text; wherein, the first information list includes candidate SQL statements related to the intent information and / or the entity information; based on a statistical algorithm, a first SQL statement matching the question text is selected from the candidate SQL statements.

[0023] Optionally, the second determining module is specifically used for:

[0024] If the similarity between the first SQL statement and the second SQL statement meets the requirements, then either the first SQL statement or the second SQL statement is used as the target SQL statement of the question text; if the similarity between the first SQL statement and the second SQL statement does not meet the requirements, then it is determined whether the score of the first SQL statement is greater than a set threshold. If so, then the first SQL statement is used as the target SQL statement of the question text; otherwise, the second SQL statement is used as the target SQL statement of the question text.

[0025] Optionally, the device further includes a preprocessing module;

[0026] The preprocessing module is used to perform at least one of the following preprocessing operations on the question text:

[0027] The text in the question text is converted into a specified text type; if the question text contains typos, the typos are corrected; if the question text contains time information, the time information is converted into time information in a specified format; the punctuation marks in the question text are converted into English punctuation marks; auxiliary words in the question text are deleted based on the stop word list; and the question text is segmented based on a word segmentation dictionary.

[0028] Optionally, the device further includes an SQL statement operation module; the SQL statement operation module is used to execute the target SQL statement and output the execution result, the execution result being used to indicate the answer to the question text.

[0029] Thirdly, an electronic device is provided, comprising:

[0030] A memory for storing computer programs; a processor for executing the computer programs stored in the memory to implement the method steps described in any one of the first aspects.

[0031] Fourthly, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when executed by a processor, the computer program implements the method steps described in any one of the first aspects.

[0032] In this embodiment, in response to a user's input of question text, intent recognition is performed on the question text to determine its intent information; entity recognition is performed on the question text to determine its entity information, which includes keywords in the question text; based on the intent information and the keywords in the question text, the first SQL statement of the question text is determined, thus improving the feature representation capability of the question text and thereby improving the recognition effect of the question text; furthermore, based on the NL2SQL model, the question text is converted into a second SQL statement; based on the first SQL statement and the second SQL statement, the target SQL statement of the question text is determined, thus improving the accuracy of the SQL statement corresponding to the question text compared to determining the SQL statement of the question text through a single mechanism, and also ensuring the accuracy of the output result of the question text, thereby satisfying the user experience.

[0033] For the various aspects of the second to fourth aspects mentioned above, and the technical effects that each aspect may achieve, please refer to the above description of the technical effects that can be achieved for the first aspect or the various possible solutions in the first aspect, which will not be repeated here. Attached Figure Description

[0034] Figure 1 This is a schematic diagram illustrating the application scenarios applicable to the embodiments of this application;

[0035] Figure 2 A flowchart illustrating an intelligent question-answering processing method provided in this application embodiment;

[0036] Figure 3 This is a schematic diagram of the structure of an encoder provided in an embodiment of this application;

[0037] Figure 4 This is a schematic diagram of the structure of an NL2SQL model provided in an embodiment of this application;

[0038] Figure 5 A logical diagram of an intelligent question-answering process provided in an embodiment of this application;

[0039] Figure 6 A schematic diagram of the structure of an intelligent question-answering processing device provided in an embodiment of this application;

[0040] Figure 7 A schematic diagram of another intelligent question-answering processing device provided in the embodiments of this application;

[0041] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The specific operational methods in the method embodiments can also be applied to the device embodiments or system embodiments. It should be noted that in the description of this application, "multiple" is understood as "at least two". "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. A connected to B can represent: A and B directly connected, and A and B connected through C. Furthermore, in the description of this application, terms such as "first" and "second" are used only for distinguishing the purpose of description and should not be construed as indicating or implying relative importance or order.

[0043] The embodiments of this application will now be described in detail with reference to the accompanying drawings.

[0044] To better understand the embodiments of this application, the technical terms involved in the embodiments of this application will be explained below.

[0045] (1) Structured Query Language is a language for users to operate databases. It is a statement composed of keywords, literals, operators, comments, delimiters, etc. It is widely used in various databases to improve the working quality and efficiency of computer application systems.

[0046] (2) NL2SQL (Natural Language to SQL), as the name suggests, converts natural language into SQL statements. It can act as an intelligent interface for databases, allowing users unfamiliar with databases to quickly find the data they want.

[0047] (3) Abstract Syntax Tree (AST): The result of SQL after lexical analysis and syntax analysis is the Abstract Syntax Tree. It is a multi-branch tree, and each non-leaf node describes the semantics of an SQL fragment.

[0048] (4) BERT stands for Bidirectional Encoder Representation from Transformers. It is a pre-trained language representation model based on Transformers. It emphasizes that instead of using traditional unidirectional language models or shallow concatenation of two unidirectional language models for pre-training, it adopts a new masked language model (MLM) to generate deep bidirectional language representations. The goal of the BERT model is to train on large-scale unlabeled corpora to obtain a representation of the problem text containing rich semantic information, that is, the semantic representation of the text. Then, the semantic representation of the text is fine-tuned in a specific sequence labeling task and finally applied to the task.

[0049] (5) Bidirectional Long Short-Term Memory (Bi-LSTM) Neural Network Model: A type of Recurrent Neural Network (RNN). The Bi-LSTM neural network structure consists of two independent LSTMs. The input sequence is fed into the two LSTM neural networks in both forward and reverse order for entity recognition. The word vector formed by concatenating the two output vectors (i.e., the extracted feature vectors) is used as the final feature representation of the word. The main structure of LSTM is similar to that of RNN. Its main improvement is the addition of three gate structures in the hidden layer h: the forget gate, the input gate, and the output gate. It also adds a hidden state (cellstate).

[0050] (6) Conditional Random Field (CRF) is a discriminative probability model and a type of random field. It is often used to label or analyze sequence data, such as natural language text or biological sequences.

[0051] (7) TF-IDF is a statistical method used to assess the importance of a word to a document within a document set or corpus. A word's importance increases proportionally to its frequency of occurrence in the document, but decreases inversely proportionally to its frequency of occurrence in the corpus. Various weighted forms of TF-IDF are commonly used by search engines as a measure or ranking of the relevance between documents and user queries. In addition to TF-IDF, internet search engines also use link analysis-based ranking methods to determine the order in which documents appear in search results.

[0052] (8) Stop words are an important tool in the field of natural language processing. They are often used to improve the quality of text features or reduce the dimensionality of text features.

[0053] (9) A tax data dictionary is a tool used to describe and represent the data flow, data storage, and data processing content in a tax data flow diagram in dictionary form. A tax data dictionary consists of five different types of entries: data element, data flow, data structure, data processing, and data storage. By compiling a data dictionary, the types, characteristics, quantities, and transformation relationships of various data in the data flow diagram are described and represented to further clarify the data structure and processing logic. Tax data dictionaries come in different forms, but are usually in the form of index cards for easy searching.

[0054] (10) The Relation-Aware Transformer-SQL (RAT-SQL) model is mainly applied to semantic encoding (schema encoder), semantic linking (schema linking), and feature representation problems. It utilizes a relation-aware self-attention mechanism to construct global reasoning between the schema and the question, used to encode the relational structure within a given question and database schema. The features extracted by the traditional attention mechanism layer satisfy the following expression:

[0055]

[0056]

[0057] Where, x i For the i-th word in the input question text, x j Given the j-th word in the input question text, For x i query vector and x j The dot product score of the key vector. These are weight matrices of different dimensions; For x i Attention weights for different word vectors; For x i The self-attention output. It can be seen that the features extracted by the traditional attention mechanism layer do not reflect the differences in x. i The relationship between (features) is poorly identified.

[0058] The following is a brief introduction to the application scenarios to which the technical solutions of the embodiments of this application are applicable. It should be noted that the application scenarios described below are only for illustrating the embodiments of this application and are not intended to limit the scope. In specific implementation, the technical solutions provided by the embodiments of this application can be flexibly applied according to actual needs.

[0059] Figure 1 This is a schematic diagram illustrating an application scenario applicable to the embodiments of this application. As shown in the figure, the scenario mainly includes: terminal 10 and server 11. Figure 1 This is a schematic diagram illustrating an application scenario applicable to the embodiments of this application. As shown in the figure, the application scenario mainly includes: terminal 10 and server 11. Terminal 10 and server 11 can interact via a communication network, which can employ communication methods including wireless communication and wired communication.

[0060] For example, terminal 10 can access the network and communicate with server 11 through cellular mobile communication technology, which may include 5th Generation Mobile Networks (5G) technology.

[0061] For example, terminal 10 can access the network and communicate with server 11 via short-range wireless communication, which may include Wireless Fidelity (Wi-Fi) technology.

[0062] This application embodiment does not impose any limitation on the number of the above-mentioned devices, such as Figure 1 As shown, only terminal 10 and server 11 are described as examples. The following is a brief introduction to each of the above devices and their respective functions.

[0063] Terminal 10 is a device that can provide users with voice and / or data connectivity, including: handheld terminal devices with wireless connectivity, vehicle-mounted terminal devices, etc.

[0064] For example, terminal 10 includes, but is not limited to: mobile phones, tablets, laptops, handheld computers, mobile internet devices (MID), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminal devices in industrial control, wireless terminal devices in autonomous driving, wireless terminal devices in smart grids, wireless terminal devices in transportation safety, wireless terminal devices in smart cities, or wireless terminal devices in smart homes, etc.

[0065] In addition, a client related to intelligent question-and-answer processing can be installed on the terminal 10. This client can be software (such as an APP, browser, etc.), or a webpage, mini-program, etc.

[0066] In this embodiment, terminal 10 can use the aforementioned intelligent question-and-answer processing client and can interact with server 11 to exchange information related to the intelligent question-and-answer scenario. For example, terminal 10 can send a question text to server 11. After receiving the question text sent by terminal 10, server 11 can further analyze and process the question text and output the answer to the question text.

[0067] Furthermore, server 11 can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.

[0068] Furthermore, in this embodiment of the application, the server 11 may be equipped with an intelligent question-and-answer service system corresponding to the client. The intelligent question-and-answer service system is used to respond to user operations that input question text, analyze and process the input question text, and output the accurate answer to the question text.

[0069] Of course, the methods provided in the embodiments of this application are not limited to... Figure 1 The application scenarios shown can also be used in other possible application scenarios, and the embodiments of this application do not impose limitations. Figure 1 The functions that each device in the application scenario shown can achieve will be described in subsequent method embodiments, and will not be elaborated on here.

[0070] To further illustrate the technical solutions provided in the embodiments of this application, a detailed description is provided below in conjunction with the accompanying drawings and specific implementation methods. Although the embodiments of this application provide method operation steps as shown in the following embodiments or drawings, the method may include more or fewer operation steps based on conventional or non-inventive methods. In steps where there is no logically necessary causal relationship, the execution order of these steps is not limited to the execution order provided in the embodiments of this application. In actual processing or when the device executes the method, it may be executed in the order shown in the embodiments or drawings, or in combination.

[0071] For ease of understanding, the intelligent question-answering processing method provided in this application will be described in detail below through specific embodiments. Figure 2 This document provides a flowchart of an intelligent question-answering processing method according to an embodiment of this application. This process can be executed by an intelligent question-answering device, which can be implemented through software, hardware, or a combination of both. As shown in the figure, the process includes the following steps:

[0072] 201: In response to a user's input of question text, perform intent recognition on the question text to determine the intent information of the question text.

[0073] Optionally, the user operation can be a manual input method, such as the user manually entering the question text on the user interface, or it can be a voice input method, where the question text is entered through voice recognition. This embodiment of the application does not impose any limitations on this.

[0074] Optionally, intent recognition can be performed on the question text to determine its intent information. Text classification models (e.g., BERT model) can be used to analyze the user's operational intent when inputting the question text. For example, discrimination rules for aggregation operations can be used to determine whether the question text belongs to one or more of operations such as AVG, MAX, MIN, and SUM. Alternatively, discrimination rules for conditional types can be used to determine whether the question text belongs to one or more of operations such as >, <, ==, and ! =, thereby accurately determining the intent information of the question text.

[0075] In some embodiments, before performing intent recognition on the question text, the input question text may be preprocessed, and at least one of the following preprocessing operations may be performed on the question text:

[0076] Number Conversion: Converts the text in the question text into a specified type of text. For example, for Chinese question text, Chinese numbers can be converted into Arabic numerals (including dates), which makes it easier for the model to process the data. In addition, expressions such as hundreds, thousands, and billions can be replaced in the numbers to facilitate matching with data in the database. The conversion method is mainly based on regular expression matching to extract the parts of the question text that need to be processed, process them, and then restore them to the original question text.

[0077] Text correction: If the question text contains typos, then the typos will be corrected. Since user-entered questions may contain typos, which are a significant cause of ambiguity, correcting these errors before analyzing the question text will improve the accuracy of subsequent output.

[0078] Time parsing: If the question text includes time information, the time information will be converted into time information in a specified format. For example, the time information in the question text will be retrieved and converted into standard time according to the time base.

[0079] Punctuation Conversion: Converts punctuation marks in the problem text into English punctuation marks.

[0080] Stop word removal: Based on the stop word list, remove auxiliary words from the question text. For example, use the Harbin Institute of Technology stop word list, Baidu stop word list, etc., to remove colloquial query words, modal words, auxiliary words, and words that are not closely related to the content of the question text.

[0081] Word segmentation: Based on the word segmentation dictionary, the question text is segmented. For example, the tax data is introduced to expand the word dictionary, and the jieba word segmentation is used to segment the question text.

[0082] By using the above preprocessing methods, we can obtain concise and semantically clear problem texts, which improves the accuracy of subsequent problem text processing results.

[0083] 202: Perform entity recognition on the above-mentioned problem text to determine the entity information of the problem text.

[0084] Optionally, the entity information may include keywords in the question text, and may also include attributes of the keywords.

[0085] Optionally, entity recognition can be performed on the question text to determine its entity information. This can be achieved as follows: Entity recognition is performed on the question text to determine its i features and their positional information (i is an integer greater than 0); based on these i features and their positional information, the entity information of the question text is determined. This positional information can include the absolute and relative positions of each feature. This method combines the BERT model, Bi-LSTM model, and CRF model to perform entity recognition on the question text, improving the effectiveness of entity recognition and ensuring the accuracy of the output results. Specifically, the BERT model is first used as the feature acquisition layer for word vectors. The question text is input into the BERT model to obtain its i features (Embeddings) and their positional information. These i features and their positional information are then input into the Bi-LSTM model. After passing through the Bi-LSTM model, the predicted label corresponding to each feature is output. This predicted label is then used as the input to the CRF model, ultimately outputting the entity information of the question text. The features input into the Bi-LSTM model satisfy the following formula:

[0086] U i =W i (W 1i P i +W 2i E i )+b i .........(3)

[0087] Among them, U i For the i-th feature input into the Bi-LSTM model, P i For the location information of the i-th feature, E i For the i-th embedding obtained through the BERT model, b i W is the bias of the i-th feature. i W 1i and W 2i All of these are weight parameters for the i-th feature.

[0088] In this embodiment, the absolute position information of each feature is introduced during the feature acquisition process based on the BERT model, thereby improving the feature representation ability of the question text. Furthermore, relative position information is also introduced in each embedding. After passing through the Bi-LSTM model, the predicted label corresponding to each feature is output, and the predicted label corresponding to each feature is used as the input of the CRF model. The feature with the highest score in the feature sequence or that meets the set score threshold is used as the entity information (keywords) of the question text, which improves the entity recognition effect and ensures the accuracy of the subsequent output results.

[0089] 203: Based on the above intent information and the keywords in the above question text, determine the first SQL statement of the question text.

[0090] Optionally, the first SQL statement for the question text can be determined as follows: First, a database is queried based on the intent information and keywords to obtain a first information list associated with the question text. In some implementations, this first information list includes candidate SQL statements related to the intent information; in other embodiments, it includes candidate SQL statements related to the keywords; and in still other embodiments, it includes candidate SQL statements related to both the intent information and the keywords. Then, based on a statistical algorithm (e.g., the TF-IDF algorithm), the first SQL statement matching the question text is selected from the candidate SQL statements. Specifically, this first SQL statement may refer to the SQL statement with the highest score.

[0091] 204: Based on the NL2SQL model, the above question text is converted into a second SQL statement.

[0092] Optionally, based on the NL2SQL model, the question text is converted into a second SQL statement in the following way: This model can include an encoder and a decoder. The encoder can process semantic vectors of commonly used natural language, while incorporating relational vectors from natural language and database table information, thereby encoding the user-input natural language (question text) and outputting the corresponding encoded vector. Correspondingly, the encoder can input the output encoded vector into the decoder, which decodes the encoded vector through a series of prediction actions to infer the implicit grammatical rules within the encoded vector. In this embodiment, a relation-aware self-attention layer is used in the encoder to replace the transformer layer, thereby improving feature representation capabilities.

[0093] Specifically, firstly, the given question text is input into the relation-aware self-attention mechanism layer of the encoder, and relational features are added to this layer. Entity recognition is performed based on the relative positions or distances between words in the question text, and the extracted features satisfy the following expression:

[0094]

[0095]

[0096] in, This is used to characterize the hypothesis that there are R relation pairs, and The relation R is obtained through learning. (s) The vector representation of x i For the i-th word in the input question text, x j Given the j-th word in the input question text, For x i query vector and x j The dot product score of the key vector. These are weight matrices of different dimensions; For x i Attention weights for different word vectors (features); For x i Self-attention output.

[0097] The structure of the encoder described above is as follows: Figure 3 As shown, an exemplary structural diagram of an encoder 301 provided in an embodiment of this application is illustrated. As shown, the structure mainly consists of three parts: column names, table names, and question words. For each table, column, and question word node, glove embedding is used to obtain its respective word vector, and these word vectors are processed by Bi-LSTM. The word vectors processed by Bi-LSTM are then combined into a set (X = [C; T; Q]), and X is input into a relation-aware self-attention layer for training. Finally, the output of encoder 301 is obtained.

[0098] Then, the output of encoder 301 (encoded vector) is used as the input of decoder. LSTM is used to output the Actions sequence of decoder. The finally generated node is expanded into a grammar rule. When a leaf node is completed, a row, column or table information is selected from the semantic information to fill it. Finally, the AST of the question text is generated. The second SQL statement corresponding to the question text is determined based on the AST.

[0099] Figure 4 The figure shows a schematic diagram of the structure of an NL2SQL model provided in an embodiment of this application. The NL2SQL model 400 mainly consists of an input layer 401, an encoder 301, and a decoder 402.

[0100] Input layer 401 can input the column names, table names, and question words extracted from the question text into their respective modules (e.g., ...). Figure 4 The algorithm first generates the column name module, table name module, and question word module in the encoder 301, then trains it through the relation-aware self-attention mechanism in the encoder 301, generates the basic structure through the application rules in the decoder 402, fills the table name and column name by selecting columns and tables, generates the AST of the question text, and finally derives the corresponding SQL statement (second SQL statement) based on the AST of the question text.

[0101] 205: Based on the first and second SQL statements above, determine the target SQL statement for the problem text.

[0102] Optionally, the target SQL statement for the problem text can be determined as follows: First, determine whether the first SQL statement and the second SQL statement meet the similarity requirement. If the similarity between the first SQL statement and the second SQL statement meets the requirement (e.g., the first SQL statement and the second SQL statement are the same), then either the first SQL statement or the second SQL statement is taken as the target SQL statement for the problem text. If the similarity between the first SQL statement and the second SQL statement does not meet the requirement, then determine whether the score of the first SQL statement is greater than a set threshold (e.g., whether the score of the first SQL statement is greater than 90). If so, then the first SQL statement is taken as the target SQL statement for the problem text; otherwise, the second SQL statement is taken as the target SQL statement for the problem text.

[0103] Two different mechanisms are used to process the problem text to obtain their respective corresponding SQL statements. The SQL statements are then compared and combined to determine the final SQL statement for the problem text, thereby further improving the accuracy of the SQL statement corresponding to the problem text.

[0104] Optionally, after determining the target SQL statement for the question text, the target SQL statement can be executed, and the execution result can be output, which indicates the answer to the question text.

[0105] In this embodiment, in response to a user's input of question text, intent recognition is performed on the question text to determine its intent information; entity recognition is performed on the question text to determine its entity information, which includes keywords in the question text; based on the intent information and the keywords in the question text, the first SQL statement of the question text is determined, thus improving the feature representation capability of the question text and thereby improving the recognition effect of the question text; furthermore, based on the NL2SQL model, the question text is converted into a second SQL statement; based on the first SQL statement and the second SQL statement, the target SQL statement of the question text is determined, thus improving the accuracy of the SQL statement corresponding to the question text compared to determining the SQL statement of the question text through a single mechanism, and also ensuring the accuracy of the output result of the question text, thereby satisfying the user experience.

[0106] Based on the above Figure 2 The flowchart shown is for the method. Figure 5 An exemplary schematic diagram of the intelligent question-answering processing provided in this application embodiment is illustrated. As shown in the figure, the input question text Q is preprocessed to obtain the preprocessed question text Q. The preprocessed question text Q is then input into the entity recognition module B, the intent recognition module C, and the NL2SQL module D, respectively, to obtain the entity information, intent information, and second SQL statement of the question text Q. Based on the entity information and intent information, a database search is performed to determine the first SQL statement. The first SQL statement and the second SQL statement are input into the rule matching module M. The rule matching module M compares and corrects the first SQL statement and the second SQL statement, outputting the target SQL statement of the question text Q. The target SQL statement is then operated by the SQL statement operation module N, and finally, the answer K of the question text Q is output.

[0107] Based on the same technical concept, this application also provides a schematic diagram of the structure of an intelligent question-and-answer processing device.

[0108] Figure 6 The figure shows a schematic diagram of an intelligent question-answering processing device provided in an embodiment of this application. The device includes: an intent recognition module 601, an entity recognition module 602, a first determination module 603, a conversion module 604, and a second determination module 605.

[0109] The intent recognition module 601 is used to respond to a user operation that inputs question text, perform intent recognition on the question text, and determine the intent information of the question text.

[0110] The entity recognition module 602 is used to perform entity recognition on the question text and determine the entity information of the question text, wherein the entity information includes keywords in the question text.

[0111] The first determining module 603 is used to determine the first SQL statement of the question text based on the intent information and the keywords in the question text.

[0112] The conversion module 604 is used to convert the question text into a second SQL statement based on the NL2SQL model.

[0113] The second determining module 605 is used to determine the target SQL statement of the problem text based on the first SQL statement and the second SQL statement.

[0114] Optional, the entity recognition module 602 is specifically used for:

[0115] Entity recognition is performed on the question text to determine i features of the question text and the position information of the i features, where i is an integer greater than 0; based on the i features and the position information of the i features, the entity information of the question text is determined.

[0116] Optionally, the first determining module 603 is specifically used for:

[0117] Based on the intent information and the entity information, a database is queried to obtain a first information list associated with the question text; wherein, the first information list includes candidate SQL statements related to the intent information and / or the entity information; based on a statistical algorithm, a first SQL statement matching the question text is selected from the candidate SQL statements.

[0118] Optionally, the second determining module 605 is specifically used for:

[0119] If the similarity between the first SQL statement and the second SQL statement meets the requirements, then either the first SQL statement or the second SQL statement is used as the target SQL statement of the problem text; if the similarity between the first SQL statement and the second SQL statement does not meet the requirements, then it is determined whether the accuracy of the first SQL statement is greater than a set threshold. If so, then the first SQL statement is used as the target SQL statement of the problem text; otherwise, the second SQL statement is used as the target SQL statement of the problem text.

[0120] In some embodiments, the structural schematic diagram of the intelligent question-answering processing device, in addition to Figure 6In addition to the modules in the system, it may also include a preprocessing module and an SQL statement operation module. Figure 7 This is a schematic diagram of another intelligent question-answering processing device provided in an embodiment of this application. As shown in the figure, the device includes: an intent recognition module 601, an entity recognition module 602, a first determination module 603, a conversion module 604, a second determination module 605, a preprocessing module 701, and an SQL statement operation module 702. The relevant descriptions of the intent recognition module 601, entity recognition module 602, first determination module 603, conversion module 604, and second determination module 605 are as described above. Figure 6 This will not be described again here.

[0121] Preprocessing module 701 is used to perform at least one of the following preprocessing operations on the question text:

[0122] The text in the question text is converted into a specified text type; if the question text contains typos, the typos are corrected; if the question text contains time information, the time information is converted into time information in a specified format; the punctuation marks in the question text are converted into English punctuation marks; auxiliary words in the question text are deleted based on the stop word list; and the question text is segmented based on a word segmentation dictionary.

[0123] The SQL statement operation module 702 is used to execute the target SQL statement and output the execution result, which is used to indicate the answer to the question text.

[0124] It should be noted that the device provided in this application embodiment can implement all the method steps in the above intelligent question-answering processing embodiment and achieve the same technical effect. Therefore, the parts and beneficial effects that are the same as those in the method embodiment will not be described in detail here.

[0125] Based on the same technical concept, this application also provides an electronic device that can realize the function of the aforementioned intelligent question-and-answer processing device.

[0126] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0127] At least one processor 801 and a memory 802 connected to at least one processor 801. In this embodiment, the specific connection medium between the processor 801 and the memory 802 is not limited. Figure 8 The example shown is the connection between processor 801 and memory 802 via bus 800. Bus 800 is... Figure 8The connections between other components are indicated by thick lines and are for illustrative purposes only, not as limiting information. The 800 bus can be divided into address bus, data bus, control bus, etc., for ease of representation. Figure 8 The term is represented by a single thick line, but this does not imply that there is only one bus or one type of bus. Alternatively, the processor 801 can also be called a controller; there is no restriction on the name.

[0128] In this embodiment, the memory 802 stores instructions executable by at least one processor 801. By executing the instructions stored in the memory 802, the at least one processor 801 can execute the intelligent question-answering processing method described above. The processor 801 can implement... Figure 6 or Figure 7 The functions of each module in the device shown.

[0129] The processor 801 is the control center of the device. It can connect to various parts of the control device through various interfaces and lines. By running or executing instructions stored in memory 802 and calling data stored in memory 802, the processor can perform various functions and process data, thereby monitoring the device as a whole.

[0130] In one possible design, processor 801 may include one or more processing units. Processor 801 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, driver interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into processor 801. In some embodiments, processor 801 and memory 802 may be implemented on the same chip; in some embodiments, they may also be implemented on separate chips.

[0131] The processor 801 can be a general-purpose processor, such as a central processing unit (CPU), digital signal processor, application-specific integrated circuit, field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the intelligent question-answering processing method disclosed in the embodiments of this application can be directly manifested as execution by a hardware processor, or execution by a combination of hardware and software modules within the processor.

[0132] Memory 802, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 802 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic storage, magnetic disk, optical disk, etc. Memory 802 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, memory 802 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.

[0133] By designing and programming the processor 801, the code corresponding to the intelligent question-answering processing method described in the foregoing embodiments can be embedded into the chip, enabling the chip to execute it during operation. Figure 3 The illustrated embodiment presents an intelligent question-answering processing method. How to design and program the processor 801 is a technique well-known to those skilled in the art and will not be described further here.

[0134] It should be noted that the electronic device provided in this application embodiment can implement all the method steps implemented in the above method embodiment and can achieve the same technical effect. Here, the parts that are the same as those in the method embodiment and the beneficial effects will not be described in detail.

[0135] This application also provides a computer-readable storage medium storing computer-executable instructions for causing a computer to execute an intelligent question-answering processing method as described in the above embodiments.

[0136] This application also provides a computer program product, which, when invoked by a computer, causes the computer to execute an intelligent question-answering processing method as described in the above embodiments.

[0137] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0138] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0139] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0140] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

Claims

1. An intelligent question-answering processing method, characterized in that, include: In response to a user's input of question text, intent recognition is performed on the question text to determine the intent information of the question text; Entity recognition is performed on the question text to determine the entity information of the question text, and the entity information includes keywords in the question text; Based on the intent information and the keywords in the question text, determine the first SQL statement of the question text; Based on the NL2SQL model, the question text is converted into a second SQL statement; Based on the first SQL statement and the second SQL statement, determine the target SQL statement for the question text; The specific steps for determining the target SQL statement of the problem text based on the first SQL statement and the second SQL statement include: If the similarity between the first SQL statement and the second SQL statement meets the requirements, then either the first SQL statement or the second SQL statement is used as the target SQL statement of the question text; if the similarity between the first SQL statement and the second SQL statement does not meet the requirements, then it is determined whether the score of the first SQL statement is greater than a set threshold. If so, then the first SQL statement is used as the target SQL statement of the question text; otherwise, the second SQL statement is used as the target SQL statement of the question text. The specific steps of performing entity recognition on the question text to determine the entity information of the question text include: The question text is input into a BERT model to obtain i features of the question text and the position information of the i features; the i features and the position information of the i features are input into a Bi-Short Memory Neural Network (Bi-LSTM) model to obtain the predicted label corresponding to each feature; the predicted labels corresponding to each of the i features are input into a Conditional Random Field (CRF) model to obtain the entity information of the question text; wherein, i is an integer greater than 0, and the position information includes the absolute position and relative position of each feature.

2. The method as described in claim 1, characterized in that, The step of determining the first SQL statement for the question text based on the intent information and the keywords in the question text includes: Based on the intent information and the keywords, a database is queried to obtain a first information list associated with the question text; wherein, the first information list includes candidate SQL statements related to the intent information and / or the keywords; Based on a statistical algorithm, the first SQL statement that matches the question text is selected from the candidate SQL statements.

3. The method as described in claim 1 or 2, characterized in that, Before performing intent recognition on the question text, the method further includes: Perform at least one of the following preprocessing operations on the question text: Convert the text in the question text into a specified text type; If the problem text contains typos, then the typos are corrected; If the question text includes time information, then the time information will be converted into time information in a specified format; Convert the punctuation marks in the question text to English punctuation marks; The auxiliary words in the problem text were deleted based on the stop word list; The problem text is segmented based on a word segmentation dictionary.

4. The method as described in claim 1 or 2, characterized in that, After determining the target SQL statement for the problem text based on the first SQL statement and the second SQL statement, the method further includes: Execute the target SQL statement and output the execution result, which indicates the answer to the question text.

5. An intelligent question-and-answer processing device, characterized in that, include: An intent recognition module is used to respond to a user's input of question text, perform intent recognition on the question text, and determine the intent information of the question text; An entity recognition module is used to perform entity recognition on the question text and determine the entity information of the question text, wherein the entity information includes keywords in the question text; The first determining module is used to determine the first structured query SQL statement of the question text based on the intent information and the keywords in the question text; The conversion module is used to convert the question text into a second SQL statement based on the NL2SQL model; The second determining module is used to determine the target SQL statement of the problem text based on the first SQL statement and the second SQL statement; The second determining module is specifically used for: If the similarity between the first SQL statement and the second SQL statement meets the requirements, then either the first SQL statement or the second SQL statement is used as the target SQL statement of the question text; if the similarity between the first SQL statement and the second SQL statement does not meet the requirements, then it is determined whether the score of the first SQL statement is greater than a set threshold. If so, then the first SQL statement is used as the target SQL statement of the question text; otherwise, the second SQL statement is used as the target SQL statement of the question text. Specifically, the entity recognition module is used for: The question text is input into a BERT model to obtain i features of the question text and the position information of the i features; the i features and the position information of the i features are input into a Bi-Short Memory Neural Network (Bi-LSTM) model to obtain the predicted label corresponding to each feature; the predicted labels corresponding to each of the i features are input into a Conditional Random Field (CRF) model to obtain the entity information of the question text; wherein, i is an integer greater than 0, and the position information includes the absolute position and relative position of each feature.

6. The apparatus as claimed in claim 5, characterized in that, The first determining module is specifically used for: Based on the intent information and the entity information, a database is queried to obtain a first information list associated with the question text; wherein, the first information list includes candidate SQL statements related to the intent information and / or the entity information; Based on a statistical algorithm, the first SQL statement that matches the question text is selected from the candidate SQL statements.

7. The apparatus as described in claim 5 or 6, characterized in that, The device also includes a preprocessing module; The preprocessing module is used to perform at least one of the following preprocessing operations on the question text: Convert the text in the question text into a specified text type; If the problem text contains typos, then the typos are corrected; If the question text includes time information, then the time information will be converted into time information in a specified format; Convert the punctuation marks in the question text to English punctuation marks; The auxiliary words in the problem text were deleted based on the stop word list; The problem text is segmented based on a word segmentation dictionary.

8. The apparatus as described in claim 5 or 6, characterized in that, The device also includes an SQL statement operation module; The SQL statement operation module is used to execute the target SQL statement and output the execution result, which is used to indicate the answer to the question text.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, when executing a computer program stored in the memory, implements the method steps of any one of claims 1-4.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the method steps of any one of claims 1-4.

Citation Information

Patent Citations

  • Intelligent question answering method, apparatus, computer device and storage medium

    CN109522393A

  • Intelligent question and answer method and system combining retrieval and generation

    CN112364150A

  • Statement matching method, statement matching device and intelligent equipment

    CN113139034A

  • Chinese language processing method and device based on neural network model

    CN114185931A