Generate: Add exception path for Donut (#22955)

This commit is contained in:
Joao Gante 2023-04-24 13:05:55 +01:00 committed by GitHub
parent df017c3ccc
commit 2fbd6df81c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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():