HuggingFace Model Hub (summarisation) - models not working locally (404 not found)
Author: teodortita2
Pull request: no

## Environment info

- `transformers` version: 4.10.0
- Platform: Linux-5.11.0-36-generic-x86_64-with-glibc2.29
- Python version: 3.8.10
- PyTorch version (GPU?): not installed (NA)
- Tensorflow version (GPU?): 2.6.0 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: No

 -->

## Information

I am using a text summarisation model from HuggingFace Model Hub. However, this issue occurs regardless of what model I use.

The problem arises when using any text summarisation model from HuggingFace Model Hub locally.

The tasks I am working on is dialogue summarisation.

## To reproduce

Steps to reproduce the behavior:

1. Run this code locally with the environment I specified in the beginning:
```
from transformers import pipeline
summarizer = pipeline("summarization", model="lidiya/bart-large-xsum-samsum")
conversation = '''Jeff: Can I train a 🤗 Transformers model on Amazon SageMaker? 
Philipp: Sure you can use the new Hugging Face Deep Learning Container. 
Jeff: ok.
Jeff: and how can I get started? 
Jeff: where can I find documentation? 
Philipp: ok, ok you can find everything here. https://huggingface.co/blog/the-partnership-amazon-sagemaker-and-hugging-face                                   '''
print(summarizer(conversation))
```
2. Output is:
```
2021-09-28 14:20:06.034022: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2021-09-28 14:20:06.034044: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
404 Client Error: Not Found for url: https://huggingface.co/lidiya/bart-large-xsum-samsum/resolve/main/tf_model.h5
404 Client Error: Not Found for url: https://huggingface.co/lidiya/bart-large-xsum-samsum/resolve/main/tf_model.h5
Traceback (most recent call last):
  File "test.py", line 2, in <module>
    summarizer = pipeline("summarization", model="lidiya/bart-large-xsum-samsum")
  File "/home/teodor/Desktop/test/env/lib/python3.8/site-packages/transformers/pipelines/__init__.py", line 429, in pipeline
    framework, model = infer_framework_load_model(
  File "/home/teodor/Desktop/test/env/lib/python3.8/site-packages/transformers/pipelines/base.py", line 145, in infer_framework_load_model
    raise ValueError(f"Could not load model {model} with any of the following classes: {class_tuple}.")
ValueError: Could not load model lidiya/bart-large-xsum-samsum with any of the following classes: (<class 'transformers.models.auto.modeling_tf_auto.TFAutoModelForSeq2SeqLM'>, <class 'transformers.models.bart.modeling_tf_bart.TFBartForConditionalGeneration'>).
```

## Expected behavior

On Google Colab and on HugginFace website a string is outputted containing the summary of the inputted text:
"Jeff wants to train a Transformers model on Amazon SageMaker. He can use the new Hugging Face Deep Learning Container. The documentation is available on HuggingFace.co and on the blog, Jeff can find it here. . . Jeff can train a model on Huging Face.co."

Why is it not working locally? Any help would be much appreciated. I've been trying to solve this problem for the past few days but I couldn't find a working solution so far. Thank you!

Comments:
It seems that pytorch is not installed, you should install pytorch to be able to use this model.

@patil-suraj True, but I have TensorFlow 2.6 installed and this works as an equivalent. If I had neither TensorFlow not PyTorch installed, in the terminal it said: "install either Tensorflow or PyTorch". So the problem is somewhere else. Did you replicate my code and it worked for you with PyTorch?

there is no TF checkpoint for `lidiya/bart-large-xsum-samsum`, so we should pass `from_pt=True` to `pipeline` so it'll convert the PT checkpoint to PyTorch. But that conversion also requires Pytorch to be able to read the `state_dict`, so you should install torch.

@patil-suraj Makes sense, I will try that right now

@patil-suraj "from_pt" is an unexpected keyword argument when passed to "pipeline". Am I doing something wrong?

aah, sorry. It should be passed as 

```python
pipeline("...", model_kwargs={"from_pt": True})
```

This is only required if you want to use tensorflow, if you have pytroch installed it should just work.

@patil-suraj you helped me find the solution. The only thing that worked for me is:

```
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM

conversation = '''Jeff: Can I train a 🤗 Transformers model on Amazon SageMaker? 
Philipp: Sure you can use the new Hugging Face Deep Learning Container. 
Jeff: ok.
Jeff: and how can I get started? 
Jeff: where can I find documentation? 
Philipp: ok, ok you can find everything here. https://huggingface.co/blog/the-partnership-amazon-sagemaker-and-hugging-face                                           
'''

tokenizer = AutoTokenizer.from_pretrained("lidiya/bart-large-xsum-samsum")

model = AutoModelForSeq2SeqLM.from_pretrained("lidiya/bart-large-xsum-samsum")

summarizer = pipeline("summarization", model=model, tokenizer=tokenizer)

print(summarizer(conversation))
```

Thank you a lot for your patience. Hope many people see this.