How LLMs Are Actually Trained - Raw Text → “Aligned” Model
CORPUS trillions of tokens
TOKENIZER TRAINING BPE - learned from the corpus
frequent pairs merge → vocab of ~128K pieces, frozen forever
BATCHING self-supervision - no human labels
the target is the input shifted by one - every position is a training example: “guess the next token”
EMBEDDING + POSITIONAL ENCODING learned from random init
learned / sinusoidal / RoPE
TRANSFORMER STACK × N layers, causal mask
attention + FFN
✕ = future hidden
LOSS one number rules everything
the entire pretraining objective: predict the next token. Truth, safety, helpfulness - not in the formula.
BACKPROP + ADAMW repeat ~10⁶ steps
every weight nudged downhill
grad clipping 1000s of GPUs
data ∥ tensor ∥ pipeline
SCALING LAWS → the base model
a next-token predictor - not an assistant, continues anything
POST-TRAINING where “alignment” happens - same mechanism, new data
SFT
curated instruction → response pairs teach the assistant format
RLHF / DPO
preference pairs push weights toward answers people rate helpful + harmless
unwanted behavior gets rarer - never impossible