Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
8453201c
Unverified
Commit
8453201c
authored
Dec 03, 2020
by
Sylvain Gugger
Committed by
GitHub
Dec 03, 2020
Browse files
Avoid erasing the attention mask when double padding (#8915)
parent
0deece9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
3 deletions
+2
-3
src/transformers/tokenization_utils_base.py
src/transformers/tokenization_utils_base.py
+2
-3
No files found.
src/transformers/tokenization_utils_base.py
View file @
8453201c
...
@@ -3047,9 +3047,8 @@ class PreTrainedTokenizerBase(SpecialTokensMixin):
...
@@ -3047,9 +3047,8 @@ class PreTrainedTokenizerBase(SpecialTokensMixin):
encoded_inputs
[
"input_ids"
]
=
[
self
.
pad_token_id
]
*
difference
+
encoded_inputs
[
"input_ids"
]
encoded_inputs
[
"input_ids"
]
=
[
self
.
pad_token_id
]
*
difference
+
encoded_inputs
[
"input_ids"
]
else
:
else
:
raise
ValueError
(
"Invalid padding strategy:"
+
str
(
self
.
padding_side
))
raise
ValueError
(
"Invalid padding strategy:"
+
str
(
self
.
padding_side
))
else
:
elif
return_attention_mask
and
"attention_mask"
not
in
encoded_inputs
:
if
return_attention_mask
:
encoded_inputs
[
"attention_mask"
]
=
[
1
]
*
len
(
encoded_inputs
[
"input_ids"
])
encoded_inputs
[
"attention_mask"
]
=
[
1
]
*
len
(
encoded_inputs
[
"input_ids"
])
return
encoded_inputs
return
encoded_inputs
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment