Source-linked AI summary

SpreadsheetLLM: Encoding Spreadsheets for Large Language Models

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

arXiv:2407.09025v2cs.AI

TL;DR

LLMs face challenges with spreadsheets’ expansive grids, two-dimensional structures, and cell addresses and formats. SpreadsheetLLM introduces SheetCompressor to encode spreadsheets for LLMs; it reports gains in table detection and spreadsheet QA and concludes that the approach supports large-dataset applications.

  • Problem

    Expansive grids, two-dimensional layouts, and spreadsheet-specific cell addresses and formats make spreadsheets difficult for LLMs to parse and process.

    Source: §1 · p. 1
  • Method

    SheetCompressor encodes spreadsheets for LLMs using structural-anchor extraction and data-format-aware aggregation.

    Source: §1 · p. 2, §3.2 · p. 4, §3.4 · p. 5
  • Results

    Across table detection and spreadsheet QA, performance improves; the table-detection gain over the previous SOTA is 12.3%.

    Source: §1 · p. 2
  • Takeaways & Limitations

    The authors conclude that the framework reduces token usage and computational costs, enabling practical applications on large datasets.

    Source: §6 · p. 9

    The methods omit background-color and border details because they consume too many tokens, and lack sophisticated semantic compression for natural-language cells.

    Source: §3.1 · p. 4, Limitations · p. 10

Abstract

from arXiv · show

Spreadsheets are characterized by their extensive two-dimensional grids, flexible layouts, and varied formatting options, which pose significant challenges for large language models (LLMs). In response, we introduce SpreadsheetLLM, pioneering an efficient encoding method designed to unleash and optimize LLMs' powerful understanding and reasoning capability on spreadsheets. Initially, we propose a vanilla serialization approach that incorporates cell addresses, values, and formats. However, this approach was limited by LLMs' token constraints, making it impractical for most applications. To tackle this challenge, we develop SheetCompressor, an innovative encoding framework that compresses spreadsheets effectively for LLMs. It comprises three modules: structural-anchor-based compression, inverse index translation, and data-format-aware aggregation. It significantly improves performance in the spreadsheet table detection task, outperforming the vanilla approach by 25.6% in GPT4's in-context learning setting. Moreover, fine-tuned LLM with SheetCompressor has an average compression ratio of 25 times, and achieves a state-of-the-art 78.9% F1 score, surpassing the best existing models by 12.3%. Finally, we propose Chain of Spreadsheet for downstream tasks of spreadsheet understanding and validate it in a new and demanding spreadsheet QA task. We methodically leverage the inherent layout and structure of spreadsheets, demonstrating that SpreadsheetLLM is highly effective across a variety of spreadsheet tasks.

1 Introduction

The introduction frames spreadsheets’ size, two-dimensional layout, and cell-specific features as barriers for LLMs, then presents SpreadsheetLLM and SheetCompressor as an encoding-based response. It reports compression and table-detection gains and introduces Chain of Spreadsheet for spreadsheet QA.

1 Introduction

  • Vanilla serialization adds cell addresses and optional formats to spreadsheet sequences, while expansive grids and two-dimensional structure challenge LLM input.Source: §1 · p. 1
  • Structural-anchor extraction retains heterogeneous rows and columns near table boundaries while removing distant homogeneous bands to form a compact spreadsheet skeleton.Source: §1 · p. 2
  • Inverted-index translation replaces row- or column-wise serialization with a lossless JSON dictionary that merges addresses sharing non-empty cell text.Source: §1 · p. 2
  • Data-format-aware aggregation clusters adjacent numerical cells with matching formats or types, representing regions without encoding every exact value.Source: §1 · p. 2
  • 96% lower token usage and a 12.3% advantage over the previous SOTA method are reported for spreadsheet encoding and table detection, respectively.The table-detection comparison is attributed to Dong et al. (2019b).Source: §1 · p. 2
  • Chain of Spreadsheet decomposes spreadsheet reasoning into table detection, matching, and reasoning, and significantly outperformed existing SOTA methods for table QA.Source: §1 · p. 2

2 Related Work

Related work covers spreadsheet representations, spreadsheet understanding tasks, and prompt-compression strategies. The cited approaches leave challenges around multi-table layouts, explicit cell addresses, and preserving structure in compressed tabular data.

Spreadsheet Representation

  • Prior spreadsheet representations span spatial models, sequential models, pretrained language models, and Markdown, HTML, JSON, or DFLoader formats.The review notes that traditional representations assume a single table and omit explicit cell addresses.Source: §2 · pp. 2–3

Spreadsheet Understanding

  • Spreadsheet table detection identifies all tables on a sheet and their ranges, while spreadsheet QA adds the challenge of detecting and matching multiple tables.The review describes spreadsheet QA as an extension of table QA for spreadsheet data.Source: §2 · p. 3

LLMs’ Token Efficiency

  • Prompt-compression methods mainly target natural language and may lose tabular structure, while database schema routing is described as impractical for complex spreadsheet layouts.Source: §2 · p. 3

3 Method

SpreadsheetLLM uses a Markdown-like spreadsheet representation and SheetCompressor’s three combinable modules to compress spreadsheets for LLMs. Chain of Spreadsheet (CoS) extends the approach to spreadsheet question answering.

3.1 Vanilla Spreadsheet Encoding with Cell Value, Address, and Format

  • Markdown-like encoding represents cell values and addresses, with optional formatting; detailed formatting can hurt performance through token costs and weak format handling.The paper notes that including detailed formats can exceed token limits and that LLMs do not effectively use format information.Source: §3.1 · p. 4

3.2 Structural-anchor-based Extraction

  • Structural anchors identify heterogeneous rows and columns at table-boundary edges; extraction filters 75% of spreadsheet content while preserving 97% of rows and columns at those edges.Rows and columns more than k cells from an anchor are discarded; coordinates are remapped after extraction to preserve data relationships.Source: §3.2 · p. 4

3.3 Inverted-index Translation

  • 4.41 to 14.91: lossless inverted-index translation maps repeated values to merged address ranges and excludes empty cells, increasing SheetCompressor’s compression ratio.The method replaces grid-style serialization with a dictionary that indexes addresses by cell value.Source: §3.3 · pp. 4–5

3.4 Data-format-aware Aggregation

  • 14.91 to 24.79: data-format-aware aggregation groups cells by number-format strings or recognized data types, though number-format strings may be absent.The method uses a rule-based recognizer as a complement when cells lack number-format strings.Source: §3.4 · p. 5

3.5 Chain of Spreadsheet

  • CoS first identifies the table and boundaries relevant to a query, then re-inputs that table section with the query to generate a response.The paper validates CoS on a spreadsheet QA task.Source: §3.5 · p. 5

4 Experiments

Experiments assess spreadsheet table detection as a foundational task and spreadsheet QA as a downstream application. They use a validated table-boundary test set and a new dataset for multi-table QA.

4.1.1 Dataset

  • The validated detection test set has 188 spreadsheets and 311 tables, partitioned Small/Medium/Large/Huge at 64:32:70:22 and scored by exact-boundary EoB-0.The test annotations were quality-improved by five human professionals; EoB-0 requires exact top, left, bottom, and right boundaries.Source: §4.1.1 · p. 6

4.1.2 Experiment Setup

  • TableSense-CNN is the detection baseline and micro F1 the primary metric; evaluated LLMs include GPT4, GPT3.5, Llama2, Llama3, Phi3, and Mistral-v2.Source: §4.1.2 · p. 6

4.2.1 Dataset

  • The new multi-table QA dataset samples 64 spreadsheets and contains 307 questions on searching, comparison, and basic arithmetic, excluding composite operations.Each spreadsheet has 4–6 questions, with answers given as a cell address or a formula containing cell addresses.Source: §4.2.1 · p. 6

4.2.2 Experiment Setup

  • TAPEX and Binder serve as adapted QA baselines: a fine-tuned model selects relevant table regions, and inputs exceeding baseline token limits are truncated.Answer accuracy is assessed using the correctness of cell addresses and cell combinations or calculations.Source: §4.2.2 · p. 6

4.2.3 Experiment Procedure

  • QA procedure uses the fine-tuned boundary-detection model as an ablation and evaluates accuracy after table detection, structure understanding, table splitting, and sub-table QA.For exceptionally large tables, a splitting algorithm recognizes headers and concatenates segments to retain contextual integrity.Source: §4.2.3 · pp. 6–7

5 Results

SheetCompressor reduces spreadsheet encoding costs while improving table detection, and the Chain of Spreadsheet pipeline extends the approach to spreadsheet QA. Results cover compression, model performance, spreadsheet sizes, ablations, and downstream QA.

5.1 Compression Ratio

  • 25× compression ratio was achieved on the test set, substantially reducing the computational load for processing large datasets.Table 1 compares compression ratios across SheetCompressor module combinations.Source: §5.1 · p. 7

5.2.1 Main Results

  • Approximately 79% F1 across all datasets made encoding without aggregation SOTA, 27% above the same model fine-tuned on original data and 13% above TableSense-CNN.The table caption identifies Table 2 as the comparison of model and method configurations for spreadsheet table detection.Source: §5.2.1 · p. 7, Table 2 · p. 7
  • 75% over GPT4 and 19% over TableSense-CNN on huge spreadsheets were among the largest reported F1 improvements; gains were smaller on large, medium, and small sheets.The reported improvements were 45% and 17% on large spreadsheets, 13% and 5% on medium spreadsheets, and 8% on small spreadsheets.Source: §5.2.1 · pp. 7–8
  • Nearly 26% improvement in GPT4 performance on all data showed that compact encoding also enhanced in-context learning.The test set also showed a 96% cost reduction for GPT4 and GPT3.5-turbo in in-context learning.Source: §5.2.1 · p. 8

5.2.2 Ablation Experiment Results

  • Removing the extraction module substantially lowered F1, while removing aggregation slightly increased it; the NFS method nevertheless offered high compression.The authors suggest NFS's abstract representations may challenge LLM interpretation; the extraction module also achieved the greatest token reduction.Source: §5.2.2 · p. 8, Table 3 · p. 8

5.3 Spreadsheet QA

  • CoS with SpreadsheetLLM significantly boosted QA accuracy, with a reported 22% increase over baseline GPT4; question-relevant regions added 3% in ICL and 5% in fine-tuning.CoS selects the related table and re-encodes it for downstream tasks without structural-anchor-based extraction.Source: §5.3 · p. 8, Table 4 · p. 8
  • For downstream QA, fine-tuning on spreadsheet table detection improved accuracy by 6% and outperformed TAPEX and Binder by 37% and 12%, respectively.Table 4 defines “-FT” as a model fine-tuned on spreadsheet table detection and applied to QA.Source: Table 4 · p. 8, §5.3 · p. 9

6 Conclusion

SpreadsheetLLM combines spreadsheet encoding and fine-tuning to improve spreadsheet understanding, while Chain of Spreadsheet extends the framework to downstream tasks. The conclusion reports reduced token use and computational costs alongside improved understanding performance.

6 Conclusion

  • The framework addresses spreadsheet size, diversity, and complexity through SheetCompressor, reducing token usage and computational costs.The conclusion describes fine-tuning LLMs as further enhancing spreadsheet-understanding performance.Source: §6 · p. 9
  • Fine-tuning a variety of cutting-edge LLMs further enhances spreadsheet understanding performance.The conclusion presents this alongside the encoding method's handling of spreadsheet size, diversity, and complexity.Source: §6 · p. 9
  • Chain of Spreadsheet extends the framework to downstream spreadsheet tasks and illustrates its broad applicability.The conclusion points to potential applications in spreadsheet data management, analysis, and user interaction.Source: §6 · p. 9

Limitations

The current methods omit spreadsheet background colors and borders and do not use semantic-based compression for natural-language cells. The paper identifies these as areas for further development.

Limitations

  • Background colors and borders are not used because they take too many tokens, despite potentially valuable contextual and visual cues.The limitation concerns the formats currently used by the methods.Source: Limitations · p. 10
  • SheetCompressor does not yet apply sophisticated semantic-based compression to natural-language cells.The paper gives grouping country names under a shared label as an example of a possible approach.Source: Limitations · p. 10
  • Developing advanced semantic compression techniques for natural-language cells is identified as ongoing work.The authors state that such techniques could increase compression and deepen LLM semantic understanding of data.Source: Limitations · p. 10

Ethics Statement

The ethics statement describes data handling and worker protections. A separate spreadsheet-format experiment reports that adding cell-format information can affect detection results differently across settings.

Ethics Statement

  • The authors state that data were collected, analyzed, and reported without bias or influence from external sources.They also state that participant privacy and confidentiality were maintained and personal identifiers were not used.Source: Ethics Statement · p. 10
  • Data-standard personnel were paid according to the highest local standard and limited to no more than eight working hours daily.The ethics statement presents these conditions as protections for workers' rights and interests.Source: Ethics Statement · p. 10

A GPT4 Struggles to Understand Spreadsheets

  • Adding format information marginally improved ICL results on small datasets but worsened larger-dataset results and significantly reduced fine-tuned overall F1.The authors attribute the decline to additional tokens pushing some data beyond model limits and to LLMs' limited ability to understand format information.Source: A GPT4 Struggles to Understand… · p. 13, Table 5 · p. 13

B Traditional Encoding Methods for Spreadsheets

Markdown uses fewer tokens than XML and HTML but lacks explicit cell addresses and handles merged cells poorly. Structural-anchor heuristics propose table boundaries, then retain neighboring rows and columns to preserve headers, titles, and notes.

B Traditional Encoding Methods for Spreadsheets

C Lightweight Heuristics for Structural-anchor Proposal

  • Boundary heuristics enumerate rows and columns with cell-value or formatting discrepancies, filter implausible candidates, then resolve overlaps using position and header evidence.Candidate filtering considers internal sparsity, boundary size, and header-like rows and columns.Source: C Lightweight Heuristics for… · p. 14, Figure 6 · p. 15
  • Candidate boundaries produced by the heuristics achieve 46.3% F1 under the EoB-0 metric; fine-grained discrimination among headers, titles, and notes is challenging for the heuristics.Source: C Lightweight Heuristics for… · p. 14
  • Retaining rows and columns within k=4 of structural anchors preserves over 97% of ground-truth table border rows and columns.Neighboring rows and columns help retain headers, titles, and notes that may span beyond exact table boundaries.Source: C Lightweight Heuristics for… · p. 15

D.1 Results on Structure-anchor Threshold

The threshold study found the strongest table-detection F1 results when four rows and columns were retained near candidate boundaries. The section also reports ICL comparisons, test-set curation, dataset partitions, and estimated processing-cost savings.

D.1 Results on Structure-anchor Threshold

  • Four retained rows and columns yielded the highest F1 score across all datasets, balancing boundary information against compression.Fewer retained rows or columns can reduce Recall, while retaining more can diminish compression and risk exceeding token limits.Source: §D.1 · p. 15, Table 7 · p. 15

D.2 Results of Spreadsheet Table Detection on ICL

  • The GPT4-0125-preview ICL results were consistent with the conclusions from fine-tuned experiments.Table 8 presents ICL ablation results and reports that the compression method achieved the best F1 score in that setting.Source: §D.2 · p. 15, Table 8 · p. 15

E Spreadsheet Table Detection Test Dataset Quality Improvement Pipeline

  • The curated detection test set contains 188 type 1 and type 2 spreadsheet entries, with multiple reasonable labels retained for type 2.Curation excluded non-English spreadsheets and same-workbook overlaps with training data, then used five annotators.Source: E Spreadsheet Table Detection Test… · pp. 15–16

F Spreadsheet Table Detection Test Dataset Partition

  • The detection data was partitioned into small, medium, large, and huge groups using token-count cutoffs of <4k, 4–8k, 8–32k, and >32k.The spreadsheet features were encoded in a Markdown-like style with format information.Source: F Spreadsheet Table Detection Test… · p. 16

H Spreadsheet QA Test Dataset

  • The QA dataset uses English-language spreadsheets and annotator cross-checking; answer labeling achieved Fleiss Kappa agreement of 0.846.Questions were selected to be answerable with relative certainty from the tables.Source: H Spreadsheet QA Test Dataset · p. 16

I Cost calculation

  • 96.0% lower average processing cost was reported for GPT3.5 turbo and GPT4, with similar reductions across the other evaluated LLMs.The calculation uses GPT4 ICL pricing and neglects output sequences because they are much shorter than inputs.Source: I Cost calculation · p. 17

J.1 Compression Results

The compression section reports stage-wise and total compression-ratio tables, notes weaker open-source-model ICL detection performance than closed-source models, and describes QA ablations in which removing modules generally lowers accuracy.

J.2 The ICL results of open-source models on spreadsheet table detection.

  • Open-source models performed far worse than closed-source models in ICL spreadsheet table detection.Table 11 reports open-source models' ICL F1 scores for the task.Source: §J.2 · p. 17, Table 11 · p. 17

J.3 Spreadsheet QA Ablation Experiment

  • Removing any SheetCompressor module generally lowered QA answer accuracy and relevant-region accuracy, with the largest drop when extraction was omitted.The authors suggest the extraction module's lower compression ratio may explain why longer context can hinder accurate interpretation.Source: §J.3 · p. 17, Table 10 · p. 17

J.1 Compression Results

  • Table 9 reports compression ratios for the data region, while Table 10 reports total compression ratios for training and validation datasets.The supplied table captions specify these scopes but do not provide the ratio values.Source: Table 9 · p. 17, §J.1 · p. 17, Table 10 · p. 17

K.1 Comparison of results before and after structural-anchor-based extraction

The case comparisons illustrate how extraction, inverted-index translation, and format-aware aggregation affect spreadsheet table detection. The accompanying prompts specify compressed spreadsheet inputs for detection and a two-stage process for locating QA answers.

K.1 Comparison of results before and after structural-anchor-based extraction

  • Structural-anchor extraction compacted a sparse sheet and changed GPT4-FT's incorrect two-table prediction into the correct range B2:M20.Before extraction, GPT4 predicted B2:AK14 and B19:F25; the authors also report token reduction and improved detection for sparse sheets with many empty cells.Source: §K.1 · pp. 17–18, Figure 7 · p. 17

K.2 Comparison of results before and after inverted-index translation

  • Inverted-index translation let GPT4-FT separate two nearby tables, correcting a single predicted range B1:D14 to B1:D10 and B11:D14.The example attributes the improvement to aggregating shared cell values and recognizing semantic relationships across non-adjacent rows and columns.Source: §K.2 · p. 18, Figure 8 · p. 18

K.3 Comparison of results before and after data-format-aware cell aggregation

  • Format-aware aggregation replaced date and numeric values with format or type labels while preserving the correct predicted range B1:C38.The example reports reduced token count while retaining the spreadsheet's semantic information.Source: §K.3 · p. 18, Figure 9 · p. 18

K.4 Comparison of SPREADSHEETLLM and TableSense-CNN

  • SPREADSHEETLLM included R5:R14 in the second table range K5:R14, which TableSense-CNN omitted as K5:M14.The example describes the added region as semantically related to the cells on its left despite being spatially distant.Source: §K.4 · p. 18, Figure 10 · p. 19

A Vanilla Prompt Template for Spreadsheet Table Detection:

L.2 Prompt Template for Spreadsheet Table Detection

  • The detection prompt encodes cells as content-address tuples, permits format and datatype regions, and asks for table ranges without titles or comments.Empty cells may be omitted from the compressed input.Source: §L.2 · pp. 19–20

L.3 Prompt Template for Spreadsheet QA

  • The QA prompt first asks how many tables there are and which table contains the answer, then asks for the answer's cell address.Stage 1 uses compressed spreadsheet input; Stage 2 supplies the chosen table and question.Source: §L.3 · p. 20
Loading 2407.09025v2…