Training Objective

LLMs interview question · Medium difficulty

What is the training objective of an LLM, and how does next-token prediction actually work?medium

Status
✓
Type
conceptual
Topic
training-objective
Frequency
common
Tags
training-objective, next-token-prediction, cross-entropy-loss
Answer

The main training objective for GPT-style LLMs is next-token prediction: given a sequence of tokens, the model predicts a probability distribution over the vocabulary for what comes next, that prediction is compared against the actual next token using cross-entropy loss, and the weights are updated to reduce that loss.

Explanation

Concretely, given input "The capital of India is" the target is "New"; then given "The capital of India is New" the target is "Delhi." At massive scale, this simple objective — repeated across huge amounts of text — teaches grammar, facts, reasoning patterns, code patterns, style, translation, summarization, and instruction-following behavior, none of which were explicitly labeled as separate tasks. The important caveat: the model is not explicitly trained to know truth, only to predict likely continuations, which is one of the fundamental reasons hallucination exists — a fluent, high-probability continuation and a factually correct one are not the same target.

Follow-upWhy does a single objective like next-token prediction produce behaviors like translation or reasoning that weren't explicitly trained for?
Follow-upHow does cross-entropy loss actually penalize a wrong next-token prediction?
Follow-upWhy is 'predicting a likely continuation' different from 'predicting a true statement'?