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
ab19f907
Unverified
Commit
ab19f907
authored
May 28, 2024
by
Younes Belkada
Committed by
GitHub
May 28, 2024
Browse files
FIX / OPT: Fix OPT multi-GPU training for `OPTForQuestionAnswering` (#31092)
Update modeling_opt.py
parent
94d416f0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
src/transformers/models/opt/modeling_opt.py
src/transformers/models/opt/modeling_opt.py
+2
-2
No files found.
src/transformers/models/opt/modeling_opt.py
View file @
ab19f907
...
...
@@ -1427,8 +1427,8 @@ class OPTForQuestionAnswering(OPTPreTrainedModel):
end_positions
=
end_positions
.
squeeze
(
-
1
)
# sometimes the start/end positions are outside our model inputs, we ignore these terms
ignored_index
=
start_logits
.
size
(
1
)
start_positions
=
start_positions
.
clamp
(
0
,
ignored_index
)
end_positions
=
end_positions
.
clamp
(
0
,
ignored_index
)
start_positions
=
start_positions
.
clamp
(
0
,
ignored_index
)
.
to
(
logits
.
device
)
end_positions
=
end_positions
.
clamp
(
0
,
ignored_index
)
.
to
(
logits
.
device
)
loss_fct
=
CrossEntropyLoss
(
ignore_index
=
ignored_index
)
start_loss
=
loss_fct
(
start_logits
,
start_positions
)
...
...
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