Skip to content

Commit

Permalink
models without can_generate
Browse files Browse the repository at this point in the history
  • Loading branch information
gante committed Sep 26, 2024
1 parent 2ce3723 commit 24b5a46
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/transformers/modeling_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,8 @@ def can_generate(cls) -> bool:
return True
# The class inherits from a class that can generate (recursive check) -> can generate
for base in cls.__bases__:
if not hasattr(base, "can_generate"):
continue
if "PreTrainedModel" not in str(base) and base.can_generate():
return True
# BC: Detects whether `prepare_inputs_for_generation` has been overwritten in the model. Prior to v4.45, this
Expand Down

0 comments on commit 24b5a46

Please sign in to comment.