Introduction
Microsoft Excel remains a cornerstone of modern data work, used by a vast spectrum of users ranging from casual hobbyists to professional data scientists. While basic operations are accessible, complex tasks such as multi-step data cleaning, conditional formatting, and automated chart generation often require deep technical knowledge of formulas or scripting. To bridge this gap, researchers have introduced INSTRUCTEXCEL, a comprehensive benchmark designed to evaluate and improve the ability of Large Language Models (LLMs) to translate natural language instructions into executable Excel OfficeScripts.
The Challenge of Spreadsheet Automation
Automating spreadsheets presents unique challenges compared to general-purpose code generation. Unlike Python or Java, Excel scripts interact with a live, stateful grid of data. Existing benchmarks often fail to capture these constraints. OfficeScript, a TypeScript-based API, requires models to understand both the intent of the user and the specific structure of the spreadsheet metadata to generate functional code.
The INSTRUCTEXCEL Dataset
The core contribution of this work is the INSTRUCTEXCEL benchmark, which consists of 10,347 samples derived from 2,000 publicly available Excel spreadsheets. The dataset covers over 170 unique Excel operations, ensuring a high degree of diversity.
To ensure the quality and executability of the ground-truth code, the researchers employed a "human-in-the-loop" creation process. Crowdworkers performed specific actions in Excel, used the built-in "Automate" feature to record these actions into clean code, and then provided natural language descriptions of their work.
Each sample in the dataset includes the natural language instruction, spreadsheet metadata (such as URLs and descriptions), and the target OfficeScript code, providing a complete context for model training and evaluation.
Experimental Methodology
The researchers evaluated several strategies for mapping instructions to code:
- Prompting Strategies: Testing GPT-3.5 and GPT-4 in zero-shot and few-shot settings.
- Dynamic Prompting: This "secret sauce" involves searching the training set for tasks semantically similar to the user's query and including them as examples in the prompt.
- API Contextualization: Providing the full OfficeScript API documentation within the model's context window.
- Fine-tuning: Training a specialized T5-Large model on the INSTRUCTEXCEL dataset.
Results and Key Insights
The benchmark proved to be a significant challenge for current AI models. The highest "Exact Match" (EM) score was achieved by the fine-tuned T5 model at 17.0%, while GPT-4 with Dynamic Prompting reached 15.0%. However, automated metrics like EM can be deceptive in the spreadsheet domain, where multiple valid code solutions often exist for the same task. To address this, the authors introduced "Function-based Evaluation," which focuses on the underlying logic rather than specific parameters.
Human evaluations revealed a different story: GPT-4 with Dynamic Prompting was the most reliable, successfully completing tasks 56.91% of the time, compared to 52.38% for the fine-tuned T5. A key finding was that Dynamic Prompting led to a 40% relative improvement across metrics, whereas providing the full API documentation often hindered performance by consuming valuable context space and leading to "hallucinated" code.
Conclusion and Future Directions
InstructExcel highlights the current frontier of spreadsheet automation. While LLMs like GPT-4 show promise, significant hurdles remain, including handling massive spreadsheets that exceed context windows and supporting multi-lingual environments. Future research will likely focus on multi-turn dialogues for clarifying user intent and improving models' structural reasoning over grid data.
Summary updated