> Agent-ready spec from Diff of the Day (2026-11-30, playbook 1). Give this file to your coding agent (Claude Code, Codex, Cursor) and ask it to build the P0 requirements first.

# Spec: A probability-scored small model for your highest-volume check (small-team version)

## Problem Statement
Canva cut LLM costs by about 85% by replacing a hosted model with a fine-tuned 4B vision model for a stable, high-volume review task. A small team rarely has that volume or a training pipeline, but it often has one repeated check that makes up most of its model bill. The team needs evidence, from its own data, on whether a small model can take that check, before anyone spends time on fine-tuning or GPUs.

## Goals
- Identify the single check that accounts for the largest share of hosted model calls.
- Build a labelled set of 200 real examples for that check, with agreement between two labellers recorded.
- Measure a small open model on that set, with a probability per answer, and compare accuracy, cost and latency with the hosted model.
- End with a written decision: stay hosted, route by confidence, or fine-tune.

## Non-Goals
- Building a training pipeline: only if the decision says so, in a later phase.
- Replacing every model call: one check only.
- Speculative decoding and other serving optimisations from the Canva post: they matter after a model is chosen.

## User Stories
- As a team lead, I want to know which single check costs us the most so that we optimise the right thing.
- As an engineer, I want a labelled set from real traffic so that the comparison reflects production.
- As an engineer, I want a probability per answer so that confident cases can skip the expensive model.
- As a team lead, I want one page with the decision and the numbers so that the choice is not a matter of taste.
- Edge case: as an engineer, I want examples where the two labellers disagree kept in a separate file, because they show where the check itself is unclear.

## Requirements
### P0 (must have)
- **Call analysis**
  - [ ] A script groups the last 30 days of hosted model calls by purpose and reports volume and cost per group
  - [ ] The top group is named in the report with its share of total cost
- **Labelled set**
  - [ ] 200 examples of the top check are exported with personal data removed
  - [ ] Two people label each example; agreement and the disputed cases are recorded
- **Measurement**
  - [ ] A small open model answers each example in a fixed JSON format with the probability of the positive answer
  - [ ] The report shows precision and recall for both models and cost and latency per 1,000 examples
- **Decision**
  - [ ] decision.md states one of three outcomes with the numbers that support it
### P1 (nice to have)
- **Confidence routing sketch**
  - [ ] The report estimates how many calls the small model could answer alone at a threshold that keeps recall equal to the hosted model
- **Fine-tuning estimate**
  - [ ] The report estimates the GPU hours and labelled examples that a LoRA fine-tune would need
### P2 (later)
- LoRA fine-tuning with the loss focused on the decision tokens.
- Several checks in one structured response.
- Serving optimisations such as speculative decoding.

## Success Metrics
- Leading: the top check and its cost share are known within one day.
- Leading: the labelled set has at least 90% agreement, or the disputed cases are documented.
- Lagging: the monthly model bill for that check drops, or a documented decision explains why it stays.

## Open Questions
- Do logs hold enough detail to group calls by purpose? (engineering, blocking)
- May the examples leave production storage for labelling? (legal or data owner, blocking)
- Is there a GPU, or does the test run on a laptop or a rented instance? (you)

## Timeline
Three days for one or two people: one for the call analysis and export, one for labelling, one for measurement and the decision.

## Agent Instructions
- **Suggested stack**: Python 3.12, your existing log store, and a small open model that exposes token probabilities locally.
- **Build order**: call analysis first, then the export with personal data removed, then labelling, then the measurement script with a test on five hand-checked examples, then decision.md.
- **Safety**: remove personal data before export; keep the labelled set inside your own storage; send no production data to a new third party; ask before any step that costs money, such as renting a GPU.
- **Done when**: decision.md exists with the cost share, the agreement rate, both models' scores and one stated decision.

## Sources
- Training and Serving Multimodal LLMs in Production (Canva Engineering): https://www.canva.dev/blog/engineering/local-jev-multimodal-llms-in-production/
