~/satyajit

Program-as-Weights: compiling a natural-language spec into a tiny local model

mdjsonmcp

2026-07-04 · 6 min · llm · inference-optimization · fine-tuning · systems · explainer

Some everyday programming tasks refuse to be written as rules. Alerting a human on only the log lines that matter, repairing malformed JSON, ranking snippets by intent, deciding whether a message is urgent — even a regex for "parse this messy text" shatters on edge cases. The modern move is to punt: call a large language model API and let it decide, per input. That works, but you pay for it on every call, and you give up locality, reproducibility, and price.

Program-as-Weights (PAW) — from Waterloo, Cornell, and Harvard — proposes a different deal. Treat that fuzzy function like source code: compile it once from a natural-language specification into a compact, locally-executable neural artifact, and then run that artifact cheaply for every subsequent input. The compiler is a 4B model; the artifact is a small LoRA adapter; the thing that executes it is a frozen 0.6B interpreter. Play with the loop first — pick a spec, compile it, then feed inputs through the interpreter:

program-as-weights · compile once, run locallyillustrative
COMPILE ONCE · IN THE CLOUDRUN LOCALLY · EVERY CALL AFTERloads oncenatural-language specclassify urgency4B compilerpress compileneural program · LoRA adapteremptyinputcompile first❄ frozen interpreter0.6B+ LoRAurgent?
spec

spec: Flag a message as urgent only if it needs action today.

compile first, then run inputs
≈1/50 the memory30 tok/s on an M3offline

The foundation model runs once per function definition, not once per call. It stops being a per-input problem solver and becomes a tool builder: the compiled adapter is a small artifact you own, run locally, and reuse for free.

The headline result is the payoff of that split: a 0.6B Qwen3 interpreter running PAW programs matches direct prompting of Qwen3-32B, while using roughly one-fiftieth of the inference memory and running at 30 tokens/second on a MacBook M3.

The compiler–interpreter system

PAW borrows the oldest idea in programming — separate the compiler from the runtime — and instantiates it with neural parts. The compiler reads a function specification (plus an optional pseudo-program sketch) and emits a parameter-efficient adapter. The interpreter is a small, frozen model that, loaded with that adapter, executes the function on real inputs.

Three-panel PAW architecture. Left, the LoRA Compiler: a trainable Compiler model reads a function spec, a pseudo-program, and prefix tokens. Middle, the LoRA Mapper: mean-pooled compiler features go through an MLP that mixes a set of learned LoRA A and B basis matrices into the adapter's low-rank A and B factors. Right, the Interpreter: a frozen model runs the pseudo-program plus input through the injected LoRA to produce output.
PAW's best instantiation, Text-to-LoRA: the compiler's representation of the spec is mapped by a small MLP into a low-rank LoRA adapter (a mixture of learned basis matrices), which is injected into the frozen interpreter (paper, Figure 3).

The load-bearing piece is the LoRA mapper. Rather than have the compiler regress raw adapter weights (a huge, unstructured output), it mean-pools the compiler's features and passes them through an MLP that produces mixing coefficients over a set of learned LoRA basis matrices — the emitted adapter is a combination of reusable low-rank factors. That keeps the compiler's output small and well-conditioned, and it's what makes "spec → weights" learnable at all. (An earlier prefix-tuning variant works too; Text-to-LoRA is just the current best.)

To train the compiler, the authors built FuzzyBench, a 10-million-example dataset of fuzzy functions spanning text processing, search and matching, custom classification, code and NL commands, safety and verification, agentic tool use, and format repair — with clean and noisy specification variants so the compiler learns to be robust to sloppy prompts:

Donut chart of FuzzyBench's 10 million examples by theme: core text processing and NLP 30%, search/matching/web intelligence 18%, custom classification and filtering 15%, code and natural-language commands 12%, safety/verification/domain knowledge 12%, agentic and tool use 8%, format repair and validation 5%.
FuzzyBench: 10M fuzzy-function examples across seven themes, released with the paper, used to train the 4B compiler (paper, Figure 2).

Why compile at all? The economics

The reason this framing matters is cost structure. Calling a big model's API is a cost you pay on every input. PAW pays a one-time compile — a single pass of the 4B compiler — and then each application runs locally for almost nothing. So cumulative cost crosses over fast, and the gap only widens. Drag the number of calls:

cost to run a fuzzy function N timesrelative units · illustrative
calls so far
40
call the 32B API
40
compile once, run local
8.8
PAW is
4.5× cheaper
break-even ≈ 8 callsnumber of times the function is applied →

The API bill grows with every input. PAW pays once to compilethe function, then each application is nearly free — so the lines cross within the first handful of calls and the gap only widens. That's the shift from per-input problem solver to tool builder.

That's the thesis in one picture: PAW reframes the foundation model from a per-input problem solver into a tool builder. You invoke the big model once per function definition, get back a small reusable artifact you own, and every function application after that is cheap, offline, and reproducible. Compile a library of them and each becomes a tiny local endpoint:

Three-stage flow. Function Specification: three plain-language specs (classify message urgency, fix malformed JSON, remove personal information). Neural Programs: the compiler turns each into a pseudo-program plus a colored LoRA adapter (LoRA 1, 2, 3). Local Deployment: each adapter runs on a small local LM as PAW Email Triage, PAW Json Fixer, and PAW PII Redactor, processing inputs into outputs on-device.
Compile a library: each spec becomes a pseudo-program plus a LoRA adapter, deployed as a small, local, single-purpose model (paper, Figure 15).

Two practical wins reinforce it: the paper reports the adapters quantize with no measurable accuracy loss, and the whole thing runs at interactive speed (30 tok/s) on a laptop — so the compiled function is genuinely local, not a cloud dependency in disguise.

The honest caveats

PAW is a genuinely new framing, but it buys its efficiency with real constraints, and the paper is candid about them:

The take

What I like about PAW is that it's a systems idea wearing an ML paper's clothes. The interesting move isn't a new architecture — it's noticing that we've quietly turned every fuzzy function into a recurring API bill, and that the compile/runtime split we use for ordinary code applies here too: pay the big model once to build the tool, then run the tool locally forever. The Text-to-LoRA mapper is the clever engineering that makes "spec → weights" tractable, but the reframing is the contribution — a foundation model as a compiler for behaviors rather than an always-on oracle. Whether it generalizes past single-step functions is the open question; as a way to make a hundred small fuzzy tasks local, private, and nearly free, it's one of the freshest ideas of the season. Code, the 4B compiler, and the 10M-example FuzzyBench are released (CC BY 4.0).


Built on Program-as-Weights: A Programming Paradigm for Fuzzy Functions (Zhang, Hotsko, Kim, Nie, Shieber, Deng; University of Waterloo, Cornell, Harvard; 2026, CC BY 4.0). Figures are reproduced from the paper; benchmark and efficiency figures (0.6B ≈ 32B, ~1/50 memory, 30 tok/s on an M3) are quoted from it. The interactive playground and cost model are illustrations of the mechanism, not runs of the released model.

Cite this article

For attribution, please use the following reference or BibTeX:

Satyajit Ghana, "Program-as-Weights: compiling a natural-language spec into a tiny local model", ai.thesatyajit.com, July 2026.

bibtex
@misc{ghana2026programasweights,
  author = {Satyajit Ghana},
  title  = {Program-as-Weights: compiling a natural-language spec into a tiny local model},
  url    = {https://ai.thesatyajit.com/articles/program-as-weights},
  year   = {2026}
}
share