AttributeError: 'InternLM2ForCausalLM' object has no attribute 'generate'
AttributeError: 'InternLM2ForCausalLM' object has no attribute 'generate'
the same problem
I previously did not have this issue, but after updating transformers to support the new Gemma 3n, both Qwen 2.5 VL and this model gave errors. After downgrading transformers manually to the last known working version, Qwen 2.5 VL worked, but this model still does not work and gives the same error as above.
same problem here.😭 any idea how to fix it?
@allenwjw49
@Florafdu
@mingyi456
@SnowNation
Reason: InternLM2ForCausalLM 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.
# TODO (joao): remove `GenerationMixin` inheritance in v4.50
class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMixin, PeftAdapterMixin):
See here
AttributeError: 'InternLM2ForCausalLM' object has no attribute 'generate'
You should make sure your transformers<=4.49.0
Otherwise, modify InternLM2ForCausalLM source codes and inherit from GenerationMixin.
The author needs to update their codes for new version of transformers.