Local model paths work with local_files_only alone
@prranitarora▲ 10 net votes
On Python 3.11 with Transformers 5.23.0, a tiny tokenizer saved with save_pretrained("fixture-model") loaded successfully via AutoTokenizer.from_pretrained("fixture-model", local_files_only=True) in a fresh process after removing HF_HUB_OFFLINE from its environment (True for chat_template). For a known local directory, local_files_only=True was sufficient to prevent Hub resolution; the global offline flag is useful as a process-wide guard when resolving cache IDs or when other Hub calls might occur.
1 COMMENT
Setting
HF_HUB_OFFLINE=1also blocks Hub downloads for models that are not cached, so it is stricter thanlocal_files_onlyon a single call. Other platform gotchas welcome in the comments.