NeedleInATable: Exploring Long-Context Capability of Large Language Models towards Long-Structured Tables

Lanrui Wang, Mingyu Zheng, Hongyin Tang, Zheng Lin, Yanan Cao, Jingang Wang, Xunliang Cai, Weiping Wang

TL;DR

While Large Language Models (LLMs) have mastered "Needle-in-a-Haystack" tests for unstructured text, they remain surprisingly clumsy with structured data. This paper introduces NeedleInATable (NIAT), a benchmark revealing that models often rely on semantic shortcuts rather than true structural understanding. However, teaching models to "locate" cells through specialized synthetic data significantly boosts their performance on complex reasoning tasks.

What Problem Does This Paper Address?

We are increasingly asking LLMs to act as data analysts, feeding them massive Markdown or HTML tables. While models perform well on standard Table Question Answering (TQA) benchmarks, the authors of this paper suspected a "shortcut" was at play.

Existing benchmarks focus on high-level reasoning (e.g., "What was the total revenue in Q3?"). If a model can find the keywords "revenue" and "Q3" using its attention mechanism, it might stumble upon the answer without actually understanding the table's two-dimensional structure. To test this, the authors ask a more fundamental question: Can an LLM simply find a specific cell based on its coordinates? If a model cannot reliably identify the value at Row 10, Column 4, its "reasoning" on larger tables is likely fragile and prone to hallucination.

Comparison of Needle in a Table vs. traditional benchmarks

Methods and Datasets

The researchers developed the NeedleInATable (NIAT) task, which treats every individual table cell as a "needle." They evaluated models using two query types:

  1. Cell Locating: Asking for a value based strictly on coordinates (e.g., "What is the value in the 5th row and 2nd column?"). This tests the model’s ability to parse 2D structures from serialized text.
  2. Cell Lookup: Asking for a value based on header/row keys (e.g., "What is the attendance on August 20?"). This tests semantic retrieval.

The authors constructed the NIAT benchmark using 750 tables sourced from existing datasets like WTQ (WikiTableQuestions), HiTab, and AIT-QA. The resulting dataset contains 287K questions covering three structures (flat, horizontal, and hierarchical) and three formats (Markdown, HTML, and Image).

To fix the performance gaps they found, the authors proposed a "Strong2Weak" data synthesis method. They used GPT-4o to generate 12,000 training samples that include detailed Chain-of-Thought (CoT) reasoning. These samples teach "weaker" models (like Llama-3.1-8B) to systematically count rows and columns to find data, rather than just "guessing" based on proximity.

Key Insights and Ideas

  • The Structural Blind Spot: Models are significantly better at "Lookup" than "Locating." This confirms that LLMs use semantic cues as a crutch. When those cues are removed (Locating), performance craters, showing they don't truly "see" the table grid.
  • "Lost-in-the-Middle-Table": Similar to the "lost-in-the-middle" phenomenon in long-context text, LLMs are great at retrieving cells from the very beginning or end of a table but struggle with the middle rows.
Performance heatmaps showing the Lost-in-the-Middle-Table effect
  • Vision isn't a Panacea: Multimodal LLMs (which "see" table images) actually performed worse on structural tasks. The authors hypothesize that visual encoders (like ViT) fragment the table into patches that break the continuity of rows and columns.
  • Foundational Skills Matter: The most striking insight is that training a model to do the "simple" task of locating cells (NIAT) automatically makes it better at "hard" tasks like math and logic (TQA). Fine-grained perception is the bedrock of robust reasoning.

Key Results

  • Performance Gap: There is a massive disparity between reasoning and perception. For example, a model might achieve high accuracy on a TQA task but fail to locate the same answer cell by its row/column index.
  • The Power of NIAT Training: Fine-tuning Llama-3.1-8B and Qwen-2.5-7B on the 12K synthetic NIAT samples led to an average accuracy gain of 14.55% across four major downstream benchmarks (WTQ, TabFact, HiTab, and TABMWP).
  • State-of-the-Art Reasoning: DeepSeek-R1 showed the strongest "innate" structural understanding, likely due to its reinforcement learning-based reasoning capabilities, but even it showed a performance drop as table size increased.

Limitations and Future Work

The authors acknowledge several areas for growth:

  • Single-Table Focus: The benchmark currently looks at one table at a time. Real-world scenarios often involve multi-table joins or hybrid documents (text + tables).
  • Language and Scale: The study was limited to English and "medium-sized" tables (up to 120k tokens). Future work should explore multi-lingual tables and "extra-long" contexts exceeding thousands of rows.
  • Visual Tokenization: Since MLLMs struggled with table structures, the authors suggest that developing "structure-aware" visual tokenizers is a necessary next step for multimodal table understanding.

Summary updated

BibTeX
@inproceedings{wang2025needleinatable,
  author = {Lanrui Wang and Mingyu Zheng and Hongyin Tang and Zheng Lin and Yanan Cao and Jingang Wang and Xunliang Cai and Weiping Wang},
  title = {{NeedleInATable: Exploring Long-Context Capability of Large Language Models towards Long-Structured Tables}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=z5vZDI2r6J},
}
Figure