{
  "id": "huggingface/peft-lora-target-modules-mismatch",
  "signature": "ValueError: Target modules ['q_proj', 'v_proj'] not found in the base model. Available modules are: ['query', 'value', 'key', 'output']",
  "signature_zh": "ValueError: 目标模块 ['q_proj', 'v_proj'] 在基础模型中未找到。可用模块为: ['query', 'value', 'key', 'output']",
  "regex": "Target modules.*not found in the base model.*Available modules are",
  "domain": "huggingface",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "LoRA target_modules specified with incorrect module names that do not match the base model's actual layer naming convention.",
  "root_cause_type": "generic",
  "root_cause_zh": "LoRA 的 target_modules 参数指定了错误的模块名称，与基础模型实际的层命名约定不匹配。",
  "versions": [
    {
      "version": "peft>=0.4.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "transformers>=4.30.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "torch>=1.13.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The model may not have those exact names; e.g., LLaMA uses 'self_attn.q_proj' while GPT-2 uses 'attn.c_attn'. This can still fail if names are wrong.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Includes non-linear layers (e.g., activation functions) which are invalid for LoRA and cause shape errors during forward pass.",
      "fail_rate": 0.3,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "'all-linear' was introduced in peft>=0.7.0; older versions raise AttributeError or silently ignore it.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Print the model's module names to identify correct target modules: `for name, _ in model.named_modules(): print(name)` then select only linear layers (e.g., 'q_proj', 'v_proj' for LLaMA, 'query', 'value' for BERT).",
      "success_rate": 0.9,
      "how": "Print the model's module names to identify correct target modules: `for name, _ in model.named_modules(): print(name)` then select only linear layers (e.g., 'q_proj', 'v_proj' for LLaMA, 'query', 'value' for BERT).",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use peft.get_peft_model() with target_modules='all-linear' if using peft>=0.7.0 and the model is transformer-based, which automatically selects all linear layers except the output projection.",
      "success_rate": 0.85,
      "how": "Use peft.get_peft_model() with target_modules='all-linear' if using peft>=0.7.0 and the model is transformer-based, which automatically selects all linear layers except the output projection.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Check the model configuration via model.config.model_type and refer to the PEFT documentation for the correct module names for that architecture.",
      "success_rate": 0.8,
      "how": "Check the model configuration via model.config.model_type and refer to the PEFT documentation for the correct module names for that architecture.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Print the model's module names to identify correct target modules: `for name, _ in model.named_modules(): print(name)` then select only linear layers (e.g., 'q_proj', 'v_proj' for LLaMA, 'query', 'value' for BERT).",
    "Use peft.get_peft_model() with target_modules='all-linear' if using peft>=0.7.0 and the model is transformer-based, which automatically selects all linear layers except the output projection.",
    "Check the model configuration via model.config.model_type and refer to the PEFT documentation for the correct module names for that architecture."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://huggingface.co/docs/peft/en/developer_guides/lora#target-modules",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-06-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}