Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
0b418673
Unverified
Commit
0b418673
authored
Aug 03, 2020
by
Suraj Patil
Committed by
GitHub
Aug 03, 2020
Browse files
fix labels (#6213)
parent
cedc547e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
1 deletion
+2
-1
src/transformers/data/data_collator.py
src/transformers/data/data_collator.py
+2
-1
No files found.
src/transformers/data/data_collator.py
View file @
0b418673
...
@@ -87,7 +87,8 @@ class DataCollatorForLanguageModeling:
...
@@ -87,7 +87,8 @@ class DataCollatorForLanguageModeling:
return
{
"input_ids"
:
inputs
,
"labels"
:
labels
}
return
{
"input_ids"
:
inputs
,
"labels"
:
labels
}
else
:
else
:
labels
=
batch
.
clone
().
detach
()
labels
=
batch
.
clone
().
detach
()
labels
[
labels
==
self
.
tokenizer
.
pad_token_id
]
=
-
100
if
self
.
tokenizer
.
pad_token_id
is
not
None
:
labels
[
labels
==
self
.
tokenizer
.
pad_token_id
]
=
-
100
return
{
"input_ids"
:
batch
,
"labels"
:
labels
}
return
{
"input_ids"
:
batch
,
"labels"
:
labels
}
def
_tensorize_batch
(
self
,
examples
:
List
[
torch
.
Tensor
])
->
torch
.
Tensor
:
def
_tensorize_batch
(
self
,
examples
:
List
[
torch
.
Tensor
])
->
torch
.
Tensor
:
...
...
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