Use get_input_embeddings() Instead of Accessing .embed_tokens Directly

#8
No description provided.

Problem

Code was previously accessing self.base.model.embed_tokens(input_ids) directly, which works on transformers < 4.51.0, but raises:

AttributeError: 'Qwen2VLModel' object has no attribute 'embed_tokens'

in transformers >= 4.51.0 due to internal API refactoring.

✅ Solution

Switched to the standardized HuggingFace API:

inputs_embeds = self.base.get_input_embeddings()(input_ids)

This makes the code compatible across all transformers >= 4.0, and avoids reliance on internal attributes that may change.

🧪 Tested

  • Confirmed working on both transformers==4.50.0 and 4.52.3.
  • No behavior changes, but now forward-compatible.
Publish this branch
This branch is in draft mode, publish it to be able to merge.

Sign up or log in to comment