BERT's training loss is only computed on the masked positions. Unmasked tokens contribute nothing, so the model learns to recover the hidden words from their context on both sides.
Implement masked_lm_loss(log_probs, targets, mask), which averages the negative log-probability of the correct token over masked positions.
0.0 when no position is masked.Index the correct log-probability at each position, negate, then average over the masked entries only.
No results yet
Run your code to check it against the examples, or submit to run every test.