Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BERT is broken on v4.49.0-Gemma-3 #36802

Open
4 tasks
koute opened this issue Mar 18, 2025 · 2 comments
Open
4 tasks

BERT is broken on v4.49.0-Gemma-3 #36802

koute opened this issue Mar 18, 2025 · 2 comments
Labels

Comments

@koute
Copy link

koute commented Mar 18, 2025

System Info

I'm using pytorch 2.6.0 on Linux.

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

Consider the following code:

import transformers

model = transformers.AutoModelForMaskedLM.from_pretrained("google-bert/bert-base-cased")
tokenizer = transformers.AutoTokenizer.from_pretrained("google-bert/bert-base-cased")

text = "Hi! My name is Stinky Bob and I'm a [MASK]."
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
masked_index = inputs["input_ids"][0].tolist().index(tokenizer.mask_token_id)
predicted_token_id = outputs["logits"][0, masked_index].argmax(axis=-1)
predicted_token = tokenizer.decode(predicted_token_id)
print(predicted_token)

On v4.49.0-Gemma-3 it produces the following output:

man

On 4.49.0, 4.48.0, 4.40.0, 4.30.0 it produces the following output:

friend

As far as I can see it breaks on v4.49.0-Gemma-3 because the checkpoint loading is broken, and it doesn't load the weights for the model.cls.predictions.transform.LayerNorm properly (the weights are just default initialized).

Expected behavior

I expect the BERT weights to be properly loaded and the output consistent with the previous version of transformers.

@koute koute added the bug label Mar 18, 2025
@zucchini-nlp
Copy link
Member

Hey! Can you try to update and install from source, since we did a big refactoring for model load on main branch?

@koute
Copy link
Author

koute commented Mar 21, 2025

Hey! Can you try to update and install from source, since we did a big refactoring for model load on main branch?

Yep, it's fixed on the newest main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants