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
2fbd6df8
Unverified
Commit
2fbd6df8
authored
Apr 24, 2023
by
Joao Gante
Committed by
GitHub
Apr 24, 2023
Browse files
Generate: Add exception path for Donut (#22955)
parent
df017c3c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
0 deletions
+3
-0
src/transformers/generation/utils.py
src/transformers/generation/utils.py
+3
-0
No files found.
src/transformers/generation/utils.py
View file @
2fbd6df8
...
@@ -667,6 +667,9 @@ class GenerationMixin:
...
@@ -667,6 +667,9 @@ class GenerationMixin:
# no user input -> use decoder_start_token_id as decoder_input_ids
# no user input -> use decoder_start_token_id as decoder_input_ids
if
decoder_input_ids
is
None
:
if
decoder_input_ids
is
None
:
decoder_input_ids
=
decoder_input_ids_start
decoder_input_ids
=
decoder_input_ids_start
# exception: Donut checkpoints have task-specific decoder starts and don't expect a BOS token
elif
self
.
config
.
model_type
==
"vision-encoder-decoder"
and
"donut"
in
self
.
name_or_path
.
lower
():
pass
# user input but doesn't start with decoder_start_token_id -> prepend decoder_start_token_id (and adjust
# user input but doesn't start with decoder_start_token_id -> prepend decoder_start_token_id (and adjust
# decoder_attention_mask if provided)
# decoder_attention_mask if provided)
elif
(
decoder_input_ids
[:,
0
]
!=
decoder_start_token_id
).
all
().
item
():
elif
(
decoder_input_ids
[:,
0
]
!=
decoder_start_token_id
).
all
().
item
():
...
...
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