Skip to content

resize_token_embeddings does not effect to output_embeddings#45311

Open
KoichiYasuoka wants to merge 9 commits intohuggingface:mainfrom
KoichiYasuoka:patch-10
Open

resize_token_embeddings does not effect to output_embeddings#45311
KoichiYasuoka wants to merge 9 commits intohuggingface:mainfrom
KoichiYasuoka:patch-10

Conversation

@KoichiYasuoka
Copy link
Copy Markdown
Contributor

@KoichiYasuoka KoichiYasuoka commented Apr 8, 2026

What does this PR do?

Fixes #45292 (seems to come from #41580)

Code Agent Policy

The Transformers repo is currently being overwhelmed by a large number of PRs and issue comments written by
code agents. We are currently bottlenecked by our ability to review and respond to them. As a result,
we ask that new users do not submit pure code agent PRs at this time.
You may use code agents in drafting or to help you diagnose issues. We'd also ask autonomous "OpenClaw"-like agents
not to open any PRs or issues for the moment.

PRs that appear to be fully agent-written will probably be closed without review, and we may block users who do this
repeatedly or maliciously.

This is a rapidly-evolving situation that's causing significant shockwaves in the open-source community. As a result,
this policy is likely to be updated regularly in the near future. For more information, please read CONTRIBUTING.md.

  • I confirm that this is not a pure code agent PR.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

@KoichiYasuoka
Copy link
Copy Markdown
Contributor Author

"download and unzip hub cache" all failed... How do I do @ArthurZucker?

@Rocketknight1
Copy link
Copy Markdown
Member

cc @ArthurZucker this does seem like a real regression after #41580 when we resize the vocab on models with a tied LM head.

@KoichiYasuoka
Copy link
Copy Markdown
Contributor Author

Thank you @Rocketknight1, this bug occurs in transformers==5.0.0rc0 but not in 4.57.6:

  • Quick reproduce
from transformers import AutoModelForMaskedLM
mdl = AutoModelForMaskedLM.from_pretrained("google-bert/bert-base-uncased")
e = mdl.get_input_embeddings()
g = mdl.get_output_embeddings()
print(e.num_embeddings, g.out_features)
assert e.num_embeddings == g.out_features
e = mdl.resize_token_embeddings(e.num_embeddings + 1)
g = mdl.get_output_embeddings()
print(e.num_embeddings, g.out_features)
assert e.num_embeddings == g.out_features

@KoichiYasuoka
Copy link
Copy Markdown
Contributor Author

Then how do I do @Rocketknight1 and @ArthurZucker ?

@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=45311&sha=345ee0

@JLiu4Coding
Copy link
Copy Markdown

Hi Koichi, how is the status of this issue? I have also reproduced this issue and already fixed. I can submit a PR if needed.

@KoichiYasuoka
Copy link
Copy Markdown
Contributor Author

Thank you @JLiu4Coding. It seems that https://github.com/huggingface/transformers/pull/45324/changes#diff-6b72b98c4c2dcfc6cc606843917733f5d858374fbc22a735ff483bbc0c1e63ea has fixed this bug #45292. I will close this PR after I confirm #45324 released in v5.5.5 or after.

@Rocketknight1
Copy link
Copy Markdown
Member

Thank you @KoichiYasuoka, and sorry for the delays! It does seem like this bug got fixed, so you can close it whenever you're happy.

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.

resize_token_embeddings does not effect to output_embeddings

3 participants