Abstract
Large Language Models (LLMs) are primarily optimized for one-dimensional text sequences, creating a fundamental mismatch when processing two-dimensional tabular data. Standard "flattening" techniques destroy spatial relationships, making it difficult for models to relate cells that are vertically adjacent but token-distant. We introduce 2D-TPE (Two-Dimensional Table Positional Encoding), a novel plug-and-play method that enables attention heads to dynamically select optimal table traversal orders (e.g., row-wise vs. column-wise). Our approach significantly outperforms standard 1D baselines on complex table reasoning tasks and exhibits remarkable stability as table sizes scale.
Introduction
The real world relies heavily on structured data, yet LLMs struggle to interpret tables effectively. To process a table, it is typically flattened into a 1D string, often row-by-row. This process introduces a "spatial disconnect": in a large table, a cell and the one directly below it might be separated by hundreds of tokens.
The authors demonstrate that standard LLMs fail even at simple "proxy tasks" designed to test basic spatial awareness, such as identifying cells in the same column or navigating relative to a reference point.
Methodology: 2D-TPE
2D-TPE builds upon the Rotary Positional Embedding (RoPE) framework to preserve 2D structure. Unlike static flattening, 2D-TPE allows each attention head to choose its own "view" of the table.
Dynamic Routing and Permutation
The core of 2D-TPE is a Routing Network—a small MLP-based router added to each attention layer. It calculates routing weights that determine which traversal order (permutation) is most relevant for a specific token at a specific head. For example, one head might prioritize a row-wise view while another focuses on a column-wise view.
To ensure clarity, an Auxiliary Entropy Loss is employed to encourage the model to pick one primary traversal mode per head rather than blending views. Furthermore, Permutation Re-ranking ensures that the causal nature of the LLM is maintained relative to the chosen structural traversal before applying self-attention.
Experimental Evaluation
The researchers evaluated 2D-TPE using both newly introduced proxy tasks and standard benchmarks:
- Proxy Tasks: Counting-Stars (identifying cells in the same row/column) and Locating-Values (relative navigation).
- Standard Benchmarks: HiTab (hierarchical QA), TURL (annotation and extraction), and FeTaQA (free-form QA).
The proxy tasks revealed a dramatic failure in 1D models: in a 20x20 table, standard models achieved less than 5% accuracy on Counting-Stars, proving that increased data alone cannot fix structural misunderstanding.
Key Results and Insights
2D-TPE consistently outperformed strong baselines, including specialized table models like TABBIE, across all benchmarks.
- HiTab Performance: 2D-TPE achieved 68.19% accuracy, compared to 66.31% for standard row-wise flattening.
- Scalability: 2D-TPE's most significant advantage is its robustness to table size. When HiTab table lengths increased from ~600 to ~2,600 tokens, the row-wise baseline's accuracy plummeted from 57% to 27%. In contrast, 2D-TPE only dropped from 59% to 54%.
- Efficiency: The method is highly efficient, increasing memory usage and TFLOPs by less than 2%, with a modest 13% increase in inference time.
- Model Agnostic: The approach was successfully validated on both MiniCPM-2B and Llama-3-8B.
Conclusion
2D-TPE addresses the fundamental limitation of 1D sequence modeling for 2D data. By allowing dynamic, head-specific structural views, it enables LLMs to reason about tables with much greater spatial accuracy and scalability. Future work may explore more complex traversal patterns, such as Hilbert-curves or Z-orders, and extend this dynamic permutation approach to other structured data types like graphs or 3D point clouds.
Summary updated