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

Donut: fix `generate` call from local path (#31470)



* local donut path fix

* engrish

* Update src/transformers/generation/utils.py
Co-authored-by: default avataramyeroberts <22614925+amyeroberts@users.noreply.github.com>

---------
Co-authored-by: default avataramyeroberts <22614925+amyeroberts@users.noreply.github.com>
parent 76289fbc
...@@ -575,8 +575,12 @@ class GenerationMixin: ...@@ -575,8 +575,12 @@ 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_start_token_id decoder_input_ids = decoder_start_token_id
# exception: Donut checkpoints have task-specific decoder starts and don't expect a BOS token # exception: Donut checkpoints have task-specific decoder starts and don't expect a BOS token. Note that the
elif self.config.model_type == "vision-encoder-decoder" and "donut" in self.name_or_path.lower(): # original checkpoints can't be detected through `self.__class__.__name__.lower()`, needing custom logic.
# See: https://github.com/huggingface/transformers/pull/31470
elif "donut" in self.__class__.__name__.lower() or (
self.config.model_type == "vision-encoder-decoder" and "donut" in self.config.encoder.model_type.lower()
):
pass pass
elif self.config.model_type in ["whisper"]: elif self.config.model_type in ["whisper"]:
pass pass
......
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