A table question and answer method and system based on thought chain guidance
By using a thought chain-guided table-based question-and-answer method, the table-based question-and-answer process is decomposed into a constrained sequence of operations. Combined with lightweight model training, this solves the problems of opaque reasoning, high resource consumption, and insufficient generalization ability in existing technologies, and realizes a transparent, low-resource-consumption, and high-generalization table-based question-and-answer system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FUZHOU LIANCHUANG ZHIYUN INFORMATION TECH CO LTD
- Filing Date
- 2026-02-13
- Publication Date
- 2026-05-29
AI Technical Summary
Existing table-based question-answering models suffer from opaque reasoning processes, high computational resource consumption, and insufficient generalization capabilities, making it difficult to meet compliance requirements in key scenarios and deployment needs of lightweight terminals.
By employing a thought chain-guided approach, the table-based question-and-answer process is decomposed into a constrained sequence of table transformation operations. An operation chain is constructed through a large model and the operation history is explicitly recorded. This is combined with a lightweight small model for supervised training, achieving transparent reasoning and low resource consumption.
It achieves traceability and interpretability of the table-based question-and-answer process, reduces computational resource consumption, improves system reliability and generalization ability, and is suitable for lightweight deployment.
Smart Images

Figure CN122113874A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of natural language processing technology, specifically relating to a table-based question-and-answer method and system guided by thought chains. Background Technology
[0002] Table-based question answering, as an interdisciplinary technology combining natural language processing and structured data understanding, focuses on semantic matching and reasoning between natural language questions and tabular data, and is widely used in scenarios such as financial analysis and business intelligence. However, existing technologies still suffer from three key shortcomings that limit their practical application effectiveness: 1. Lack of transparency in the reasoning process: Traditional table understanding methods rely on manual rules or linear text matching. Deep learning-driven methods (including LLM-based, graph-based, and multimodal methods) mostly adopt implicit reasoning patterns and do not explicitly record the table transformation logic in the reasoning process. This results in a lack of traceability and credibility of the answers, making it difficult to meet the compliance requirements of key scenarios.
[0003] 2. High computational resource consumption: Current high-performance table question answering models mostly rely on large pre-trained language models with huge parameter scale, high inference latency, and high deployment cost, which cannot adapt to the needs of lightweight terminals or real-time response scenarios.
[0004] 3. Insufficient generalization ability: Existing methods do not adequately model the semantics of complex tables (such as multi-level headers and nested structures) and rely excessively on specific table formats or model structures, resulting in a sharp decline in performance in cross-domain and cross-format table question answering tasks.
[0005] Therefore, there is an urgent need for a table-based question-answering technology that balances reasoning transparency, low resource consumption, and strong generalization ability to address the core bottlenecks of existing technologies. Summary of the Invention
[0006] To address the issues of opaque reasoning processes, high computational resource requirements, and insufficient generalization ability in existing table-based question-answering models, this paper proposes a table-based question-answering method and system based on thought chain guidance and distillation. This method features transparent reasoning processes, low computational resource requirements, and strong generalization ability.
[0007] The technical solution of the present invention is as follows: A table-based question-and-answer method guided by thought chain includes the following steps: Step 1: Obtain and process the tabular dataset, which includes table titles, text tables with headers, natural language descriptions of the questions corresponding to the tables, and corresponding standard answers; Step 2: Construct the table operation chain required for table processing; including the following four operations: Delete table columns that are irrelevant to the natural language problem. Sort or group the table columns related to the natural language problem; Delete table rows that are irrelevant to the natural language problem. Generate a textual summary for the remaining table rows; Step 3: Construct operation descriptions and prompts for the operation chain; Step 4: Based on the question described in the natural language and the current table state, the large model operates according to the preset table reasoning operation chain template to determine the next table transformation operation and its corresponding parameters. The table transformation operation must be selected from the first three steps of the operation chain in sequence. Step 5: Based on the operation chain selected by the current large model and the operation description and prompt words of the operation chain, execute the table transformation operation to update the table state and add it to the table change state record, and record the table transformation operation and its corresponding parameters to the operation history sequence; Step 6: Based on the updated table state, repeat steps 4-5 until the table state meets the termination condition. Then, execute the last step in the operation chain, that is, generate a summary for the remaining table rows and record the last historical operation and its parameters in the operation history sequence. Finally, the large model outputs the answer corresponding to the natural language question based on the text summary of the generated table rows. Step 7: Based on the original table data or intermediate table data generated during table processing, and combined with table-related questions described in natural language, use them as model input; use the intermediate table generated by the large model for the table-related questions or the historical operation sequence containing complete operation logic and corresponding parameters as labeled answers, and conduct supervised training tasks on the small model in two stages; so that the small model can generate executable operations and operation parameter sequences that match the records in the operation history data under the guidance of the given question and the preset fixed operation sequence template.
[0008] Preferably, in step 1, the table dataset includes text-based table data, table titles, table-related questions and their standard answers obtained from authoritative public datasets such as WikiTQ, FetaQA, and TabFact; the processing of the table dataset includes removing various useless tags from the table dataset and parsing the text-based table data into a format that the program can directly process.
[0009] Preferably, step 2 specifically includes: Deleting table columns unrelated to the natural language problem involves the large model generating the corresponding operations and sequences for the next step based on the historical operation sequence and parameters of table processing, the current table data state, and prompts generated for the parameters required for the next operation. Finally, a Delete_unrelated_clomn() operation program is designed. The generated parameters are input and the program is executed to remove irrelevant columns from the table, retaining only columns that are directly or indirectly related to the problem. The corresponding parameters are the current table data and the index of the column to be removed. The sorting or grouping of key columns in the table related to the natural language problem refers to the large model generating the corresponding operations and sequences to be performed next by taking the historical operation sequence and parameters of table processing, the current table data state, and prompt words generated for the parameters required for the next operation as input. Finally, a Groupby_or_sortby_clomn() operation program is designed. The corresponding parameters are input and the program is executed to sort or group the key columns in the table related to the problem. The corresponding parameters are the current table, operation selection parameters, and key column names or indexes. The operation selection parameters refer to the int parameter groupby_or_sortby, where a value of 1 executes the Group_by grouping operation, a value of 2 executes the Sort_by sorting operation, and a value of 3 executes the Group_by grouping operation first and then the Sort_by sorting operation. Deleting table rows unrelated to the natural language problem involves the large model generating the corresponding operations and sequence to be performed next based on the historical operation sequence and parameters of table processing, the current state of the table data, and prompts generated for the parameters required for the next operation. Finally, a Delete_unrelated_rows() operation program is designed. The corresponding parameters are input and the program is executed to retain table rows that are directly or indirectly related to the problem, while removing table rows that are completely unrelated to the problem. The corresponding parameters are the index sequence of the multiple rows to be deleted from the current table data. Generating textual summaries for the remaining table rows involves the large model using the historical operation sequence and parameters of table processing, the current table data state, and prompts generated for the parameters required for the next operation as input to generate the corresponding operation and sequence to be performed next. Finally, a Generate_key_rows_abstract() operation program is designed. The corresponding parameters are input and the program is executed to generate a summary of the table rows that are directly or indirectly related to the problem. The corresponding parameters are the current table, its retained multi-row index sequence, and the prompt information for the operation.
[0010] Preferably, step 3 specifically includes: the operation description including the name of the current operation, a detailed description of the execution process of the current operation, and a corresponding operation example; the prompt words including the historical operations of table processing and their parameters, the current table data status, and prompt words for generating parameters required for the next operation; The method for implementing the operation description and prompt words for constructing the operation chain is as follows: Step 3.1: Predefine a corresponding operation description for each table transformation operation. The operation description shall include at least the operation identifier, parameter type description, and executable conditions. Step 3.2: Based on the current table status and operation history sequence, generate control information to limit the optional operation types and parameter value ranges; Step 3.3: Based on the operation description and the control information, determine the next table transformation operation and its corresponding parameters, thereby forming a constrained table reasoning operation chain.
[0011] Preferably, in step 4, based on the question described in natural language and the current table state, the large model operates according to a preset table reasoning operation chain template, specifically as follows: Step 4.1: If this is the first time processing a table, then use the table information as input and select the first operation in the operation chain. The large model will generate the parameters corresponding to the current operation based on the table information, the corresponding table question, and the current operation description. If this is not the first time processing the current table, the large model will select the parameters corresponding to the next operation based on the current table status, the corresponding table question, the historical operation sequence and parameters, and the next operation description and prompt words as input. Step 4.2: Based on the generated operation type, call the corresponding operation program to perform table transformation and update the table state; for each generated operation type, the system integrates a predefined operation program library, specifically including: The Delete_unrelated_column() function takes the current table data and column index as parameters, deletes columns in the table that are not related to the problem, adds a demo example as a prompt, returns the updated table state, and adds the current operation to the operation history sequence. The Groupby_or_sortby_column() function takes the current table, operation selection parameters, and key column names, performs grouping or sorting operations, such as sorting by numerical ascending order or grouping and aggregating by category, adds demo examples as prompts, returns the updated table state, and adds the current operation to the history operation sequence. The Delete_unrelated_rows() function takes the current table and row index sequence, deletes rows in the table that are not related to the problem, returns the updated table state, and adds the current operation to the historical operation sequence. The Generate_key_rows_abstract() function receives the current table, the row index sequence, and a prompt message. It converts the specified row into key-value pair text, calls the large model to generate a natural language summary, and adds a demo example as a prompt message. It does not need to record the table state again; it only adds the current operation to the historical operation sequence list. Each operation procedure is designed to be executed atomically to ensure the accuracy and reversibility of table transformations. After execution, the system verifies the operation effect in real time, such as checking whether columns were successfully deleted or whether the sorting was consistent, and updates the table status to intermediate results for use in the next iteration. Step 4.3: For each operation performed above, the current operation type and parameters are added to the historical operation sequence, and the new intermediate table is placed in the table status record. Repeat the above steps until the termination condition is met to generate a complete operation sequence and a complete table status change record. Finally, the large model can directly output the answer and save the traceable operation history based on the table's relevant row summary and its corresponding question.
[0012] Preferably, in step 5, the table change status record and operation history sequence refer to the fact that the current operation parameters generated by the large model under the current table status, table-related issues, and current operation description will be saved as a record in the operation history sequence along with the current operation. When the program finishes executing the current operation, it will also save the currently processed table status to the record.
[0013] Preferably, step 6 specifically involves: iterating until the table state meets the termination condition, then generating a summary for the remaining table rows. The termination condition is reaching a preset number of iterations or having fewer than a preset number of table rows. After reaching this termination condition, a text summary of the table rows needs to be generated by the large model. The specific process is as follows: first, the table header information is concatenated with each row of data in the table to form a key-value pair format of "column name-value", resulting in a key-value pair sequence for each row; then, the table header data, the concatenated key-value pair sequence for each row, and the prompt information for generating the summary are input into the large model, and finally, the large model outputs the required row summary. Preferably, in step 7, the training of the small model employs a two-stage supervised learning approach: First, the first stage of training for the small model is based on the historical data of the thought chain operations generated by the large model as a supervision signal. The training dataset consists of preprocessed samples from multiple authoritative public table datasets, including the WikiTQ dataset, the FetaQA dataset, and the TabFact dataset. Each preprocessed sample should include the current table title as input, the table data of the current state, the question in natural language, the current operation description, and the corresponding operation parameters that should be generated by the large model as the answer part. During training, the small model receives the current table state, the question, and the current operation description as input, and outputs a sequence of predicted operation parameters. The loss function uses cross-entropy loss to calculate the difference between the prediction and a single true operation parameter, expressed by the formula: ; Where O is the operation parameter, t is the fixed operation chain iteration round, n is the iteration round, Q is the question text, T is the table state, and P is the probability distribution generated by the small model, which enables the small model to obtain the basic ability to generate relevant parameters. Secondly, in the second stage of training, the small model takes unprocessed tabular data, table titles, natural language descriptions of related questions, operation chains and their descriptions as input, and only uses the complete operation chains and their parameters processed by the large model as the answer. This trains the small model's ability to independently generate parameters related to complete operation chains. The loss function calculates the difference between the predicted operation parameter sequence and the operation parameter sequence generated by the large model, and the formula is: ; Where Os represents all operation parameters generated for a single table corresponding to the question, t is the table number, m is the number of tables in the dataset, Q is the question text, T is the original table data, and P is the probability distribution of the sequence of all operation parameters generated by the small model, enabling the small model to independently generate the relevant parameters corresponding to the operation sequence. The training dataset includes single-level header table queries and multi-level header tables to further improve generalization ability and avoid overfitting; The small model employs a lightweight language model with parameter size controlled to less than 1 / 10 of the large model to achieve efficient distillation. After training, the small model can accurately simulate the inference mode of the large model, significantly reducing computational overhead while retaining high performance.
[0014] Preferably, in step 2, the method for generating textual summaries for the remaining table rows is as follows: first, the table header information and each row of data in the table are concatenated sequentially into column name-value key-value pairs; finally, the concatenated key-value pair sequence and the corresponding summary generation prompt information are input into the large model to obtain the required row summary; the large model refers to a large language model.
[0015] A table-based question-answering system guided by thought chain is implemented using the aforementioned table-based question-answering method guided by thought chain. The trained small model is integrated with the fixed operation sequence template and deployed as a table-based question-answering system. For new input questions and tables, the system can automatically call the matching fixed operation sequence template and drive the small model to gradually generate operations and operation parameters, perform table transformations, and finally output the answer. At the same time, it outputs a complete and traceable operation history as the basis for reasoning.
[0016] Compared with the prior art, the present invention has the following beneficial effects: (1) By decomposing the table question-and-answer process into a constrained table transformation operation sequence, the gradual evolution of the table state is realized, avoiding the accumulation of errors caused by unconstrained reasoning. (2) By explicitly recording the operation history sequence, the reasoning process of the table question and answer is made traceable and interpretable, which improves the reliability of the system; (3) By transferring complex reasoning capabilities to a lightweight reasoning model, the system can significantly reduce computational resource consumption while ensuring the accuracy of question answering, making it suitable for engineering deployment; (4) The method does not depend on a specific model structure or table format and has good versatility and scalability. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of the table-based question-and-answer method in an embodiment of the present invention; Detailed Implementation
[0018] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.
[0019] See Figure 1 A table-based question-and-answer method guided by thought chain includes the following steps: Step 1: Obtain and process the tabular dataset, which includes table titles, text tables with headers, natural language descriptions of the questions corresponding to the tables, and corresponding standard answers; The table dataset includes authoritative public datasets such as WikiTQ, FetaQA, and TabFact, from which text-based table data, table titles, table-related questions, descriptions, and standard answers are obtained. The processing of the table dataset includes removing various useless tags from the table dataset and parsing the text-based table data into a format that the program can directly process.
[0020] Step 2: Construct the table operation chain required for table processing; including the following four operations: Delete table columns that are irrelevant to the natural language problem. Sort or group the table columns related to the natural language problem; Delete table rows that are irrelevant to the natural language problem. Generate a textual summary for the remaining table rows; Specifically: Deleting table columns unrelated to the natural language problem involves the large model generating the corresponding operations and sequence to be performed next based on the historical operation sequence and parameters of table processing, the current table data state, and prompts generated for the parameters required for the next operation. Finally, a Delete_unrelated_clomn() operation program is designed. The corresponding parameters are input and the program is executed to remove irrelevant columns from the table, retaining only columns that are directly or indirectly related to the problem. The corresponding parameters are the current table data and the index of the column to be removed. The details are shown in Table 1 below: Table 1
[0021] The sorting or grouping of key columns in the table related to the natural language problem refers to the large model generating the corresponding operations and sequences to be performed next by taking the historical operation sequence and parameters of table processing, the current table data state, and prompt words generated for the parameters required for the next operation as input. Finally, a Groupby_or_sortby_clomn() operation program is designed. The corresponding parameters are input and the program is executed to sort or group the key columns in the table related to the problem. The corresponding parameters are the current table, operation selection parameters, and key column names or indexes. The operation selection parameters refer to the int parameter groupby_or_sortby, where a value of 1 executes the Group_by grouping operation, a value of 2 executes the Sort_by sorting operation, and a value of 3 executes the Group_by grouping operation first and then the Sort_by sorting operation. The details are shown in Table 2 below: Table 2
[0022] Deleting table rows unrelated to the natural language problem involves the large model generating the corresponding operations and sequence to be performed next based on the historical operation sequence and parameters of table processing, the current state of the table data, and prompts generated for the parameters required for the next operation. Finally, a Delete_unrelated_rows() operation program is designed. The corresponding parameters are input and the program is executed to retain table rows that are directly or indirectly related to the problem, while removing table rows that are completely unrelated to the problem. The corresponding parameters are the index sequence of the multiple rows to be deleted from the current table data. Generating textual summaries for the remaining table rows involves the large model using the historical operation sequence and parameters of table processing, the current table data state, and prompts generated for the parameters required for the next operation as input to generate the corresponding operation and sequence to be performed next. Finally, a Generate_key_rows_abstract() operation program is designed. The corresponding parameters are input and the program is executed to generate a summary of the table rows that are directly or indirectly related to the problem. The corresponding parameters are the current table, its retained multi-row index sequence, and the prompt information for the operation.
[0023] The details are shown in Table 3 below: Table 3
[0024] Step 3: Construct operation descriptions and prompts for the operation chain; Specifically: the operation description includes the name of the current operation, a detailed description of the execution process of the current operation, and a corresponding operation example; the prompt words include the historical operations of table processing and their parameters, the current table data status, and prompt words for generating parameters required for the next operation; The method for implementing the operation description and prompt words for constructing the operation chain is as follows: Step 3.1: Predefine a corresponding operation description for each table transformation operation. The operation description shall include at least the operation identifier, parameter type description, and executable conditions. Step 3.2: Based on the current table status and operation history sequence, generate control information to limit the optional operation types and parameter value ranges; Step 3.3: Based on the operation description and the control information, determine the next table transformation operation and its corresponding parameters, thereby forming a constrained table reasoning operation chain.
[0025] Step 4: Based on the question described in the natural language and the current table state, the large model operates according to the preset table reasoning operation chain template to determine the next table transformation operation and its corresponding parameters. The table transformation operation must be selected from the first three steps of the operation chain in sequence. Specifically, based on the question described in natural language and the current table state, the large model operates according to a preset table inference operation chain template, specifically: Step 4.1: If this is the first time processing a table, then use the table information as input and select the first operation in the operation chain. The large model will generate the parameters corresponding to the current operation based on the table information, the corresponding table question, and the current operation description. If this is not the first time processing the current table, the large model will select the parameters corresponding to the next operation based on the current table status, the corresponding table question, the historical operation sequence and parameters, and the next operation description and prompt words as input. Specifically, the large-scale model employs a pre-trained language model (such as Llama3-70B), with a structured input format including: the corresponding table question; the current table state: table data in a program-readable and easy-to-write format (such as Markdown), containing header, row, and column information; historical operation sequences and parameters: for example, a JSON-formatted sequence recording the types of operations performed (such as deleting columns, sorting / grouping, deleting rows), their respective parameters (such as column index, column value, row index), and a description and prompt for the next operation; the description and prompt for the next operation: text prompts generated based on a fixed operation sequence template, such as "Historical operation sequences and parameters are: ......; Current table is: ......; The description of the operation to be performed is: ......; Please generate the parameters required for the next operation based on the historical operation sequence and parameters, the current table and its question, and the description of the current operation. The operation parameter type is: ......". The large-scale model generates the corresponding parameters (such as column names or indices) required for the next operation through autoregressive decoding. The generation process is based on an attention mechanism, where the model calculates the probability distribution based on the input context and selects the operation and parameters with the highest confidence. The operation type and operation sequence are strictly limited to the predefined operation chain (delete column, sort group, select row or generate summary) to ensure the standardization of the inference path.
[0026] Step 4.2: Based on the generated operation type, call the corresponding operation program to perform table transformation and update the table state; for each generated operation type, the system integrates a predefined operation program library, specifically including: The Delete_unrelated_column() function takes the current table data and column index as parameters, deletes columns in the table that are not related to the problem, adds a demo example as a prompt, returns the updated table state, and adds the current operation to the operation history sequence. The Groupby_or_sortby_column() function takes the current table, operation selection parameters (such as the groupby_or_sortby value), and key column names, performs grouping or sorting operations, such as sorting by numerical ascending order or grouping and aggregating by category, adds demo examples as prompts, returns the updated table state, and adds the current operation to the history operation sequence. The Delete_unrelated_rows() function takes the current table and row index sequence, deletes rows in the table that are not related to the problem, returns the updated table state, and adds the current operation to the historical operation sequence. The Generate_key_rows_abstract() function receives the current table, the row index sequence, and a prompt message. It converts the specified row into key-value pair text, calls the large model to generate a natural language summary, and adds a demo example as a prompt message. It does not need to record the table state again; it only adds the current operation to the historical operation sequence list. Each operation procedure is designed to be executed atomically to ensure the accuracy and reversibility of table transformations. After execution, the system verifies the operation effect in real time, such as checking whether columns were successfully deleted or whether the sorting was consistent, and updates the table status to intermediate results for use in the next iteration. Step 4.3: For each operation performed above, the current operation type and parameters are added to the historical operation sequence, and the new intermediate table is placed in the table status record. Repeat the above steps until the termination condition is met to generate a complete operation sequence and a complete table status change record. Finally, the large model can directly output the answer and save the traceable operation history based on the table's relevant row summary and its corresponding question.
[0027] Step 5: Based on the operation chain selected by the current large model and the operation description and prompt words of the operation chain, execute the table transformation operation to update the table state and add it to the table change state record, and record the table transformation operation and its corresponding parameters to the operation history sequence; The table change status record and operation history sequence refer to the fact that the current operation parameters generated by the large model under the current table status, table-related issues and current operation description will be saved as a record in the operation history sequence along with the current operation. When the program finishes executing the current operation, it will also save the currently processed table status to the record.
[0028] Step 6: Based on the updated table state, repeat steps 4-5 until the table state meets the termination condition. Then, execute the last step in the operation chain, that is, generate a summary for the remaining table rows and record the last historical operation and its parameters in the operation history sequence. Finally, the large model outputs the answer corresponding to the natural language question based on the text summary of the generated table rows. Specifically: Iteration continues until the table state meets the termination condition before generating a summary for the remaining table rows. The termination condition is reaching a preset number of iterations or the number of table rows is less than a preset number of rows. Preferably, the termination condition is a maximum of 3 iterations or fewer than 10 rows in the table; Once the termination condition is met, the large model needs to generate a text summary of the table rows. The specific process is as follows: First, the table header information is concatenated with each row of data in the table to form a key-value pair format of "column name-value", thus obtaining the key-value pair sequence corresponding to each row; then, the table header data, the concatenated key-value pair sequence of each row, and the prompt information used to generate the summary are fed into the large model as input, and finally, the large model outputs the required row summary. Step 7: To enable the small model to generate executable operations and operation parameter sequences that match the records in the operation history data, under the guidance of a given problem and a preset fixed operation sequence template; This scheme employs the following supervised training method: Based on the original table data or intermediate table data generated during table processing, and combined with table-related questions described in natural language, the model input is used; the intermediate table generated by the large model for the table-related questions, or a historical operation sequence containing complete operational logic and corresponding parameters, is used as the labeled answer, and supervised training is conducted on the small model in two stages; this enables the small model to generate executable operations and operation parameter sequences that match the records in the historical operation data, guided by a given question and a preset fixed operation sequence template.
[0029] The term "small model" specifically refers to a lightweight language model with a parameter size much smaller than that of a large model, such as open-source lightweight language models: Llama-2-7B, Llama-3-7B, Llama-3-8B, etc. These small models have the characteristics of low deployment cost and fast inference speed, and can adapt to the application requirements of lightweight scenarios. The training of the small model employs a two-stage supervised learning approach: First, the first stage of training for the small model is based on the historical data of the thought chain operations generated by the large model as a supervision signal. The training dataset consists of preprocessed samples from multiple authoritative public table datasets, including the WikiTQ dataset, the FetaQA dataset, and the TabFact dataset. Each preprocessed sample should include the current table title as input, the table data of the current state, the question in natural language, the current operation description, and the corresponding operation parameters that should be generated by the large model as the answer part. During training, the small model receives the current table state, the question, and the current operation description as input, and outputs a sequence of predicted operation parameters. The loss function uses cross-entropy loss to calculate the difference between the prediction and a single true operation parameter, expressed by the formula: ; Where O is the operation parameter, t is the fixed operation chain iteration round, n is the iteration round, Q is the question text, T is the table state, and P is the probability distribution generated by the small model, which enables the small model to obtain the basic ability to generate relevant parameters. Secondly, in the second stage of training, the small model takes unprocessed tabular data, table titles, natural language descriptions of related questions, operation chains and their descriptions as input, and only uses the complete operation chains and their parameters processed by the large model as the answer. This trains the small model's ability to independently generate parameters related to complete operation chains. The loss function calculates the difference between the predicted operation parameter sequence and the operation parameter sequence generated by the large model, and the formula is: ; Where Os represents all operation parameters generated for a single table corresponding to the question, t is the table number, m is the number of tables in the dataset, Q is the question text, T is the original table data, and P is the probability distribution of the sequence of all operation parameters generated by the small model, enabling the small model to independently generate the relevant parameters corresponding to the operation sequence. The training dataset includes single-level header table queries and multi-level header tables to further improve generalization ability and avoid overfitting; The small model employs a lightweight language model with parameter size controlled to less than 1 / 10 of the large model to achieve efficient distillation. After training, the small model can accurately simulate the inference mode of the large model, significantly reducing computational overhead while retaining high performance.
[0030] The trained small model is integrated with the fixed operation sequence template and deployed as a table-based question-answering system. A table-based question-and-answer system guided by thought chain is provided. For new input questions and tables, the system can automatically call a matching fixed operation sequence template, drive the small model to gradually generate operations and operation parameters, perform table transformations, and finally output the answer. At the same time, it outputs a complete and traceable operation history as the basis for reasoning.
[0031] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A table-based question-and-answer method guided by thought chain, characterized in that, Includes the following steps: Step 1: Obtain and process the tabular dataset, which includes table titles, text tables with headers, natural language descriptions of the questions corresponding to the tables, and corresponding standard answers; Step 2: Construct the operation chain of the table required to process the table; Includes the following four operations: Delete table columns that are irrelevant to the natural language problem. Sort or group the table columns related to the natural language problem; Delete table rows that are irrelevant to the natural language problem. Generate a textual summary for the remaining table rows; Step 3: Construct operation descriptions and prompts for the operation chain; Step 4: Based on the question described in the natural language and the current table state, the large model operates according to the preset table reasoning operation chain template to determine the next table transformation operation and its corresponding parameters. The table transformation operation must be selected from the first three steps of the operation chain in sequence. Step 5: Based on the operation chain selected by the current large model and the operation description and prompt words of the operation chain, execute the table transformation operation to update the table state and add it to the table change state record, and record the table transformation operation and its corresponding parameters to the operation history sequence; Step 6: Based on the updated table state, repeat steps 4-5 until the table state meets the termination condition. Then, execute the last step in the operation chain, that is, generate a summary for the remaining table rows and record the last historical operation and its parameters in the operation history sequence. Finally, the large model outputs the answer corresponding to the natural language question based on the text summary of the generated table rows. Step 7: Based on the original table data or intermediate table data generated during table processing, and combined with table-related questions described in natural language, use them as model input; use the intermediate table generated by the large model for the table-related questions or the historical operation sequence containing complete operation logic and corresponding parameters as labeled answers, and conduct supervised training tasks on the small model in two stages; so that the small model can generate executable operations and operation parameter sequences that match the records in the operation history data under the guidance of the given question and the preset fixed operation sequence template.
2. The table-based question-and-answer method based on thought chain guidance according to claim 1, characterized in that, In step 1, the table dataset includes authoritative public datasets such as WikiTQ, FetaQA, and TabFact, from which text-based table data, table titles, table-related questions, descriptions, and standard answers are obtained. The processing of the table dataset includes removing various useless tags from the table dataset and parsing the text-based table data into a format that the program can directly process.
3. The table-based question-and-answer method based on thought chain guidance according to claim 1, characterized in that, Step 2 is as follows: Deleting table columns unrelated to the natural language problem involves the large model generating the corresponding operations and sequences for the next step based on the historical operation sequence and parameters of table processing, the current table data state, and prompts generated for the parameters required for the next operation. Finally, a Delete_unrelated_clomn() operation program is designed. The generated parameters are input and the program is executed to remove irrelevant columns from the table, retaining only columns that are directly or indirectly related to the problem. The corresponding parameters are the current table data and the index of the column to be removed. The sorting or grouping of key columns in the table related to the natural language problem refers to the large model generating the corresponding operations and sequences to be performed next by taking the historical operation sequence and parameters of table processing, the current table data state, and prompt words generated for the parameters required for the next operation as input. Finally, a Groupby_or_sortby_clomn() operation program is designed. The corresponding parameters are input and the program is executed to sort or group the key columns in the table related to the problem. The corresponding parameters are the current table, operation selection parameters, and key column names or indexes. The operation selection parameters refer to the int parameter groupby_or_sortby, where a value of 1 executes the Group_by grouping operation, a value of 2 executes the Sort_by sorting operation, and a value of 3 executes the Group_by grouping operation first and then the Sort_by sorting operation. Deleting table rows unrelated to the natural language problem involves the large model generating the corresponding operations and sequence to be performed next based on the historical operation sequence and parameters of table processing, the current state of the table data, and prompts generated for the parameters required for the next operation. Finally, a Delete_unrelated_rows() operation program is designed. The corresponding parameters are input and the program is executed to retain table rows that are directly or indirectly related to the problem, while removing table rows that are completely unrelated to the problem. The corresponding parameters are the index sequence of the multiple rows to be deleted from the current table data. Generating textual summaries for the remaining table rows involves the large model using the historical operation sequence and parameters of table processing, the current table data state, and prompts generated for the parameters required for the next operation as input to generate the corresponding operation and sequence to be performed next. Finally, a Generate_key_rows_abstract() operation program is designed. The corresponding parameters are input and the program is executed to generate a summary of the table rows that are directly or indirectly related to the problem. The corresponding parameters are the current table, its retained multi-row index sequence, and the prompt information for the operation.
4. The table-based question-and-answer method based on thought chain guidance according to claim 2, characterized in that, Step 3 specifically involves: the operation description including the name of the current operation, a detailed description of the execution process of the current operation, and a corresponding operation example; the prompt words including the historical operations of table processing and their parameters, the current table data status, and prompt words for generating parameters required for the next operation; The method for implementing the operation description and prompt words for constructing the operation chain is as follows: Step 3.1: Predefine a corresponding operation description for each table transformation operation. The operation description shall include at least the operation identifier, parameter type description, and executable conditions. Step 3.2: Based on the current table status and operation history sequence, generate control information to limit the optional operation types and parameter value ranges; Step 3.3: Based on the operation description and the control information, determine the next table transformation operation and its corresponding parameters, thereby forming a constrained table reasoning operation chain.
5. The table-based question-and-answer method based on thought chain guidance according to claim 3, characterized in that, In step 4, based on the question described in natural language and the current table state, the large model operates according to a preset table reasoning operation chain template, specifically as follows: Step 4.1: If this is the first time processing a table, then use the table information as input and select the first operation in the operation chain. The large model will generate the parameters corresponding to the current operation based on the table information, the corresponding table question, and the current operation description. If this is not the first time processing the current table, the large model will select the parameters corresponding to the next operation based on the current table status, the corresponding table question, the historical operation sequence and parameters, and the next operation description and prompt words as input. Step 4.2: Based on the generated operation type, call the corresponding operation program to perform table transformation and update the table status; For each generated operation type, the system integrates a predefined operation program library, specifically including: The Delete_unrelated_column() function takes the current table data and column index as parameters, deletes columns in the table that are not related to the problem, adds a demo example as a prompt, returns the updated table state, and adds the current operation to the operation history sequence. The Groupby_or_sortby_column() function takes the current table, operation selection parameters, and key column names, performs grouping or sorting operations, such as sorting by numerical ascending order or grouping and aggregating by category, adds demo examples as prompts, returns the updated table state, and adds the current operation to the history operation sequence. The Delete_unrelated_rows() function takes the current table and row index sequence, deletes rows in the table that are not related to the problem, returns the updated table state, and adds the current operation to the historical operation sequence. The Generate_key_rows_abstract() function receives the current table, the row index sequence, and a prompt message. It converts the specified row into key-value pair text, calls the large model to generate a natural language summary, and adds a demo example as a prompt message. It does not need to record the table state again; it only adds the current operation to the historical operation sequence list. Each operation procedure is designed to be executed atomically to ensure the accuracy and reversibility of table transformations. After execution, the system verifies the operation effect in real time, such as checking whether columns were successfully deleted or whether the sorting was consistent, and updates the table status to intermediate results for use in the next iteration. Step 4.3: For each operation performed above, the current operation type and parameters are added to the historical operation sequence, and the new intermediate table is placed in the table status record. Repeat the above steps until the termination condition is met to generate a complete operation sequence and a complete table status change record. Finally, the large model can directly output the answer and save the traceable operation history based on the table's relevant row summary and its corresponding question.
6. The table-based question-and-answer method based on thought chain guidance according to claim 1, characterized in that, In step 5, the table change status record and operation history sequence refer to the fact that the current operation parameters generated by the large model under the current table status, table-related issues and current operation description will be saved as a record in the operation history sequence along with the current operation. When the program finishes executing the current operation, it will also save the currently processed table status to the record.
7. The table-based question-and-answer method based on thought chain guidance according to claim 1, characterized in that, Step 6 specifically involves iterating until the table state meets the termination condition, then generating a summary for the remaining table rows. The termination condition is reaching a preset number of iterations or having fewer than a preset number of table rows. After reaching this termination condition, the large model needs to generate a text summary of the table rows. The specific process is as follows: First, the table header information is concatenated with each row of data in turn to form a "column name-value" key-value pair format, resulting in a key-value pair sequence for each row. Then, the table header data, the concatenated key-value pair sequence for each row, and the prompt information used to generate the summary are input into the large model. Finally, the large model outputs the required row summary.
8. The table-based question-and-answer method based on thought chain guidance according to claim 1, characterized in that, In step 7, the training of the small model employs a two-stage supervised learning approach: First, the first stage of training for the small model is based on the historical data of the thought chain operations generated by the large model as a supervision signal. The training dataset consists of preprocessed samples from multiple authoritative public table datasets, including the WikiTQ dataset, the FetaQA dataset, and the TabFact dataset. Each preprocessed sample should include the current table title as input, the table data of the current state, the question in natural language, the current operation description, and the corresponding operation parameters that should be generated by the large model as the answer part. During training, the small model receives the current table state, the question, and the current operation description as input, and outputs a sequence of predicted operation parameters. The loss function uses cross-entropy loss to calculate the difference between the prediction and a single true operation parameter, expressed by the formula: ; Where O is the operation parameter, t is the fixed operation chain iteration round, n is the iteration round, Q is the question text, T is the table state, and P is the probability distribution generated by the small model, which enables the small model to obtain the basic ability to generate relevant parameters. Secondly, in the second stage of training, the small model takes unprocessed tabular data, table titles, natural language descriptions of related questions, operation chains and their descriptions as input, and only uses the complete operation chains and their parameters processed by the large model as the answer. This trains the small model's ability to independently generate parameters related to complete operation chains. The loss function calculates the difference between the predicted operation parameter sequence and the operation parameter sequence generated by the large model, and the formula is: ; Where Os represents all operation parameters generated for a single table corresponding to the question, t is the table number, m is the number of tables in the dataset, Q is the question text, T is the original table data, and P is the probability distribution of the sequence of all operation parameters generated by the small model, enabling the small model to independently generate the relevant parameters corresponding to the operation sequence. The training dataset includes single-level header table queries and multi-level header tables to further improve generalization ability and avoid overfitting; The small model employs a lightweight language model with parameter size controlled to less than 1 / 10 of the large model to achieve efficient distillation. After training, the small model can accurately simulate the inference mode of the large model, significantly reducing computational overhead while retaining high performance.
9. A table-based question-and-answer method guided by thought chain according to claim 3, characterized in that, In step 2, the method for generating textual summaries for the remaining table rows is as follows: First, the table header information and each row of data in the table are concatenated sequentially into column name-value key-value pairs; finally, the concatenated key-value pair sequence of each row and the corresponding summary generation prompt information are input into the large model to obtain the required row summary; the large model refers to a large language model.
10. A table-based question-and-answer system guided by thought chain, implemented using the table-based question-and-answer method guided by thought chain as described in any one of claims 1-9, characterized in that, The trained mini-model is integrated with the fixed operation sequence template and deployed as a table question answering system. For new input questions and tables, the system can automatically call the matching fixed operation sequence template and drive the mini-model to gradually generate operations and operation parameters, perform table transformations, and finally output the answer. At the same time, it outputs a complete and traceable operation history as the basis for reasoning.