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
95a90410
Unverified
Commit
95a90410
authored
Sep 13, 2023
by
Yih-Dar
Committed by
GitHub
Sep 13, 2023
Browse files
Fix `test_finetune_bert2bert` (#25984)
Co-authored-by:
ydshieh
<
ydshieh@users.noreply.github.com
>
parent
86ffef87
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
src/transformers/trainer_seq2seq.py
src/transformers/trainer_seq2seq.py
+6
-5
No files found.
src/transformers/trainer_seq2seq.py
View file @
95a90410
...
...
@@ -281,15 +281,16 @@ class Seq2SeqTrainer(Trainer):
gen_kwargs
[
"synced_gpus"
]
if
gen_kwargs
.
get
(
"synced_gpus"
)
is
not
None
else
default_synced_gpus
)
generation_inputs
=
inputs
.
copy
()
# If the `decoder_input_ids` was created from `labels`, evict the former, so that the model can freely generate
# (otherwise, it would continue generating from the padded `decoder_input_ids`)
if
(
"labels"
in
inputs
and
"decoder_input_ids"
in
inputs
and
inputs
[
"labels"
].
shape
==
inputs
[
"decoder_input_ids"
].
shape
"labels"
in
generation_
inputs
and
"decoder_input_ids"
in
generation_
inputs
and
generation_
inputs
[
"labels"
].
shape
==
generation_
inputs
[
"decoder_input_ids"
].
shape
):
inputs
=
{
k
:
v
for
k
,
v
in
inputs
.
items
()
if
k
!=
"decoder_input_ids"
}
generated_tokens
=
self
.
model
.
generate
(
**
inputs
,
**
gen_kwargs
)
generation_
inputs
=
{
k
:
v
for
k
,
v
in
inputs
.
items
()
if
k
!=
"decoder_input_ids"
}
generated_tokens
=
self
.
model
.
generate
(
**
generation_
inputs
,
**
gen_kwargs
)
# Temporary hack to ensure the generation config is not initialized for each iteration of the evaluation loop
# TODO: remove this hack when the legacy code that initializes generation_config from a model config is
...
...
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