Methods and equipment for handling form-based question-and-answer tasks

By filtering out the target table that matches the query information from multiple data tables and performing SQL statement transformation, the inefficiency of the NL2SQL model in complex scenarios is solved, and faster table-based question-and-answer response is achieved.

CN115577085BActive Publication Date: 2026-06-02ALIBABA (CHINA) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ALIBABA (CHINA) CO LTD
Filing Date
2022-10-17
Publication Date
2026-06-02

Smart Images

  • Figure CN115577085B_ABST
    Figure CN115577085B_ABST
Patent Text Reader

Abstract

This application provides a method and apparatus for processing table-based question-and-answer tasks. The method, based on user-input query information, filters out target tables matching the query information from multiple data tables in the table-based question-and-answer task. This significantly reduces the number of target tables and the total number of columns, enabling precise filtering and location of the data tables involved in the current query. Furthermore, the query information is converted into a first SQL statement based on the target table, improving the efficiency of converting query information into SQL statements. This, in turn, improves the efficiency of table-based question-and-answer processing, shortens response time, and enhances the timeliness of user responses.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to artificial intelligence technology, and more particularly to a method and device for processing table-based question-and-answer tasks. Background Technology

[0002] Table-based question answering (CQA) engines are question-answering engines that provide answers based on table content using natural language processing technology. They are the core dialogue engines in table-based CQA products such as intelligent customer service chatbots, primarily involving technologies such as NL2SQL (Natural Language to SQL) and SQL (Structured Query Language) execution. Table-based CQA chatbots rely on using the NL2SQL model to convert user-input questions into SQL statements, and then executing these SQL statements to obtain the response.

[0003] Current NL2SQL models typically operate on only one table, and the number of columns in the table is limited (usually a dozen or so). In most business scenarios, multiple tables exist, working together to serve users. Often, these tables are merged into a single table with more columns to accommodate the NL2SQL model and implement table-based question-and-answer functionality. However, the NL2SQL model has many parameters. In complex business scenarios with a large number of columns, converting user queries into SQL statements using the NL2SQL model is time-consuming, resulting in low efficiency, long response times, and untimely user feedback in table-based question-and-answer systems. Summary of the Invention

[0004] This application provides a method and device for processing table-based question-and-answer tasks, which solves the problems of low efficiency, long response time, and untimely response to users in complex business scenarios with a large number of table columns.

[0005] On the one hand, this application provides a method for processing a form-based question-and-answer task, including:

[0006] Obtain the query information entered by the user;

[0007] Based on the query information, a target table matching the query information is selected from multiple data tables in the table-based question-and-answer task.

[0008] The query information is converted into a first SQL statement based on the target table;

[0009] Execute the first SQL statement to query the target table and obtain the query result data corresponding to the query information.

[0010] On the other hand, this application provides a processing apparatus for a form-based question-and-answer task, comprising:

[0011] The information acquisition module is used to acquire the query information input by the user;

[0012] The table selection module is used to filter out the target table that matches the query information from multiple data tables in the table-based question-and-answer task.

[0013] The conversion module is used to convert the query information into a first SQL statement based on the target table;

[0014] The query module is used to execute the first SQL statement to query the target table and obtain the query result data corresponding to the query information.

[0015] On the other hand, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;

[0016] The memory stores computer-executed instructions;

[0017] The processor executes computer execution instructions stored in the memory to implement the method described in the first aspect.

[0018] On the other hand, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method described in the first aspect.

[0019] The table question-and-answer task processing method and device provided in this application, by filtering out target tables that match the query information from multiple data tables in the table question-and-answer task based on the query information input by the user, greatly reduces the number of target tables and the total number of columns after filtering, and achieves accurate filtering and positioning of the data tables involved in this round of query. Furthermore, the query information is converted into a first SQL statement based on the target table, which can improve the efficiency of converting query information into SQL statements, thereby improving the efficiency of table question-and-answer, shortening the response time, and improving the timeliness of response to users. Attached Figure Description

[0020] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0021] Figure 1 This is a schematic diagram of an example network architecture on which this application is based;

[0022] Figure 2 A flowchart of a form-based question-and-answer method provided as an exemplary embodiment of this application;

[0023] Figure 3A flowchart of a form-based question-and-answer method provided as an exemplary embodiment of this application;

[0024] Figure 4 A framework diagram for generating SQL statements corresponding to query information based on semantic rules, provided for an exemplary embodiment of this application;

[0025] Figure 5 A flowchart of a table-based question-and-answer method including table selection intervention is provided for an exemplary embodiment of this application;

[0026] Figure 6 A flowchart for generating response information provided as an exemplary embodiment of this application;

[0027] Figure 7 A framework diagram for generating response information with an added response intervention mechanism provided for an exemplary embodiment of this application;

[0028] Figure 8 A general architecture diagram of a table-based question-and-answer format provided for an exemplary embodiment of this application;

[0029] Figure 9 A schematic diagram of the structure of a form question-and-answer task processing device provided in an example embodiment of this application;

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

[0031] The accompanying drawings have illustrated specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to specific embodiments. Detailed Implementation

[0032] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0033] First, let me explain the terms used in this application:

[0034] Table-based question answering: This is for Natural Language (NL) questions, and provides answers based on the content of a table using natural language technology.

[0035] NL2SQL (Natural Language to SQL) is an abbreviation for converting natural language into Structured Query Language (SQL) statements. Essentially, it transforms the user's natural language into a standardized semantic representation that a computer can understand.

[0036] Relational Database: A database that uses a relational model to organize data, storing data in rows and columns for easy user understanding.

[0037] Elasticsearch (ES for short) is a search server built on top of Lucene. It provides a distributed, multi-user, full-text search engine. Developed in Java and released as open source under the Apache License, Elasticsearch is a popular enterprise-grade search engine.

[0038] Trie (or Trie Tree): Also known as a word lookup tree, it is a tree-like structure and a variant of a hash tree.

[0039] Table-based question answering (CQA) engines are question-answering engines that provide answers based on table content using natural language processing (NLP) technology. They are the core dialogue engines in table-based CQA products such as intelligent customer service chatbots, and primarily involve technologies such as NL2SQL and SQL (Structured Query Language) execution. Table-based CQA chatbots rely on the NL2SQL model to convert user-input questions into SQL statements, and then execute these SQL statements to obtain the response.

[0040] In most business scenarios, multiple tables are typically used together to serve users, but a user's question usually only involves one table at a time. For example, in a furniture e-commerce scenario, there might be separate tables storing data related to tables, TV cabinets, curtains, and lighting fixtures. A user's question might be "the size information of the dining table," which involves data from the table for "tables" and not other tables. Currently, NL2SQL models usually only work on one data table. Multiple data tables are often merged into a single table with more columns to adapt to the NL2SQL model and implement table-based question-and-answer functionality. However, NL2SQL models have many parameters, and processing based on tables with many columns can lead to performance issues. In complex business scenarios with many table columns, converting user questions into SQL statements using the NL2SQL model is time-consuming, resulting in low efficiency, long response times, and untimely user responses in table-based question-and-answer systems.

[0041] Furthermore, in some complex business scenarios, the number of data tables may reach dozens, with hundreds of columns, far exceeding the column limit supported by existing NL2SQL models. A single chatbot cannot implement table-based question-and-answer functionality in complex scenarios. In such cases, multiple chatbots need to be implemented, and a scheduler needs to be added to schedule multiple chatbots to retrieve query results data based on different tables. The scheduler then identifies the correct query results data based on the chatbots' feedback, which is prone to misidentification, costly, and none of the chatbots records the complete end-to-end table-based question-and-answer process, making later maintenance very unfriendly.

[0042] The table-based question-answering method provided in this application identifies entity information contained in the user-input query information, generates at least one first SQL statement corresponding to the query information based on the entity information, selects the data table involved in the first SQL statement from multiple data tables in the table-based question-answering task as the target table matching the query information, i.e., the target table involved in this round of query, converts the query information into a second SQL statement based only on the target table, and obtains the SQL statement converted from the query information. Based on the query information, a small number of target tables involved in this round of query are selected from a large number of data tables, eliminating interference from other irrelevant data tables. The user-input query information is converted into an SQL statement based only on a small number of target tables, which can improve the efficiency of converting to SQL statements, improve the efficiency of table-based question answering, shorten the response time, and improve the timeliness of responding to users.

[0043] For example, Figure 1 This is a schematic diagram of an example network architecture on which this application is based, as shown below. Figure 1 As shown, the network architecture includes terminals and servers.

[0044] The server can be a server cluster deployed in the cloud, a local electronic device with computing capabilities, or an Internet of Things (IoT) device. This server stores multiple data tables for the table-based question-and-answer task and an NL2SQL model, and can obtain the query information input by the user. Through pre-defined computational logic within the server, the server obtains the user-input query information, identifies the entity information contained in the query information, and generates at least one first SQL statement corresponding to the query information based on the entity information. From the multiple data tables of the table-based question-and-answer task, the data table involved in the first SQL statement is selected as the target table for this round of querying, and the query information is converted into a second SQL statement based on the target table. The second SQL statement is executed to query the target table and obtain the query result data corresponding to the query information.

[0045] The terminal can specifically be a hardware device with network communication, computing and information display functions, including but not limited to smartphones, tablets, desktop computers, and Internet of Things devices.

[0046] Through communication and interaction with the server, the terminal can upload the query information entered by the user to the server so that the server can obtain the query result data corresponding to the query information.

[0047] After the server obtains the query result data corresponding to the query information, it can send the query result data back to the terminal, or it can post-process the query result data to generate reply information and send the reply information back to the terminal.

[0048] The table-based question-and-answer method provided in this application can be implemented as products with table-based question-and-answer functions, such as chatbots and question-and-answer systems. It can be applied to table-based question-and-answer in various application scenarios / fields, such as smart education, e-commerce, finance, healthcare, and transportation.

[0049] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0050] Figure 2 This is a flowchart illustrating a form-based question-and-answer method provided as an exemplary embodiment of this application. The execution entity of the method provided in this embodiment is the server mentioned above, which can specifically be a server / cluster deployed in the cloud or locally, an IoT device, etc. Figure 2 As shown, the specific steps of this method are as follows:

[0051] Step S201: Obtain the query information input by the user.

[0052] The query information consists of natural language questions entered by the user in the table-based question-and-answer task. These questions can be text information entered by the user on the interactive interface, or text information converted from other modalities such as voice information uploaded by the user.

[0053] Step S202: Based on the query information, select the target table that matches the query information from multiple data tables in the table question and answer task.

[0054] In this embodiment, before converting the query information into an SQL statement using the NL2SQL model, a small number of data tables closely related to the query information are first selected from multiple data tables in the table-based question-and-answer task based on the content of the query information. These selected target tables are usually few in number and account for a very small proportion of the data tables in the current table-based question-and-answer task.

[0055] Step S203: Convert the query information into a first SQL statement based on the target table.

[0056] Furthermore, based on the target tables that match the query information after filtering, the NL2SQL model is used to convert the query information into SQL-like statements based on the target tables, and then the SQL-like statements are rewritten into executable first SQL statements. Compared to all data tables in the current table-based question-answering task, the number of target tables and the total number of columns after filtering are greatly reduced. Therefore, compared to the existing technology of converting query information into SQL statements based on all data tables in the current table-based question-answering task, converting query information into first SQL statements based on target tables can greatly improve the efficiency of converting query information into SQL statements.

[0057] Step S204: Execute the first SQL statement to query the target table and obtain the query result data corresponding to the query information.

[0058] After obtaining the query results, these results can be returned to the user. For example, the results can be output in a table format as a response.

[0059] After obtaining the query results data corresponding to the query information, a reply script can be generated based on the query results data and then fed back to the user.

[0060] In this embodiment, by filtering out the target table that matches the query information from multiple data tables in the table-based question-and-answer task according to the query information, the query information is converted into a first SQL statement based on the target table. This greatly reduces the total number of columns in the data tables on which the NL2SQL model is based, thereby improving the efficiency of converting query information into SQL statements. This can improve the efficiency of table-based question-and-answer, shorten the response time, and improve the timeliness of responding to users.

[0061] In an optional embodiment, in step S202 above, the column names and column values ​​(i.e., table values) contained in the query information can be identified, and the data table containing the column names and column values ​​contained in the query information can be determined as the target table that matches the query information, i.e., the target table involved in this round of query.

[0062] Figure 3This is a flowchart of a table-based question-and-answer method provided in an exemplary embodiment of this application. Considering that the number of data tables containing column names and values ​​in the query information is still relatively large, in order to more accurately locate the target table involved in this round of querying, in an optional embodiment, step S202 above can also identify entity information contained in the query information and generate at least one second SQL statement corresponding to the query information based on the entity information; among the multiple data tables in the table-based question-and-answer task, the data table involved in the second SQL statement is selected as the target table matching the query information. This is a process of selecting a table based on semantic rules.

[0063] like Figure 3 As shown, the specific steps of the table-based question-and-answer method provided in this embodiment are as follows:

[0064] Step S301: Obtain the query information input by the user.

[0065] Step S302: Identify the entity information contained in the query information, and generate the second SQL statement corresponding to the query information based on the entity information.

[0066] This step identifies entity information contained in the query information, such as column names, column values, aggregate functions, operators, and connectors.

[0067] Specifically, this step first identifies the entity information contained in the query information by recognizing the possible slots and their locations in the user-input query information; then, the entity information is concatenated according to the location of the corresponding slot to obtain the possible query result clause (the select part of the SQL statement) and query condition clause (the where part of the SQL statement); finally, the SQL statement is generated based on the query result clause and the query condition clause to obtain the second SQL statement corresponding to the query information.

[0068] In this step, semantic parsing of the query information input by the user generates a second SQL statement corresponding to the query information. Based on the second SQL statement corresponding to the query information, the data tables involved in the query information can be accurately filtered out.

[0069] Step S303: In the multiple data tables of the table-based question-and-answer task, select the data table involved in the second SQL statement as the target table that matches the query information.

[0070] After generating the second SQL statement corresponding to the query information, the data tables involved in the second SQL statement (including the data tables involved in the query condition clause and the data tables involved in the query result clause) are used as the target tables to match the query information, so as to achieve accurate filtering and positioning of the data tables involved in this round of query.

[0071] Step S304: Convert the query information into a first SQL statement based on the target table.

[0072] Based on the target table that matches the query information after filtering, the NL2SQL model is used to convert the query information into a first SQL statement based on the target table. Compared with all data tables in the current table-based question-and-answer task, the number of target tables and the total number of columns after filtering are greatly reduced. Therefore, compared with the existing technology of converting query information into SQL statements based on all data tables in the current table-based question-and-answer task, converting query information into a first SQL statement based on the target table can greatly improve the efficiency of converting query information into SQL statements.

[0073] Step S305: Execute the first SQL statement to query the target table and obtain the query result data corresponding to the query information.

[0074] In this embodiment, by identifying the entity information contained in the query information input by the user, and generating a second SQL statement corresponding to the query information based on the entity information, the second SQL statement corresponding to the query information is generated using semantic parsing. In a large number of tables in the table-based question-and-answer task, the data table involved in the second SQL statement corresponding to the query information is taken as the target table that matches the query information. The number of target tables and the total number of columns after filtering are greatly reduced, achieving accurate filtering and positioning of the data tables involved in this round of query. Furthermore, converting the query information into a first SQL statement based on the target table can greatly improve the efficiency of converting the query information into an SQL statement.

[0075] In an optional embodiment, in step S302 above, the entity information identified in the query information includes column names, column values, aggregate functions, operators, and connectors. Column names and column values ​​are dynamically changing business configuration data. Considering the large volume of column names and values ​​in practical applications, a search engine can be used to roughly recall candidate column names and values ​​that the query information may contain. Then, the column names and values ​​contained in the query information can be precisely determined from the candidate column names and values. Specifically, this can be achieved using the following steps S3021-S3022:

[0076] Step S3021: In the search engine that stores the column names and column values ​​of multiple data tables containing the table-based question-and-answer task, search for candidate column names and candidate column values ​​that the query information may contain based on the matching degree with the query information.

[0077] The search engine can be ES (Elasticsearch) or other engines that can achieve fast search.

[0078] Taking Elasticsearch (ES) as an example, ES stores the column names and values ​​of all data tables for the current table-based question-and-answer task, and configures preset conditions for coarse recall. In this step, candidate column names and values ​​that meet the preset conditions are recalled from the search engine.

[0079] It should be noted that the preset conditions set the conditions that the candidate column names and candidate column values ​​must meet. The conditions that the candidate column names must meet are different from the conditions that the candidate column values ​​must meet, and they can be configured separately.

[0080] In this embodiment, the matching degree between column name / column value and query information can be the number of matched characters or other information that can measure the semantic similarity between texts. This embodiment does not make specific limitations here.

[0081] Optionally, in a search engine storing column names and column values ​​of multiple data tables containing table-based question-and-answer tasks, when searching for candidate column names that may be included in the query information based on their matching degree with the query information, the search engine can search for candidate column names whose matching degree with the query information is greater than or equal to a first matching degree threshold, so as to coarsely recall a larger number of candidate column names that may be included in the query information.

[0082] The first matching threshold is set to a relatively low value to coarsely recall a larger number of candidate column names. The first matching threshold can be set and adjusted according to the needs of the actual application scenario, and no specific limitation is made here.

[0083] For example, the matching degree between the column name and the query information can be the number of matching characters. The first matching degree threshold can be set to 1, that is, a column name that matches at least 1 character with the query information can be recalled as a candidate column name.

[0084] Optionally, in a search engine storing column names and column values ​​of multiple data tables containing table-based question-and-answer tasks, when searching for candidate column names that may be included in the query information based on their matching degree with the query information, the column names in the search engine can be sorted according to their matching degree with the query information. Based on the column name sorting results, candidate column names with at least a column name recall threshold can be determined to coarsely recall a large number of candidate column names that may be included in the query information.

[0085] The column name recall threshold can be several dozen, which is a relatively large value, to coarsely recall a large number of candidate column names. The specific value of the column name recall threshold can be set and adjusted according to the needs of the actual application scenario, and no specific limit is set here.

[0086] For example, the matching degree between column names and query information can be the number of matched words. Column names can be sorted in descending order based on the number of matched words between column names and query information. Based on the sorting result, candidate column names with more matched words are selected to meet the recall threshold.

[0087] Optionally, in a search engine storing column names and values ​​of multiple tables containing table-based question-and-answer tasks, when searching for candidate column values ​​that may be included in the query information based on their matching degree with the query information, the column values ​​in the search engine can be grouped according to their table and column; the column values ​​within each group can be sorted according to their matching degree with the query information; and candidate column values ​​with a minimum recall threshold can be determined within each group based on the column value sorting results, thereby recalling at least the minimum recall threshold of the column value group in each group to coarsely recall a large number of candidate column values ​​that may be included in the query information.

[0088] Specifically, when grouping column values ​​in the search engine according to their table and column, grouping is done by table and by column. Column values ​​from different data tables are in different groups, and values ​​from different columns within the same data table are in different groups. If multiple identical column values ​​exist within the same column of the same data table, deduplication is performed during grouping to ensure that there are no duplicate column values ​​in the same group, which can improve the efficiency of recalling candidate column values.

[0089] Furthermore, when recalling candidate column values ​​that meet at least the recall threshold for each column value group in each group, the groups can be processed in parallel to improve the efficiency of recalling candidate column values.

[0090] The threshold for the number of items recalled by column name can be 10, 20, etc., and can be set and adjusted according to the needs of the actual application scenario. No specific limit is set here.

[0091] Optionally, in a search engine storing column names and values ​​of multiple data tables containing table-based question-and-answer tasks, when searching for candidate column values ​​that may be included in the query information based on their matching degree with the query information, a method similar to searching for candidate column names can be used. Based on the matching degree between the column values ​​and the query information, candidate column values ​​with a matching degree greater than or equal to a second matching degree threshold can be searched in the search engine. Alternatively, the column values ​​in the search engine can be sorted according to their matching degree with the query information, and candidate column values ​​with at least a column value recall threshold can be determined based on the column value sorting results to coarsely recall a larger number of candidate column values ​​that may be included in the query information.

[0092] The second matching threshold can be the same as or different from the first matching threshold. The column value recall threshold is greater than the column name recall threshold. The second matching threshold and the column value recall threshold can be configured and adjusted according to the actual application scenario, and no specific restrictions are made here.

[0093] Step S3022: Determine the column names included in the query information from the candidate column names, and determine the column values ​​included in the query information from the candidate column values.

[0094] After recalling candidate column names, the column names included in the query information are precisely determined from the candidate column names. After recalling candidate column values, the column values ​​included in the query information are precisely determined from the candidate column values.

[0095] The overall process for identifying column names and values ​​in a query includes: preprocessing, coarse recall, and post-processing. Preprocessing involves segmenting the table data for the current table-based question-and-answer task according to a preset segmentation protocol and storing it in the search engine. During coarse recall, the query information is also segmented according to the preset segmentation protocol, and candidate column names and values ​​are coarsely recalled from the search engine based on the segmentation results. Post-processing precisely determines the column names and values ​​contained in the query information. The preset segmentation protocol can adopt text segmentation methods commonly used in coarse recall; its specific configuration and adjustment are not limited here.

[0096] For example, taking the matching degree between column names / values ​​and query information as the number of matched characters as an example, during preprocessing, each column name and each column value in the table data is segmented into individual characters (such as a Chinese character or an English word) and stored in Elasticsearch. During coarse recall, the query information is also segmented into individual characters, and based on the segmentation results, column names that match the query information by at least one character are coarsely recalled in the search engine as candidate column names; the column names contained in the query information are then precisely determined from the candidate column names.

[0097] Furthermore, in practical applications, some column names (headers) have diverse descriptions. For example, "Fund Name" could have synonyms such as "Fund Abbreviation," "Fund Product Name," or "Fund Name." This embodiment can also incorporate a column name intervention mechanism to configure synonyms for one or more column names. During the coarse recall of candidate column names, if the query information matches any synonym of a column name, it is considered that the query information matches the column name. When precisely determining whether the query information contains a candidate column name, if the query information contains a synonym of a candidate column name, it is considered that the query information contains the candidate column name.

[0098] Similarly, in practical applications, column values ​​may also have synonyms. For example, the column "color" has a value of "multicolored," and possible synonyms include "colorful" and "patterned." This embodiment can also incorporate a column value intervention mechanism to configure synonyms for one or more column values. During the coarse recall of candidate column values, if the query information matches any synonym of a column value, it is considered that the query information matches the column value. When precisely determining whether the query information contains a candidate column value, if the query information contains a synonym of a candidate column value, it is considered that the query information contains the candidate column value.

[0099] In step S302 above, the entity information included in the query information also includes aggregate functions, operators, and connectors. These are aggregate functions, operators, and connectors used in structured query language, and are static entity information that generally does not change. The possible queries for this static entity information can be enumerated, and the data volume is not large. Therefore, a trie approach can be used to identify the aggregate functions, operators, and connectors included in the query information, thereby improving the efficiency of identifying entity information such as aggregate functions, operators, and connectors.

[0100] Specifically, we can obtain as many available queries as possible for each entity information in aggregate functions, operators, and connectors, and construct a trie tree. Identifying the aggregate functions, operators, and connectors contained in the query information can be achieved as follows: obtain the trie tree, which contains available queries for aggregate functions, operators, and connectors; search for the aggregate functions, operators, and connectors contained in the query information within the trie tree.

[0101] Optionally, available queries for aggregate functions, operators, and connectors can be stored in a key-value database, where the key is the available query and the value is the corresponding entity information (which can be an aggregate function, operator, or connector). Based on the key-value database, query information is matched against the key, thereby retrieving aggregate functions, operators, and connectors contained in the query information.

[0102] In an optional embodiment, in step S302 above, identifying the entity information contained in the query information includes multiple entity words, each entity word corresponding to an entity. After identifying the entity information contained in the query information, generating the second SQL statement corresponding to the query information based on the entity information can be achieved using the following steps S3023-S3026:

[0103] Step S3023: Concatenate the entity information to obtain the query result clause and query condition clause for this round of query.

[0104] In this step, entity concatenation can be performed according to the syntax rules of SQL statements, concatenating entity information into query result clauses and query condition clauses.

[0105] It should be noted that the current table-based question-and-answer task involves multiple data tables. During entity concatenation, query result clauses and query condition clauses are generated for each data table based on the column names and values. Concatenating the query result clauses and query condition clauses for the same data table yields a third-party SQL statement for querying that table. If the identified entity information involves multiple data tables, a third-party SQL statement can be generated for querying each of those tables.

[0106] The following explains the specific process of generating query result clauses and query condition clauses for a given data table based on the column names and values ​​belonging to the same data table in the entity information contained in the query information, as well as the aggregate functions, operators, and connectors in the entity information:

[0107] The query condition clause refers to the WHERE clause in an SQL statement. Specifically, it can be constructed as follows: 1) Determine the column names, column values, and operators; 2) If the column value's attribute supports the operator, and the text distance between the column value and the operator in the query information is less than a first distance threshold (e.g., this value is 0), and if the column name's attribute supports the operator, and the text distance between the column name and the operator in the query information is less than a second distance threshold (e.g., this value is 0), then concatenate the column name, column value, and operator into a query condition, using the column name in the query condition as the first column name; 3) Determine the logical relationships between the various query conditions; 4) Based on the logical relationships between the various query conditions, concatenate multiple query conditions into a query condition clause.

[0108] For each possible column value, first determine the possible corresponding column name information. This can be based on the distance between the column value and column name in the query information, and the relationship between the column value and column name in the data table. If a relationship can be found, retain the column value; otherwise, discard it. After determining the column value and column name, further determine whether to retain it by using the attribute of the column value (text or number) and the distance between the column value and the operator in the query information, ultimately determining the WHERE clause.

[0109] The query result clause refers to the SELECT part of the SQL statement. Specifically, it can be constructed as follows: 1) Based on the first column name and entity term, determine the second column name related to the query result clause, or the second column name and an aggregate function; 2) If the attribute of the column value corresponding to the second column name supports an aggregate function, and the text distance between the second column name and the aggregate function in the query information is less than a third distance threshold (e.g., this value is 0), then generate an aggregate column name based on the second column name and the aggregate function; 3) Concatenate the second column name and the aggregate column name (without an associated aggregate function) into the query result clause.

[0110] To determine the select part, you can use the column names and aggregate functions identified by entity recognition, as well as the results of the WHERE part. First, remove the column names that have already appeared in the WHERE part. Then, for each column name, associate it with the aggregate function. The judgment condition is the distance between the column name and the aggregate function in the text. If no association is found, it is assumed that there is no aggregate function.

[0111] Step S3024: Generate multiple third-party SQL statements based on the query result clause and query condition clause.

[0112] In this step, the query result clause and query condition clause of the same data table are concatenated to obtain a third SQL statement used to query the data table.

[0113] Specifically, using the WHERE and SELECT parts of the same data table obtained by concatenating entities, SQL is concatenated based on SQL syntax to generate a third SQL statement for querying the data table.

[0114] Optionally, to support multi-round question answering, query result clauses and query condition clauses obtained from previous rounds of queries can be retrieved. Based on the query result clauses and query condition clauses of the current round of queries and previous rounds of queries, multiple third-party SQL statements can be generated. By combining the query result clauses and query condition clauses of the current round of queries and previous rounds of queries, the target tables that match the query information can be filtered by combining information from multiple rounds of queries. This can improve the accuracy of the target table filtering involved in the current round of queries, and can realize multi-round inheritance, supporting multi-round question answering.

[0115] For example, the query result clauses and query condition clauses obtained from the previous round (or multiple historical rounds in the current session) can be retrieved; a third SQL statement can be generated based on the query result clauses and query condition clauses of the current round and the previous round (or multiple historical rounds in the current session).

[0116] Step S3025: Sort the third SQL statement according to the number of query result clauses and / or the number of query condition clauses contained in the third SQL statement.

[0117] The third SQL statement is composed of query result clauses and query condition clauses. The query result clauses and query condition clauses are composed based on the entity information contained in the query information. The more query result clauses and query condition clauses a third SQL statement contains, the higher the relevance of the third SQL statement to the query information entered by the user, and the closer it is to the user's true query intent, indicating that the quality of the third SQL statement is higher.

[0118] In this step, the third SQL statement is sorted according to the number of query result clauses and / or the number of query condition clauses it contains. The sorting result reflects the quality of the third SQL statement.

[0119] Optionally, the third SQL statements are first sorted according to the number of query condition clauses they contain. For third SQL statements with the same number of query condition clauses, they are then sorted according to the number of query result clauses they contain to obtain the final sorting result.

[0120] Optionally, the third SQL statement can be sorted according to the sum of the number of query condition clauses it contains and the total number of query condition clauses it contains, to obtain the final sorting result.

[0121] Optionally, the third SQL statement can be sorted according to the number of query condition clauses it contains to obtain the final sorting result.

[0122] Optionally, the third SQL statement can be sorted according to the number of query condition clauses it contains to obtain the final sorting result.

[0123] Step S3026: Based on the sorting result of the third SQL statement, select the third SQL statement that is less than or equal to the SQL statement quantity threshold as the second SQL statement corresponding to the query information. The SQL statement quantity threshold is a positive integer.

[0124] In this step, based on the sorting results, the third SQL statement with higher quality, which does not exceed the threshold for the number of SQL statements, is selected as the second SQL statement corresponding to the query information.

[0125] Considering that in practical applications, users usually ask questions about one or a few tables in each round of query, the threshold for the number of SQL statements can be set to a small value, such as 1, 3, 5, 6, 7, etc., to identify a small number of high-quality second SQL statements, so that the number of target tables involved in the second SQL statements is small, thereby accurately locating the target tables involved in this round of query.

[0126] For example, Figure 4 A framework diagram for generating SQL statements corresponding to query information based on semantic rules, as provided in an exemplary embodiment of this application, is shown below. Figure 4As shown, taking the user-input query "What products are gray in color, longer than 170cm, and deeper than 20cm?" as an example, entity recognition can identify the following entity information in the query: Column values: grayscale, 170, 20; Operators: greater than, equal to; Column names: color, length, depth, product name; Connector: AND. Based on the column names, data from three tables can be matched: Sofa table (containing all identified column names: color, length, depth, product name), Curtain table (containing column names: color, length, product name), and Bookshelf table (containing column names: color, depth, product name). For each table, entity information is concatenated to generate the query result clause (the select part shown in the figure) and query condition clause (the where part shown in the figure) for each table. By concatenating the query result clause (the select part shown in the figure) and query condition clause (the where part shown in the figure) for the same table according to SQL syntax rules, the SQL statement (SQL-like) based on each table can be determined.

[0127] Furthermore, considering that in practical applications, there are multiple question-and-answer types for a single column of data (i.e., a column name), such as maximum value type, equal to type, greater than type, etc., and multiple possible questions for the same question-and-answer type. For example, the equal to type can have multiple different questions such as "equal to", "is", "called", "is", etc., during the question-and-answer process, situations where recognition is not possible are inevitable. Moreover, the model training cycle is relatively long, and it cannot accurately recognize new questions when they appear. In this embodiment, during the table selection process based on semantic rules, a column question-and-answer type intervention mechanism can be combined to configure multiple questions for a column name. Configuring multiple questions for a column name takes effect immediately. When the query information matches a question for a specific question-and-answer type for a column name, a query result clause corresponding to that question for that column name is generated. This query result clause will be used as part of the generated third SQL statement.

[0128] It should be noted that the second and third SQL statements do not have to be executable SQL, but rather SQL-like statements. Based on these SQL-like statements, data table filtering can be implemented to determine the target table that matches the query information.

[0129] In an optional embodiment, environmental variable information of the user-input query information can also be obtained, and entity information contained in the environmental variable information can be identified. The environmental variable information may include other information that affects the query result data when the user inputs query information, including but not limited to information about the target object associated with the query information and the source information of the query information.

[0130] For example, when a user consults the intelligent customer service about the product they are browsing on the product details page, the question the user wants to ask is the query information entered by the user. The environment variables of the query information include the identifier (ID) of the currently viewed product, the link, and other information such as the store information of the currently viewed product.

[0131] In step S202 above, when generating the second SQL statement corresponding to the query information based on the entity information, the second SQL statement corresponding to the query information can also be generated based on the entity information contained in the environment variable information and the entity information contained in the query information. This makes the generated second SQL statement closer to the user's actual query intent, thereby enabling more accurate location of the target table involved in this round of query based on the second SQL statement.

[0132] In an optional embodiment, in steps S203 and S304 above, after filtering out the target table that matches the query information from multiple data tables in the table-based question-and-answer task, if there are multiple target tables, a virtual table is determined based on the column names of the target tables, and the virtual table contains the columns of the target tables; the query information is converted into a fourth SQL statement based on the virtual table; the fourth SQL statement is rewritten into a first SQL statement based on the target table, and each first SQL statement involves a target table.

[0133] If there are still multiple target tables after filtering, the column names of all target tables can be combined to form a virtual table. The NL2SQL model is then used to convert the query information into a fourth SQL statement based on this virtual table. This fourth SQL statement is SQL-like, not an executable SQL statement. Further, by rewriting the fourth SQL statement into multiple first SQL statements that each involve only one target table, the first SQL statement corresponding to the query information can be obtained. By executing this first SQL statement to query the target table, the query result data corresponding to the query information can be obtained.

[0134] By constructing a virtual table, the query information is converted into a fourth SQL statement based on the virtual table. Then, the fourth SQL statement is rewritten into a first SQL statement based on the actual target table, resulting in an executable first SQL statement. This eliminates the need to store all table data under the table-based question-and-answer task in a large data table, saving storage space and improving the query efficiency of the SQL statement, thereby improving the efficiency of table-based question-and-answer.

[0135] Based on any of the above embodiments, after selecting the data table involved in the second SQL statement as the target table that matches the query information from multiple data tables in the table question-and-answer task in step S303, if the total number of columns in the target table is greater than the preset column limit, steps S304-S305 are not executed, but the second SQL statement is executed, and the query result data is used as the query result data corresponding to the query information input by the user, which can improve the performance of table question-and-answer.

[0136] Based on any of the above embodiments, table selection intervention rules can be flexibly configured as needed to intervene in the table selection process in a timely manner.

[0137] In some practical applications, different data tables (such as table A and table B) share common storage characteristics. This can lead to situations where a user's query intent expects an answer for table A, but the table-based question-and-answer chatbot returns an answer for table B. To address this, configuration of table selection intervention rules is supported. These rules specify the exact question to ask when querying that table. When a query contains a specific question from the table selection intervention rule, the query is considered a match, and that table is directly selected as the target table matching the query.

[0138] Figure 5 A flowchart illustrating a table-based question-and-answer method including table selection intervention, provided as an exemplary embodiment of this application. Figure 5 As shown, the specific steps of this method are as follows:

[0139] Step S501: Obtain the query information input by the user.

[0140] Step S502: Determine whether the query information matches the table selection intervention rules.

[0141] In this embodiment, one or more table selection intervention rules can be configured for each data table. Each data table's table selection intervention rule can be configured to query one or more specific queries for that data table. When the query information contains any specific query from the table selection intervention rule for that data table, it is determined that the query information matches that table selection intervention rule.

[0142] If the query information matches the table selection intervention rule, then step S503 is executed to determine the target table that matches the query information.

[0143] If the query information does not match the table selection intervention rule, then execute steps S504-S505 to determine the target table that matches the query information.

[0144] Step S503: Use the data table corresponding to the table selection intervention rule matched by the query information as the target table that matches the query information.

[0145] Step S504: Identify the entity information contained in the query information, and generate the second SQL statement corresponding to the query information based on the entity information.

[0146] Step S505: In the multiple data tables of the table-based question-and-answer task, select the data table involved in the second SQL statement as the target table that matches the query information.

[0147] Step S506: Convert the query information into a first SQL statement based on the target table.

[0148] Step S507: Execute the first SQL statement to query the target table and obtain the query result data corresponding to the query information.

[0149] Step S508: Query the query result data corresponding to the query information and generate the response information.

[0150] In this embodiment, the implementation of steps S504-S507 is the same as that of steps S302-S305. For details, please refer to the relevant content of the above embodiment, which will not be repeated here.

[0151] Based on any of the above embodiments, the source channel intervention rules for query information can be flexibly configured as needed. In many practical application scenarios of table-based Q&A, channel segmentation is supported, with different channels specifying data tables or columns for intelligent Q&A, while information from other data tables or other unspecified columns cannot be queried. For example, intelligent customer service can provide channels that implement different types (Q&A with different functions) (e.g., using 0, 1, 2 to represent different channels) for users to choose from. After the user selects one type of channel (e.g., the user selects 1), for the query information entered by the user, the query result data is only retrieved from the specified data table or specified column corresponding to that channel.

[0152] In this scenario, source channel intervention rules for query information are supported. A source channel intervention rule configures the specified data tables or columns that are allowed to be queried by that source channel; that is, the data table or specified column corresponding to the source channel. If the query information has a source channel, and that source channel has configured source channel intervention rules, then using the data table or specified column corresponding to that source channel as the target table or target column to match the query information can improve the efficiency of selecting the target table involved in this round of querying.

[0153] Specifically, a specific channel set with source channel intervention rules can be configured, along with a data table and designated columns corresponding to each specific source channel within the set. After obtaining the user's input query information, before step S302, it is determined whether the configured specific channel set contains the source channel of the query information, based on the source channel of the user's input query information. If the specific channel set contains the source channel of the query information, the data table or designated column corresponding to the source channel of the query information is used as the target table or target column matching the query information.

[0154] If a specific channel set does not contain the source channel of the query information, then by executing step S302 to identify the entity information contained in the query information and subsequent steps, the target table that matches the query information is selected from multiple data tables of the table question-and-answer task.

[0155] Based on any of the above embodiments, end-to-end SQL intervention rules can be flexibly configured as needed. In some practical applications, users ask unusual questions and expect specific responses. The SQL queries generated by the NL2SQL model for these unusual questions are often inaccurate. In such cases, end-to-end SQL intervention rules can be configured for specific questions, each containing a corresponding SQL statement. When a query contains a specific question from an end-to-end SQL intervention rule, it is determined that the query matches that rule. The SQL statement corresponding to the rule is then used as the first SQL statement for the query, and executing this statement retrieves the query results and generates a response.

[0156] Specifically, after obtaining the user's query information, before filtering out the target table matching the query information from multiple data tables in the table-based question-and-answer task, it is determined whether the query information matches an end-to-end SQL intervention rule. If the query information matches an end-to-end SQL intervention rule, the SQL statement corresponding to the matching rule is executed. If the query information does not match an end-to-end SQL intervention rule, the process of filtering out the target table matching the query information from multiple data tables in the table-based question-and-answer task, and subsequent steps, is executed.

[0157] By configuring end-to-end SQL intervention rules for unusual user queries in certain scenarios, the accuracy of tabular question-and-answer results data in these scenarios can be improved, and problems in special scenarios can be solved.

[0158] Based on any of the above embodiments, in this embodiment, response intervention rules can also be configured to intervene in the response information generated based on the query result data, so that the generated response information is more fluent and more in line with human speaking habits.

[0159] Specifically, one or more response templates can be configured. Each response template includes one or more response segments. The format information of the response segments can be configured in the response template, as well as the pre-response and / or post-response scripts for each segment. If multiple response segments are included, the transition scripts between the response segments can also be configured in the response template. Response segments include result segments and conditional segments. Each response template can include result segments and / or conditional segments.

[0160] The condition fragment corresponds to the query conditions in the user-input query information. By adding condition fragments to the response template, the query conditions can be displayed in the response content, and flexible configuration of column names and wording within the condition fragment is supported. The result fragment corresponds to the query result data. By configuring the format information of the result fragment in the response template, the display format of the query result data in the response content can be configured, and flexible configuration of column names and conditions within the result fragment is also supported.

[0161] Figure 6 A flowchart illustrating the generation of response information provided for an exemplary embodiment of this application. See also... Figure 6 In one optional embodiment, after executing the first SQL statement to query the target table and obtaining the query result data corresponding to the query information, the specific process for generating response information based on the query result data is as follows:

[0162] Step S600: Execute the first SQL statement to query the target table and obtain the query result data corresponding to the query information.

[0163] Step S601: Determine whether the first SQL statement matches the response template.

[0164] The reply template is configured with the format information of the reply fragments included in the reply information. The reply fragments include result fragments and / or condition fragments.

[0165] In this step, the column names contained in the first SQL statement are matched with the column names in the configured response template, and the first SQL statement is determined to match (i.e., hit) the response template according to the preset matching rules.

[0166] In this embodiment, to reduce the number of response templates that need to be configured and to improve the applicability of the response templates, the response templates may include mandatory and optional response segments, and the response templates are configured with information indicating whether a response segment is mandatory. The hit rules for the response templates include:

[0167] 1) All required reply segments in the reply template must be included;

[0168] 2) If the response template contains multiple conditional segments connected by "or", then it is necessary to hit one of the multiple conditional segments connected by "or", and only one of the multiple conditional segments connected by "or" can be hit.

[0169] 3) Optional reply fragments may or may not be selected;

[0170] 4) If multiple response templates are matched simultaneously, the response templates will be sorted according to the following priority strategy, and one response template will be selected as the final matched response template based on the sorting result:

[0171] a) Reply templates that hit the required reply segment have higher priority than those that hit the optional reply segment;

[0172] b) For response templates that all hit the required response segments, the response templates that hit fewer non-required response segments have higher priority;

[0173] c) For response templates that all hit the required response segments and have the same number of hit non-required response segments, the response template with fewer hit response segments has higher priority.

[0174] For example, suppose the first SQL statement is: `select a, b where c, d`. The matched response template 1 contains the following response fragments: `a, b, c, d, e`, where `e` is an optional response fragment, and `a, b, c, d` are required response fragments. The matched response template 2 contains the following response fragments: `a, b, c, d`, where `a, b, c, d` are all required response fragments. For both response templates 1 and 2, the first SQL statement matched all required response fragments. The first SQL statement matched one non-required response fragment from response template 1, and zero non-required response fragments from response template 2. Since the first SQL statement matched fewer non-required response fragments from response template 2, based on b) above, it can be determined that for the given first SQL statement, response template 2 has a higher priority than response template 1, and response template 2 is chosen as the matched response template for the first SQL statement.

[0175] The phrase "the first SQL statement hits the response fragment" means that the column names contained in the first SQL statement match the columns in the response fragment. Specifically, it means that the first SQL statement contains the column names of the columns involved in the response fragment.

[0176] In this step, if the first SQL statement matches the response template, then step S602 is executed to generate response information from the query result data according to the format of the response template.

[0177] If the first SQL statement fails to match a reply template, a reply fragment is generated based on the query result data according to the configured default reply generation rule, and the reply fragment is assembled into a reply message.

[0178] Step S602: If the first SQL statement matches a reply template, a reply message is generated based on the query result data and the reply template.

[0179] The reply template is spliced by reply fragments, connecting words, preface words, and postscript words in a certain format. The reply fragment is spliced by column names (or synonyms of column names), custom words, and column values in a certain format. When generating a reply message based on the query result data and the reply template, the column values in the query result data are inserted into the corresponding column value positions in the reply fragment of the reply template to generate the corresponding reply message.

[0180] Step S603: If the first SQL statement fails to match a reply template, a reply fragment is generated based on the query result data, and the reply fragment is assembled into a reply message.

[0181] If the first SQL statement fails to match a reply template, according to the configured default reply generation rule, the query result clause and query result data in the first SQL statement are converted into text information to obtain a result fragment; the query condition clause in the first SQL statement is converted into natural language text information to obtain a condition fragment, and the condition fragment and the result fragment are spliced by connecting words to obtain a reply message.

[0182] Exemplarily, see Figure 7 , Figure 7 shows a framework diagram of reply message generation with a reply intervention mechanism. Taking the query information entered by the user as "What are the medium-risk products" as an example, the SQL-like expression of the first SQL statement generated can be: select fund name from wealth management information table where risk level = medium risk. The query result data queried according to the first SQL statement is as shown in Figure 7 . Based on the hit rule of the reply template, if the first SQL statement fails to match a reply template, a reply message is generated based on the default reply generation rule. The reply fragment (i.e., the result fragment) corresponding to the query result clause in the select part is generated as "The fund names are Healthcare Stock A and Strategic Allocation Hybrid", and the reply fragment (i.e., the condition fragment) corresponding to the query condition clause in the where part is generated as "The risk level is equal to medium risk". The reply fragments are spliced by the connecting word "of" to obtain the reply message "The fund names with a risk level equal to medium risk are Healthcare Stock A and Strategic Allocation Hybrid". Based on the hit rule of the reply template, if the first SQL statement matches a reply template, the matched reply template is as shown in Figure 7As shown in the image, the "[]" in the condition and result segments of the response template represents customizable information. By filling the table values ​​from the query results into the corresponding table value positions in the response segments of the response template, a response message conforming to the template's format can be generated.

[0183] Additionally, the response template can be configured to specify whether a response fragment is displayed in the response information. If a response fragment in a response template is configured not to be displayed in the response information, then when the first SQL statement matches the response template and generates the response information based on the response template, the response information will not include the response fragment configured not to be displayed in the response information.

[0184] In this embodiment, a response intervention rule is introduced. By configuring a response template, the format of the response information can be customized. When the first SQL statement corresponding to the query information matches the response template, the response information is generated according to the response template, making the generated response information more fluent and more in line with human speaking habits, thereby effectively improving the quality of the response information.

[0185] For example, Figure 8 A general architecture diagram of a form-based question-and-answer system provided for an exemplary embodiment of this application, as shown below. Figure 8 As shown, the table-based question-and-answer system is generally divided into several modules: preprocessing, Natural Language Understanding (NLU), Dialogue Manager (DM), Natural Language Generation (NLG), and postprocessing.

[0186] The preprocessing module is responsible for loading the dialogue context, table metadata, intervention configuration information, and multi-turn configuration information. Table metadata includes the table name, column names, and column attributes. Intervention configuration information contains the relevant configuration information for each intervention mechanism. Multi-turn configuration information includes whether multi-turn question-and-answer is supported.

[0187] The Natural Language Understanding module is responsible for table selection, NL2SQL model recognition, and post-processing of recognition results. Table selection refers to filtering the target tables involved in the current query. If table selection intervention rules are configured, the SQL statement corresponding to the query information is directly determined based on the matched rules when the query information matches them. If the query information does not match the matched rules, a second SQL statement is generated based on semantic rules. Specifically, entity recognition is performed on the query information, and the second SQL statement is generated by concatenating the identified entities. The target tables that match the query information are then selected based on the second SQL statement, which are the target tables involved in the current query. NL2SQL model recognition constructs a virtual table based on the selected target tables, serving as the table for the NL2SQL model. The NL2SQL model is used to recognize the query information and convert it into a SQL-like structure based on the virtual table. Post-processing of recognition results includes functions such as SQL merging, multi-round inheritance, SQL sorting, and SQL correction. SQL merging can combine multiple SQL statements based on the same table into a single SQL statement. Multi-round inheritance, in a configuration supporting multi-round question answering, allows the inheritance of query result clauses and condition clauses from previous rounds of SQL statements during the semantic rule-based table selection process, as well as other information that needs to be inherited from previous rounds. SQL sorting, in the semantic rule-based table selection process, sorts multiple generated third-party SQL statements to select the higher-quality third-party SQL statement as the second SQL statement used to filter the target table. SQL correction refers to the ability to correct the SQL-like statements generated using the NL2SQL model based on the second SQL statement used to filter the target table, thereby improving the quality of the SQL-like statements.

[0188] The Dialogue Management (DM) module implements SQL rewriting and SQL execution. SQL rewriting includes functions such as executable SQL transformation, multi-table SQL rewriting, and expression SQL rewriting. Executable SQL transformation refers to converting SQL-like statements (such as the second SQL statement corresponding to the query information, or SQL-like statements generated using the NL2SQL model) into executable SQL statements. Multi-table SQL rewriting involves rewriting SQL statements based on virtual tables (the fourth SQL statement) generated using the NL2SQL model into first SQL statements based on multiple existing target tables. Expression SQL rewriting refers to rewriting dynamic columns in SQL statements to make the rewritten SQL statements executable.

[0189] The Natural Language Generation (NLG) module is used to generate response information to be displayed to the user based on the query results. Specifically, if response intervention rules are introduced, i.e., response templates are configured, before generating the response information, it is first determined whether the first SQL statement corresponding to the query results matches the response template. If no response template is matched, the response information is generated based on the default response generation rules. If a response template is matched, the response information is generated in a format that conforms to the response template. Furthermore, when generating the response information, the query results can be displayed in a table format to generate a table-based response, or the query results can be displayed in text format to generate a text-based response.

[0190] The post-processing module implements the functions of updating the dialogue context and encapsulating the results.

[0191] In the table-based question-answering process, this solution employs a rule-based semantic table selection scheme in the NLU module. This enables the chatbot based on table-based question-answering tasks to support table-based question-answering for multiple business tables without any performance issues, thus providing a fundamental guarantee for system scalability.

[0192] In practical applications, as artificial intelligence (AI) products, table-based question-and-answer (Q&A) products inevitably experience performance issues. This application's embodiments support combining one or more intervention mechanisms. The architecture of table-based Q&A requires intervention in two categories: the identification process and the response process. Throughout the entire lifecycle of table-based Q&A, from basic to advanced interventions, interventions in the identification process include: table selection intervention, table header intervention (column name synonym intervention), column value intervention, column question-and-answer type intervention, end-to-end SQL intervention, environment variable intervention, and source channel intervention. Response intervention addresses the response process. Throughout the entire table-based Q&A process, including NLU and NLG, rapid intervention solutions are provided, making the industrialization of table-based Q&A possible.

[0193] Figure 9 This is a schematic diagram of a processing apparatus for a table-based question-and-answer task provided in an example embodiment of this application. The apparatus provided in this embodiment is used to execute a method for processing table-based question-and-answer tasks. Figure 9 As shown, the processing device 90 for the table question-and-answer task includes: an information acquisition module 91, a table selection module 92, a conversion module 93, and a query module 94.

[0194] Among them, the information acquisition module 91 is used to acquire the query information input by the user.

[0195] The table selection module 92 is used to filter out the target table that matches the query information from multiple data tables in the table-based question-and-answer task.

[0196] The conversion module 93 is used to convert query information into a first SQL statement based on the target table.

[0197] The query module 94 is used to execute the first SQL statement to query the target table and obtain the query result data corresponding to the query information.

[0198] In an optional embodiment, when implementing the process of filtering out a target table that matches the query information from multiple data tables in a table-based question-and-answer task, the table selection module 92 is further configured to:

[0199] Identify the entity information contained in the query information and generate a second SQL statement corresponding to the query information based on the entity information; select the data table involved in the second SQL statement from multiple data tables in the table-based question-and-answer task as the target table that matches the query information.

[0200] In an optional embodiment, when implementing the identification of entity information contained in the query information, the table selection module 92 is further configured to:

[0201] In a search engine that stores column names and values ​​of multiple tables containing table-based question-and-answer tasks, candidate column names and values ​​that the query information may contain are searched based on their matching degree with the query information; the column names contained in the query information are determined from the candidate column names, and the column values ​​contained in the query information are determined from the candidate column values.

[0202] In an optional embodiment, in a search engine implementing column names and column values ​​of multiple data tables storing table-based question-and-answer tasks, when searching for candidate column names that may be included in the query information based on the degree of matching with the query information, the table selection module 92 is further configured to:

[0203] Based on the matching degree between the column name and the query information, search for candidate column names in the search engine whose matching degree with the query information is greater than or equal to a first matching degree threshold; or, based on the matching degree between the column name and the query information, sort the column names in the search engine, and determine candidate column names with at least a column name recall quantity threshold based on the column name sorting results.

[0204] In an optional embodiment, in a search engine implementing column names and values ​​of multiple data tables storing table-based question-and-answer tasks, when searching for candidate column values ​​that may be included in the query information based on the degree of matching with the query information, the table selection module 92 is further configured to:

[0205] Group the column values ​​in the search engine according to the table and column they belong to; sort the column values ​​in each group according to the matching degree between the column values ​​and the query information; and determine candidate column values ​​within each group that meet at least the column value group recall threshold based on the column value sorting results.

[0206] In an optional embodiment, when implementing the identification of entity information contained in the query information, the table selection module 92 is further configured to:

[0207] Retrieve the trie, which contains available queries for aggregate functions, operators, and connectors; search within the trie for aggregate functions, operators, and connectors included in the query.

[0208] In an optional embodiment, when generating the second SQL statement corresponding to the query information based on the entity information, the table selection module 92 is further configured to:

[0209] The entity information is concatenated to obtain the query result clause and query condition clause for this round of query; a third SQL statement is generated based on the query result clause and query condition clause, and different third SQL statements involve different data tables; the third SQL statements are sorted according to the number of query result clauses and / or the number of query condition clauses contained in the third SQL statements; based on the sorting results of the third SQL statements, the third SQL statements with a number of SQL statements less than or equal to the SQL statement number threshold are selected as the second SQL statements corresponding to the query information, and the SQL statement number threshold is a positive integer.

[0210] In an optional embodiment, when generating multiple third-party SQL statements based on the query result clause and the query condition clause, the table selection module 92 is further configured to:

[0211] Retrieve the query result clauses and query condition clauses obtained from the queries in the previous rounds; generate multiple third-party SQL statements based on the query result clauses and query condition clauses of the current round and the previous rounds.

[0212] In an optional embodiment, when implementing the conversion of query information into a first SQL statement based on the target table, the conversion module 93 is further configured to:

[0213] If there are multiple target tables, a virtual table is determined based on the column names of the target tables. The virtual table contains the columns of the target tables. The query information is converted into a fourth SQL statement based on the virtual table. The fourth SQL statement is rewritten into a first SQL statement based on the target tables. Each first SQL statement involves one target table.

[0214] In an optional embodiment, the information acquisition module 91 is further configured to: acquire environmental variable information of the user-input query information. The table selection module 92 is further configured to: identify entity information contained in the environmental variable information.

[0215] When generating the second SQL statement corresponding to the query information based on the entity information, the table selection module 92 is also used to generate the second SQL statement corresponding to the query information based on the entity information contained in the environment variable information and the entity information contained in the query information.

[0216] In an optional embodiment, before identifying the entity information contained in the query information, the table selection module 92 is further configured to:

[0217] Determine whether the query information matches a table selection intervention rule; if the query information matches a table selection intervention rule, then the data table corresponding to the table selection intervention rule that the query information matches is taken as the target table that matches the query information; if the query information does not match a table selection intervention rule, then perform the identification of entity information contained in the query information and subsequent steps to filter out the target table that matches the query information from multiple data tables in the table question answering task.

[0218] In an optional embodiment, before identifying the entity information contained in the query information, the table selection module 92 is further configured to: determine whether the configured specific channel set contains a source channel based on the source channel of the query information input by the user; if the specific channel set contains a source channel, then the data table or column corresponding to the source channel is used as the target table or target column that matches the query information; if the specific channel set does not contain a source channel, then the identification of the entity information contained in the query information and subsequent steps are performed to filter out the target table that matches the query information from multiple data tables of the table question-and-answer task.

[0219] In an optional embodiment, the processing apparatus 90 for the form-based question-and-answer task further includes:

[0220] The end-to-end SQL intervention module is used to determine whether the query information matches the end-to-end SQL intervention rules.

[0221] The query module 94 is also used to: if the query information matches an end-to-end SQL intervention rule, execute the SQL statement corresponding to the end-to-end SQL intervention rule matched by the query information.

[0222] The table selection module 92 is also used to: if the query information does not match the end-to-end SQL intervention rules, then perform the filtering of target tables that match the query information from multiple data tables in the table question and answer task based on the query information.

[0223] In an optional embodiment, the processing apparatus 90 for the form-based question-and-answer task further includes:

[0224] The response module is used to determine whether the first SQL statement matches the response template. The response template is configured with the format information of the response fragments included in the response information. The response fragments include result fragments and / or condition fragments. If the first SQL statement matches the response template, the response information is generated based on the query result data and the response template. If the first SQL statement does not match the response template, the response fragments are generated based on the query result data and then assembled into the response information.

[0225] The device provided in this embodiment can be used to execute the method based on any of the above embodiments. The specific functions and technical effects that can be achieved will not be described in detail here.

[0226] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an example embodiment of this application. Figure 10 As shown, the electronic device 100 includes a processor 1001 and a memory 1002 communicatively connected to the processor 1001, the memory 1002 storing computer execution instructions.

[0227] The processor executes computer execution instructions stored in the memory to implement the solution provided in any of the above method embodiments. The specific functions and technical effects that can be achieved will not be elaborated here.

[0228] This application also provides a computer-readable storage medium storing computer-executable instructions. When executed by a processor, the computer-executable instructions are used to implement the solution provided in any of the above method embodiments. The specific functions and technical effects to be achieved are not described here.

[0229] This application also provides a computer program product, which includes a computer program stored in a readable storage medium. At least one processor of the electronic device can read the computer program from the readable storage medium. The at least one processor executes the computer program to cause the electronic device to perform the solution provided in any of the above method embodiments. The specific functions and technical effects that can be achieved are not described here.

[0230] Furthermore, in some of the processes described in the above embodiments and accompanying drawings, multiple operations appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or may be executed in parallel. The sequence numbers are merely used to distinguish different operations, and the sequence number itself does not represent any execution order. Additionally, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first," "second," etc., in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types. "Multiple" means two or more, unless otherwise explicitly specified.

[0231] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0232] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A method for processing a table-based question-and-answer task, characterized in that, include: Obtain the query information entered by the user; Identify the entity information contained in the query information; Generate a second SQL statement corresponding to the query information based on the entity information; Among the multiple data tables in the table-based question-and-answer task, the data table involved in the second SQL statement is selected as the target table that matches the query information; The query information is converted into a first SQL statement based on the target table; Execute the first SQL statement to query the target table and obtain the query result data corresponding to the query information; The step of generating the second SQL statement corresponding to the query information based on the entity information includes: The entity information is concatenated to obtain the query result clause and query condition clause for this round of query; A third SQL statement is generated based on the query result clause and the query condition clause. Different third SQL statements involve different data tables. The third SQL statement is sorted according to the number of query result clauses and / or the number of query condition clauses contained in the third SQL statement; Based on the sorting result of the third SQL statement, a third SQL statement less than or equal to the SQL statement quantity threshold is selected as the second SQL statement corresponding to the query information. The SQL statement quantity threshold is a positive integer.

2. The method according to claim 1, characterized in that, The identification of entity information contained in the query information includes: In a search engine that stores the column names and column values ​​of multiple data tables containing the table-based question-and-answer task, candidate column names and candidate column values ​​that the query information may contain are searched based on the degree of matching with the query information. The column names included in the query information are determined from the candidate column names, and the column values ​​included in the query information are determined from the candidate column values.

3. The method according to claim 2, characterized in that, In a search engine storing the column names and values ​​of multiple data tables containing the table-based question-and-answer task, candidate column values ​​that the query information may contain are searched based on their matching degree with the query information, including: Group the column values ​​in the search engine according to the table and column they belong to; Based on the matching degree between the column values ​​and the query information, the column values ​​within each group are sorted. Based on the column value sorting results, candidate column values ​​that meet at least the column value group recall threshold are determined within each group.

4. The method according to claim 1, characterized in that, The identification of entity information contained in the query information includes: Obtain the trie, which contains the available queries for aggregate functions, operators, and connectors; Search the trie for the aggregate functions, operators, and connectors contained in the query information.

5. The method according to claim 1, characterized in that, The generation of multiple third-party SQL statements based on the query result clause and query condition clause includes: Retrieve query result clauses and query condition clauses from historical rounds of queries; Based on the query result clauses and query condition clauses of the current query and the previous query, multiple third SQL statements are generated.

6. The method according to claim 1, characterized in that, The step of converting the query information into a first SQL statement based on the target table includes: If there are multiple target tables, a virtual table is determined based on the column names of the target tables, and the virtual table contains the columns of the target tables; The query information is converted into a fourth SQL statement based on the virtual table; The fourth SQL statement is rewritten as a first SQL statement based on the target table, and each first SQL statement relates to one of the target tables.

7. The method according to any one of claims 1-5, characterized in that, Also includes: Obtain the environment variable information of the user's input query information, and identify the entity information contained in the environment variable information; The step of generating the second SQL statement corresponding to the query information based on the entity information includes: Based on the entity information contained in the environment variable information and the entity information contained in the query information, a second SQL statement corresponding to the query information is generated.

8. The method according to any one of claims 1-5, characterized in that, Before identifying the entity information contained in the query information, the method further includes: The table selection intervention rule determines whether the query information matches; If the query information matches a table selection intervention rule, then the data table corresponding to the table selection intervention rule matched by the query information is taken as the target table that matches the query information. If the query information does not match the table selection intervention rule, then the entity information contained in the query information and subsequent steps are performed to filter out the target table that matches the query information from multiple data tables in the table question-and-answer task.

9. The method according to any one of claims 1-5, characterized in that, Before identifying the entity information contained in the query information, the method further includes: Based on the source channel of the query information input by the user, determine whether the configured specific channel set includes the source channel; If the specific channel set contains the source channel, then the data table or column corresponding to the source channel is used as the target table or target column that matches the query information; If the specific channel set does not contain the source channel, then the entity information contained in the query information and subsequent steps are performed to filter out the target table that matches the query information from multiple data tables of the table question-and-answer task.

10. The method according to any one of claims 1-6, characterized in that, Before filtering out the target table that matches the query information from multiple data tables in the table-based question-and-answer task, the method further includes: Determine whether the query information matches the end-to-end SQL intervention rules; If the query information matches an end-to-end SQL intervention rule, then execute the SQL statement corresponding to the end-to-end SQL intervention rule matched by the query information; If the query information does not match the end-to-end SQL intervention rule, then the target table that matches the query information is selected from multiple data tables in the table-based question-and-answer task based on the query information.

11. The method according to any one of claims 1-6, characterized in that, After executing the first SQL statement to query the target table and obtain the query result data corresponding to the query information, the method further includes: Determine whether the first SQL statement matches the response template, wherein the response template is configured with the format information of the response fragments contained in the response information, and the response fragments include result fragments and / or condition fragments; If the first SQL statement matches the response template, then response information is generated based on the query result data and the response template; If the first SQL statement does not match the response template, a response fragment is generated based on the query result data, and the response fragment is assembled into response information.

12. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1-11.