Where does AutoModelForSeq2SeqLM.from_pretrained() store the model to disk?

Question:

I attempted the following on a Windows device:

from transformers import AutoModelForSeq2SeqLM, AutoTokenizer

model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small")
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small")

It worked, but when I tried to download a larger version of the model:

model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-XL")

I ran out of disk space: OSError: [Errno 28] No space left on device

However, it did not appear to delete what it had downloaded, and I can’t seem to locate the model files on the disk. Where does it store?

Asked By: b_g

||

Answers:

In most cases the loaded models are saved in the transformers cache directory.

On Windows, the default directory is given by C:Usersusername. cachehuggingfacetransformers.

You can specify the cache directory everytime you load a model by the setting the parameter cache_dir

For python

import os
os.environ['TRANSFORMERS_CACHE'] = '/path/cache/'
Answered By: Bhavyajeet