Beta

Sync to cloud

Uses your current signed-in YoolVi account. A Learn profile is not required.

Upload a snapshot of this browser’s saved lesson work across all subjects, including notes, experiments, journal and review history. Existing guest work is included only when you confirm below. This does not upload account credentials or award XP.

Sync uploads to your private account; it does not automatically merge or replace this device’s work. On another device, download the cloud copy and use My Learning’s backup import. The previous cloud snapshot is retained when a new one replaces it.

Export or import this device’s work

No background uploads. Edits made after a snapshot need another sync. On shared devices, work is bound to the first account observed by cloud sync; another account must use a separate browser profile. Keep your own downloaded backup too.

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Back to Training and data

Shared AI lesson · Training and data

Explain: Next-token targets

READ & CONNECT

Understand what changed.

Back to the experiment

A shorter explanation, with the original worked examples available below. Both explain the same experiment and its limits.

Same learning goal in both modes: Calculate target-token loss, identify future leakage, and explain why teacher-forced scores do not replace free-running task evaluation.

The idea in everyday terms

Next-token prediction asks for the piece after the visible prefix. During training, inputs and targets are shifted: the current input is not its own answer. A start marker begins the sequence and an end target teaches where it finishes.

What to watch in the experiment

Follow the supplied probabilities at each position and calculate the loss for the actual next token. Compare correct masking with access to future answers. A copied or leaked target can make the score look excellent without teaching the intended task.

What this does not establish

This lab changes a supplied probability table rather than training a neural model. Low loss on familiar text does not prove factual accuracy or reliable behavior outside the tiny grammar.

Open the full worked examples, calculations and limitations

This is the same reference used in Technical mode. Expand it whenever you need the exact numbers, assumptions or further explanation.

One sentence supplies several prediction questions

Take the authored reference red apples grow. Add a start marker before it and an end target after it. The aligned inputs are start, red, apples, grow; the targets are red, apples, grow, end. Each prediction asks for the next token, not a copy of the token at the same input position.

The lab uses seven fixed output tokens, supplied probabilities and four tiny grammar sentences. It does not fit a neural network. Changing the controls changes a probability table so you can inspect the objective before introducing parameter updates.

Past reference tokens are allowed; future targets are not

At the row predicting grow, the reference prefix is start, red, apples. The next input position contains grow, so exposing that position would reveal the answer. The visibility matrix makes this boundary explicit: a causal row includes current and earlier input positions, and hides later ones.

Teacher forcing means using the reference’s earlier tokens as the conditioning prefix while predicting its next token. The target is available separately to calculate the error. That is different from allowing the prediction mechanism to read the target as an input.

The lab’s broken mode deliberately copies the next input and assigns it probability one. This is an explicit leakage oracle, not a claim that every network without a causal mask immediately learns perfect copying. The final end target is outside the input array, so that last row has no next input to copy.

Give a confident wrong answer a larger penalty

Suppose the actual next token is grow. Assigning it probability one half means the model left substantial room for other answers. Assigning it one eighth makes the observed answer much less expected. Cross-entropy measures that difference using the probability assigned to the target, not just whether the largest-probability token was correct.

For one observed target, its loss in bits is:

ℓ=−log⁡2p\ell=-\log_2 p

Here p is the target’s predicted probability, between zero and one. ℓ is its loss. Read the formula as “negative base-two logarithm of the target probability”. At probabilities that are powers of one half, count halvings: one half gives one bit; one quarter gives two; one eighth gives three. Other probabilities give values between those landmarks.

Probability one gives zero loss. Exactly zero gives infinite loss: the table ruled out an event that occurred. The lab shows infinity explicitly rather than silently replacing zero with a small positive number. Practical implementations often calculate log-probabilities from logits for numerical stability, which is a separate implementation issue.

For several scored targets, add their losses and divide by their count:

L=1N∑t=1N−log⁡2ptL=\frac{1}{N}\sum_{t=1}^{N}-\log_2 p_t

N is the number of scored targets, t identifies a position and pₜ is the probability assigned to that position’s actual target. Two targets with probabilities one half and one eighth have losses one and three: their mean is two bits. This lab includes the end target in its denominator. Natural logarithms instead give losses in nats; do not mix those units.

Generation follows its own decisions

With the default settings, a greedy generator chooses red birds sing end. The reference may instead be red apples grow end. Under teacher forcing, grow is scored after the reference prefix ending in apples. During the actual rollout, the corresponding history ends in birds.

Those are different conditional questions. The generated-prefix column diagnoses how reference-token probabilities change after a different choice. Its average is not the likelihood of the reference sequence, because it conditions on other histories. The ordinary causal, reference-prefix score follows the reference sequence’s own chain of conditional probabilities.

Both sentences are valid in this small grammar. A different reference match is therefore not automatically a task failure. For a task requiring a particular fact or exact output, the distinction may matter greatly; for an open-ended task, several outputs may be acceptable. Specify task success separately from prediction loss and grammar validity.

Lower scores can come from the wrong information

Enable future copying and compare the table with generation. The leaked reference score falls, but the generated sentence does not improve: the future reference inputs do not exist during generation. The base probability recipe did not change, and this demonstration has no trained parameters.

A useful diagnosis records the input/target alignment, allowed information, probabilities, loss units and denominator. Include an actual generated trace too. A lower number alone does not show that a training change improved the intended capability.

Apply the check before training

For guided practice, explain one row and reproduce its arithmetic. For implementation practice, test that changing future tokens cannot affect an earlier causal output and that targets are shifted correctly. For a decision brief, require both leakage-free reference scoring and task-relevant generated-output evaluation.

Export a note with one permitted prefix, one calculation, one leakage failure and one limitation. These temporary experiments and the lesson challenge are practice, not independent implementation review. Return to causal attention to inspect masking inside an attention mechanism, or language-task evaluation to compare loss with evidence of task success.

Notes, help and related ideas
My notes and reflection
CURIOSITY JOURNAL

What will you take away?

Keep a private reminder for yourself.

Loading your journal…

Add a short reflection

Open your journal or back it up.

Prerequisites and related ideas

Key terms: