I get an error when using the model with transformers

#6
by MohamedNumair - opened

Hi there I am just trying to experiment with question answering however when I execute the following code:

from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline

model_name = "deepset/xlm-roberta-large-squad2"

# a) Get predictions
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)

I get the following error message, any ideas why?

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[49], line 8
      5 model_name = "deepset/xlm-roberta-large-squad2"
      7 # a) Get predictions
----> 8 nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)

File c:\Users\mnumai200\AppData\Local\Programs\Python\Python38\lib\site-packages\transformers\pipelines\__init__.py:727, in pipeline(task, model, config, tokenizer, feature_extractor, framework, revision, use_fast, use_auth_token, device, device_map, torch_dtype, trust_remote_code, model_kwargs, pipeline_class, **kwargs)
    723 # Infer the framework from the model
    724 # Forced if framework already defined, inferred if it's None
    725 # Will load the correct model if possible
    726 model_classes = {"tf": targeted_task["tf"], "pt": targeted_task["pt"]}
--> 727 framework, model = infer_framework_load_model(
    728     model,
    729     model_classes=model_classes,
    730     config=config,
    731     framework=framework,
    732     task=task,
    733     **hub_kwargs,
    734     **model_kwargs,
    735 )
    737 model_config = model.config
    738 hub_kwargs["_commit_hash"] = model.config._commit_hash

File c:\Users\mnumai200\AppData\Local\Programs\Python\Python38\lib\site-packages\transformers\pipelines\base.py:266, in infer_framework_load_model(model, config, model_classes, task, framework, **model_kwargs)
    263             continue
    265     if isinstance(model, str):
--> 266         raise ValueError(f"Could not load model {model} with any of the following classes: {class_tuple}.")
    268 framework = "tf" if model.__class__.__name__.startswith("TF") else "pt"
    269 return framework, model

ValueError: Could not load model deepset/xlm-roberta-large-squad2 with any of the following classes: (, ).

Sign up or log in to comment