Closed AADeLucia closed 2 months ago
Hey I want to resolve this by raising a PR. I am new to it, do let me how can I proceed.
Hey!
I don't think it's a bug. The documentation says that a GenerationConfig
object is expected as input. In case you have a dict type, you can still pass it directly to the forward like below. See docs for more 🤗
model.generate(**inputs, **gen_config_dict)
cc @gante to confirm
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.
There is a small bug when a dictionary with generation config arguments is passed to
.generate()
instead of ageneration.GenerationConfig
object. The bug happens in this line in_prepare_generation_config
: https://github.com/huggingface/transformers/blob/25245ec26dc29bcf6102e1b4ddd0dfd02e720cf5/src/transformers/generation/utils.py#L1382model_kwargs
is set correctly whengeneration_config
is ageneration.GenerationConfig
object but whengeneration_config
is a dictionary,model_kwargs
is set toNone
and an error is thrown in.generate()
fromhttps://github.com/huggingface/transformers/blob/25245ec26dc29bcf6102e1b4ddd0dfd02e720cf5/src/transformers/generation/utils.py#L1633
Small example:
Possible fixes could be:
generation_config
is a dictionary ingenerate
generation.GenerationConfig
object before passing it to_prepare_generation_config
_prepare_generation_config