Handbooks  /  On-Device AI
AI Engineering~12 min readIntermediate
Deep Dive

Small models, everywhere: the on-device AI handbook.

The frontier gets the headlines, but a quieter revolution shipped in the other direction: models small enough to run on your laptop, your phone, your factory floor — and good enough that, for most everyday tasks, users can't tell. Here's why small got good, the physics that governs it, the stack that runs it, and when local beats the cloud.

01

Why small models suddenly got good

In 2022, "small" meant "toy." Today a modern 8B model beats the 175B giants of that era on most practical tasks. Two forces did it. Distillation: frontier models now generate and grade the training data, so a small model inherits capability instead of rediscovering it from raw internet text — every frontier release quietly raises the ceiling for the small models trained in its shadow. And data quality: the phi-family experiments proved that textbook-grade tokens beat web-scale sludge, parameter for parameter.

→ The mental model

Model capability isn't a function of size alone — it's size × data quality × teacher quality. Two of those three kept improving even where size stayed fixed. Small models ride the frontier's coattails, about 12–18 months behind at a hundredth the cost.

The result is a genuine tier system: sub-2B models for classification, extraction and autocomplete on phones; 3–8B for chat, summarization and RAG on laptops; 8–14B approaching last year's frontier for reasoning-lite work on a single consumer GPU.

02

The physics: it's bandwidth, not FLOPs

Local inference speed obeys one equation. Generating a token means streaming essentially all active weights through the processor once. So:

→ The napkin law

tokens/sec ≈ memory bandwidth ÷ model size in bytes. A laptop with 100 GB/s bandwidth runs a 4 GB model at ~25 tok/s and an 8 GB model at ~12. Compute barely enters the picture — decode is a memory workout.

Everything about the on-device world follows from this law. Quantization works because INT4 weights are 4× fewer bytes than FP16 — near-4× more tokens/sec, same bandwidth. Apple Silicon punches high because unified memory offers 100–800 GB/s to a big pool. NPUs matter for prefill and energy, but decode still queues at the bandwidth window. Size your expectations with the GPU VRAM calculator — the same math, one slider away.

03

The stack that actually runs things

LayerThe toolWhat it does
Enginellama.cppThe C++ inference engine behind most local AI; runs GGUF-quantized models on CPU, GPU, and Metal.
FormatGGUF (Q4/Q5/Q8…)Pre-quantized model files — the de facto distribution format for local weights.
ServerOllamaDeveloper-friendly wrapper: pull a model like a Docker image, get an OpenAI-compatible local API.
AppleMLXApple's array framework — the fastest path on M-series unified memory.
BrowserWebGPU runtimesIn-browser inference: zero install, model ships with the web page.
PhoneCore ML / AICoreVendor NPU runtimes running distilled sub-4B models inside iOS and Android.

The pattern across the stack: OpenAI-compatible local APIs everywhere, so the same application code targets a cloud frontier model in production and a local 8B in development — or routes between them at runtime.

04

When on-device wins — and when it doesn't

The decision, honestly

Local wins on

  • Privacy — data physically never leaves
  • Latency — no network round-trip, instant first token
  • Offline — planes, fields, factories, air-gaps
  • Unit cost — zero marginal cost per request at scale
  • Residency — regulation that forbids the cloud

Cloud wins on

  • Frontier reasoning — hard multi-step work
  • Long contexts — local KV caches eat scarce RAM
  • Freshest capability — new models land in the API first
  • Fleet simplicity — one deployment, not a million devices
  • Burst compute — batch jobs beyond any laptop

The mistake is framing it as either/or. The pattern that ships in 2026 is hybrid: a local model handles the instant, private, frequent 80% — autocomplete, classification, summarizing the meeting you just had — and a router-style fallback escalates the hard 20% to the cloud, with user consent where privacy is the point.

05

Hybrid patterns that actually ship

Four production hybrids
Local-firstSmall model answers immediately; escalate to cloud on low confidence or explicit user request. The assistant pattern.
Split by taskEmbeddings, classification and extraction local (cheap, private); generation and reasoning cloud. The RAG pattern — retrieval never leaves the device.
Draft & verifyThe local model drafts, the cloud model verifies or polishes — speculative decoding's logic, applied across the network boundary.
Cloud dev, local shipPrototype against a frontier API, then distill/fine-tune a small model on the traces once the task is pinned down — frontier quality, local economics.

That last pattern deserves emphasis: a LoRA/QLoRA fine-tune of an 8B model on a few thousand task-specific examples routinely beats a prompted frontier model on that one task — at zero marginal cost, forever. Narrow beats general when you own the narrow.

06

The craft: choosing and proving a small model

Day-to-day, on-device work is an evals discipline. Leaderboard rank tells you little — small models vary wildly by task, and quantization moves quality in task-specific ways. The working loop: shortlist three candidate models in your size budget, build a golden set of 50–200 real examples from your task, score each model × quantization level (Q4 vs Q8 can matter more than model choice), and watch the tails — small models fail weirder than big ones, so read the worst 10 outputs, not the average.

→ The rule that saves weeks

Fix the memory budget first (device RAM − OS − your app), then shop for the best model+quant that fits with room for the KV cache. Teams that pick the model first and discover the budget later ship six weeks late, twice.

Frequently asked

Quick answers

Why did small models get good?

Distillation (frontier models generate the training data) plus textbook-quality data curation. Small models inherit capability ~12–18 months behind the frontier at a hundredth the cost.

What limits local inference speed?

Memory bandwidth: tokens/sec ≈ bandwidth ÷ model bytes. Quantization speeds decode almost linearly because it shrinks the bytes.

When should AI run on-device?

Privacy, instant latency, offline, zero marginal cost, or data-residency rules. The cloud keeps frontier reasoning, long contexts and the newest capabilities.

What is the standard local stack?

llama.cpp + GGUF underneath, Ollama as the friendly server, MLX on Apple Silicon, WebGPU in browsers, Core ML / AICore on phones.

Small Models & On-Device AI · AI Engineering · Vibe Engines · 2026
Finished this one? 0 / 49 Handbooks done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.