propenster/excel-slm-0.5b
A 0.5B-parameter model that turns a plain-English request plus a preview of a worksheet into an Excel formula for a target cell. Fine-tuned from Qwen/Qwen2.5-Coder-0.5B-Instruct on real spreadsheets from Sheetpedia.
Merged 16-bit weights, ready to use with Transformers.
Results
Held-out Sheetpedia test split: 481 formula tasks from workbooks never seen in training (split by workbook, so no table appears in both train and test). Both models get the identical prompt.
| Metric | Base Qwen2.5-Coder-0.5B-Instruct | This model |
|---|---|---|
| Exact formula match (normalized) | 15.2% | 46.6% |
| Uses all reference functions | 45.3% | 87.1% |
Output starts with = and is non-empty | 100.0% | 100.0% |
How to read these numbers:
- Exact match compares text after removing whitespace and case, so it understates accuracy:
=COUNTIF(F2:F7,">"&1000)is correct but does not match=COUNTIF(F2:F7,">1000"). - Uses all reference functions is a looser signal: right functions, but references may still be wrong.
- 11 test prompts longer than 2,048 tokens were skipped for both models.
Execution sanity check (small)
Predicted formulas are written into real .xlsx files and recalculated with headless LibreOffice Calc; the cell value must match the expected value.
| Base | This model | |
|---|---|---|
| Correct results | 0/6 | 5/6 |
This benchmark has only 6 hand-written tasks, so it is a smoke test, not a reliable accuracy estimate.
Usage
The model was trained on one prompt format: a system prompt, then a user message with the task, the request, and a Markdown preview of the sheet (Row column plus column letters). Use the same format for best results.
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "propenster/excel-slm-0.5b"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto")
messages = [
{"role": "system", "content": "You are an expert Microsoft Excel assistant. Write accurate, executable Excel formulas grounded in the provided worksheet structure. Never guess arithmetic in your head when a formula or tool execution is required."},
{"role": "user", "content": "Task: Write the Excel formula for cell I3 (<TARGET>) in sheet 'Sales'.\nRequest: Sum Revenue (F2:F7) where Region (B2:B7) is West and Product (C2:C7) is Alpha.\n\nSpreadsheet Context:\n| Row | A | B | C | D | E | F | G | H | I |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n| 1 | OrderID | Region | Product | Units | UnitPrice | Revenue | | Metric | Value |\n| 2 | 1001 | West | Alpha | 10 | 120 | 1200 | | Total Revenue | |\n| 3 | 1002 | East | Beta | 5 | 180 | 900 | | West Alpha Revenue | <TARGET> |\n| 4 | 1003 | West | Gamma | 8 | 100 | 800 | | | |\n| 5 | 1004 | North | Alpha | 12 | 120 | 1440 | | | |\n| 6 | 1005 | West | Alpha | 6 | 120 | 720 | | | |\n| 7 | 1006 | East | Alpha | 4 | 120 | 480 | | | |\n\nRespond with ONLY the Excel formula starting with '='."},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=96, do_sample=False)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
# Expected: =SUMIFS(F2:F7,B2:B7,"West",C2:C7,"Alpha")
Variants
propenster/excel-slm-0.5b: merged 16-bit weights (easiest to use)propenster/excel-slm-0.5b-lora: LoRA adapter onlypropenster/excel-slm-0.5b-GGUF: Q4_K_M GGUF (if published)
Training data
- Formulas and tables: real spreadsheets from Sheetpedia. For each target cell, the model sees a Markdown preview of the sheet with the target masked as
<TARGET>and other formula cells shown as values (never as formulas), so the answer cannot be copied from the context. - Requests: each natural-language request was written by a teacher model (
deepseek/deepseek-chat) from the table and the hidden formula, then verified: the teacher had to rebuild an equivalent formula from the request and table alone (same functions and cell references), otherwise the example was discarded. - Filters: formulas longer than 150 characters and very large table previews were excluded; near-duplicate formulas (same structure, different row) were removed.
- Split by workbook: train 5,137, validation 511, test 492 examples.
Training
LoRA (r=16, alpha=32, all attention and MLP projections) with Unsloth, 16-bit, 2 epochs, lr 2e-4, cosine schedule, effective batch 16, max length 2,048 tokens. Loss is computed only on the assistant's formula, not on the prompt. The checkpoint with the lowest validation loss was kept.
Limitations
- Small model (0.5B): expect mistakes. Check formulas before relying on them, especially in financial work.
- Lookups where the request gives a literal value ("find the product for order 1004") are a known weak spot: the model sometimes looks up a cell instead of the value.
- Sees at most about 25 rows x 12 columns of the sheet, and only the target sheet. Cross-sheet formulas work only when the request names the other sheet and its ranges.
- Trained only on formulas up to 150 characters; long nested formulas are out of scope.
- Requests in the training data are synthetic (teacher-written), and the spreadsheets are mostly English.
- Evaluation is mostly text-based; execution-based evaluation so far covers only a handful of tasks.
License and data provenance
- Base model:
Qwen/Qwen2.5-Coder-0.5B-Instruct. Check its license on its model page. - Training spreadsheets: Sheetpedia, listed on Hugging Face as CC-BY-SA-4.0 (attribution + ShareAlike).
- Training requests: generated with
deepseek/deepseek-chat; the teacher model's license terms may apply to models trained on its outputs.
Please review these terms for your own use case.
Citation
If you use this model, please cite Sheetpedia:
@inproceedings{tian2025sheetpedia,
title = {Sheetpedia: A 300K-Spreadsheet Corpus for Spreadsheet Intelligence and LLM Fine-Tuning},
author = {Tian, Zailong and Han, Zhuoheng and Wang, Houfeng and Liao, Lizi},
booktitle = {Advances in Neural Information Processing Systems (NeurIPS) Datasets and Benchmarks Track},
year = {2025}
}