Introduction
Spreadsheet formulas are the backbone of modern data analysis, yet they remain a significant hurdle for many users. Traditional AI models for formula automation often fail due to grammar fragility and a lack of user interaction. HERMES introduces a novel framework that moves away from error-prone "left-to-right" formula generation. Instead, it builds formulas hierarchically using "Formulets"—common structural patterns mined from real-world data. By generating formulas based on their underlying parse tree, HERMES guarantees grammatical correctness and enables a powerful interactive interface where users can co-create complex formulas step-by-step.
Problem Statement
Despite being the world's most popular "programming language," spreadsheet formulas present two major challenges for AI automation:
- Grammar Fragility: Most models generate formulas one token at a time. A single mistake early on cascades into a completely invalid formula.
- The "All-or-Nothing" Trap: Existing systems are typically "black boxes," providing a final prediction that the user must either accept or reject, with no room for collaborative refinement.
HERMES addresses these by respecting the tree-like structure of formulas and fostering a dialogue between the human and the machine.
Methodology: Hierarchical Formulet Expansion
The core innovation of HERMES is Hierarchical Formulet Expansion. Instead of predicting individual characters, the model predicts Formulets—pre-defined sub-trees representing common idioms like SUM([Cell]:[Cell]) or ( [Cell] - [Cell] ) / [Cell].
The system operates in a three-stage pipeline:
- Sketch Decoder (SD): Builds the structural skeleton (the sketch) by iteratively expanding nodes in a parse tree using Formulets.
- Value Decoder (VD): Fills in constant values, such as specific numbers or text strings.
- Cell Reference Decoder (CRD): Identifies specific cell references (e.g.,
A1,B20) by calculating context similarity.
To enable interactivity, a lattice-based sampling strategy is used during training, allowing the model to learn how to complete formulas regardless of which part the user fills in first.
Data and Evaluation
The researchers evaluated HERMES using two primary benchmarks:
- Enron Corpus: A database of over 17,000 real-world spreadsheets, providing 106,000 table-formula pairs.
- FUSE Corpus: 30,000 samples used to test generalization to unseen spreadsheets.
- Formulet Library: 2,223 unique multi-level patterns mined to serve as building blocks.
Key Results
HERMES significantly outperformed previous state-of-the-art models like FORTAP and SpreadsheetCoder:
- Accuracy: On the Enron dataset, HERMES achieved 60.3% top-1 formula accuracy, a 4.5% improvement over the previous best.
- Sketch Success: Structural "sketch" prediction reached 78.8%.
- Interactive Potential: Under the Interaction Upper Bound (IUB) metric, sketch accuracy jumped to 96.9%, suggesting that minimal user guidance can solve nearly any formula task.
- Efficiency: HERMES reduced the number of generation steps by nearly 50% compared to token-by-token methods.
Conclusion and Future Work
HERMES demonstrates that grammar-by-design and pattern-based thinking are superior to standard autoregressive models for structured tasks. While highly effective, future work will focus on expanding contextual awareness beyond immediate rows/columns and aligning AI suggestions more closely with human reasoning patterns. This hierarchical approach holds promise for other structured languages like SQL or command-line scripts.
Summary updated