Is there an API to re-download a model?

Let’s say I download a model

transformers.AutoModelForQuestionAnswering.from_pretrained(
"distilbert-base-cased-distilled-squad",
trust_remote_code=True)

That saves it in the cache and it won’t download it again in the future. If I then train it, the model changes, right? I can re-download it from scratch by deleting it from the cache, but is there an API way to do this?

In the future, I’ll download it and then use save_pretrained to save it to a different file and then train the one that I saved outside the cache.

Hi,

You can clean your cache as explained here: Manage huggingface_hub cache-system.

Yes you can also pass force_download=True to the from_pretrained method.

Can I ask you a question? When you said, If I then train it, the model changes, right? what does this mean, sir? If I train the model, the cache of this model will change? Do you have a reference for me to read more?

If I train the model, the cache of this model will change?

Hi @Nevermetyou, no, training the model has no impact on the cached version of the model.

When you download a model, the cached version will be saved in a location specified by the HF_HOME environment variable (you can read more here). By default, that location is ~/.cache/huggingface.

On the other hand, when your training finishes, the trained (modified) version of the model will be saved in a folder specified by the output_dir argument given to the Huggingface trainer (you can see this arg here)

1 Like

Thanks for your clarification.

Ah, thanks!