FLAME: A Small Language Model for Spreadsheet Formulas

Harshit Joshi, Abishai Ebenezer, José Pablo Cambronero Sánchez, Sumit Gulwani, Aditya Kanade, Vu Le, Ivan Radicek, Gust Verbruggen

Abstract

Spreadsheet formulas represent a unique programming paradigm used by billions, yet they remain underserved by large-scale code models. We present FLAME, a 60-million parameter T5-based model optimized specifically for Excel. By employing domain-specific tokenization, sketch-based deduplication, and specialized pre-training objectives like language-aware masking and user-inspired denoising, FLAME achieves performance comparable to or exceeding models three orders of magnitude larger, such as Codex-Davinci (175B). Our results demonstrate that for specialized domains like spreadsheets, precise architectural and training choices can outweigh raw parameter scale.

Introduction

While Large Language Models (LLMs) have revolutionized general programming assistance through tools like GitHub Copilot, spreadsheet users have largely been left behind. General-purpose code models are often inefficient for client-side deployment and waste significant expressive power on natural languages and programming syntax (like C++ or Python) irrelevant to Excel. FLAME addresses the challenge of creating a "small but mighty" model that is efficient enough for local deployment while remaining accurate enough to handle the unique, grid-based logic of spreadsheet formulas.

Methodology

FLAME is built on the T5-small encoder-decoder architecture. Its success stems from three domain-specific innovations:

1. Sketch Deduplication

To avoid training on millions of nearly identical formulas (e.g., =SUM(A1:A10) vs. =SUM(B1:B10)), formulas are converted into "sketches" where constants and references are replaced by types. This reduced a massive corpus of 927M formulas to a diverse set of 6.1M unique logical patterns. Interestingly, global deduplication across the entire dataset was found to hurt performance; deduplicating per workbook provided the optimal balance of diversity and realism.

2. Excel-Specific Tokenizer

Standard tokenizers often fragment Excel functions or cell references in ways that destroy semantic meaning. FLAME utilizes a custom tokenizer that treats punctuation, function names, and digits as individual tokens, combined with Byte-Pair Encoding (BPE) for strings and sheet names.

3. Specialized Pre-training

Beyond standard masking, FLAME incorporates two novel objectives:

  • Language-aware Masked Span Prediction (laMSP): This objective masks spans while respecting Excel lexer boundaries, ensuring the model learns complete structural units (e.g., full cell references).
  • User-inspired Denoising: The model is trained to "fix" formulas injected with 17 types of noise based on common real-world user mistakes, such as incorrect function arity.
FLAME's specialized pre-training objectives: Language-aware Masked Span Prediction (laMSP) and User-inspired Denoising.

Evaluation and Results

FLAME was evaluated against several benchmarks, including a "Forum Benchmark" of 273 real-world buggy formulas and the Enron Corpus for retrieval tasks.

Performance

In the Forum benchmark, FLAME achieved a 0.71 Top-1 accuracy (zero-shot), significantly outperforming Codex-Davinci (0.60) and Codex-Cushman (0.55). In formula completion tasks, FLAME outperformed much larger models in 10 out of 14 evaluation settings, showing particular strength in "Exact Match" completion where general models often hallucinate references.

Performance comparison of FLAME variants against larger models on Last Mile Repair (LMR) and Formula Completion tasks.

Efficiency

Due to its compact 60M parameter size, FLAME is capable of running on a standard CPU with low latency. It performs formula embedding for retrieval tasks up to 41% faster than CodeT5, making it highly suitable for client-side integration within spreadsheet software.

Discussion and Conclusion

The primary insight from FLAME is that domain specificity can effectively compensate for scale. By making pre-training objectives "lexer-aware," the model learns the underlying grammar of Excel rather than just statistical character associations.

Future work includes incorporating grid context—allowing the model to "see" surrounding cell data—and integrating symbolic search strategies to further improve accuracy by ensuring syntactic validity during decoding.

Summary updated

BibTeX
@inproceedings{joshi2024flame,
  author = {Harshit Joshi and Abishai Ebenezer and José Pablo Cambronero Sánchez and Sumit Gulwani and Aditya Kanade and Vu Le and Ivan Radicek and Gust Verbruggen},
  title = {{FLAME: A Small Language Model for Spreadsheet Formulas}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  doi = {10.1609/aaai.v38i12.29197},
}
Figure