Skip to content

Commit

Permalink
fixes huggingface#32329 : The Torch code is correct - to get an avera…
Browse files Browse the repository at this point in the history
…ge of 10% o… (huggingface#32335)

fixes huggingface#32329 : The Torch code is correct - to get an average of 10% of the total, we want to take 50% of the remainder after we've already masked 80% with [MASK] in the previous step.
  • Loading branch information
fkrasnov2 authored and tGhattas committed Jul 31, 2024
1 parent fea0224 commit e20a751
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/transformers/data/data_collator.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ def tf_mask_tokens(
inputs = tf.where(indices_replaced, mask_token_id, inputs)

# 10% of the time, we replace masked input tokens with random word
indices_random = self.tf_bernoulli(input_shape, 0.1) & masked_indices & ~indices_replaced
indices_random = self.tf_bernoulli(input_shape, 0.5) & masked_indices & ~indices_replaced
random_words = tf.random.uniform(input_shape, maxval=vocab_size, dtype=inputs.dtype)

inputs = tf.where(indices_random, random_words, inputs)
Expand Down

0 comments on commit e20a751

Please sign in to comment.