daari (ದಾರಿ β "path")
Compile your frozen LLM into a zero-matmul speculative drafter β no training, ~15 minutes, one GPU.
daari clusters your teacher model's own hidden states over your corpus into a finite map of semantic nodes, records the observed dynamics as lookup tables, and drafts tokens by walking that map β a 32-way argmax plus a binary search per token, no matrix multiplication. The teacher verifies drafts in single forward passes and the walker is re-anchored onto the teacher's true hidden state every round, so drift is structurally impossible and output is the teacher's own greedy stream.
On a production SMS-classification workload (Qwen3-4B teacher, NVIDIA GB10), a 9 MB compiled graph delivers:
| metric | value |
|---|---|
| wall-clock speedup | 4.33Γ (17.4 β 75.2 tok/s) |
| tokens per teacher forward | 4.16 |
| output | teacher-identical (greedy), up to teacher-internal bf16 ties |
| artifact | 9 MB .npz Β· compiled in 35 s from 3.56M states |
Full method, forensics, and honest prior-art positioning:
paper/daari-paper.md.
Compile your own daari
pip install -r requirements.txt
# 1. extract teacher states over YOUR data (~minutes, one forward per sequence)
python -m daari.extract --teacher your-org/your-model \
--data train.jsonl --workdir ./work
# 2. compile the graph (~seconds)
python -m daari.compile --workdir ./work
# 3. benchmark against vanilla greedy on held-out data
python -m daari.spec_decode --teacher your-org/your-model \
--graph ./work/graph.npz --data test.jsonl --n 30
train.jsonl rows are either chat ({"messages": [...]}, rendered with your
model's chat template) or plain text ({"text": "..."}).
Use it in code
from daari.spec_decode import SpecEngine
eng = SpecEngine("your-org/your-model", "work/graph.npz")
text, stats = eng.generate_chat(
[{"role": "user", "content": "sender: XYZ\nmessage: ..."}])
print(stats) # {'tokens': ..., 'calls': ..., 'tokens_per_call': ...}
Watch it think
python -m daari.annotate --teacher your-org/your-model \
--graph ./work/graph.npz --data test.jsonl --idx 0
Prints every round: the graph's drafted path (node ids + edge probabilities), the teacher's β/β verdicts, the bonus token, and the re-anchor β the whole negotiation, live:
ββ round 3 ββββββββββββββββββββββββββββββββββββββββββββββ
graph : n5692β1.00β' null' n4356β1.00β',' β¦ n6520β0.62β'1'
teacher: βββββββ accepted 7/7 β all agreed
bonus : '0' β 8 tokens this round, 1 forward
re-anchor β n5092
When does this work well?
daari shines where your outputs have structure: classifiers with JSON
output, extractors, form-fillers, routers, agent tool-calls β any workload
whose sublanguage is much smaller than open text. Diagnostic: after
compiling, check compile_stats.json β high mean top-edge mass (ours: 0.86)
and high path reuse (ours: 43Γ) predict high acceptance. Free-form creative
text will draft poorly (the system then gracefully degrades to βvanilla
speed β verification means it is never worse than the teacher alone).
Best hardware fit: memory-bandwidth-bound, batch-1 decoding (unified-memory devices like DGX Spark / Apple Silicon, or any single-stream serving), where a verify pass over Ξ³+1 tokens costs β one token's weight-streaming and drafted tokens ride free.
What daari is not
- Not a LoRA β nothing is trained; the graph is compiled from a frozen teacher (minutes, deterministic).
- Not a standalone model β the graph is teacher-locked (it lives in that model's hidden geometry) and domain-bound. Standalone walking nails rigid templates and provably degenerates in open text; the drafter deployment is the honest configuration.
- Not a hallucination-safe oracle β quality equals the teacher's, no more.
Example: sms-shield
examples/sms_shield/ contains the compiled graph
(9 MB), compile stats, and the 30-prompt benchmark results from the paper.
Note: the graph only functions with its exact teacher checkpoint (a merged
Qwen3-4B LoRA for Indian SMS scam classification).
Prior art, honestly
Every ingredient here exists in prior work: lexical automaton drafters (SAM-Decoding, SuffixDecoding), drafting from hidden states (EAGLE-1/2/3), verifier-state-keyed retrieval drafting (Oilbird, SENSE β continuous forms), LLMβdiscrete-surrogate distillation (Ctrl-G). daari's contribution is the composition: post-hoc discretization of a frozen teacher's states into an executable automaton, drafted with zero matmuls and re-anchored per round. Full comparison table and citations in the paper (Β§2).
Citation
@misc{daari2026,
title = {daari: Compiling a Frozen Transformer into a Zero-Matmul
Speculative Drafter},
author = {Santosh},
year = {2026},
note = {Ganmoor AI Labs},
}