Error in pipeline() when model left as None
Author: leungi
Pull request: no
Labels: name: wontfix

name: Core: Pipeline

## 🐛 Bug

<!-- Important information -->

Model I am using (Bert, XLNet....): Default models as per `SUPPORTED_TASKS` config in [pipeline.py](https://github.com/huggingface/transformers/blob/master/src/transformers/pipelines.py)

Language I am using the model on (English, Chinese....): English

The problem arise when using:
* [x] the official example scripts: (`pipeline.py`)
* [ ] my own modified scripts: (give details)

The tasks I am working on is:
* [x] an official GLUE/SQUaD task: (`question-answering`, `ner`, `feature-extraction`, `sentiment-analysis`)
* [ ] my own task or dataset: (give details)

## To Reproduce

Steps to reproduce the behavior:

1. Install `transformers` 2.3.0
2. Run [example](https://github.com/huggingface/transformers#quick-tour-of-pipelines)

<!-- If you have a code sample, error messages, stack traces, please provide it here as well. -->

```py
from transformers import pipeline
>>> nlp = pipeline('question-answering')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Continuum\anaconda3\envs\transformers\lib\site-packages\transformers\pipelines.py", line 860, in pipeline
    model = models[framework]
TypeError: string indices must be integers
>>> nlp = pipeline('question-answering', model='distilbert-base-uncased-distilled-squad', tokenizer='distilbert-base-uncased')
```

## Expected behavior

Leaving `model`/`tokenizer` args to `None` should not yield error.

<!-- A clear and concise description of what you expected to happen. -->

## Environment

* OS: system='Windows', release='10', version='10.0.17134', machine='AMD64'
* Python version: 3.5.5
* PyTorch version: 1.3.1
* PyTorch Transformers version (or branch): 2.3.0
* Using GPU ? No
* Distributed of parallel setup ? No
* Any other relevant information:

## Additional context

<!-- Add any other context about the problem here. -->


Comments:
Upgraded to Python 3.6.7, and two of _tasks_ (sentiment-analysis and question-answering) works as expected (i.e., no error without specifying `model` args).

The remaining two _tasks_ (ner and feature-extraction) fail on a new (similar) error:

#### feature-extraction
```py
>>> from transformers import pipeline
To use data.metrics please install scikit-learn. See https://scikit-learn.org/stable/index.html
>>> nlp = pipeline('feature-extraction')
Traceback (most recent call last):
  File "D:\Continuum\anaconda3\envs\transformers-py36\lib\site-packages\transformers\modeling_utils.py", line 415, in from_pretrained
    state_dict = torch.load(resolved_archive_file, map_location='cpu')
  File "D:\Continuum\anaconda3\envs\transformers-py36\lib\site-packages\torch\serialization.py", line 426, in load
    return _load(f, map_location, pickle_module, **pickle_load_args)
  File "D:\Continuum\anaconda3\envs\transformers-py36\lib\site-packages\torch\serialization.py", line 620, in _load
    deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
RuntimeError: unexpected EOF, expected 9211648 more bytes. The file might be corrupted.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Continuum\anaconda3\envs\transformers-py36\lib\site-packages\transformers\pipelines.py", line 905, in pipeline
    model = model_class.from_pretrained(model, config=config, **model_kwargs)
  File "D:\Continuum\anaconda3\envs\transformers-py36\lib\site-packages\transformers\modeling_auto.py", line 238, in from_pretrained
    return DistilBertModel.from_pretrained(pretrained_model_name_or_path, *model_args, **kwargs)
  File "D:\Continuum\anaconda3\envs\transformers-py36\lib\site-packages\transformers\modeling_utils.py", line 417, in from_pretrained
    raise OSError("Unable to load weights from pytorch checkpoint file. "
OSError: Unable to load weights from pytorch checkpoint file. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
```

#### ner
```py
>>> from transformers import pipeline
To use data.metrics please install scikit-learn. See https://scikit-learn.org/stable/index.html
>>> nlp = pipeline('ner')
Traceback (most recent call last):
  File "D:\Continuum\anaconda3\envs\transformers-py36\lib\site-packages\transformers\modeling_utils.py", line 415, in from_pretrained
    state_dict = torch.load(resolved_archive_file, map_location='cpu')
  File "D:\Continuum\anaconda3\envs\transformers-py36\lib\site-packages\torch\serialization.py", line 426, in load
    return _load(f, map_location, pickle_module, **pickle_load_args)
  File "D:\Continuum\anaconda3\envs\transformers-py36\lib\site-packages\torch\serialization.py", line 620, in _load
    deserialized_objects[key]._set_from_file(f, offset, f_should_read_directly)
RuntimeError: unexpected EOF, expected 3733591 more bytes. The file might be corrupted.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Continuum\anaconda3\envs\transformers-py36\lib\site-packages\transformers\pipelines.py", line 905, in pipeline
    model = model_class.from_pretrained(model, config=config, **model_kwargs)
  File "D:\Continuum\anaconda3\envs\transformers-py36\lib\site-packages\transformers\modeling_auto.py", line 882, in from_pretrained
    return BertForTokenClassification.from_pretrained(pretrained_model_name_or_path, *model_args, **kwargs)
  File "D:\Continuum\anaconda3\envs\transformers-py36\lib\site-packages\transformers\modeling_utils.py", line 417, in from_pretrained
    raise OSError("Unable to load weights from pytorch checkpoint file. "
OSError: Unable to load weights from pytorch checkpoint file. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
```

#### Troubleshooting attempts
1. Tried specifying `model` args, but Python crashes every time.
2. Tried adding `force_download=True`, but same error as above

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.


To close the loop.

Using `transformers-2.5.1` solves the issue.

Thanks!