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
02b63702
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "69bac2a20e17070fb8734278c3796321b3521f07"
Unverified
Commit
02b63702
authored
Oct 18, 2022
by
Ivan Sedykh
Committed by
GitHub
Oct 18, 2022
Browse files
fix seq2seqtrainer predict without labels (#19721)
parent
fac1f4b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
src/transformers/trainer_seq2seq.py
src/transformers/trainer_seq2seq.py
+2
-2
No files found.
src/transformers/trainer_seq2seq.py
View file @
02b63702
...
...
@@ -208,9 +208,9 @@ class Seq2SeqTrainer(Trainer):
generated_tokens
=
self
.
_pad_tensors_to_max_len
(
generated_tokens
,
gen_kwargs
[
"max_new_tokens"
]
+
1
)
with
torch
.
no_grad
():
with
self
.
compute_loss_context_manager
():
outputs
=
model
(
**
inputs
)
if
has_labels
:
with
self
.
compute_loss_context_manager
():
outputs
=
model
(
**
inputs
)
if
self
.
label_smoother
is
not
None
:
loss
=
self
.
label_smoother
(
outputs
,
inputs
[
"labels"
]).
mean
().
detach
()
else
:
...
...
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