BERT (Devlin et al., 2018) pretrains by hiding some input tokens and predicting them. If it always showed a [MASK] token, the model would never see real text at fine-tuning time. So among the selected tokens, most become [MASK], some become random words, and some stay unchanged.
Implement masking_action(u), which maps a uniform draw to "mask", "random" or "keep" with probabilities 0.8, 0.1 and 0.1.
u < 0.8 is mask, u < 0.9 is random, otherwise keep.Compare u against the two thresholds in order.
No results yet
Run your code to check it against the examples, or submit to run every test.