How Can I use cashed models from HuggingFace? 
Author: khabibulloevm
Pull request: no

I want to use models from: [https://huggingface.co/ARTeLab/mbart-summarization-mlsum](https://stackoverflow.com/) in offline mode, meaning that after downloading them from Hugging Face, they will be saved locally and I will be able to use them offline. However, I don't know how to do this. If anyone has already figured this out, please advise me. I use these lines to download models:

```
from transformers import MBartTokenizer, MBartForConditionalGeneration
tokenizer = MBartTokenizer.from_pretrained("ARTeLab/mbart-summarization-mlsum")
model = MBartForConditionalGeneration.from_pretrained("ARTeLab/mbart-summarization-mlsum")
```

The problem is that when I run this line, I download several files from the repository at once, and I don’t know which one is then used for tokenization:

![image](https://github.com/huggingface/transformers/assets/86304910/82a8ab68-e7b1-46a8-ad26-01ce0fbdc56f)







Comments:
Hi @khabibulloevm, thanks for opening an issues, 

This is a question best placed in our [forums](https://discuss.huggingface.co/). We try to reserve the github issues for feature requests and bug reports.

That being said, all of these files are used to construct a tokenizer which will perform tokenization.

Hello, @amyeroberts I apologize for opening the problem in the wrong place. Could you tell me where I can find information about how these files are used? That is, I want to see how these files are accessed, I will be very grateful for your answer!

You can inspect the tokenization files to see how they're used: 
* Model-specific tokenizer: https://github.com/huggingface/transformers/blob/c5037b459e117b9286c611092f38663f6cb763b0/src/transformers/models/bert/tokenization_bert.py#L4
* `from_pretrained` method: https://github.com/huggingface/transformers/blob/c5037b459e117b9286c611092f38663f6cb763b0/src/transformers/tokenization_utils_base.py#L1799

for that you will need:
1. call `x.save_pretrained(output_dirrectory)` for each x where x is tokenizer, model and feature_extractor(for some models there may be no featrue extractor, in that case ignore it) to the same output directory.
2. then you can use `x.from_pretrained` to read the model, tokenizer and feature extractor from saved directories.

For example, download your model and save:

```python

from transformers import WhisperForConditionalGeneration, WhisperFeatureExtractor, WhisperTokenizer
# this will download weights and configs from hf
model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-small")
tokenizer = WhisperTokenizer.from_pretrained("openai/whisper-small")
feature_extractor = WhisperFeatureExtractor.from_pretrained("openai/whisper-small")

output_dir = './my_awesome_model'
os.makedirs(output_dir, exists_ok=True)
model.save_pretrained(output_dir)
tokenizer.save_pretrained(output_dir)
feature_extractor.save_pretrained(output_dir)
```

Then read your model, but supply output_dir to read it from file system (without internet):
```python

from transformers import (
    WhisperForConditionalGeneration,
    WhisperFeatureExtractor,
    WhisperTokenizer,
)

model = WhisperForConditionalGeneration.from_pretrained("./my_awesome_model")
tokenizer = WhisperTokenizer.from_pretrained("./my_awesome_model")
feature_extractor = WhisperFeatureExtractor.from_pretrained("./my_awesome_model")
```

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.