Skip to main content
← Back to Insights

Aligning an LLM: From Autocomplete to Assistant

· 6 min read
Jitender Sharma
Advisor & Technical Leader · Enterprise AI & Platforms

Aligning an LLM: from pre-trained autocomplete through SFT and preference tuning to an aligned assistant

Pre-training grows a model that predicts the next token extremely well. That is not the same as a helpful assistant. A raw base model will continue any prompt, mimic toxic text, or ignore an instruction when a more statistically likely continuation wins.

Alignment is the stage that reshapes that behavior. It still updates weights with the same four-step loop (forward, loss, backprop, optimizer), but with different data, a different objective, and far fewer steps. The result is the chat-style model you actually ship.

This is a deep dive into Stage 3 of How LLM Works Under the Hood. It follows During Training an LLM, which covers how pre-training fills the weight tensors, and precedes After Training an LLM, which covers frozen inference.

THE CLAIM

Alignment is still training, but it is a thin layer on top of pre-training. It shapes behavior (instruction-following, helpfulness, refusals). It does not pour in the knowledge. Almost everything the model knows came from the base pre-training run.

Why pre-training is not enough

By the end of pre-training, each component has settled into its role: embeddings encode meaning, attention routes context, FFNs transform, LayerNorm stabilises. The model is a strong next-token predictor over internet-scale text.

What it has not learned:

CapabilityPre-trained baseAligned assistant
Continue text fluentlyYesYes
Follow an instruction as a taskUnreliableExpected
Prefer helpful, clear answersNo explicit preferenceTuned
Refuse harmful requestsNoTuned
Stay in assistant formatNoTuned

A base model optimises one thing: p(next token | context). An assistant needs a second job on top of that: given a user prompt, produce a good response, not just a plausible continuation of the prompt string.

Same loop, different job

Alignment does not invent a new training algorithm. It reuses the loop from pre-training:

  1. Forward pass
  2. Compute loss
  3. Backpropagation
  4. Optimizer step

What changes:

DialPre-trainingAlignment
DataTrillions of tokens of raw (or lightly filtered) textThousands to millions of curated examples or preference pairs
Loss focusEvery token in the sequenceOften response tokens only (SFT), or a preference / reward objective
Steps and costWeeks/months, enormous computeShort, comparatively cheap
What improvesKnowledge, fluency, latent skillsBehavior, format, preference
Same weights, new objective

The architecture dials and vocabulary stay frozen from Before Training an LLM. Alignment only changes values inside those tensors, and only a little compared with pre-training.

Stage 1: supervised fine-tuning (SFT)

Train on curated (prompt, ideal response) pairs written or vetted by humans (or strong models). The loop matches pre-training with one important change: the loss is computed on the response tokens, so the model learns to produce good answers rather than merely continue the prompt.

What SFT teaches:

  • When asked a question, answer it
  • When asked for a list, produce a list
  • Stay in assistant voice and format
  • Rough instruction-following

Dataset size is typically thousands to a few million examples, versus trillions of tokens in pre-training. After SFT the model behaves like an assistant, but its sense of which answer is best among several plausible ones is still rough.

Stage 2: preference tuning (RLHF / DPO)

Humans (or a model) rank competing responses to the same prompt. That preference signal pushes the model toward the preferred kind of answer.


Two common recipes:

  • RLHF: train a separate reward model to score responses, then use reinforcement learning (often PPO) so the LLM maximises that score while staying close to the SFT policy.
  • DPO (and variants): skip the separate reward model and optimise directly on preference pairs with a classification-style loss. Simpler, and now very common.

This stage shapes helpfulness, tone, and harmlessness. It is why a model refuses dangerous requests and prefers clear, well-structured answers.

Variants such as RLAIF (AI feedback instead of human labels) or constitutional-style rule sets are the same idea: a preference or principle signal, not a second internet-scale pre-train.

Alignment is a thin layer

Main training (pre-train)Polish (alignment)
DataTrillions of wordsThousands to millions of examples
Length / costWeeks/months, huge costShort, cheap
What it doesTeaches knowledgeShapes behavior

Alignment still changes weights, but typically with a tiny dataset, a small learning rate, and few steps (often with parameter-efficient methods like LoRA that update only a slice of the weights). It mostly elicits and shapes behavior the base model already latently has. It does not replace pre-training as the source of capability.

TAKEAWAY

If the base model never saw the underlying skill in pre-training, alignment rarely invents it. Alignment is how you steer what is already there.

What this means for architects

QuestionMostly answered by
Does the model know enough about my domain?Pre-training (and later domain fine-tunes / RAG), not alignment alone
Will it follow instructions and stay in format?SFT
Will it prefer safe, helpful answers?Preference tuning
Why is the chat model different from the base download?Alignment stages on top of the same architecture
Where did most of the $ go?Pre-training

Product choice often looks like "base vs instruct/chat." That label is largely this stage: same frozen shape from Before, knowledge from During, behavior from Align.

Handoff: freeze and ship

After alignment the weights are shipped and locked. No optimiser, no loss, no backward pass at serve time. Everything from here is read-only inference: prefill, decode, sampling, KV cache.

Deep dive: After Training an LLM: From Frozen Weights to Token-by-Token Inference.

Final takeaway

Pre-training grows knowledge into the tensors. Alignment is a short second training phase that turns a next-token predictor into an assistant: SFT for format and instruction-following, preference tuning (RLHF/DPO) for which answers are better. For architects, keep the split clear: quality of knowledge and most of the cost live in pre-training; product behavior, refusals, and "chat vs base" live in alignment.