Abstract
Retrieval-Augmented Generation (RAG) has demonstrated considerable effectiveness in open-domain question answering. However, when applied to heterogeneous documents, comprising both textual and tabular components, existing RAG approaches exhibit critical limitations. The prevailing practice of flattening tables and chunking strategies disrupts the intrinsic tabular structure, leads to information loss, and undermines the reasoning capabilities of LLMs in multi-hop, global queries. To address these challenges, we propose TableRAG, an SQL-based framework that unifies textual understanding and complex manipulations over tabular data. TableRAG iteratively operates in four steps: context-sensitive query decomposition, text retrieval, SQL programming and execution, and compositional intermediate answer generation. We also develop HeteQA, a novel benchmark designed to evaluate the multi-hop heterogeneous reasoning capabilities. Experimental results demonstrate that TableRAG consistently outperforms existing baselines on both public datasets and our HeteQA, establishing a new state-of-the-art for heterogeneous document question answering.
Introduction: The "Broken Table" Problem
Standard Retrieval-Augmented Generation (RAG) systems are designed primarily for unstructured text. When encountering "heterogeneous" documents—those containing both prose and structured tables—these systems typically "flatten" tables into Markdown or CSV formats and split them into chunks for indexing.
This approach introduces two fundamental flaws. First, structural information loss occurs when chunking severs the relationships between rows and columns, obscuring the table's logic. Second, it lacks a global view. For queries requiring aggregation (e.g., "What is the average value in Column A?"), a standard RAG system only retrieves the most "similar" fragments, never seeing the full dataset. This often results in mathematically incorrect or incomplete answers.
The TableRAG Framework
To overcome these limitations, TableRAG treats tables as structured databases rather than flat text. The framework operates in two distinct phases:
Offline Phase: Database Construction
Instead of simple indexing, TableRAG parses tables and stores them in a relational database (e.g., MySQL). Crucially, it maintains a mapping function that links flattened table chunks in the vector database back to their original structured schema in the relational database.
Online Phase: Iterative Reasoning
When a query is received, TableRAG enters a four-step iterative loop:
- Context-Sensitive Query Decomposition: The LLM breaks the complex question into manageable sub-queries.
- Text Retrieval: Relevant text and table fragments are searched using vector embeddings.
- SQL Programming and Execution: If a table is identified as relevant, TableRAG prompts the LLM to write and execute an SQL query against the relational database. This enables precise filtering, math, and aggregation that LLMs struggle to perform through text alone.
- Compositional Answer Generation: The system synthesizes the SQL results and retrieved text to form an intermediate answer, repeating the loop until a final conclusion is reached.
Evaluation and Benchmarking
The effectiveness of TableRAG was evaluated on two established benchmarks—HybridQA and WikiTableQuestion (WikiTQ)—and a new benchmark, HeteQA.
HeteQA was specifically designed to test multi-hop heterogeneous reasoning. It consists of 304 high-quality examples across nine domains, including Sports, Technology, and Culture. Notably, 18% of its questions require "multi-source" reasoning, necessitating the combination of information from both text and tables.
Key Results and Insights
TableRAG consistently outperformed baselines such as NaiveRAG, ReAct, and specialized models like TableGPT2.
- Superior Accuracy: On HeteQA, TableRAG (using Claude-3.5) achieved an accuracy of 44.19%, compared to 34.54% for NaiveRAG and 29.60% for ReAct.
- State-of-the-Art Performance: It reached 84.62% accuracy on WikiTQ, setting a new benchmark for complex data manipulation.
- SQL as a Symbolic Interface: A key insight is that LLMs are more effective at writing code to solve problems than performing calculations directly. SQL ensures 100% accuracy in data manipulation, provided the query logic is sound.
Limitations and Future Work
While powerful, TableRAG's performance is heavily dependent on the underlying LLM's ability to generate accurate SQL and decompose queries. Smaller models show a significant performance drop. Additionally, the current HeteQA benchmark is limited to English, leaving cross-lingual generalization as a future challenge. The authors plan to expand the framework's compatibility with open-source models and extend benchmarks to multi-lingual settings.
Summary updated