Unverified Commit 2fbd6df8 authored by Joao Gante's avatar Joao Gante Committed by GitHub
Browse files

Generate: Add exception path for Donut (#22955)

parent df017c3c
...@@ -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():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment