Abstract
Large Language Models (LLMs) have demonstrated remarkable capabilities in natural language understanding, yet they face significant hurdles when reasoning over large-scale tabular data. Constraints such as the "lost in the middle" effect, input truncation, and hallucinations often occur when tables exceed the model's context window. We present TabSQLify, a method designed to enhance table reasoning by decomposing large tables into task-relevant snippets using SQL. By leveraging the symbolic precision of SQL for sub-table selection, TabSQLify significantly reduces context length and computational overhead. Our evaluation across four major benchmarks—WikiTQ, TabFact, FeTaQA, and WikiSQL—shows that TabSQLify not only improves accuracy but also maintains robustness on tables that typically cause standard LLMs to fail.
1. Introduction
Table reasoning, the task of answering questions or verifying facts based on structured data, requires a unique blend of linguistic comprehension and logical operations. While state-of-the-art LLMs like GPT-4 are proficient at these tasks for small tables, their performance degrades sharply as table size increases. When a table is too large to fit into a prompt, or even when it occupies a significant portion of the context window, models often fail to aggregate data correctly or hallucinate values from the "haystack" of information.
Existing solutions often rely on complex multi-step agents or intensive self-consistency sampling, which are computationally expensive and slow. TabSQLify addresses these challenges by introducing a "look before you leap" philosophy: pruning the table to its most essential components before the reasoning process begins.
2. Methodology
The core of TabSQLify is the Decomposition of the reasoning task into symbolic retrieval and neural reasoning. The process follows three primary stages:
2.1 Table Preprocessing
To ensure the robustness of the generated SQL queries, the system first normalizes dates and numerical values. For example, varied date formats (e.g., "31 Oct 2008") are converted into a standardized ISO format ("2008-10-31"). This step minimizes syntax errors during the execution phase.
2.2 Sub-table Selection (The Filter)
Instead of processing the entire table, the LLM is provided with the table's schema (column names), the title, and three representative example rows. The model is then prompted to generate a SQL query designed to retrieve only the rows and columns necessary to answer the specific user question. This query is executed against the original table using a standard engine like SQLite to produce a concise "sub-table."
2.3 Reasoning and Answer Generation
The resulting sub-table, which is typically a fraction of the size of the original, is fed back to the LLM alongside the original question. The model then employs Chain-of-Thought (CoT) prompting to perform the final reasoning and generate the answer. This ensures that the "answer" is always front-and-center in the model's context.
3. Experimental Setup
The authors evaluated TabSQLify across four diverse benchmarks:
- WikiTQ (WikiTableQuestions): Complex questions requiring comparisons and arithmetic.
- TabFact: Large-scale fact verification (binary classification).
- FeTaQA: Free-form table question answering requiring descriptive responses.
- WikiSQL: A test of basic semantic parsing and SQL generation.
4. Key Results and Insights
4.1 Performance and Accuracy
TabSQLify achieved significant gains over LLM-based baselines. Using GPT-3.5-turbo, the method reached 64.7% accuracy on WikiTQ and 79.5% on TabFact. Notably, the system achieved these results using only one or two samples, whereas competing models like BINDER or DATER often require 20 to 100 samples to achieve comparable performance through self-consistency.
4.2 Context Reduction and Efficiency
The most striking result was the reduction in token usage. In the WikiTQ dataset, the average table size was pruned from 183 cells down to just 32 cells. This reduction is critical for cost-efficiency and for staying within the token limits of smaller or more restricted models.
4.3 Robustness to Scale
TabSQLify demonstrated superior performance on "Large" instances (those exceeding 4000 tokens). While some competing models dropped to 0% accuracy because they could not handle the input length, TabSQLify maintained a 52.3% accuracy by successfully reducing the input to a manageable size.
4.4 Symbolic Power
The study highlights that SQL is scale-invariant. A query to find a "maximum value" functions identically regardless of whether the table has 10 rows or 10,000. By using SQL as an intermediate step, TabSQLify leverages the symbolic precision of databases to bypass the inherent neural limits of LLMs.
5. Limitations
While effective, TabSQLify is dependent on the accuracy of the initial SQL generation. If the LLM generates a query with a typo or an incorrect logic gate (e.g., an error in a WHERE clause), the resulting sub-table may be empty or irrelevant, leaving the reasoning step with no data to process. Additionally, the method assumes data can be represented in a relational format; tables with highly unstructured layouts or complex merged cells still present a challenge for this decomposition approach.
6. Conclusion
TabSQLify represents a significant step forward in making table reasoning more scalable and efficient. By treating the LLM as a sophisticated interface for SQL generation rather than a brute-force data processor, the framework achieves state-of-the-art results with a fraction of the context and computational cost. Future work will likely focus on self-correction mechanisms to further refine the SQL generation phase and handle increasingly irregular data structures.
Summary updated