{
  "id": "llm/huggingface-model-load-cache-corruption",
  "signature": "OSError: Unable to load weights from huggingface checkpoint. Error: file is corrupted or truncated",
  "signature_zh": "OSError：无法从 Hugging Face 检查点加载权重。错误：文件已损坏或截断",
  "regex": "Unable to load weights from huggingface checkpoint.*file is corrupted or truncated",
  "domain": "llm",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "Partial download or disk corruption of Hugging Face model cache files, often due to interrupted downloads or concurrent write access to the cache directory.",
  "root_cause_type": "generic",
  "root_cause_zh": "Hugging Face 模型缓存文件的部分下载或磁盘损坏，通常是由于下载中断或对缓存目录的并发写入访问导致。",
  "versions": [
    {
      "version": "transformers==4.41.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "huggingface_hub==0.23.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "torch==2.3.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The corrupted file remains in the cache; the loader will attempt to read the same broken file and fail again.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The error is about file integrity, not capacity; more space won't fix a truncated file.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This changes the model entirely and doesn't address the cache corruption for the original model.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Clear the specific model cache and re-download: `rm -rf ~/.cache/huggingface/hub/models--bert-base-uncased` then reload the model.",
      "success_rate": 0.95,
      "how": "Clear the specific model cache and re-download: `rm -rf ~/.cache/huggingface/hub/models--bert-base-uncased` then reload the model.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `snapshot_download` with `resume_download=False` to force a fresh download: `from huggingface_hub import snapshot_download; snapshot_download('bert-base-uncased', resume_download=False)`",
      "success_rate": 0.9,
      "how": "Use `snapshot_download` with `resume_download=False` to force a fresh download: `from huggingface_hub import snapshot_download; snapshot_download('bert-base-uncased', resume_download=False)`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Set `HF_HUB_ENABLE_HF_TRANSFER=1` to use the faster download library which includes integrity checks by default.",
      "success_rate": 0.85,
      "how": "Set `HF_HUB_ENABLE_HF_TRANSFER=1` to use the faster download library which includes integrity checks by default.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Clear the specific model cache and re-download: `rm -rf ~/.cache/huggingface/hub/models--bert-base-uncased` then reload the model.",
    "Use `snapshot_download` with `resume_download=False` to force a fresh download: `from huggingface_hub import snapshot_download; snapshot_download('bert-base-uncased', resume_download=False)`",
    "Set `HF_HUB_ENABLE_HF_TRANSFER=1` to use the faster download library which includes integrity checks by default."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://huggingface.co/docs/huggingface_hub/en/guides/download#corrupted-files",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-09-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}