Inherit from GenerationMixin

#80
by Link161 - opened

Florence-2 currently triggers the following deprecation warning in the transformers library:

Florence2LanguageForConditionalGeneration has generative capabilities, as `prepare_inputs_for_generation` is explicitly overwritten. However, it doesn't directly inherit from `GenerationMixin`. From 👉v4.50👈 onwards, `PreTrainedModel` will NOT inherit from `GenerationMixin`, and this model will lose the ability to call `generate` and other related functions.
  - If you're using `trust_remote_code=True`, you can get rid of this warning by loading the model with an auto class. See https://huggingface.co/docs/transformers/en/model_doc/auto#auto-classes
  - If you are the owner of the model architecture code, please modify your model class such that it inherits from `GenerationMixin` (after `PreTrainedModel`, otherwise you'll get an exception).
  - If you are not the owner of the model architecture class, please contact the model code owner to update it.

This PR follows the advice of the warning and adds GenerationMixin as a parent class of Florence2LanguageForConditionalGeneration.

Link161 changed pull request status to open

Thanks for reporting, I'm not part of the Microsoft org but will try to ping some members

Microsoft org

Thanks @Link161

haipingwu changed pull request status to merged

Sign up or log in to comment