From Pretraining to Token Generation

The theoretical arc reaches the local LLM

During pretraining, a decoder-only Transformer sees enormous token sequences and learns to predict each next token. Backpropagation assigns loss through output, feed-forward, attention, and embedding parameters. Later instruction tuning may teach response formats and interaction patterns, but the core model remains a next-token predictor.

During inference, prompt tokens pass through the stack to produce logits for the next token. A decoding rule selects one token, appends it, and repeats. The key-value cache introduced later in serving stores attention state so earlier tokens need not be fully recomputed at every generation step.

prompt -> Transformer stack -> next-token logits -> choose token
   ^                                                |
   └---------------- append chosen token <-----------┘
Goal: Continue to the existing ai-llm-foundations module next. Its tokens, parameters, training-versus-inference distinction, context windows, and hallucinations now rest on the neural and Transformer mechanisms built here.
Warning: Understanding architecture does not make generated claims trustworthy. Next-token prediction optimizes plausible continuation; grounding, evaluation, guardrails, and human judgment remain necessary throughout the later track.