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.
1. Introduction: The Limitation of Standard RAG
Standard Retrieval-Augmented Generation (RAG) systems typically process documents by "chunking" them into small text segments and indexing them for vector retrieval. While effective for unstructured text, this approach fails significantly when documents contain complex tables. The common practice of "flattening" a table into Markdown or CSV format before chunking leads to two primary issues:
- Structural Information Loss: Chunking often splits tables arbitrarily, separating headers from data rows and breaking the semantic links necessary for an LLM to interpret the data correctly.
- Lack of Global Perspective: For "global" queries—such as calculating averages or finding maximum values across an entire column—standard RAG only retrieves a few relevant chunks. Consequently, the model never sees the complete dataset required for accurate calculation.
TableRAG addresses these gaps by treating tables as structured relational databases rather than simple text, allowing for precise symbolic reasoning alongside semantic text retrieval.
2. The TableRAG Framework
TableRAG introduces a robust two-stage architecture designed to bridge the gap between unstructured text and structured data.
2.1 Offline Database Construction
Instead of relying solely on text indexing, TableRAG extracts tables from heterogeneous documents and stores them in a relational database (e.g., MySQL). A key innovation is the creation of a "tabular schema database" that maps flattened table chunks back to their original SQL schemas. This ensures that even if a specific table fragment is retrieved via semantic search, the system can identify the corresponding structured table for SQL execution.
2.2 Online Iterative Reasoning
During the query phase, TableRAG follows an iterative four-step loop:
- Context-Sensitive Query Decomposition: The Large Language Model (LLM) breaks complex, multi-hop questions into manageable sub-queries.
- Text Retrieval: Standard vector search identifies relevant textual passages.
- SQL Programming and Execution: For sub-queries requiring tabular data, an "NL2SQL" module generates executable SQL. This allows the system to perform global operations (like
AVG,SUM, orCOUNT) directly on the database. - Compositional Answer Generation: The LLM synthesizes results from both SQL execution and text retrieval to form intermediate answers, repeating the process until a final conclusion is reached.
3. Experimental Evaluation
The framework was evaluated across three major benchmarks:
- HybridQA: A standard dataset for multi-hop questions involving both tables and text.
- WikiTableQuestion (WikiTQ): Focused on complex reasoning over tabular data.
- HeteQA: A new benchmark introduced by the authors to specifically test multi-hop reasoning across heterogeneous sources. It includes 304 high-quality examples across nine domains, such as Sports, Technology, and Military.
4. Key Results and Insights
TableRAG demonstrates superior performance compared to baselines like NaiveRAG, ReAct, and TableGPT2.
- Accuracy: On the HeteQA benchmark, TableRAG achieved an overall accuracy of 44.85% (using DeepSeek-V3), outperforming standard RAG approaches which typically hover around 35%.
- Efficiency and Latency: TableRAG resolved 63.55% of queries in fewer than five reasoning steps. By using precise SQL calls instead of verbose "Chain-of-Thought" reasoning for every table row, it reduced total latency by nearly 50% compared to the ReAct framework.
- Symbolic vs. Semantic Reasoning: The results highlight that while text is best handled semantically, tables require symbolic manipulation. TableRAG successfully toggles between these modes dynamically.
5. Conclusion and Future Work
While TableRAG sets a new state-of-the-art, it remains dependent on the underlying LLM's ability to generate accurate SQL. Future work will focus on improving performance with smaller models, extending support to multilingual settings, and reducing the setup overhead required for offline table parsing.
Summary updated