Table question and answer method, device and equipment based on retrieval enhancement generated table, and medium

By using quintuple knowledge units from an external knowledge vector library and a two-stage retrieval strategy in a table-based question-and-answer scenario, the reasoning process and SQL generation are decoupled, solving the problems of insufficient accuracy and generation quality in existing technologies and achieving more efficient reasoning and SQL generation.

CN123178579APending Publication Date: 2026-11-27FAW CAR COMPANY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611626010.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-10-20
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing RAG technology lacks decoupling between the reasoning process and SQL generation in table-based question-answering scenarios, resulting in insufficient accuracy and generation quality, as well as low efficiency in reusing reasoning information.

Method used

By employing five-tuple knowledge units from an external knowledge vector library and using a two-stage serial progressive retrieval strategy, we first retrieve similar tables and question pairs to obtain the reasoning process, and then use the generated reasoning process to retrieve similar SQL generation examples, thereby achieving decoupling and enhancement between the reasoning process and SQL generation.

Benefits of technology

It improves the inference accuracy and SQL generation quality in table-based question-and-answer scenarios, and enhances the application value of retrieval enhancement generation technology in table-based question-and-answer scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123178579A_ABST
    Figure CN123178579A_ABST
Patent Text Reader

Abstract

The application discloses a table question and answer method and device based on retrieval enhancement generation, equipment and medium. Including: obtaining an external knowledge vector library, vectorizing a target table and a target question corresponding to a target query requirement to obtain a first query vector; retrieving a candidate reasoning example set based on the first query vector in the external knowledge vector library; inputting the candidate reasoning example set into a preset reasoning process generation model to obtain a target reasoning process, and vectorizing the target reasoning process to obtain a second query vector; retrieving a candidate query sentence set based on the second query vector in the external knowledge vector library; inputting the candidate query sentence set into a preset query sentence generation model to obtain a target query sentence, and executing the target query sentence in a database environment of the target table to obtain a target answer. Through the technical scheme of the application, the decoupling enhancement of the reasoning process and SQL generation can be realized, and the reasoning accuracy and SQL generation quality in the table question and answer scene are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of natural language processing and database query technology, and in particular to a method, apparatus, device and medium for generating table-based question and answering based on retrieval enhancement. Background Technology

[0002] With the rapid development of large language model technology, tabular data querying and question answering based on natural language has become an important research direction in the field of intelligent data analysis. The tabular question answering task aims to automatically generate executable structured query language (SQL) statements and return query results based on the user's input natural language question and corresponding tabular data. However, in tabular question answering scenarios, the questions are complex, the table structures are diverse, and the database syntax is strict. Directly generating SQL using large language models often results in low accuracy, numerous syntax errors, and opaque reasoning logic.

[0003] In existing technologies, Retrieval-Augmented Generation (RAG) technology is often applied to table-based question-answering scenarios. By retrieving examples or knowledge related to the current task from an external knowledge base and using them as context input to a large language model, the accuracy and reliability of the generated results can be effectively improved.

[0004] However, existing RAG technologies mostly employ a single-retrieval strategy, lacking attention to the progressive retrieval relationship between the reasoning process and SQL generation. The guiding role of the reasoning process is not fully reused in the SQL generation stage. Furthermore, example matching in existing RAG technologies is often based on coarse-grained filtering such as question type or SQL framework category, making it difficult to guarantee retrieval accuracy. In addition, existing RAG technologies mostly do not incorporate the reasoning process as an independent index element into the knowledge base structure, nor do they establish an index of correspondence between elements, resulting in low efficiency in reusing reasoning information.

[0005] Therefore, how to decouple and enhance the reasoning process from SQL generation, thereby improving the reasoning accuracy and SQL generation quality in table-based question-answering scenarios and better leveraging the practical application value of retrieval enhancement generation technology in table-based question-answering scenarios, is an urgent problem to be solved. Summary of the Invention

[0006] This invention provides a method, apparatus, device, and medium for generating table-based question-and-answer systems based on enhanced retrieval, which can solve the problem of low SQL generation accuracy caused by complex question descriptions and diverse table structures in table-based question-and-answer scenarios.

[0007] According to one aspect of the present invention, a table-based question-answering method based on retrieval enhancement is provided, comprising: The process involves acquiring an external knowledge vector library, a target table corresponding to the target query requirement, and a target question, and then quantifying the target table and target question to obtain a first query vector corresponding to the target query requirement. The external knowledge vector library includes multiple quintuple knowledge units, each of which includes a table, a question, a reasoning process, a query statement, and an answer. The reasoning process is vectorized separately and indexed to correspond to the table, question, query statement, and answer within the same quintuple knowledge unit. In the external knowledge vector base, candidate related questions and table pairs and corresponding candidate reasoning processes are retrieved based on the first query vector to obtain a set of candidate reasoning examples; The candidate reasoning example set is input into a preset reasoning process generation model to obtain the target reasoning process, and the target reasoning process is quantized to obtain a second query vector; In the external knowledge vector base, candidate query statements are retrieved based on the second query vector to obtain a set of candidate query statements; The candidate query statement set is input into a preset query statement generation model to obtain the target query statement, and the target query statement is executed in the database environment where the target table is located to obtain the target answer corresponding to the target query requirement.

[0008] According to another aspect of the present invention, a table-based question-answering apparatus based on retrieval enhancement generation is provided, comprising: The data acquisition module is used to acquire an external knowledge vector library, a target table and a target question corresponding to the target query requirement, and to quantify the target table and the target question to obtain a first query vector corresponding to the target query requirement; wherein, the external knowledge vector library includes multiple quintuple knowledge units, each quintuple knowledge unit includes a table, a question, a reasoning process, a query statement and an answer, and the reasoning process is vectorized separately and a corresponding relationship index is established with the table, question, query statement and answer in the same quintuple knowledge unit; The first retrieval module is used to retrieve candidate related questions and table pairs and corresponding candidate reasoning processes from the external knowledge vector base based on the first query vector, and obtain a set of candidate reasoning examples. The reasoning generation module is used to input the candidate reasoning example set into a preset reasoning process generation model to obtain the target reasoning process, and to quantize the target reasoning process to obtain a second query vector. The second retrieval module is used to retrieve candidate query statements from the external knowledge vector base based on the second query vector to obtain a set of candidate query statements. The answer generation module is used to input the candidate query statement set into a preset query statement generation model to obtain the target query statement, and execute the target query statement in the database environment where the target table is located to obtain the target answer corresponding to the target query requirement.

[0009] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the table question-answering method based on retrieval enhancement generation as described in any embodiment of the present invention.

[0010] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the table question-answering method based on retrieval enhancement generation as described in any embodiment of the present invention.

[0011] The technical solution of this invention involves acquiring an external knowledge vector library, a target table corresponding to the target query requirement, and a target question. The target table and target question are then quantized to obtain a first query vector corresponding to the target query requirement. The external knowledge vector library includes multiple quintuple knowledge units, each comprising a table, a question, a reasoning process, a query statement, and an answer. The reasoning process is individually vectorized and indexed to correspond to the table, question, query statement, and answer within the same quintuple knowledge unit. Next, candidate related question-table pairs and corresponding candidate reasoning processes are retrieved from the external knowledge vector library based on the first query vector, resulting in a candidate reasoning example set. Further, the candidate reasoning example set is input into a preset reasoning process generation model to obtain the target reasoning process, which is then quantized to obtain a second query vector. Further, candidate query statements are retrieved from the external knowledge vector library based on the second query vector, resulting in a candidate query statement set. Finally, the candidate query statement set is input into a preset query statement generation model to obtain the target query statement, which is then executed in the database environment containing the target table to obtain the target answer corresponding to the target query requirement. The online phase employs a two-stage sequential retrieval strategy: the first stage retrieves similar tables and question pairs based on the target question and table, obtaining corresponding reasoning processes as examples to guide the large language model in generating the reasoning process for the current question; the second stage retrieves similar reasoning processes based on the generated reasoning processes, obtaining corresponding SQL as examples to guide the large language model in generating the SQL statement for the current question, executing the SQL to obtain the final answer, and completing the current application scenario. This solves the problem of low SQL generation accuracy caused by complex question descriptions and diverse table structures in table-based question-and-answer scenarios. Since the reasoning process serves as both the retrieval target in the first stage and the retrieval clue in the second stage, it achieves decoupling and enhancement between the reasoning process and SQL generation, thereby improving the reasoning accuracy and SQL generation quality in table-based question-and-answer scenarios and better leveraging the practical application value of retrieval enhancement generation technology in table-based question-and-answer scenarios.

[0012] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0013] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0014] Figure 1 This is a flowchart of a table-based question-and-answer method based on retrieval enhancement provided in Embodiment 1 of the present invention; Figure 2 This is a flowchart of a table-based question-and-answer method based on retrieval enhancement provided in Embodiment 2 of the present invention; Figure 3 This is a flowchart of an optional table-based question-and-answer method based on retrieval enhancement provided in Embodiment 2 of the present invention; Figure 4 This is a schematic diagram of a table-based question-and-answer device based on retrieval enhancement provided in Embodiment 3 of the present invention; Figure 5 This is a schematic diagram of the structure of an electronic device that implements the table-based question-and-answer method based on retrieval enhancement according to an embodiment of the present invention. Detailed Implementation

[0015] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0016] It should be noted that the terms "first," "second," "target," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0017] Example 1 Figure 1This is a flowchart of a table-based question-and-answer method based on retrieval enhancement provided in Embodiment 1 of the present invention. This embodiment is applicable to situations where table data is queried based on natural language questions and SQL statements are automatically generated. It is particularly suitable for table-based question-and-answer scenarios with complex question descriptions, diverse table structures, and high requirements for the accuracy of SQL generation. This method can be executed by a table-based question-and-answer device based on retrieval enhancement, which can be implemented in hardware and / or software and can be configured in an electronic device. Figure 1 As shown, the method includes: S110. Obtain an external knowledge vector library, a target table and a target question corresponding to the target query requirement, and perform quantitative processing on the target table and the target question to obtain a first query vector corresponding to the target query requirement; wherein, the external knowledge vector library includes multiple quintuple knowledge units, each quintuple knowledge unit includes a table, a question, a reasoning process, a query statement and an answer, and the reasoning process is vectorized separately and a corresponding relationship index is established with the table, question, query statement and answer in the same quintuple knowledge unit.

[0018] External knowledge vectors can refer to the numerical vector representations obtained after vectorizing various types of data in a knowledge base. An external knowledge vector base can refer to an offline, pre-built retrieval database composed of multiple quintuple knowledge units, which has undergone vectorization and indexing. A quintuple knowledge unit can refer to the basic data unit used to construct the external knowledge vector base. Typically, a quintuple knowledge unit organizes the five core elements involved in a complete table-based question-and-answer task into an interconnected, searchable, and reusable knowledge record. A quintuple means that the unit contains five fields. A table can refer to the tabular data within a quintuple knowledge unit. Typically, a table provides information on its structure and content. A question can refer to the natural language question within a quintuple knowledge unit, i.e., the query request for the table. Typically, in a quintuple, the question corresponds to the table, representing the user's query intent. The reasoning process can refer to the natural language text describing the derivation steps from the question to the answer, i.e., the problem-solving approach or thought process. A query statement can refer to the SQL statement within a quintuple knowledge unit. Typically, a query statement is used to retrieve the answer to a question from a table. The answer can refer to the query result obtained after executing the query statement in the quintuple knowledge unit. Typically, the answer provides the endpoint information of the complete reasoning chain, supporting the integrity and verifiability of the knowledge base. The relation index can refer to the index structure used to establish the correspondence between the elements in the quintuple. The query requirement can refer to the query intent or query task proposed by the user. The target query requirement can refer to the query requirement that needs to be processed in the current online phase, i.e., the query task submitted by the user this time. The target table can refer to the table data targeted by the current user's query. The target question can refer to the natural language question proposed by the current user. The query vector can refer to the vector representation used for similarity retrieval in an external knowledge vector base. The first query vector can refer to the joint semantic vector obtained after vectorizing the target table and the target question.

[0019] S120. In the external knowledge vector base, based on the first query vector, retrieve candidate related questions and table pairs and corresponding candidate reasoning processes to obtain a candidate reasoning example set.

[0020] Here, "related question and table pair" refers to a combination of questions and tables in an external knowledge vector base that are semantically similar to the target query requirement. "Candidate related question and table pair" refers to related question and table pairs obtained after the first-stage retrieval that meet the similarity criteria. "Candidate reasoning process" refers to a reasoning process belonging to the same quintuple knowledge unit as the candidate related question and table pair. "Candidate reasoning example set" refers to a set composed of multiple candidate reasoning processes.

[0021] S130. Input the candidate reasoning example set into the preset reasoning process generation model to obtain the target reasoning process, and quantize the target reasoning process to obtain the second query vector.

[0022] The preset reasoning process generation model can refer to a pre-set large language model used to generate the target reasoning process based on reasoning examples. The target reasoning process can refer to the reasoning process output by the preset reasoning process generation model, which is specific to the target question and the target table. The second query vector can refer to the vector representation obtained after vectorizing the target reasoning process.

[0023] S140. In the external knowledge vector base, candidate query statements are retrieved based on the second query vector to obtain a set of candidate query statements.

[0024] Candidate query statements can refer to query statements from an external knowledge vector base that correspond to reasoning processes similar to the target reasoning process. The candidate query statement set can refer to a collection of multiple candidate query statements.

[0025] S150. Input the candidate query statement set into the preset query statement generation model to obtain the target query statement, and execute the target query statement in the database environment where the target table is located to obtain the target answer corresponding to the target query requirement.

[0026] The preset query generation model can refer to a pre-set large language model used to generate the target query statement based on the SQL example. The target query statement can refer to the SQL statement output by the preset query generation model, targeting the target question and the target table. The database environment can refer to the database system where the target table resides and its runtime environment. The target answer can refer to the query result obtained after executing the target query statement in the database environment where the target table resides.

[0027] The technical solution of this invention involves acquiring an external knowledge vector library, a target table corresponding to the target query requirement, and a target question. The target table and target question are then quantized to obtain a first query vector corresponding to the target query requirement. The external knowledge vector library includes multiple quintuple knowledge units, each comprising a table, a question, a reasoning process, a query statement, and an answer. The reasoning process is individually vectorized and indexed to correspond to the table, question, query statement, and answer within the same quintuple knowledge unit. Next, candidate related question-table pairs and corresponding candidate reasoning processes are retrieved from the external knowledge vector library based on the first query vector, resulting in a candidate reasoning example set. Further, the candidate reasoning example set is input into a preset reasoning process generation model to obtain the target reasoning process, which is then quantized to obtain a second query vector. Further, candidate query statements are retrieved from the external knowledge vector library based on the second query vector, resulting in a candidate query statement set. Finally, the candidate query statement set is input into a preset query statement generation model to obtain the target query statement, which is then executed in the database environment containing the target table to obtain the target answer corresponding to the target query requirement. The online phase employs a two-stage sequential retrieval strategy: the first stage retrieves similar tables and question pairs based on the target question and table, obtaining corresponding reasoning processes as examples to guide the large language model in generating the reasoning process for the current question; the second stage retrieves similar reasoning processes based on the generated reasoning processes, obtaining corresponding SQL as examples to guide the large language model in generating the SQL statement for the current question, executing the SQL to obtain the final answer, and completing the current application scenario. This solves the problem of low SQL generation accuracy caused by complex question descriptions and diverse table structures in table-based question-and-answer scenarios. Since the reasoning process serves as both the retrieval target in the first stage and the retrieval clue in the second stage, it achieves decoupling and enhancement between the reasoning process and SQL generation, thereby improving the reasoning accuracy and SQL generation quality in table-based question-and-answer scenarios and better leveraging the practical application value of retrieval enhancement generation technology in table-based question-and-answer scenarios.

[0028] Example 2 Figure 2This is a flowchart of a table-based question-answering method based on retrieval enhancement provided in Embodiment 2 of the present invention. This embodiment is a refinement based on the above embodiment. Specifically, it refines the step of "vectorizing the target table and the target question to obtain the first query vector corresponding to the target query requirement." Specifically, it may include: performing structural parsing on the target table to obtain target table metadata; wherein, the target table metadata includes column names, column types, and sample row data; concatenating the target question with the target table metadata to obtain joint input text; and inputting the joint input text into a preset embedding model to generate the first query vector corresponding to the target query requirement. Figure 2 As shown, the method includes: S210. Obtain the external knowledge vector library, the target table and target question corresponding to the target query requirements.

[0029] In an optional implementation, before obtaining the external knowledge vector base, the target table corresponding to the target query requirement, and the target question, the following steps are further included: Step a1: Obtain the table-based question-and-answer dataset; wherein the table-based question-and-answer dataset includes tables, questions, query statements, and answers.

[0030] In this context, a table-based question-and-answer dataset can refer to the original dataset used to construct an external knowledge vector library. Table-based question-and-answer data can refer to a single data record within the dataset, i.e., a complete table-based question-and-answer sample. For example, each table-based question-and-answer data record contains at least one table, a natural language question for that table, a standard query statement (SQL) corresponding to that question, and the answer obtained after executing that query statement.

[0031] Step a2: For each table and question pair in the table question-and-answer dataset, determine the reasoning process corresponding to the table and question pair.

[0032] In this context, a table and question pair refers to a combination of a specific table and a specific natural language question posed to that table. Typically, one table may correspond to multiple questions, so there are multiple table and question pairs in a dataset.

[0033] In an optional implementation, determining the reasoning process corresponding to each table and question pair in the table-based question-and-answer dataset includes: Step b1: If the table question-and-answer dataset contains standard reasoning process annotations for tables and question pairs, then extract the standard reasoning process annotations as the reasoning process for the tables and question pairs.

[0034] In this context, standard reasoning process annotation refers to pre-annotated text describing the reasoning process for a specific table and question pair within a tabular question-and-answer dataset, either manually or from a reliable source. For example, standard reasoning process annotation describes the steps from question to answer. Typically, standard reasoning process annotation may include understanding the question, analyzing the table structure, determining filtering, aggregation, or sorting methods, and synthesizing the answer-finding approach.

[0035] Step b2: If there is no standard reasoning process annotation for the table and question pair in the table question-answer dataset, then input the structure information of the table, the example row data of the table, the question, the query statement and the answer into the preset reasoning process completion model to generate the reasoning process for the table and question pair.

[0036] The preset reasoning process completion model can refer to a pre-set large language model used to automatically generate a reasoning process when standard reasoning process annotations are missing. For example, in this embodiment of the invention, the prompt word template for the preset reasoning process completion model is as follows: You are a table reasoning expert. Given the following table and question, as well as the required SQL statement and answer, please complete the reasoning process: Table structure: [Column names and data type descriptions of the table]; Table content: [Example data from the first few rows of the table]; Question: [User question]; SQL: [Standard SQL statement]; Answer: [Answer]; Please output the reasoning process in the following format: Step 1: Understand the question and determine the target to be queried; Step 2: Analyze the table structure and determine the columns involved; Step 3: Determine the filtering conditions / aggregation methods / sorting methods; Step 4: Synthesize the approach to obtaining the final answer.

[0037] Specifically, when determining the corresponding reasoning process for each table and question pair in the table-based question-and-answer dataset, the system first checks whether a standard reasoning process annotation exists for that table and question pair in the dataset. If it exists, the standard reasoning process annotation is directly extracted as the reasoning process for that table and question pair and used to construct a quintuple knowledge unit. If it does not exist, the table's structural information, sample row data, the question in the table and question pair, the query statement corresponding to the question, and the answer obtained after executing the query statement are input into a preset reasoning process completion model. This model generates the reasoning process for the table and question pair and uses the generated reasoning process to construct the quintuple knowledge unit. Thus, through these two differentiated processing methods, it is ensured that each table and question pair in the table-based question-and-answer dataset can obtain a corresponding reasoning process, thereby forming a complete quintuple knowledge unit and providing a complete data foundation for the construction of an external knowledge vector library.

[0038] Step a3: Construct the table, the question, the reasoning process, the query statement, and the answer into a quintuple knowledge unit.

[0039] Step a4: Vectorize the tables, questions, and reasoning processes in the five-tuple knowledge unit, and establish an index of the correspondence between each element to form an external knowledge vector library.

[0040] Specifically, by pre-constructing an external knowledge vector library before acquiring it, the tables, questions, reasoning processes, query statements, and answers in the table-based question-and-answer dataset are organized into five-tuple knowledge units. Tables, questions, and reasoning processes are vectorized separately, and a correspondence index is established between each element. This provides a structured and searchable knowledge foundation for the two-stage progressive retrieval in the online phase. Consequently, the reasoning process becomes an independently searchable index element, supporting subsequent retrieval of similar reasoning processes and obtaining corresponding SQL examples, achieving full reuse of reasoning information between reasoning generation and SQL generation. Simultaneously, the correspondence index ensures that when any element is retrieved, other elements in the same five-tuple can be associated with it, improving the retrieval efficiency of the knowledge base and the reuse efficiency of reasoning information. This lays a data foundation for improving the reasoning accuracy and SQL generation quality in table-based question-and-answer scenarios.

[0041] S220. Perform structural parsing on the target table to obtain the target table metadata corresponding to the target table; wherein, the target table metadata includes column names, column types, and sample row data.

[0042] Structural parsing refers to the process of analyzing a target table to extract its structured information. Typically, a target table exists in two-dimensional form and may contain complex structures such as headers, data rows, merged cells, and null values. The purpose of structural parsing is to identify the table's meta-information, such as column names, column types, and sample row data, transforming the original table into a standardized text description suitable for subsequent vectorization. Table meta-information refers to metadata used to describe the table's structure and content characteristics. Column names refer to the name of each column in the table, used to identify the meaning of the data in that column. Column types refer to the data type of each column in the table, such as numeric, character, or date. Sample row data refers to several representative rows of data selected from the table. Target table meta-information refers to the meta-information obtained after structural parsing of the target table, used to describe the structure and content characteristics of that target table.

[0043] S230. The target question and the target table meta information are concatenated to obtain the joint input text.

[0044] The combined input text can refer to the text obtained by concatenating the target question with the target table metadata. For example, the concatenation method can be to place the target question first and the target table metadata last, or to combine the two using a preset template format.

[0045] S240. Input the combined input text into a preset embedding model to generate a first query vector corresponding to the target query requirement.

[0046] The preset embedding model can refer to a pre-set machine learning model used to convert text into vector representations.

[0047] Specifically, after acquiring the external knowledge vector library, the target table corresponding to the target query requirement, and the target question, the target table is first structurally parsed to identify its column names, column types, and sample row data, thus obtaining the target table's metadata. Column names identify the meaning of each column's data, column types represent the data type of each column, and sample row data demonstrates the actual style of the table content. Then, the target question and the target table metadata are combined according to a preset concatenation method to obtain the joint input text. Finally, the joint input text is input into a preset embedding model, which outputs a first query vector corresponding to the target query requirement. This first query vector is used to retrieve candidate related question-table pairs and corresponding candidate reasoning processes from the external knowledge vector library. Thus, the target table metadata represents the table's structural and content features in a concise form, avoiding the computational overhead and information redundancy caused by inputting all table data into the embedding model. Furthermore, by concatenating the target question with the target table metadata and then performing joint vectorization, the generated first query vector can simultaneously carry the semantics of the question and the semantics of the table structure. This allows for more accurate matching of semantically similar candidate related questions and table pairs and their corresponding candidate reasoning processes in the first stage of retrieval, thereby improving retrieval accuracy and the accuracy of subsequent reasoning processes.

[0048] S250. Calculate the joint similarity between the first query vector and each table vector and question vector in the external knowledge vector base.

[0049] The joint similarity can refer to the comprehensive similarity between the first query vector and the question vector and table vector corresponding to the same quintuple knowledge unit in the external knowledge vector base. For example, the joint similarity can be obtained by calculating the similarity between the first query vector and the question vector, and the similarity between the first query vector and the table vector, respectively, and then summing them according to preset weights; alternatively, the question vector and table vector in the quintuple can be concatenated, and the similarity between the first query vector and the concatenated vector can be calculated.

[0050] S260. Based on the joint similarity, candidate related questions and table pairs that meet the preset screening conditions are selected from the external knowledge vector base.

[0051] The preset filtering conditions refer to pre-defined rules or conditions used to filter targets from an external knowledge vector base. For example, preset filtering conditions may include similarity thresholds, sorting methods, and upper limits on the number of candidates. For instance, in the process of filtering candidate related questions and table pairs, the preset filtering conditions may be that the joint similarity is greater than a preset similarity threshold, or that the top K candidate related questions and table pairs are selected in descending order of joint similarity, where K is preferably 3 to 8.

[0052] S270. Based on the correspondence index, obtain the reasoning process of the candidate related question and table pair belonging to the same five-tuple knowledge unit from the external knowledge vector library to obtain a candidate reasoning example set.

[0053] Specifically, after obtaining the first query vector corresponding to the target query requirement, the table vector and question vector are obtained for each quintuple knowledge unit in the external knowledge vector library. The joint similarity between the first query vector and the table vector and question vector is calculated. Then, based on the joint similarity, candidate related question-table pairs that meet preset screening conditions are selected from the external knowledge vector library. Finally, based on the established correspondence index in the external knowledge vector library, the reasoning process belonging to the same quintuple knowledge unit as the candidate related question-table pair is obtained from the external knowledge vector library. These reasoning processes are combined into a candidate reasoning example set, which is used to input into the preset reasoning process generation model to generate the target reasoning process. This allows for more accurate filtering of historical table-question pairs similar to the target query requirement, improving retrieval accuracy. Furthermore, by efficiently obtaining the candidate reasoning example set, high-quality reasoning examples are provided for the subsequent preset reasoning process generation model, thereby improving the accuracy of the target reasoning process generation and the quality of subsequent SQL generation.

[0054] S280. Input the candidate reasoning example set into the preset reasoning process generation model to obtain the target reasoning process, and quantize the target reasoning process to obtain the second query vector.

[0055] For example, in this embodiment of the invention, the prompt word template in the preset reasoning process generation model can be as follows: You are a table reasoning expert. Please refer to the following reasoning examples, analyze the current table, and generate a reasoning process: ## Reasoning Example 1: Table: [Table structure and data of Example 1]; Question: [Question of Example 1]; Reasoning Process: [Reasoning process of Example 1]; ## Reasoning Example 2: Table: [Table structure and data of Example 2]; Question: [Question of Example 2]; Reasoning Process: [Reasoning process of Example 2]; ... (K examples); ## Current Task: Table: [Structure and data of the target table]; Question: [Target question]; Please generate the reasoning process for the current question and output it in the following format: Step 1: ...; Step 2: ...; Step 3: ...; ...

[0056] S290. Calculate the vector similarity between the second query vector and each reasoning process vector in the external knowledge vector library.

[0057] Vector similarity refers to the degree of similarity between the second query vector and the various reasoning process vectors in the external knowledge vector base. For example, vector similarity can be calculated using cosine similarity, inner product similarity, etc.

[0058] S2100. Based on the vector similarity, select intermediate reasoning processes that meet the preset screening conditions from the external knowledge vector base.

[0059] The intermediate reasoning process can refer to the historical reasoning process that is semantically similar to the target reasoning process and is selected from an external knowledge vector database based on vector similarity.

[0060] S2110. Based on the correspondence index, obtain query statements from the external knowledge vector library that belong to the same five-tuple knowledge unit as the intermediate reasoning process, and obtain a set of candidate query statements.

[0061] Specifically, after obtaining the second query vector corresponding to the target reasoning process, the reasoning process vector for each quintuple knowledge unit in the external knowledge vector library is obtained, and the vector similarity between the second query vector and the reasoning process vector is calculated. Then, based on the vector similarity, intermediate reasoning processes that meet preset screening conditions are selected from the external knowledge vector library. For example, the top M reasoning processes with vector similarity greater than a preset threshold or sorted from high to low according to vector similarity are selected, where M can preferably be 3 to 8. Finally, based on the established correspondence index in the external knowledge vector library, query statements belonging to the same quintuple knowledge unit as the intermediate reasoning processes are obtained from the external knowledge vector library. These query statements are combined into a candidate query statement set, which is then input into a preset query statement generation model to generate the target query statement. Thus, through the above process, a second-stage retrieval is achieved, using the target reasoning process as the retrieval clue, similar reasoning processes as the bridge, and the corresponding query statement as the target, providing a high-quality SQL example for subsequent SQL generation.

[0062] S2120. Input the candidate query statement set into the preset query statement generation model to obtain the target query statement, and execute the target query statement in the database environment where the target table is located to obtain the target answer corresponding to the target query requirement.

[0063] For example, in this embodiment of the invention, the prompt word template in the preset query statement generation model can be as follows: You are an SQL generation expert. Please refer to the following SQL examples and generate the corresponding SQL query statement based on the current table and reasoning process: ##SQL Example 1: Table: [Table structure of Example 1]; Question: [Question of Example 1]; Reasoning process: [Reasoning process of Example 1]; SQL: [SQL statement of Example 1]; ##SQL Example 2: Table: [Table structure of Example 2]; Question: [Question of Example 2]; Reasoning process: [Reasoning process of Example 2]; SQL: [SQL statement of Example 2]; ... (M examples); ##Current Task: Table: [Structure of Target Table]; Question: [Target Question]; Reasoning process: [RP_target]; Please generate the SQL query statement corresponding to the current question, ensuring that the SQL syntax is correct and applicable to the database engine of the target table.

[0064] In an optional implementation, before executing the target query statement in the database environment where the target table resides to obtain the target answer corresponding to the target query requirement, the method further includes: Step c1: Perform syntax validation on the target query statement to obtain the syntax validation result.

[0065] Syntax validation refers to the operation of checking the syntax of the target query statement output by the pre-defined query statement generation model. Typically, syntax validation determines whether the target query statement conforms to the syntax rules of the database environment where the target table resides. The syntax validation result refers to the validation conclusion obtained after validating the target query statement. For example, the syntax validation result can be that the target query statement passes the syntax validation, meaning it conforms to the syntax rules of the database environment where the target table resides and can proceed to subsequent execution steps. Alternatively, it can be that the target query statement contains a syntax error, meaning it does not conform to the syntax rules and requires error feedback and regeneration.

[0066] Step c2: If the syntax check result indicates that the target query statement has a syntax error, the error information is fed back to the preset query statement generation model, and the updated target query statement is regenerated based on the error information until the target query statement passes the syntax check or reaches the preset maximum number of retries.

[0067] Error messages refer to the information returned by the syntax checking tool or database engine when the syntax check result indicates a syntax error in the target query statement, describing the specific content of the error. Typically, error messages can include the error type, error location, and error reason. The preset maximum number of retries refers to the maximum number of times the target query statement can be regenerated based on the error messages. Typically, the preset maximum number of retries can be set according to actual needs, preferably 3 times.

[0068] Specifically, after the target query statement is output by the preset query statement generation model but before it is executed in the database environment containing the target table, the target query statement is first subjected to syntax validation to obtain the validation result. This can be achieved by parsing the target query statement using an SQL syntax checking tool or the database engine's syntax parser. If the syntax validation result indicates that the target query statement passes the validation, the subsequent execution steps proceed. If the syntax validation result indicates that the target query statement contains syntax errors, the error information returned by the syntax checking tool or database engine is extracted and fed back to the preset query statement generation model. The preset query statement generation model then regenerates an updated target query statement based on the error information and performs syntax validation on the updated target query statement again. This process is repeated until the target query statement passes the syntax validation or the preset maximum number of retries is reached. If the preset maximum number of retries is reached and the target query statement still fails the syntax validation, the retries are terminated and a corresponding prompt message is output. Therefore, through this process, it is ensured that the target query statement used for execution conforms to the requirements of the database environment containing the target table at the syntax level, improving the success rate of SQL execution.

[0069] The technical solution of this invention involves acquiring an external knowledge vector library, a target table corresponding to the target query requirement, and a target question. The target table is structurally parsed to obtain its corresponding target table metadata. The target question and the target table metadata are concatenated to obtain a joint input text. This joint input text is input into a preset embedding model to generate a first query vector corresponding to the target query requirement. Then, the joint similarity between the first query vector and each table vector and question vector in the external knowledge vector library is calculated. Based on the joint similarity, candidate related question-table pairs that meet preset screening conditions are selected from the external knowledge vector library. Based on the correspondence index, reasoning processes belonging to the same quintuple knowledge unit as the candidate related question-table pairs are obtained from the external knowledge vector library, resulting in a candidate reasoning example set. Further, the candidate reasoning example set is input into a preset reasoning process generation model to obtain the target reasoning process, which is then quantified to obtain a second query vector. Further, the vector similarity between the second query vector and each reasoning process vector in the external knowledge vector library is calculated. Based on the vector similarity, intermediate reasoning processes that meet preset screening conditions are selected from the external knowledge vector library. Based on the correspondence index, query statements belonging to the same five-tuple knowledge unit as the intermediate reasoning process are obtained from the external knowledge vector library, resulting in a candidate query statement set. Finally, the candidate query statement set is input into a preset query statement generation model to obtain the target query statement. This target query statement is then executed in the database environment containing the target table to obtain the target answer corresponding to the target query requirement. The online phase employs a two-stage serial progressive retrieval strategy: the first stage retrieves similar tables and question pairs based on the target question and target table, obtaining corresponding reasoning processes as reasoning examples to guide the large language model in generating the reasoning process for the current question; the second stage retrieves similar reasoning processes based on the generated reasoning processes, obtaining corresponding SQL as SQL generation examples to guide the large language model in generating the SQL statement for the current question. Executing the SQL yields the final answer, completing the current application scenario. This solves the problem of low SQL generation accuracy in table-based question-and-answer scenarios due to complex question descriptions and diverse table structures. Since the reasoning process serves as both the retrieval target in the first stage and the retrieval clue in the second stage, it achieves decoupling and enhancement between the reasoning process and SQL generation, thereby improving the reasoning accuracy and SQL generation quality in table-based question-and-answer scenarios and better leveraging the practical application value of retrieval enhancement generation technology in table-based question-and-answer scenarios.

[0070] Figure 3The diagram shows a flowchart of an optional table-based question-answering method based on retrieval enhancement provided by an embodiment of the present invention. Specifically, firstly, an external knowledge vector library is constructed offline. Then, a target question and its corresponding target table are input. The target table is structurally parsed to obtain target table metadata containing column names, column types, and example row data. The target question and target table metadata are concatenated and input into a preset embedding model to obtain a first query vector. Next, the joint similarity between the first query vector and each table vector and question vector is calculated in the external knowledge vector library using vector similarity. Candidate relevant question-table pairs that meet preset filtering conditions are retrieved, and their corresponding candidate reasoning processes are obtained based on the correspondence index, forming a candidate reasoning example set. Furthermore, reasoning process generation prompts are constructed, and the candidate reasoning example set is input into a preset reasoning process generation model to generate a target reasoning process. Then, the target reasoning process is vectorized to obtain a second query vector. The similarity between the second query vector and each reasoning process vector is calculated in the external knowledge vector library using vector similarity. Intermediate reasoning processes that meet preset filtering conditions are retrieved, and their corresponding query statements are obtained based on the correspondence index, forming a candidate query statement set. Next, SQL generation prompts are constructed, and the set of candidate query statements is input into a preset query statement generation model to generate the target SQL. Finally, the target SQL is executed in the database environment containing the target table, the SQL execution result is obtained, and the final answer is generated accordingly. This completes the entire process from inputting the target question and target table to outputting the final answer, achieving decoupling and enhancement between the reasoning process and SQL generation.

[0071] It is worth noting that, in the embodiments of the present invention, if the reasoning process (i.e. the candidate reasoning example set) generated in the first stage is of poor quality, such as missing reasoning steps or obvious logical errors, the similarity threshold can be lowered and the knowledge base can be retrieved again, or the number of examples returned by the retrieval can be increased K and then regenerated.

[0072] Example 3 Figure 4 This is a schematic diagram of a table-based question-and-answer device based on retrieval enhancement provided in Embodiment 3 of the present invention. Figure 4 As shown, the device includes: a data acquisition module 310, a first retrieval module 320, a reasoning generation module 330, a second retrieval module 340, and an answer generation module 350; The data acquisition module 310 is used to acquire an external knowledge vector library, a target table and a target question corresponding to the target query requirement, and to quantify the target table and the target question to obtain a first query vector corresponding to the target query requirement. The external knowledge vector library includes multiple quintuple knowledge units, each of which includes a table, a question, a reasoning process, a query statement and an answer. The reasoning process is vectorized separately and a corresponding index is established between the table, question, query statement and answer in the same quintuple knowledge unit. The first retrieval module 320 is used to retrieve candidate related questions and table pairs and corresponding candidate reasoning processes from the external knowledge vector base based on the first query vector, and obtain a set of candidate reasoning examples. The reasoning generation module 330 is used to input the candidate reasoning example set into a preset reasoning process generation model to obtain the target reasoning process, and to quantize the target reasoning process to obtain a second query vector. The second retrieval module 340 is used to retrieve candidate query statements from the external knowledge vector base based on the second query vector to obtain a set of candidate query statements. The answer generation module 350 is used to input the candidate query statement set into a preset query statement generation model to obtain the target query statement, and execute the target query statement in the database environment where the target table is located to obtain the target answer corresponding to the target query requirement.

[0073] The technical solution of this invention involves acquiring an external knowledge vector library, a target table corresponding to the target query requirement, and a target question. The target table and target question are then quantized to obtain a first query vector corresponding to the target query requirement. The external knowledge vector library includes multiple quintuple knowledge units, each comprising a table, a question, a reasoning process, a query statement, and an answer. The reasoning process is individually vectorized and indexed to correspond to the table, question, query statement, and answer within the same quintuple knowledge unit. Next, candidate related question-table pairs and corresponding candidate reasoning processes are retrieved from the external knowledge vector library based on the first query vector, resulting in a candidate reasoning example set. Further, the candidate reasoning example set is input into a preset reasoning process generation model to obtain the target reasoning process, which is then quantized to obtain a second query vector. Further, candidate query statements are retrieved from the external knowledge vector library based on the second query vector, resulting in a candidate query statement set. Finally, the candidate query statement set is input into a preset query statement generation model to obtain the target query statement, which is then executed in the database environment containing the target table to obtain the target answer corresponding to the target query requirement. The online phase employs a two-stage sequential retrieval strategy: the first stage retrieves similar tables and question pairs based on the target question and table, obtaining corresponding reasoning processes as examples to guide the large language model in generating the reasoning process for the current question; the second stage retrieves similar reasoning processes based on the generated reasoning processes, obtaining corresponding SQL as examples to guide the large language model in generating the SQL statement for the current question, executing the SQL to obtain the final answer, and completing the current application scenario. This solves the problem of low SQL generation accuracy caused by complex question descriptions and diverse table structures in table-based question-and-answer scenarios. Since the reasoning process serves as both the retrieval target in the first stage and the retrieval clue in the second stage, it achieves decoupling and enhancement between the reasoning process and SQL generation, thereby improving the reasoning accuracy and SQL generation quality in table-based question-and-answer scenarios and better leveraging the practical application value of retrieval enhancement generation technology in table-based question-and-answer scenarios.

[0074] Optionally, the table-based question-answering device based on retrieval enhancement may further include: a vector library construction module, used to acquire a table-based question-answering dataset before acquiring the external knowledge vector library, the target table corresponding to the target query requirement, and the target question; wherein the table-based question-answering dataset includes tables, questions, query statements, and answers; for each table and question pair in the table-based question-answering dataset, determine the reasoning process corresponding to the table and question pair; construct the table, the question, the reasoning process, the query statement, and the answer into a five-tuple knowledge unit; vectorize the table, question, and reasoning process in the five-tuple knowledge unit respectively, and establish a correspondence index between each element to form an external knowledge vector library.

[0075] Optionally, the vector library construction module can be used to: if there are standard reasoning process annotations for tables and question pairs in the table question-answering dataset, extract the standard reasoning process annotations as the reasoning process for the table and question pairs; if there are no standard reasoning process annotations for the table and question pairs in the table question-answering dataset, input the structure information of the table, the example row data of the table, the question, the query statement and the answer into the preset reasoning process completion model to generate the reasoning process for the table and question pairs.

[0076] Optionally, the data acquisition module 310 can be used to: perform structural parsing on the target table to obtain target table metadata corresponding to the target table; wherein the target table metadata includes column names, column types and sample row data; concatenate the target question with the target table metadata to obtain joint input text; input the joint input text into a preset embedding model to generate a first query vector corresponding to the target query requirement.

[0077] Optionally, the first retrieval module 320 can be specifically used to: calculate the joint similarity between the first query vector and each table vector and question vector in the external knowledge vector library; select candidate related questions and table pairs that meet preset screening conditions in the external knowledge vector library based on the joint similarity; and obtain the reasoning process that belongs to the same five-tuple knowledge unit as the candidate related questions and table pairs from the external knowledge vector library based on the correspondence index, thereby obtaining a candidate reasoning example set.

[0078] Optionally, the second retrieval module 340 can be specifically used to: calculate the vector similarity between the second query vector and each reasoning process vector in the external knowledge vector library; select intermediate reasoning processes that meet preset screening conditions in the external knowledge vector library based on the vector similarity; and obtain query statements that belong to the same five-tuple knowledge unit as the intermediate reasoning process from the external knowledge vector library based on the correspondence index, thereby obtaining a set of candidate query statements.

[0079] Optionally, the table-based question-and-answer device based on retrieval enhancement may further include: a query statement update module, used to perform syntax verification on the target query statement before executing the target query statement in the database environment where the target table is located to obtain the target answer corresponding to the target query requirement, and obtain a syntax verification result; if the syntax verification result indicates that the target query statement has a syntax error, the error information is fed back to the preset query statement generation model, and the updated target query statement is regenerated based on the error information, until the target query statement passes the syntax verification or reaches the preset maximum number of retries.

[0080] The table question-and-answer device based on search enhancement provided in the embodiments of the present invention can execute the table question-and-answer method based on search enhancement provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0081] Example 4 Figure 5 A schematic diagram of an electronic device 410 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0082] like Figure 5 As shown, the electronic device 410 includes at least one processor 420 and a memory, such as a read-only memory (ROM) 430 or a random access memory (RAM) 440, communicatively connected to the at least one processor 420. The memory stores computer programs executable by the at least one processor. The processor 420 can perform various appropriate actions and processes based on the computer program stored in the ROM 430 or loaded into the RAM 440 from storage unit 490. The RAM 440 may also store various programs and data required for the operation of the electronic device 410. The processor 420, ROM 430, and RAM 440 are interconnected via a bus 450. An input / output (I / O) interface 460 is also connected to the bus 450.

[0083] Multiple components in electronic device 410 are connected to I / O interface 460, including: input unit 470, such as keyboard, mouse, etc.; output unit 480, such as various types of monitors, speakers, etc.; storage unit 490, such as disk, optical disk, etc.; and communication unit 4100, such as network card, modem, wireless transceiver, etc. Communication unit 4100 allows electronic device 410 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0084] Processor 420 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 420 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 420 performs the various methods and processes described above, such as a table-based question-answering method based on retrieval enhancement generation.

[0085] The method includes: The process involves acquiring an external knowledge vector library, a target table corresponding to the target query requirement, and a target question, and then quantifying the target table and target question to obtain a first query vector corresponding to the target query requirement. The external knowledge vector library includes multiple quintuple knowledge units, each of which includes a table, a question, a reasoning process, a query statement, and an answer. The reasoning process is vectorized separately and indexed to correspond to the table, question, query statement, and answer within the same quintuple knowledge unit. In the external knowledge vector base, candidate related questions and table pairs and corresponding candidate reasoning processes are retrieved based on the first query vector to obtain a set of candidate reasoning examples; The candidate reasoning example set is input into a preset reasoning process generation model to obtain the target reasoning process, and the target reasoning process is quantized to obtain a second query vector; In the external knowledge vector base, candidate query statements are retrieved based on the second query vector to obtain a set of candidate query statements; The candidate query statement set is input into a preset query statement generation model to obtain the target query statement, and the target query statement is executed in the database environment where the target table is located to obtain the target answer corresponding to the target query requirement.

[0086] In some embodiments, the search-enhanced table-based question-answering method can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 490. In some embodiments, part or all of the computer program can be loaded and / or mounted on electronic device 410 via ROM 430 and / or communication unit 4100. When the computer program is loaded into RAM 440 and executed by processor 420, one or more steps of the search-enhanced table-based question-answering method described above can be performed. Alternatively, in other embodiments, processor 420 can be configured to perform the search-enhanced table-based question-answering method by any other suitable means (e.g., by means of firmware).

[0087] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0088] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0089] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0090] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0091] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0092] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0093] This application also discloses a computer program product, which includes a computer program that, when executed by a processor, implements the retrieval-enhanced table question-answering method provided in any embodiment of this application. This program product shares the same inventive concept as the retrieval-enhanced table question-answering method disclosed in the embodiments of this application, and therefore will not be described further here.

[0094] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0095] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A table-based question-answering method based on retrieval enhancement, characterized in that, include: The process involves acquiring an external knowledge vector library, a target table corresponding to the target query requirement, and a target question, and then quantifying the target table and target question to obtain a first query vector corresponding to the target query requirement. The external knowledge vector library includes multiple quintuple knowledge units, each of which includes a table, a question, a reasoning process, a query statement, and an answer. The reasoning process is vectorized separately and indexed to correspond to the table, question, query statement, and answer within the same quintuple knowledge unit. In the external knowledge vector base, candidate related questions and table pairs and corresponding candidate reasoning processes are retrieved based on the first query vector to obtain a set of candidate reasoning examples; The candidate reasoning example set is input into a preset reasoning process generation model to obtain the target reasoning process, and the target reasoning process is quantized to obtain a second query vector; In the external knowledge vector base, candidate query statements are retrieved based on the second query vector to obtain a set of candidate query statements; The candidate query statement set is input into a preset query statement generation model to obtain the target query statement, and the target query statement is executed in the database environment where the target table is located to obtain the target answer corresponding to the target query requirement.

2. The method according to claim 1, characterized in that, Before obtaining the external knowledge vector base, the target table corresponding to the target query requirement, and the target question, the following steps are also included: Obtain a table-based question-and-answer dataset; wherein the table-based question-and-answer dataset includes tables, questions, query statements, and answers; For each table and question pair in the table-based question-and-answer dataset, determine the reasoning process corresponding to the table and question pair; The table, the question, the reasoning process, the query statement, and the answer are constructed into a five-tuple knowledge unit; The tables, questions, and reasoning processes in the five-tuple knowledge unit are vectorized respectively, and an index of the correspondence between each element is established to form an external knowledge vector library.

3. The method according to claim 2, characterized in that, The reasoning process for determining the corresponding table and question pair for each table and question pair in the table-based question-and-answer dataset includes: If the table question-and-answer dataset contains standard reasoning process annotations for tables and question pairs, then the standard reasoning process annotations are extracted as the reasoning process for the tables and question pairs. If the table-based question-and-answer dataset does not contain standard reasoning process annotations for the table and question pair, then the structure information of the table, the sample row data of the table, the question, the query statement, and the answer are input into a preset reasoning process completion model to generate the reasoning process for the table and question pair.

4. The method according to claim 1, characterized in that, The vectorization process of the target table and the target question yields a first query vector corresponding to the target query requirement, including: The target table is parsed to obtain the target table metadata; wherein, the target table metadata includes column names, column types, and sample row data; The target question is concatenated with the target table metadata to obtain the joint input text; The combined input text is input into a preset embedding model to generate a first query vector corresponding to the target query requirement.

5. The method according to claim 1, characterized in that, In the external knowledge vector base, based on the first query vector, candidate related questions and table pairs and corresponding candidate reasoning processes are retrieved to obtain a set of candidate reasoning examples, including: Calculate the joint similarity between the first query vector and each table vector and question vector in the external knowledge vector base; Based on the joint similarity, candidate related questions and table pairs that meet the preset filtering conditions are selected from the external knowledge vector base; Based on the correspondence index, the reasoning process of the candidate related questions and table pairs belonging to the same five-tuple knowledge unit is obtained from the external knowledge vector library, resulting in a candidate reasoning example set.

6. The method according to claim 1, characterized in that, The step involves retrieving candidate query statements from the external knowledge vector base based on the second query vector to obtain a set of candidate query statements, including: Calculate the vector similarity between the second query vector and each reasoning process vector in the external knowledge vector base; Based on the vector similarity, intermediate reasoning processes that meet preset filtering conditions are selected from the external knowledge vector base; Based on the correspondence index, query statements belonging to the same quintuple knowledge unit as the intermediate reasoning process are obtained from the external knowledge vector library, resulting in a set of candidate query statements.

7. The method according to claim 1, characterized in that, Before executing the target query statement in the database environment where the target table resides to obtain the target answer corresponding to the target query requirement, the process further includes: Perform syntax validation on the target query statement and obtain the syntax validation result; If the syntax check result indicates that the target query statement has a syntax error, the error information is fed back to the preset query statement generation model, and the updated target query statement is regenerated based on the error information until the target query statement passes the syntax check or reaches the preset maximum number of retries.

8. A table-based question-and-answer device based on retrieval enhancement generation, characterized in that, include: The data acquisition module is used to acquire an external knowledge vector library, a target table and a target question corresponding to the target query requirement, and to quantify the target table and the target question to obtain a first query vector corresponding to the target query requirement; wherein, the external knowledge vector library includes multiple quintuple knowledge units, each quintuple knowledge unit includes a table, a question, a reasoning process, a query statement and an answer, and the reasoning process is vectorized separately and a corresponding relationship index is established with the table, question, query statement and answer in the same quintuple knowledge unit; The first retrieval module is used to retrieve candidate related questions and table pairs and corresponding candidate reasoning processes from the external knowledge vector base based on the first query vector, and obtain a set of candidate reasoning examples. The reasoning generation module is used to input the candidate reasoning example set into a preset reasoning process generation model to obtain the target reasoning process, and to quantize the target reasoning process to obtain a second query vector. The second retrieval module is used to retrieve candidate query statements from the external knowledge vector base based on the second query vector to obtain a set of candidate query statements. The answer generation module is used to input the candidate query statement set into a preset query statement generation model to obtain the target query statement, and execute the target query statement in the database environment where the target table is located to obtain the target answer corresponding to the target query requirement.

9. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, which enables the at least one processor to perform the table-based question-answering method based on retrieval enhancement as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the table-based question-answering method based on retrieval enhancement as described in any one of claims 1-7.