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

Google RecurrentGemma Models don't work in Transformers 4.43 anymore #32549

Closed
2 of 4 tasks
dipanjanS opened this issue Aug 8, 2024 · 3 comments · Fixed by #32554
Closed
2 of 4 tasks

Google RecurrentGemma Models don't work in Transformers 4.43 anymore #32549

dipanjanS opened this issue Aug 8, 2024 · 3 comments · Fixed by #32554
Labels

Comments

@dipanjanS
Copy link

System Info

Transformers version 4.43.3 causes this error, works fine in 4.42

from transformers import AutoTokenizer, AutoModelForCausalLM
import transformers
import torch

model_id = "google/recurrentgemma-2b-it"
dtype = torch.bfloat16
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    device_map="cuda",
    torch_dtype=dtype,
)

chat = [
    { "role": "user", "content": "Explain what is AI in 3 bullet points" },
]
prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)

inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
outputs = model.generate(input_ids=inputs.to(model.device),
                         max_new_tokens=150)
print(tokenizer.decode(outputs[0]))

Gives the following error now:

RecurrentGemmaForCausalLM.forward() got an unexpected keyword argument 'position_ids'

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

Already mentioned above.

Expected behavior

The prompt should run without errors just like in version 4.42

@dipanjanS dipanjanS added the bug label Aug 8, 2024
@ArthurZucker
Copy link
Collaborator

ArthurZucker commented Aug 9, 2024

Opening a PR for a fix!

@ArthurZucker
Copy link
Collaborator

It was broken by #31549 😅

@dipanjanS
Copy link
Author

Thanks for the prompt fix, much appreciated!

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

Successfully merging a pull request may close this issue.

2 participants