Skip to content

Commit

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

fixes #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 Jul 30, 2024
1 parent 62c60a3 commit 516af4b
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 516af4b

Please sign in to comment.