{
  "id": "llm/huggingface-model-not-found",
  "signature": "OSError: Can't load the model 'meta-llama/Llama-2-7b-chat-hf'. If you were trying to load it from 'https://huggingface.co/models', make sure you have access to the model and are logged in.",
  "signature_zh": "OSError: 无法加载模型'meta-llama/Llama-2-7b-chat-hf'。如果您正尝试从'https://huggingface.co/models'加载它，请确保您有访问该模型的权限并已登录。",
  "regex": "OSError: Can't load the model.*If you were trying to load it from.*huggingface\\.co",
  "domain": "llm",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "The model is gated or requires authentication, and the user is not logged in to Hugging Face Hub, or the access token is missing or invalid.",
  "root_cause_type": "generic",
  "root_cause_zh": "模型是受限的或需要认证，用户未登录Hugging Face Hub，或访问令牌缺失或无效。",
  "versions": [
    {
      "version": "transformers>=4.30.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "huggingface-hub>=0.16.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Even local loading may require token verification for gated models; the license must be accepted first.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The token must have explicit permission for the model; a generic token without granted access fails.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Log in to Hugging Face Hub using a valid access token:\nfrom huggingface_hub import login\nlogin(token='hf_your_token_here')\n\n# Then load the model\nfrom transformers import AutoModelForCausalLM\nmodel = AutoModelForCausalLM.from_pretrained('meta-llama/Llama-2-7b-chat-hf')",
      "success_rate": 0.95,
      "how": "Log in to Hugging Face Hub using a valid access token:\nfrom huggingface_hub import login\nlogin(token='hf_your_token_here')\n\n# Then load the model\nfrom transformers import AutoModelForCausalLM\nmodel = AutoModelForCausalLM.from_pretrained('meta-llama/Llama-2-7b-chat-hf')",
      "condition": "",
      "sources": []
    },
    {
      "action": "Set the token as an environment variable before running the script:\nexport HUGGINGFACE_TOKEN='hf_your_token_here'\n# In Python\nimport os\nfrom huggingface_hub import login\nlogin(token=os.getenv('HUGGINGFACE_TOKEN'))",
      "success_rate": 0.9,
      "how": "Set the token as an environment variable before running the script:\nexport HUGGINGFACE_TOKEN='hf_your_token_here'\n# In Python\nimport os\nfrom huggingface_hub import login\nlogin(token=os.getenv('HUGGINGFACE_TOKEN'))",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用有效的访问令牌登录Hugging Face Hub：\nfrom huggingface_hub import login\nlogin(token='hf_your_token_here')\n\n# 然后加载模型\nfrom transformers import AutoModelForCausalLM\nmodel = AutoModelForCausalLM.from_pretrained('meta-llama/Llama-2-7b-chat-hf')",
    "在运行脚本前将令牌设置为环境变量：\nexport HUGGINGFACE_TOKEN='hf_your_token_here'\n# 在Python中\nimport os\nfrom huggingface_hub import login\nlogin(token=os.getenv('HUGGINGFACE_TOKEN'))"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://huggingface.co/docs/hub/en/security-gated-models",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-07-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}