Encoding Spreadsheets for Large Language Models

Haoyu Dong, Jianbo Zhao, Yuzhang Tian, Junyu Xiong, Mengyu Zhou, Yun Lin, José Cambronero, Yeye He, Shi Han, Dongmei Zhang

Abstract

Large Language Models (LLMs) face significant challenges when processing spreadsheets due to their two-dimensional structure, large scale, and inherent redundancy. We present SHEETENCODER, a framework that compresses spreadsheets by up to 25x while simultaneously enhancing the reasoning capabilities of LLMs. By employing structural-anchor-based compression, inverted-index translation, and data-format-aware aggregation, SHEETENCODER achieves state-of-the-art performance on spreadsheet understanding tasks, outperforming specialized models by over 12%.

Introduction

Spreadsheets are a ubiquitous medium for data storage and analysis, yet they pose significant challenges for Large Language Models (LLMs). Unlike linear text, spreadsheets are inherently two-dimensional, often containing thousands of cells, complex formatting, and multiple tables within a single file. Standard serialization methods often fail due to token limits, loss of spatial context, and high redundancy.

The SHEETENCODER framework overview, illustrating the pipeline from raw spreadsheet to downstream tasks via specialized encoding and compression.

Problem Statement

LLMs face three primary hurdles when processing spreadsheets:

  1. Token Limits: Large files exceed context windows.
  2. Spatial Complexity: 1D serialization destroys 2D structural relationships.
  3. Redundancy: Sparse data and repetitive values waste tokens.

Methodology: The SHEETENCODER Framework

SHEETENCODER introduces three portable compression modules designed to preserve structural integrity while minimizing token usage:

  1. Structural-Anchor-Based Compression: This module identifies "structural anchors"—key rows and columns representing headers or boundaries. It removes repetitive data between these anchors to create a condensed "skeleton" of the spreadsheet.
  2. Inverted-Index Translation: A lossless method that maps unique cell values to their addresses or ranges in a JSON-style dictionary. This effectively eliminates the "token tax" on empty cells and repetitive entries.
  3. Data-Format-Aware Aggregation: This module clusters adjacent cells with identical formats (e.g., dates or currency). By replacing specific values with format strings (like yyyy-mm-dd), it significantly reduces token counts in data-dense regions.
Illustration of the compression modules: (left) Structural-Anchor-Based Compression identifying skeletons, and (right) Inverted-Index Translation and Data-Format-Aware Aggregation.

Additionally, the framework employs a Chain of Spreadsheet Encoding (CoS) pipeline, where the model first identifies relevant table boundaries before performing targeted reasoning.

Experimental Evaluation

The framework was evaluated on two primary benchmarks:

  • Spreadsheet Table Detection: Real-world spreadsheets with annotated boundaries.
  • Spreadsheet QA: A new dataset of 64 spreadsheets and 307 QA tuples requiring navigation of complex, multi-table layouts.

Key Results

  • Massive Compression: SHEETENCODER reduced token usage by an average of 96% compared to vanilla encoding.
  • State-of-the-Art Performance: On table detection, a fine-tuned LLM using SHEETENCODER achieved a 78.9% F1 score, a 12.3% improvement over TableSense-CNN.
  • In-Context Learning Boost: GPT-4’s performance improved by 25.6% in few-shot scenarios when using SHEETENCODER’s compression.
  • QA Accuracy: The framework reached 74.3% accuracy on the Spreadsheet QA benchmark, outperforming baselines like TAPEX and Binder.

Discussion and Limitations

While SHEETENCODER significantly advances spreadsheet processing, limitations remain. Current methods do not incorporate visual cues like cell colors or font styles, which often carry semantic meaning. Furthermore, the system clusters by format rather than semantic meaning (e.g., grouping country names) and is less optimized for long-form text within cells.

Conclusion

SHEETENCODER represents a major step toward "spreadsheet-native" LLMs. By prioritizing structure over raw data and utilizing efficient coordinate-based indexing, it enables LLMs to handle complex tabular data with unprecedented efficiency and accuracy.

Summary updated

BibTeX
@inproceedings{dong2024encoding,
  author = {Haoyu Dong and Jianbo Zhao and Yuzhang Tian and Junyu Xiong and Mengyu Zhou and Yun Lin and José Cambronero and Yeye He and Shi Han and Dongmei Zhang},
  title = {{Encoding Spreadsheets for Large Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.emnlp-main.1154},
}
Figure