Abstract
Analyzing large hierarchical tables with multi-level headers presents challenges due to their complex structure, implicit semantics, and calculation relationships. While recent advancements in large language models (LLMs) have shown promise in flat table analysis, their application to hierarchical tables is constrained by the reliance on manually curated exemplars and the model’s token capacity limitations. Addressing these challenges, we introduce a novel code-augmented LLM-based framework, E⁵, for zero-shot hierarchical table question answering. This approach encompasses self-explaining the table’s hierarchical structures, code generation to extract relevant information and apply operations, external code execution to prevent hallucinations, and leveraging LLMs’ reasoning for final answer derivation. Empirical results indicate that our method, based on GPT-4, outperforms state-of-the-art fine-tuning methods with a 44.38 Exact Match improvement. Furthermore, we present F³, an adaptive algorithm designed for token-limited scenarios, effectively condensing large tables while maintaining useful information. Our experiments prove its efficiency, enabling the processing of large tables even with models having limited context lengths.
Introduction
While Large Language Models (LLMs) have become increasingly proficient at reasoning over simple "flat" tables, hierarchical tables—common in financial reports and scientific literature—remain a significant hurdle. These tables feature multi-level headers and bi-dimensional indexing that are intuitive for human readers but structurally complex for models. Furthermore, they often contain implicit calculations (e.g., "Totals") and frequently exceed the context window limitations of standard LLMs. Existing solutions often rely on expensive, manually curated few-shot exemplars that fail to scale to the diversity of real-world table structures.
Methodology: The E⁵ Framework and F³ Algorithm
To address these limitations, we propose a two-pronged approach: the E⁵ framework for reasoning and the F³ algorithm for data management.
The E⁵ Reasoning Pipeline
E⁵ stands for five distinct steps that guide the LLM through a structured problem-solving process:
- Explain: The model describes the table's hierarchical structure and identifies relevant headers.
- Extract: The model generates Python code (using Pandas) to isolate necessary data into a simplified structure.
- Execute: An external code interpreter runs the generated code, ensuring mathematical accuracy.
- Exhibit: The results of the code execution are presented back to the model.
- Extrapolate: The model uses natural language reasoning to interpret the exhibited data and derive the final answer.
Adaptive Table Compression (F³)
For tables exceeding context limits, the F³ (Find, Filter, and Fill) algorithm identifies the most relevant cells, filters out irrelevant data, and adaptively fills the remaining space with neighboring context using strategies like row-wise, column-wise, or spiral expansion.
Experimental Results
Our framework was primarily benchmarked on HiTab, the leading dataset for hierarchical table QA, alongside flat-table datasets like WikiTableQuestions and TabFact.
Performance Gains
On the HiTab dataset, E⁵ achieved an Exact Match (EM) score of 85.08, representing a staggering 44.38-point improvement over the previous state-of-the-art fine-tuned model (NSM w/ MAPO), which scored 40.70. This demonstrates that a general-purpose model like GPT-4, when augmented with a structured workflow, can significantly outperform specialized, fine-tuned models.
Stability and Efficiency
Compared to the popular ReAct agent framework, E⁵ demonstrated superior stability. While ReAct often fails due to syntax errors or context overflows when processing entire tables, E⁵’s "Extract" step keeps data manageable. As shown in our analysis, E⁵ maintains higher performance even as the number of maximum iterations is reduced, indicating a more efficient reasoning path.
Conclusion
The E⁵ framework effectively bridges the gap between LLM reasoning and complex table structures by utilizing self-explanation and code augmentation. By offloading data manipulation to a Python interpreter, the system bypasses common pitfalls like arithmetic hallucinations. Future work will explore more advanced context-filling strategies and extend the framework to handle multi-table queries, further pushing the boundaries of automated document analysis.
Summary updated