plaese fix the below error Florence2LanguageForConditionalGeneration has generative…
- User
plaese fix the below error
Florence2LanguageForConditionalGeneration has generative capabilities, as
prepare_inputs_for_generationis explicitly overwritten. However, it doesn't directly inherit fromGenerationMixin. From 👉v4.50👈 onwards,PreTrainedModelwill NOT inherit fromGenerationMixin, and this model will lose the ability to callgenerateand 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(afterPreTrainedModel, 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.
- If you're using
- Assistant
To resolve the error message you are encountering, you need to ensure that the
Florence2LanguageForConditionalGenerationmodel class inherits fromGenerationMixin. This can be done by modifying the class definition in the model architecture code. Here are the steps you should follow:If you have access to modify the model code:
-
Locate the Class Definition: Find the definition of the
Florence2LanguageForConditionalGenerationclass in the model architecture code.
-
- User
step by step guide for applying from transformers import AutoModelForCausalLM, BertTokenizer
tokenizer = BertTokenizer.from_pretrained("your_model_directory") model = AutoModelForCausalLM.from_pretrained("your_model_directory", trust_remote_code=True)
- Assistant