f"The model '{self.model.__class__.__name__}' is not supported for {self.task}. Supported models are {supported_models}",
Author: loretoparisi
Pull request: no

## Context
I have used the official example for Q&A [here](https://huggingface.co/dbmdz/bert-base-italian-cased), but slightly modified the `Pipeline` to use the `model` and `tokenizer` objects from pretrained model as exaplained [here](https://huggingface.co/transformers/main_classes/pipelines.html#the-pipeline-abstraction). This because I need a `cache_dir` that currently is not supported by `Pipeline` object.

## Environment info
<!-- You can run the command `transformers-cli env` and copy-and-paste its output below.
     Don't forget to fill out the missing fields in that output! -->

- `transformers` version: 4.3.3
- Platform: Linux-4.19.121-linuxkit-x86_64-with-debian-10.1
- Python version: 3.7.4
- PyTorch version (GPU?): 1.7.1 (False)
- Tensorflow version (GPU?): 2.4.1 (False)
- Using GPU in script?: <NO>
- Using distributed or parallel set-up in script?: <NO>

### Who can help

Model:
https://huggingface.co/dbmdz/bert-base-italian-cased
@patrickvonplaten, @patil-suraj

<!-- Your issue will be replied to more quickly if you can figure out the right person to tag with @
 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- albert, bert, xlm: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @jplu


Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

HF projects:

- nlp datasets: [different repo](https://github.com/huggingface/nlp)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh


 -->

## Information

Model I am using (Bert, XLNet ...):

The problem arises when using:
* [] the official example scripts: (give details below)
* [X] my own modified scripts: (give details below)

The tasks I am working on is:
* [X] an official GLUE/SQUaD task: (translation)
* [ ] my own task or dataset: (give details below)

## To reproduce

Steps to reproduce the behavior:

```python
question = 'Quale filosofia seguì Marco Aurelio ?'
context = 'Marco Aurelio era un imperatore romano che praticava lo stoicismo come filosofia di vita .'

tokenizer = AutoTokenizer.from_pretrained(
    'mrm8488/bert-italian-finedtuned-squadv1-it-alfa',
    cache_dir=os.getenv("cache_dir", "model"))
model = AutoModel.from_pretrained(
    'mrm8488/bert-italian-finedtuned-squadv1-it-alfa',
    cache_dir=os.getenv("cache_dir", "model"))

nlp_qa_bert = pipeline(
    'question-answering',
    model=model,
    tokenizer=tokenizer)

out = nlp_qa_bert({
    'question': question,
    'context': context
})
print(out)
````

ERROR:

```
Traceback (most recent call last):
  File "qa/run.py", line 26, in <module>
    tokenizer=tokenizer)
  File "/usr/local/lib/python3.7/site-packages/transformers/pipelines/__init__.py", line 418, in pipeline
    return task_class(model=model, tokenizer=tokenizer, modelcard=modelcard, framework=framework, task=task, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/transformers/pipelines/question_answering.py", line 135, in __init__
    TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING if self.framework == "tf" else MODEL_FOR_QUESTION_ANSWERING_MAPPING
  File "/usr/local/lib/python3.7/site-packages/transformers/pipelines/base.py", line 577, in check_model_type
    f"The model '{self.model.__class__.__name__}' is not supported for {self.task}. Supported models are {supported_models}",
transformers.pipelines.base.PipelineException: The model 'BertModel' is not supported for question-answering. Supported models are ['ConvBertForQuestionAnswering', 'LEDForQuestionAnswering', 'DistilBertForQuestionAnswering', 'AlbertForQuestionAnswering', 'CamembertForQuestionAnswering', 'BartForQuestionAnswering', 'MBartForQuestionAnswering', 'LongformerForQuestionAnswering', 'XLMRobertaForQuestionAnswering', 'RobertaForQuestionAnswering', 'SqueezeBertForQuestionAnswering', 'BertForQuestionAnswering', 'XLNetForQuestionAnsweringSimple', 'FlaubertForQuestionAnsweringSimple', 'MobileBertForQuestionAnswering', 'XLMForQuestionAnsweringSimple', 'ElectraForQuestionAnswering', 'ReformerForQuestionAnswering', 'FunnelForQuestionAnswering', 'LxmertForQuestionAnswering', 'MPNetForQuestionAnswering', 'DebertaForQuestionAnswering', 'DebertaV2ForQuestionAnswering', 'IBertForQuestionAnswering']
```

<!-- If you have code snippets, error messages, stack traces please provide them here as well.
     Important! Use code tags to correctly format your code. See https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks#syntax-highlighting
     Do not use screenshots, as they are hard to read and (more importantly) don't allow others to copy-and-paste your code.-->

## Expected behavior
no error
<!-- A clear and concise description of what you would expect to happen. -->


Comments:
Hi there, 

You should use the `AutoModelForQuestionAnswering` class to load a QA model, the `AutoModel` class just loads the base model and doesn't load the task-specific head, which is the reason for this error.

In general, always use the task-specific auto classes to load task-specific architectures.

@patil-suraj confirmed, it works 

```python
tokenizer = AutoTokenizer.from_pretrained(
    'mrm8488/bert-italian-finedtuned-squadv1-it-alfa',
    cache_dir=os.getenv("cache_dir", "model"))
model = AutoModelForQuestionAnswering.from_pretrained(
    'mrm8488/bert-italian-finedtuned-squadv1-it-alfa',
    cache_dir=os.getenv("cache_dir", "model"))

nlp_qa_bert = pipeline(
    'question-answering',
    model=model,
    tokenizer=tokenizer)
```