{
  "id": "huggingface/lora-target-modules-mismatch",
  "signature": "ValueError: Target modules ['q_proj', 'v_proj'] not found in the base model. Available modules: ['query', 'value', 'key', 'output']",
  "signature_zh": "ValueError：在基础模型中未找到目标模块['q_proj', 'v_proj']。可用模块：['query', 'value', 'key', 'output']",
  "regex": "ValueError: Target modules \\[.*?\\] not found in the base model. Available modules: \\[.*?\\]",
  "domain": "huggingface",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The LoRA configuration specifies target module names that do not match the actual naming convention of the base model's linear layers, often due to model architecture differences (e.g., LLaMA vs GPT-2).",
  "root_cause_type": "generic",
  "root_cause_zh": "LoRA配置指定的目标模块名称与基础模型线性层的实际命名约定不匹配，通常是由于模型架构差异（例如LLaMA vs GPT-2）。",
  "versions": [
    {
      "version": "peft>=0.7.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "transformers>=4.35.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Guessing module names based on other models (e.g., using 'q_proj' for a model that uses 'query')",
      "why_fails": "Module names are model-specific; guessing leads to repeated mismatches. Must inspect the model's actual layer names.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting target_modules to 'all-linear' without checking compatibility",
      "why_fails": "While 'all-linear' often works, it may include modules that are not suitable for LoRA (e.g., output projection in some architectures), causing training instability or poor performance.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Print the model's module names to find correct targets: for name, module in model.named_modules(): if 'linear' in str(type(module)).lower(): print(name). Then set target_modules to the discovered names.",
      "success_rate": 0.95,
      "how": "Print the model's module names to find correct targets: for name, module in model.named_modules(): if 'linear' in str(type(module)).lower(): print(name). Then set target_modules to the discovered names.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use 'all-linear' as target_modules if supported by PEFT version, but verify with a small test run first.",
      "success_rate": 0.8,
      "how": "Use 'all-linear' as target_modules if supported by PEFT version, but verify with a small test run first.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Print the model's module names to find correct targets: for name, module in model.named_modules(): if 'linear' in str(type(module)).lower(): print(name). Then set target_modules to the discovered names.",
    "Use 'all-linear' as target_modules if supported by PEFT version, but verify with a small test run first."
  ],
  "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.9,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-02-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}