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

TypeError: MistralForSequenceClassification.forward() got an unexpected keyword argument 'token_type_ids' #33280

Open
2 of 4 tasks
edchengg opened this issue Sep 3, 2024 · 2 comments
Labels

Comments

@edchengg
Copy link

edchengg commented Sep 3, 2024

System Info

I got this error when I tried to use sentiment classification pipeline with "nvidia/Mistral-NeMo-Minitron-8B-Base". It works fine with llama 3.1.

TypeError: MistralForSequenceClassification.forward() got an unexpected keyword argument 'token_type_ids'

  • transformers 4.43.4

See code below:

Who can help?

@ArthurZucker

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

import torch 
from transformers import AutoModelForSequenceClassification, AutoTokenizer, pipeline 

torch.random.manual_seed(0) 

model_id = "nvidia/Mistral-NeMo-Minitron-8B-Base" # not working
# model_id = "meta-llama/Meta-Llama-3.1-8B-Instruct" # working
model = AutoModelForSequenceClassification.from_pretrained( 
    model_id,  
    device_map="auto",  
    torch_dtype=torch.bfloat16 
) 

tokenizer = AutoTokenizer.from_pretrained(model_id) 



pipe = pipeline( 
    "sentiment-analysis", 
    model=model, 
    tokenizer=tokenizer, 
) 


output = pipe("hello how are you today?")
print(output)
# TypeError: MistralForSequenceClassification.forward() got an unexpected keyword argument 'token_type_ids'

Expected behavior

expected to be able to run the code

@edchengg edchengg added the bug label Sep 3, 2024
@LysandreJik
Copy link
Member

Thanks for your PR @edchengg! Does it work with the default 7b mistral model on your side? So for example with this checkpoint: mistralai/Mistral-7B-Instruct-v0.1

@ArthurZucker
Copy link
Collaborator

(You either need to delete the token_type_ids, or update tokenizer.model_input_names 🤗

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

3 participants