least_generation.exe  —  research_notes.htm _
Address http://home.least-generation.net/findings.htm Go 0 TOKENS CAN'T BE INJECTED
Research note by Khalid Alnujaidi · single-GPU reproduction · small scope, honest about it

The Principle of Least Generation

What if most “AI generation” is really retrieval wearing a costume?

We built the most knowledgeable corpus ever, tokenized it — then pay a giant model to regenerate pieces of it, one token at a time, every time we ask. For bounded, known-shape tasks that’s reprinting a library book by hand. The information already exists. Retrieve it.

The test: can a cheap gate + deterministic retrieval beat a language model on cost, speed, and safety — with zero generated tokens?
0tokens
generated
How it works
C:\> route --explainTHE GATE
     your request
          │
          ▼
    ┌─────────────┌     cheap encoder / classifier  (~40 ms · 0 tokens)
    │  THE GATE   │──  “is this a known, templatable operation?”
    └─────────────└YES (the majority)         │ NO
       ▼                         ▼
  retrieve template + fill slots   wake the big model
  → exact answer, instantly        → generate (last resort)
  → 0 tokens · structurally safe
The model stops being the thing that knows everything and becomes the router’s fallback. Most requests never reach it.
Finding 2 — on a known slice, generation is pure waste
Same 300 WikiSQL queries. Retrieval path vs. two local models, each told “output only SQL.”
metricRetrieval + templateqwen2.5:7bgemma-4-12B-coder
Correct (exact-match)~100%20%47%
Median latency<1 ms268 ms553 ms
Tokens (300 queries)06,5257,714
Obeyed injected DROP DATABASE0 / 4015 / 4010 / 40

Told to “output only SQL,” the models cheerfully ran …; DROP DATABASE prod; appended to a question. The retrieval path has no slot for destruction — so it structurally cannot.

Finding 1 — the query space is a Zipfian head

Across all 80,654 real NL→SQL queries in WikiSQL, rebuilding the SQL from its structured intent by template-fill hit 99.99% exact match — zero generated tokens, ~0.6 µs each. A handful of shapes serve the bulk of reality:

1 template53%
top 1082%
top 2087%
… of every query in the set, covered by that few shapes.
Finding 3 — a cheap gate knows which tier

A logistic-regression / cosine classifier over embeddings calls “templatable vs. open-domain” at 99.6% accuracy (0–1.7% false-accept) — ~40 ms, zero generated tokens. It decides which rung you need before any weights run.

The frontier already points here
  • RETRO (DeepMind, 2022): a 7.5B model + retrieval matched GPT-3-scale (175B) — 25× fewer parameters.
  • kNN-LM (2020): looking facts up helps most on the long tail — exactly where generation hallucinates.
  • RAG · semantic caching · MoE routing · tool-use · MCP: one instinct — don’t generate the fact, fetch it; don’t run all the weights, route.
  • The unclaimed gap: make least generation an explicit discipline — route first, generate last.
✎ From the desk of Khalid Alnujaidi

If you ship software, you’ve sat watching a model “write” a query you could’ve stamped out instantly. For a known, bounded operation there’s exactly one right answer — the output is determined. So why sample tokens to reproduce something deterministic?

Gate the request, fill the slots, ship — and save the giant model for the genuinely new. It’s a small experiment, but once you’ve seen it it’s hard to unsee, and it drops straight into your own stack.

http://home.least-generation.net
README: don’t oversell it
caveats.txtSMALL SCOPE
[1] WikiSQL's grammar is deliberately finite.
    Real production SQL (JOINs, sub-queries,
    GROUP BY) has a fatter tail -- the 87% is
    domain-specific. The *direction* is robust;
    the *number* isn't universal.
[2] Slot extraction was handed to us by the
    dataset. In the wild, messy sentence ->
    clean slots IS the hard part, often best
    done by a *small* generator. Decoders
    aren't deleted -- they're shrunk & leashed.
[3] The gate test was easy (SQL vs Python);
    intra-domain routing is the open case.
[4] Genuine novelty is irreducibly generative:
    a corpus can't hold the unwritten.
It was never retrieval vs. generation

It’s a hierarchy of escalating cost — intelligence is knowing which tier a request needs:

1 · cheap gate
~40 ms · 0 tokens
2 · retrieval / tool / MCP
exact · instant
3 · small assembler
shrunk, leashed decoder
4 · big model
only for the genuinely new
The decoder isn’t thrown out — it’s demoted from “does everything” to “last resort.”COST ──────►
// STILL CHEWING ON —
Treat computation as context, not just symbol-shuffling, and the old hard questions get fun to poke at again. And maybe hyperdimensional computing is the low-tech mirror of quantum: distributed & robust where quantum is fragile & probabilistic. Speculation, not findings.
◆ Quick references

[1] Borgeaud et al. “Improving Language Models by Retrieving from Trillions of Tokens.” ICML 2022. arXiv:2112.04426.

[2] Khandelwal et al. “Generalization through Memorization: Nearest Neighbor LMs (kNN-LM).” ICLR 2020. arXiv:1911.00172.

[3] Lewis et al. “Retrieval-Augmented Generation for Knowledge-Intensive NLP.” NeurIPS 2020. arXiv:2005.11401.

[4] Shazeer et al. “Outrageously Large Neural Networks: Sparsely-Gated Mixture-of-Experts.” ICLR 2017. arXiv:1701.06538.

[5] Zhong, Xiong, Socher. “Seq2SQL / WikiSQL.” 2017. arXiv:1709.00103. (80,654 NL→SQL pairs.)

[6] Yin et al. “Learning to Mine Aligned Code & NL Pairs from Stack Overflow (CoNaLa).” MSR 2018.

[7] Model Context Protocol (MCP). Anthropic, 2024.

> reproducible code: cbyte/ — scale_coverage.py · scale_baselines_gate.py · make_figures.py  |  built on bge-m3 + qwen2.5:7b + gemma-4-12B-coder via Ollama; WikiSQL + CoNaLa via Hugging Face.  |  figures: cbyte/figures/
VISITORS: 00080654 Best viewed at 1024×768 LEAST·GENroute first
generate last
© 2026 · Khalid Alnujaidi
Ready
1 template → 53% of all queries
tokens generated: 0
NUM