Skip to content

[MultimodalLM] add language_model to the get/set_input_embeddings logic#46029

Merged
vasqu merged 5 commits into
mainfrom
language_model_in_EmbeddingAccessMixin
May 18, 2026
Merged

[MultimodalLM] add language_model to the get/set_input_embeddings logic#46029
vasqu merged 5 commits into
mainfrom
language_model_in_EmbeddingAccessMixin

Conversation

@eustlb

@eustlb eustlb commented May 18, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

As per-title, since we're checking self.model for encoder/decoder models, IMO there is no reason not to do it for ALM/VLMs too.

Comment on lines -287 to -292
def get_input_embeddings(self):
return self.model.get_input_embeddings()

def set_input_embeddings(self, value):
self.model.set_input_embeddings(value)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ this is not related to the addition of language_model to EmbeddingAccessMixin. This was already redundant as get/set_input_embeddings already checks self.model

@eustlb eustlb requested a review from vasqu May 18, 2026 10:53
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@eustlb

eustlb commented May 18, 2026

Copy link
Copy Markdown
Collaborator Author

run-slow: aria, audioflamingo3, aya_vision, blip_2, cohere2_vision, deepseek_vl, deepseek_vl_hybrid, ernie4_5_vl_moe, exaone4_5, fast_vlm, florence2, fuyu, gemma3, gemma3n, gemma4, glm46v

@github-actions

Copy link
Copy Markdown
Contributor

Workflow Run ⚙️

This comment contains run-slow, running the specified jobs:

models: ["models/aria", "models/audioflamingo3", "models/aya_vision", "models/blip_2", "models/cohere2_vision", "models/deepseek_vl", "models/deepseek_vl_hybrid", "models/ernie4_5_vl_moe", "models/exaone4_5", "models/fast_vlm", "models/florence2", "models/fuyu", "models/gemma3", "models/gemma3n", "models/gemma4", "models/glm46v"]
quantizations: []

@vasqu vasqu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice pickup, small but huge QoL improvement 🤗 cc @molbap @zucchini-nlp just in case that you are aware

model = getattr(self, "model", None)
if model is not None and hasattr(model, name):
return getattr(model, name)
# 4) Multimodal LMs that wrap a text sub-model at `self.language_model`.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not on you but could you put a 5) below (similar to the set method)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ofc!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually this is same as self.get_decoder() for all MLLMs, so we could

# Same as base model, we can check if embedding is inside a decoder for
# enc-dec models and for MLLMs
decoder = self.get_decoder()
embedding_layer = decoder.embedding_layer

@github-actions

Copy link
Copy Markdown
Contributor

CI Results

Workflow Run ⚙️

Commit Info

Context Commit Description
RUN 6f3de50d workflow commit (merge commit)
PR 09c86a93 branch commit (from PR)
main ca80e957 base commit (on main)

Model CI Report

1 new failed tests from this PR 😭

  • gemma4:
    tests/models/gemma4/test_modeling_gemma4.py::Gemma4IntegrationTest::test_export_text_only (❌ ⟹ ❌)

@vasqu

vasqu commented May 18, 2026

Copy link
Copy Markdown
Collaborator

It's the process number 🫠 so all good it seems

@eustlb

eustlb commented May 18, 2026

Copy link
Copy Markdown
Collaborator Author

Perfect! merging

@eustlb eustlb enabled auto-merge May 18, 2026 16:48
@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: aria, audioflamingo3, aya_vision, blip_2, cohere2_vision, deepseek_vl, deepseek_vl_hybrid, ernie4_5_vl_moe, exaone4_5, fast_vlm, florence2, fuyu, gemma3, gemma3n, gemma4, glm46v

@github-actions

Copy link
Copy Markdown
Contributor

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=46029&sha=11f297

@vasqu vasqu disabled auto-merge May 18, 2026 17:51
@vasqu vasqu merged commit 73d9159 into main May 18, 2026
28 of 30 checks passed
@vasqu vasqu deleted the language_model_in_EmbeddingAccessMixin branch May 18, 2026 17:51
@vasqu

vasqu commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Flaky test merged myself 🤗

yuchenxie4645 pushed a commit to yuchenxie4645/transformers that referenced this pull request May 28, 2026
…ic (huggingface#46029)

* add language_model to EmbeddingAccessMixin logic

* propagate changes

* fix test

* add comment
kashif pushed a commit to kashif/transformers that referenced this pull request Jun 1, 2026
…ic (huggingface#46029)

* add language_model to EmbeddingAccessMixin logic

* propagate changes

* fix test

* add comment
khushali9 pushed a commit to khushali9/transformers that referenced this pull request Jun 8, 2026
…ic (huggingface#46029)

* add language_model to EmbeddingAccessMixin logic

* propagate changes

* fix test

* add comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants