{"record":{"id":"d059e22f4c059ce5","repo":"zylon-ai/private-gpt","slug":"local-model-files-not-found-at-model-id-ensur","errorCode":null,"errorMessage":"Local model files not found at '{model_id}'. Ensure the model is downloaded locally.","messagePattern":"Local model files not found at '(.+?)'\\. Ensure the model is downloaded locally\\.","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/llm/tokenizers/huggingface.py","lineNumber":100,"sourceCode":"                force_download=force_download,\n                trust_remote_code=trust_remote_code,\n                **kwargs,\n            )\n\n            # Extract tokenizer from multimodal processor if needed\n            tokenizer: PreTrainedTokenizerBase\n            if hasattr(loaded, \"tokenizer\"):\n                processor = cast(ProcessorMixin, loaded)\n                tokenizer = cast(PreTrainedTokenizerBase, loaded.tokenizer)\n                is_multimodal = True\n            else:\n                tokenizer = cast(PreTrainedTokenizerBase, loaded)\n\n            return cls(tokenizer, is_multimodal=is_multimodal, processor=processor)\n\n        except OSError as e:\n            if local_files_only:\n                raise FileNotFoundError(\n                    f\"Local model files not found at '{model_id}'. \"\n                    f\"Ensure the model is downloaded locally.\"\n                ) from e\n            raise ValueError(f\"Could not load tokenizer from '{model_id}': {e}\") from e\n        except Exception as e:\n            raise ValueError(f\"Failed to load tokenizer: {e}\") from e\n\n    @classmethod\n    def is_available(cls, model_id: str | Path | None, **kwargs: Any) -> bool:\n        return bool(model_id)\n\n    @property\n    def all_special_tokens(self) -> list[str]:\n        tokens: list[str] = self._tokenizer.all_special_tokens\n        return tokens\n\n    @property\n    def all_special_ids(self) -> list[int]:","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/llm/tokenizers/huggingface.py#L82-L118","documentation":"When loading with local_files_only=True, AutoProcessor.from_pretrained raises OSError if the model files are not in the local cache/directory. The code converts that into FileNotFoundError telling you the model was never downloaded to '{model_id}', so offline mode cannot be honored.","triggerScenarios":"Calling HuggingFaceTokenizer.from_pretrained(model_id, local_files_only=True) when the model id is a Hub name not present in the HF cache, or when a local path is wrong/empty (e.g. a mounted volume not mounted).","commonSituations":"Air-gapped or offline deployments expecting a pre-downloaded model that was never cached in the image; HF_HOME/HF_HUB_CACHE pointing to a different location than where models were downloaded; typos in model paths or volumes.","solutions":["Pre-download the model once with network access: huggingface-cli download <model_id> (into the cache the app uses), then keep local_files_only=True.","Verify the cache dir: ensure HF_HOME/HF_HUB_CACHE matches where models were stored, and that the path in the error actually contains config/tokenizer files.","If network is available, drop local_files_only=True to allow the download."],"exampleFix":"# before\ntok = HuggingFaceTokenizer.from_pretrained('mistralai/Mistral-7B-Instruct-v0.3', local_files_only=True)  # not cached\n\n# after\n# shell: huggingface-cli download mistralai/Mistral-7B-Instruct-v0.3\ntok = HuggingFaceTokenizer.from_pretrained('mistralai/Mistral-7B-Instruct-v0.3', local_files_only=True)","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef model_cached_locally(model_id: str, cache_dir: Path | None = None) -> bool:\n    if Path(model_id).exists():\n        return bool(list(Path(model_id).glob('tokenizer*')) or Path(model_id, 'config.json').exists())\n    from huggingface_hub import scan_cache_dir\n    return any(e.repo_id == model_id for e in scan_cache_dir(cache_dir).repos)","typeGuard":null,"tryCatchPattern":"try:\n    tok = HuggingFaceTokenizer.from_pretrained(model_id, local_files_only=True)\nexcept FileNotFoundError as e:\n    raise RuntimeError(f'model {model_id} not cached; pre-download before offline run') from e","preventionTips":["Pre-download models during image build and pin HF_HOME to the same directory used at runtime.","Fail fast at startup in offline mode by checking the cache before serving traffic.","Verify mounted volumes exist and are populated before enabling local_files_only."],"tags":["huggingface","offline","cache","tokenizer"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}