huggingface / transformers

🤗 Transformers: State-of-the-art Machine Learning for Pytorch, TensorFlow, and JAX.
https://huggingface.co/transformers
Apache License 2.0
135.47k stars 27.11k forks source link

Offline mode doesn't work with models that require `trust_remote_code=True` #34855

Open VladKha opened 4 days ago

VladKha commented 4 days ago

System Info

Google Colab:

Who can help?

@Rocketknight1

Information

Tasks

Reproduction

Issue

Models that require trust_remote_code=True can't be fully saved & loaded with save_pretrained() + from_pretrained(). In offline mode on a new machine during calling from_pretrained() it doesn't locate all required files in the saved local dir and tries to reach out to hf hub for the remote code part.

How to reproduce

Colab | Kaggle Tested with popular jinaai/jina-embeddings-v3 Includes step by step reproduction + results


Additional context

Expected behavior

Model is fully saved in local dir with save_pretrained() and can be fully loaded from a local path with from_pretrained() in offline mode