SheetAlign: Locally Deployed Spreadsheet Agents With Stage-Isolated Learning
A 4B local model gains most of its accuracy from being made to say where and what to edit before writing code, plus a four-way vote, not from a bigger model; yet it gets only 32.8% of spreadsheet tasks right, 11.5% to 42.9% by domain, far from unattended.
On this page
An 800-row expense sheet cannot leave this laptop, but the default fix at the company is to paste it into a web model. Who signs off on that? Security sent a warning about exactly that last week. Now the file sits on your machine, and by Friday you have to roll 37 departments' travel costs into a new sheet, with the rules buried in paragraph six of an email. What do you do? Most likely you filter by hand, build a pivot table, or ask a small local model to write a script. Most people expect a local model to be a bit worse and plan to live with it, so they paste the same prompt they would use online. The code runs. It edits the wrong column. It also unpicks a merged cell. A paper posted on 19 November 2026 argues the gap is not model size but whether anyone forced the model to state which cells it intends to touch [1].
The Code Runs, the Cell Is Wrong
Set the scene. A workbook holds several sheets, each with headers, merged cells, formulas, and formatting. The paper has the model emit Python that edits the file through openpyxl, a library for reading and writing Excel; Excel then recalculates, and the result is compared cell by cell against a reference [1]. An agent here is a program that calls tools, reads the result, and revises, not a chat box. Trouble starts at step one. Given 'roll each department's travel costs into a new sheet', the model must decide which sheet to read, which column to write, and whether the output is a value or a formula. Get that wrong and the code still runs, the file still saves, and the content is wrong.
The paper calls this the task-to-edit grounding problem: a program executes successfully but modifies cells it should not [1]. Small local models suffer most here. With limited reasoning, they grab the wrong region in a book of dozens of sheets. You have probably seen it: no traceback, wrong numbers, and the cause turns out to be an off-by-one column.
The baseline shows the size of the hole. On the same 4B Qwen3 backbone, running it directly gives 13.5% average accuracy on SpreadsheetBench, 11.4% hard accuracy (every instance of a task correct), and a 69.1% execution success rate [1]. Three programs in ten do not run at all, and most of the rest edit the wrong place.
Four Questions Before It Writes Any Code
The interface is plain: make the model translate the task into a fixed template first. Where to edit, what to read, what to change, and how to write it [1]. The last field has four options: values, formulas, formatting, structure. Once those are filled, the harness shows only the relevant headers, nearby cells, formulas, and merged ranges, then fetches a few openpyxl usage notes for the APIs the model asked for. The harness is the outer scaffolding that fetches, executes, and reports errors. It makes no decisions.
None of this needs training, and it lifts average accuracy from 13.5% to 29.2%, hard accuracy from 11.4% to 23.9%, and execution success from 69.1% to 97.1% [1]. The ablations separate the parts. Remove task-guided inspection and accuracy falls to 21.4% while execution barely moves at 96.7%: the program still runs, it just edits the wrong region. Remove API grounding and accuracy falls to 25.2%. Remove diagnostic repair (up to two corrective rounds after an error) and accuracy falls to 24.4% while execution drops to 90.5% [1].
Three numbers, two different diseases. The first two govern whether the edit is right; the third governs whether the program runs at all. If your local failures are tracebacks, add repair. If your scripts finish and the numbers are wrong, fix the four questions. That split is more useful than any single score.
Train the Writing and the Checking Apart
Training sits on top of the interface, and there is not much of it. Two policies branch from one backbone, each with its own LoRA adapter (a small set of extra parameters while the main model stays frozen), updated independently: one writes programs, one reviews programs that already run [1]. The reward counts edit-level progress. Take the cells that should change and the cells that did change, compute precision and recall, take their harmonic mean, and mix it 0.75 to 0.25 with whether the whole task came out right [1]. Partial attempts still earn credit.
The scale is worth noting. A pool of 1,200 tasks, 1,136 for training and 64 for validation, 40 optimizer updates, 4 prompts per update with 4 samples each, a learning rate of 8e-7, LoRA rank 16 [1]. That is not a large project. The return is 29.2% to 30.4%, and hard accuracy 23.9% to 25.2% [1].
The last step sits at inference. Sample 4 candidate programs, 2 from the backbone and 2 from the generation policy, run each one, then compare fingerprints of the resulting workbooks: sheet names, non-empty cell locations, values, formulas, merges, and styles, compressed into a fixed identifier. Matching fingerprints count as agreement, and the first candidate in the largest agreeing group wins [1]. Accuracy goes 30.4% to 32.8%, hard accuracy 25.2% to 27.1%, execution 97.7% to 98.6% [1]. The cost is 4x generation, which the authors call a trade-off between compute and reliability [1].
Four times the inference for 2.4 points is awkward on a laptop. A learned selector over the same pool reaches only 31.4%. And the ceiling is visible: with the same 4 candidates and access to the reference, selection would reach 39.7% [1]. So 6.9 points sit unclaimed inside the selection step alone.
Is 32.8% Task Accuracy Good? Depends Who You Compare With
Stack the four stages and you get a staircase [1].
| Configuration | Average accuracy | Hard accuracy | Execution success |
|---|---|---|---|
| Qwen3-4B backbone | 13.5% | 11.4% | 69.1% |
| Plus the four-question interface (no training) | 29.2% | 23.9% | 97.1% |
| Plus stage-isolated training | 30.4% | 25.2% | 97.7% |
| Plus four-way consistency | 32.8% | 27.1% | 98.6% |
The sideways comparison is more interesting. Among hosted systems, GPT-4o scores 18.4% in Excel, o3 23.3%, ChatGPT Agent 35.3% and 45.5% with xlsx file access, Copilot Agent Mode 57.7%, and Gemini in Google Sheets 70.5% [1]. Among open models, Qwen3-32B reaches only 17.6%, the same 4B backbone with outcome-based RL reaches 23.4%, and TabClaw on DeepSeek-V3.2 reaches 28.8% [1]. A 4B local model beats a 32B sibling and a dedicated agent wired to a larger model, and still trails Copilot and Gemini by a wide margin.
That set of comparisons decides the job. This is not for unattended edits to a live ledger. It is for producing a first draft a person then checks. Before deploying inside a company, ask five things:
- Which kind of sheet is yours? Across the 7 domains, Finance-B reaches 42.9%, real estate 19.1%, supply chain 16.0%, HR 14.6%, and sales 11.5% [1]. If your daily files are payroll and sales detail, the 32.8% headline will mislead you.
- Who reads the output before it lands? Hard accuracy is 27.1%, so fewer than a third of tasks come out fully correct across instances. Writing review into the process beats tuning for another point.
- Can you afford 4x inference? Consistency runs 4 candidates, each executed independently, up to 2 repair attempts, with a 300-second timeout per execution [1]. On a local machine that is 4x the time.
- How big is the workbook? Fingerprints cover 200,000 cells and 64 MiB of decompressed content; anything larger is excluded from the vote [1], and workbook observation is bounded too, so very large books need adaptation [1].
- Can you roll back? The model edits files directly. Every candidate in the paper starts from the original input, and your pipeline should copy that design.
Where the Local Claim Runs Out
Start with the hardest limit: 32.8% means two out of three workbooks are still wrong. In a lab that is progress. In a payroll run it is an incident. The evaluation compares target regions cell by cell, rounding numbers to two decimals, converting dates to serial values, and comparing formulas by recalculated value [1]. It does not care that a correct edit looks ugly, and it cannot tell an error that happens to land on the same number.
The second limit is the tool surface. Everything is Python plus openpyxl, and the authors say plainly that tasks needing specialised Excel features or external integrations require additional tools [1]. Pivot tables, macros, Power Query, and pulls from an ERP are out of scope. The third is the evaluation: two benchmarks, one backbone, one language. Other spreadsheet ecosystems may behave differently.
Then there is the gap that matters most for a local pitch. The paper reports no inference latency, no memory footprint, no hardware, and no time per workbook. It gives a 32,768-token context, a 1,024-token cap on workbook understanding, and a 300-second execution timeout [1]. None of that answers 'how long does one 800-row sheet take on an office desktop with no discrete GPU'. You have to measure that yourself.
Here is the version a non-specialist can repeat: someone made a small local model state which cells to read and write, and whether to write a value or a formula, before it wrote any code; then split writing and checking into two separately trained policies; then ran four attempts and kept the one whose output file matched the others. On SpreadsheetBench that stack moved accuracy from 13.5% to 32.8%. The preconditions are a task inside the 7 tested domains, a human reviewer, and tolerance for 4x inference. One line worth a screenshot: the local bottleneck is not model size, it is whether anyone made the model name the cell first.
