mirror of
https://github.com/saymrwulf/transformers.git
synced 2026-05-14 20:58:08 +00:00
Generate: Add exception path for Donut (#22955)
This commit is contained in:
parent
df017c3ccc
commit
2fbd6df81c
1 changed files with 3 additions and 0 deletions
|
|
@ -667,6 +667,9 @@ class GenerationMixin:
|
|||
# no user input -> use decoder_start_token_id as decoder_input_ids
|
||||
if decoder_input_ids is None:
|
||||
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
|
||||
# decoder_attention_mask if provided)
|
||||
elif (decoder_input_ids[:, 0] != decoder_start_token_id).all().item():
|
||||
|
|
|
|||
Loading…
Reference in a new issue