{
  "id": "huggingface/transformers-cache-corruption",
  "signature": "OSError: Unable to load model from cache: file hash mismatch for 'pytorch_model.bin'. Expected sha256: abc123... but got xyz789...",
  "signature_zh": "OSError：无法从缓存加载模型：'pytorch_model.bin' 文件哈希不匹配。期望 sha256：abc123... 但得到 xyz789...",
  "regex": "OSError: Unable to load model from cache: file hash mismatch for '.*'",
  "domain": "huggingface",
  "category": "system_error",
  "subcategory": null,
  "root_cause": "The cached model file is corrupted (e.g., due to incomplete download, disk errors, or concurrent write) causing a SHA-256 hash mismatch during integrity verification.",
  "root_cause_type": "generic",
  "root_cause_zh": "缓存的模型文件损坏（例如由于下载不完整、磁盘错误或并发写入），导致完整性验证期间 SHA-256 哈希不匹配。",
  "versions": [
    {
      "version": "transformers>=4.20.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "huggingface_hub>=0.12.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Delete only the specific corrupted file and re-run the script",
      "why_fails": "The cache may still contain partial or corrupted metadata; the download might resume from a broken state.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "Set `torch.hub.set_dir()` to a different directory and reload",
      "why_fails": "This changes the download location but does not fix the corruption in the original cache; the error persists if the same cache is used.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "Ignore the hash check by setting `local_files_only=False`",
      "why_fails": "This forces a re-download but does not delete the corrupted file; the download may fail again or use the same broken file.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Clear the entire cache directory: rm -rf ~/.cache/huggingface/hub/; then reload the model with from_pretrained(). This forces a fresh download.",
      "success_rate": 0.95,
      "how": "Clear the entire cache directory: rm -rf ~/.cache/huggingface/hub/; then reload the model with from_pretrained(). This forces a fresh download.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use huggingface-cli to clear cache selectively: huggingface-cli delete-cache; or set HF_HUB_ENABLE_HF_TRANSFER=1 to use a robust downloader.",
      "success_rate": 0.9,
      "how": "Use huggingface-cli to clear cache selectively: huggingface-cli delete-cache; or set HF_HUB_ENABLE_HF_TRANSFER=1 to use a robust downloader.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "清除整个缓存目录：rm -rf ~/.cache/huggingface/hub/；然后使用 from_pretrained() 重新加载模型。这会强制重新下载。",
    "使用 huggingface-cli 选择性清除缓存：huggingface-cli delete-cache；或设置 HF_HUB_ENABLE_HF_TRANSFER=1 以使用稳健的下载器。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://huggingface.co/docs/huggingface_hub/en/guides/manage-cache",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-08-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}