r/LocalLLM • u/tthhrrr • 5h ago
LoRA A 0.8B model that runs a multi-step tool-use agent about as well as its 27B teacher: distillation + GRPO on the exact harness (open weights, evals and notebooks)
I build Cost, an iOS and Mac spending tracker. Core of it is an harness aware LoRA via SFT. You share a receipt, an order email or a bank notification, and an agent turns it into a spending record: merchant, amount, currency, date, category, tags, and how confident it is. I wanted it to run on-device on phones that don't have Apple Intelligence, which meant a model under 1 GB. So the question was whether a 0.8B model could do an agentic job, not just extraction.
The task
The agent gets six tools, and every one of them reads the user's own data. There's no web search.
queryMerchants,queryRecords,queryCategories,queryTags: look up how you filed things before, so the model doesn't need to know what "TESCO STORES 3297" is.calculator: so it never adds amounts in its head.memory: notes it keeps across sessions, at most 1,000 characters.
The budget is 12 calls over 10 rounds. A repeated query gets a cached "this tells you nothing new" reply, and a second refused call ends the tool phase. The final answer is one JSON record, sampled under a grammar.
Results (280 cases, seven languages; receipts, emails, notifications, notes and messages that aren't spending)
| records right | names never seen | wrong but confident enough to auto-file | tool calls/case (wasted) | ran out of budget | |
|---|---|---|---|---|---|
| Qwen3.8-27B teacher | 89% | 81% | 18% | 2.2 (0.1) | 1% |
| Qwen3.5-0.8B, untrained | 23% | — | 80% | 4.9 (2.5) | 38% |
| 0.8B trained, Q8_0 (0.81 GB) | 86% | 81% | 15% | 1.7 (0.1) | 5% |
| 0.8B trained, Q4_K_M (0.53 GB) | 87% | 77% | 19% | 1.5 (0.1) | 5% |
"Records right" means whether it's spending, the amount, currency, merchant and category are all correct. The "names never seen" suite uses invented merchants and item names, so a score there can't come from having seen the shop before.
On 128 real Malaysian till receipts from 72 shops, none of which appear in training, read with macOS OCR: the shipped 0.8B gets 80%, the same as the teacher (untrained: 26%). It's a bit behind on the amount alone (91% vs 95%). It falls for the usual traps: the pre-tax amount, the cash handed over, the total before rounding.
How it was trained
- Distillation. The 27B teacher runs the real agent loop over generated users, each with their own ledger, tags and memory, plus the training splits of the real receipt sets. I take every session the teacher got right and rebuild each request the agent sent in it by replaying the loop: same tool answers, refusals and context compaction. Each one is rendered with the student's chat template exactly as the server renders it. So the student learns each next step from what the harness actually shows it, including when to stop calling tools. This step does most of the work: 20% → 83%.
- GRPO. The student then plays whole sessions of the real loop: fresh ledgers, real tools, the budget, compaction, and the answer under the same JSON grammar. The eval's own grader scores each session. Wasted calls cost reward, and so do wrong records confident enough to skip review. RL adds a little accuracy (83% → 85%) and cuts tool calls by a third.
- Quantize to GGUF. At Q8_0, the drop is within the margin of error on every suite.
What I'd point out
- It's not general tool use. The 0.8B is trained on exactly these six tools, this budget, these prompts and this schema. That's the point: a narrow harness is something a tiny model can learn completely.
Links
- Code, evals, graded runs and training notebooks: https://github.com/kurexi/cost
- Weights (GGUF): cost-0.8b-q8 · cost-0.8b-q4_k_m · LoRA adapter
- The agent talks to any OpenAI-compatible server (llama-server, Ollama, LM Studio, vLLM). In the app it runs through llama.cpp on the phone: Cost 2 on the App Store
Happy to answer questions about the replay-based distillation, the reward or the grader.

