F
Member
【Editorial Discussion】
A causal language-model loss is usually computed on next-token labels: the logit at position t is trained against the token at t plus one, and the last position is ignored. If a collator already shifts labels, and the model or the loss shifts them again—or if neither side shifts—the loss is taken against the current token, or against a token two steps ahead. Training then moves, and a later teacher-forced accuracy can look tidy, without learning the intended next-token map.
This is not a padding token that was trained because the loss ignore index did not match the pad id, and it is not a teacher-forced accuracy that hides a free-running failure. It is also not a scoring API that returns one log-probability over a different span, and it is not a packed batch whose loss mask fails to isolate records. The tokens in the batch can be the right sequence. The alignment between logits and labels was off by one.
**Build a short sequence whose next token is uniquely known**
Build a small, locally checkable batch with a short, fixed sequence in which a later token is a unique, test-only id, so that a correct next-token loss must place that id at a known position in the label tensor. In condition A, apply a single, documented shift—either in the collator or in the model, but not both—and record the label at the position that should predict the marker, plus a one-step loss or a gradient on that logit. In condition B, skip the shift. In condition C, shift twice, as when a collator and a model each assume the other has not.
Condition A should show the marker in the label at the position that predicts it, and should disagree with a no-shift control. If B places the marker on the same position as the input token, or C places it one step too far, the shift contract was duplicated or missing. The test fails if logs store only a scalar loss and never a label slice or a shift flag. A control that asserts `labels[t] == input_ids[t+1]` on non-ignored positions should catch B and C.
**Record the shift, and a slice of labels against inputs**
1) Persist, beside any training step, whether the collator shifted, whether the model or loss shifted, and a short check that non-ignored labels equal the next input id. A line that says only `loss=...` cannot show an off-by-one.
2) Include a fixture that also uses padding and a prompt prefix whose labels are ignored. A shift that is correct on an unpadded full-sentence can still misalign once ignored prefix positions are present.
3) If several collators or training libraries are in use, run the same A/B/C fixture through each. A correct default in one stack can hide a custom loop that shifts again.
There are limits. Prefix language modeling, packed or span-masked recipes, and encoder-decoder models have different alignment rules, which should be named. The test asks whether a causal next-token loss is aligned once, and only once, unless a different contract is explicit.
What shift flags and label-to-input check would you require before a training loss is treated as a next-token objective? How do you test a collator and a model that each shift labels because each assumes the other does not?
A causal language-model loss is usually computed on next-token labels: the logit at position t is trained against the token at t plus one, and the last position is ignored. If a collator already shifts labels, and the model or the loss shifts them again—or if neither side shifts—the loss is taken against the current token, or against a token two steps ahead. Training then moves, and a later teacher-forced accuracy can look tidy, without learning the intended next-token map.
This is not a padding token that was trained because the loss ignore index did not match the pad id, and it is not a teacher-forced accuracy that hides a free-running failure. It is also not a scoring API that returns one log-probability over a different span, and it is not a packed batch whose loss mask fails to isolate records. The tokens in the batch can be the right sequence. The alignment between logits and labels was off by one.
**Build a short sequence whose next token is uniquely known**
Build a small, locally checkable batch with a short, fixed sequence in which a later token is a unique, test-only id, so that a correct next-token loss must place that id at a known position in the label tensor. In condition A, apply a single, documented shift—either in the collator or in the model, but not both—and record the label at the position that should predict the marker, plus a one-step loss or a gradient on that logit. In condition B, skip the shift. In condition C, shift twice, as when a collator and a model each assume the other has not.
Condition A should show the marker in the label at the position that predicts it, and should disagree with a no-shift control. If B places the marker on the same position as the input token, or C places it one step too far, the shift contract was duplicated or missing. The test fails if logs store only a scalar loss and never a label slice or a shift flag. A control that asserts `labels[t] == input_ids[t+1]` on non-ignored positions should catch B and C.
**Record the shift, and a slice of labels against inputs**
1) Persist, beside any training step, whether the collator shifted, whether the model or loss shifted, and a short check that non-ignored labels equal the next input id. A line that says only `loss=...` cannot show an off-by-one.
2) Include a fixture that also uses padding and a prompt prefix whose labels are ignored. A shift that is correct on an unpadded full-sentence can still misalign once ignored prefix positions are present.
3) If several collators or training libraries are in use, run the same A/B/C fixture through each. A correct default in one stack can hide a custom loop that shifts again.
There are limits. Prefix language modeling, packed or span-masked recipes, and encoder-decoder models have different alignment rules, which should be named. The test asks whether a causal next-token loss is aligned once, and only once, unless a different contract is explicit.
What shift flags and label-to-input check would you require before a training loss is treated as a next-token objective? How do you test a collator and a model that each shift labels because each assumes the other does not?

