Skip to content

Conversation

@joshwhiton
Copy link

Summary

  • Adds local_files_only parameter to FallbackNetwork and G2P
  • Respects TRANSFORMERS_OFFLINE and HF_HUB_OFFLINE env vars
  • Enables fully offline operation when models are pre-cached

Problem

FallbackNetwork.from_pretrained() attempts network access even when TRANSFORMERS_OFFLINE=1 is set, because from_pretrained() does a HEAD request to check for model updates before falling back to cache.

Solution

Check the standard HuggingFace offline environment variables and pass local_files_only=True to from_pretrained() when they're set.

Use case

  • Air-gapped deployments
  • Offline applications
  • Reducing startup latency when network is slow/unavailable

Test

import os
os.environ['TRANSFORMERS_OFFLINE'] = '1'
os.environ['HF_HUB_OFFLINE'] = '1'

from misaki import en
g2p = en.G2P()  # No network calls when model is cached

Notes

  • Backwards compatible: default behavior unchanged when env vars aren't set
  • Can also be set explicitly: G2P(local_files_only=True)

FallbackNetwork.from_pretrained() attempts network access even when
TRANSFORMERS_OFFLINE=1 is set, because from_pretrained() does a HEAD
request before falling back to cache.

This PR:
- Adds local_files_only parameter to FallbackNetwork and G2P
- Respects TRANSFORMERS_OFFLINE and HF_HUB_OFFLINE env vars
- Enables fully offline operation when models are pre-cached

Use case: Air-gapped deployments, offline applications, reducing
startup latency when network is slow/unavailable.
@joshwhiton joshwhiton marked this pull request as ready for review December 30, 2025 14:27
- PR hexgrad#90: Restrict spacy<4 to avoid pre-release/yanked versions
  Fixes Python 3.13 compatibility issues with thinc/blis dependencies

- PR hexgrad#79: Strip whitespace from merged tokens
  Fixes lexicon lookup failures when multiple spaces appear between words
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant