hello·ai

Training vs inference

AssumesParameters & layers

In one line

Training is a write path you will almost certainly never run; inference is a stateless read path, and conflating the two is the source of most bad architecture decisions here.

Why it exists

Almost every confusing question about working with models dissolves once you separate these two. "Does it remember what I told it?" No — inference does not write. "Can I teach it our API?" Not by talking to it. "Why is it cheap to serve and expensive to build?" Because one loop runs once over a corpus and the other runs per request over a frozen artefact.

The distinction is the same one you already make between a nightly batch job that rebuilds an index and the service that queries it. Treating them as one system is how teams end up trying to their way to fresh data.

TRAINING — write path, run oncebatchof documentsforwardpredict nextlosshow wrongupdate every weightmillions of times · months · someone else's capexINFERENCE — read path, run per requestpromptforwardweights frozentokenstateless · scales like any readno weight ever changes here — that is why it scales horizontally
One loop writes weights, the other never does. Everything you deploy lives on the bottom row.

The training loop#

is at scale, and the loop is four steps: take a batch of documents, predict the next token at every position, measure how wrong those predictions were with a , and nudge every slightly in the direction that would have been less wrong. Repeat for months.

The objective really is that narrow. Not "be helpful", not "be accurate" — only "be less surprised by the token that actually came next", averaged over a corpus. Every capability a base model has is a side effect of getting good at that one thing. is just that surprise re-expressed as a count of equally likely options.

Two things follow. First, the model learns the distribution of its corpus, including its errors and its cut-off date. It has no mechanism for knowing what it does not know, because nothing in the objective rewarded that. Second, the cost is enormous and one-time: millions of GPU-hours, which is why you are renting a model rather than training one.

A base model out of pretraining is not yet useful as an assistant — it completes text rather than following instructions. Post-training fixes that: supervised fine-tuning on instruction-response pairs, then or a similar preference method that trains a reward model on human comparisons and optimises against it. This stage is a rounding error on pretraining cost and is responsible for most of what you experience as the model's personality, willingness and refusals.

The inference path#

is a pure function. Weights are read, never written. Nothing about request n affects request n+1.

That has direct architectural consequences, all of them familiar:

It scales horizontally without coordination. Any replica can serve any request, because there is no shared mutable state. Capacity is a memory problem, not a consistency problem.

It has no memory between calls. Conversation history feels like memory because the client resends the entire transcript on every turn. That is why long conversations cost more per message — you are paying to re-read the whole thing each time.

It is not deterministic by default, but it can be. Sampling introduces randomness; with greedy decoding and a fixed model version, the same input produces the same output, which is what makes reproducible s possible. Floating-point non-associativity across different batch sizes can still produce rare divergence, so treat determinism as a strong tendency rather than a guarantee.

Where the middle ground is#

Between "use it as it comes" and "train your own" sits a ladder of options, ordered by cost and by how hard each is to reverse.

Prompting and examples change nothing about the model and are instant to undo. adds facts at request time and is the correct answer for anything that changes — a fact updated in your database is live on the next request, with no retraining and no staleness window.

sits one rung further: freeze the original weights, train a small pair of low-rank matrices alongside them. The adapter is megabytes rather than gigabytes, several can be hot-swapped over one served base model, and quality is close to full fine-tuning for style and format work.

Full fine-tuning updates every weight. It reliably teaches form — house tone, a specific output structure, a domain's phrasing conventions — and teaches facts badly and expensively, because every new fact means another training run. The rule of thumb that survives contact with production: retrieval for what the model should know, fine-tuning for how it should behave.

is the other direction entirely: train a small model to imitate a large one's outputs on your traffic. It is the most reliable way to cut cost at fixed quality on a narrow task, and it only becomes available once you have logged enough real requests to distil from.

Worked example

You are asked to make a support assistant "know" your product documentation, which changes weekly. Three options, priced honestly.

Fine-tune on the docs. A LoRA run over a few thousand examples is maybe $50 of compute and a day of work. It is also wrong: the docs change weekly, so you own a retraining pipeline forever, the model will still confidently answer from the old version, and you cannot cite a source. Facts are not what fine-tuning is for.

Retrieve. Chunk the docs, embed them, retrieve the top five passages per question, put them in the prompt. Costs a few hundred extra prompt tokens per request. An edit to a doc is live on the next query. You get citations for free. This is the right answer, and it took an afternoon.

Both. Retrieval for the facts, plus a small fine-tune so replies come out in your support team's voice with the right structure — greeting, answer, next step, no hedging. This is the real production shape, and note the split: the fine-tune is carrying form, the retrieval is carrying content.

One more number. If that assistant serves a million requests a month at 1,500 prompt tokens and 300 output tokens, prompt tokens dominate the bill by five to one. The lever on cost is and prompt length, not the model's size — and if the task narrows enough, distillation to a small model beats both.

Gotchas

  • Expecting the model to remember a correction. Telling it "actually our timeout is 30 seconds" affects that conversation and nothing else. Inference does not write. Persisting a correction means putting it somewhere retrieval will find it.

  • Fine-tuning to inject knowledge. It works poorly, degrades general capability if overdone, and locks the knowledge to a training snapshot. The symptom is a model that confidently states last quarter's numbers. Retrieval is not a workaround here; it is the correct mechanism.

  • Treating a model version as stable infrastructure. A provider updating a model behind the same name changes your outputs without a deploy on your side. Pin versions explicitly, and run your evals when you unpin.

  • Assuming training-time behaviour transfers to serving. A model that scores well on a benchmark was measured at temperature zero, in isolation, on clean input. Your production path has sampling on, a long system prompt, retrieved passages of variable quality and real user phrasing. Measure on your own traffic.

  • Optimising before checking prompt length. Halving a 3,000-token prompt halves the dominant cost immediately, with no infrastructure change. Serving optimisations come after that, not before.

Mental model

Training is the build and inference is the binary. You do not recompile to change a config value, and you do not retrain to change a fact. Retrieval is the config file, fine-tuning is a patch to the source, and both are much rarer than running the thing.

In practice

Problem statements that lean on this topic. Rated by the phase that makes them land.

Done reading?

Nothing marks itself complete. Say so only when you could explain this to someone else.

Next: Prefill & decode

This topic has 3 subtopics.