An assistant uses a new name correctly after you introduce yourself. Did its model weights just change? Usually, using information in the current conversation is different from training the underlying model. To see the difference, follow the data through one training step.
Before you begin: Understand next-token generation, parameters, and loss.
How text becomes a training example
Take the sentence “The class starts at noon.” In a simplified next-token task, the model sees a prefix and predicts the next token. Text itself supplies the target. This is self-supervised learning: the training procedure constructs labels from available data instead of asking a person to label every prediction.
Real tokenization may split the sentence differently from its visible words. Training examples also involve formatting, length limits, and sometimes masks that decide which positions contribute to the loss. The simplified sentence is enough to follow the objective without pretending to describe every training implementation.
How loss measures a prediction
Suppose the correct target token is “noon.” One model assigns it probability 0.8; another assigns it 0.2. Both might occasionally sample the correct word, but the first gives that target more probability. A common loss is negative log probability: loss = -log(p), where p is the assigned probability of the observed target and log is the natural logarithm.
For 0.8, the loss is about 0.223. For 0.2, it is about 1.609. Lower is better for this prediction objective. The logarithm penalizes assigning very little probability to what actually occurred. This is a mathematical score for the data, not a direct measure of truthfulness or helpfulness.
What a training example changes
Training begins with a specific comparison: the model assigned probabilities to possible next tokens, and the data tells us which token actually followed. The loss measures how poorly the distribution supported that observation. It does not compare a whole answer with an ideal human explanation unless the training setup explicitly defines such a target.
Move the correct-token probability slowly toward zero and watch the penalty grow. Then repeat the identical prediction several times. This second change helps separate a summed loss from a mean loss. Nothing in this control updates weights; it lets you inspect the quantity an optimizer would use before considering how optimization changes future predictions.
The observed next token receives probability 0.20.
Raise that token’s probability to 0.50, keeping the identity of the target fixed.
Its negative log-likelihood falls from about 1.609 to 0.693 natural-log units.
Updating the model weights
Backpropagation calculates gradients, which describe how a small parameter change would affect the loss. An optimizer uses them to change the parameters. The learning rate controls the size of an update. If steps are poorly chosen, learning may be unstable or unnecessarily slow.
Training typically uses batches of examples. An epoch is one pass through a dataset under the chosen sampling setup. Large-model training is often planned in tokens and optimization steps, so a neat whole number of epochs is not always the useful unit.
The model sees many contexts, including imperfect and conflicting text. Becoming better at predicting that text can teach useful structure while also absorbing stereotypes, mistakes, or memorized sequences. Data preparation and evaluation are part of training, not optional cleanup afterward.
Testing on new examples
Training loss answers how well the model fits its training objective on the material used to update it. Validation loss checks held-out material. Task evaluations ask more specific questions: does the model follow instructions, preserve quoted dates, answer in the right language, or identify missing evidence?
A model can improve on an average score while getting worse on a small group of important examples. That is why later lessons separate aggregate metrics from inspection of particular failures. Also check whether evaluation material was exposed during training or tuning; leaked answers make progress difficult to interpret.
Training and conversation context
When you write “My project is called Cedar,” the current prompt can include that fact on later turns. The model can use it without any parameter update. This is often called in-context learning when examples or instructions in context shape behavior.
An application's saved memory is a third mechanism: the product may store information and insert it into later requests. None of these mechanisms should be assumed from the assistant saying “I remember.” Data use for future provider training is a separate policy question that depends on the service and account controls.
Calculate the loss
This complete Python 3 example evaluates two invented predictions. It does not train or contact a model.
# Runnable: Python 3, standard library.
import math
for probability in [0.8, 0.2]:
print(round(-math.log(probability), 3))
Try a probability of 0.01. Predict whether the loss should rise or fall. Then explain why a model with lower next-token loss might still answer the room-booking question incorrectly.
Connect the score to the task
The loss rises to about 4.605 for probability 0.01. The model strongly underpredicts the observed token. A lower average language-model loss does not ensure that a particular room-booking fact is present, current, or used correctly. You need a task-specific check of that answer and its evidence.
Practice with feedback
Make a confident mistake expensive
For an observed target token with assigned probability p, negative log-likelihood is -ln(p). This experiment repeats the same constructed prediction, without updating a model.
1 identical predictions; no parameter updates.
Near-zero probability gives a large penalty. Repeating the same example multiplies the summed loss but leaves its mean unchanged. Real batches contain different examples, so weighting and reduction choices matter.
What this experiment assumes. A fixed probability calculation in natural-log units. It does not run gradient descent or prove that a high-probability answer is factually correct. Notes and recorded results here last until you leave this page.
Compute the loss on one token
Training text: "the workshop starts at". The model must predict the next token. It assigns: "18:30" 0.20, "noon" 0.50, "six" 0.25, everything else 0.05. The true next token is "18:30".
Turn a probability into a loss and explain what a training update changes.
Check your understanding
Your task
Write the loss calculation, then show what happens to it when the probability of the correct token improves.
These notes stay on this page. Download them before leaving. Code in this field is not executed.
What to include
- The loss uses only the true token's probability
- You show at least three probabilities and their losses
- You note that the loss falls steeply at first and flattens near 1.0
- You can say what loss a perfectly confident correct model would have
Compare with a worked answer
Here is one way to answer. Check how it uses the information in the task.
import math
probs = {'18:30': 0.20, 'noon': 0.50, 'six': 0.25, '<other>': 0.05}
true_token = '18:30'
def loss(probs, true_token):
return -math.log(probs[true_token])
for p in (0.20, 0.45, 0.95, 0.999):
print(f'p={p:<6} loss={-math.log(p):.3f}')
# p=0.2 loss=1.609
# p=0.45 loss=0.799
# p=0.95 loss=0.051
# p=0.999 loss=0.001
#
# Going from 0.20 to 0.45 removes about 0.81 of loss. Going from 0.95 to
# 0.999 removes only 0.05. Most of the gradient is available while the
# model is still wrong, which is why early training moves fastest.
# A perfectly confident correct model has loss 0, reached only in the limit.When you are signed in, opening the challenge carries your edited working notes into its draft in this browser. The challenge has its own completion record. Practising here does not award points or mark it complete.
Next, we will examine the finite space available for the conversation itself. That explains why a model can use a fact on one turn and appear to lose it later.
Further reading
Training language models to follow instructions with human feedback describes one post-training pipeline. Language Models are Few-Shot Learners investigates behavior shaped by examples supplied in context.