{
  "id": "llm/embedding-dimension-mismatch-in-vector-search",
  "signature": "ValueError: Query vector dimension (384) does not match index dimension (768)",
  "signature_zh": "ValueError：查询向量维度（384）与索引维度（768）不匹配",
  "regex": "dimension.*does not match|vector dimension mismatch|embedding size mismatch",
  "domain": "llm",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Embedding model used for query encoding has a different output dimension than the model used to build the vector index, often due to switching between models (e.g., from text-embedding-ada-002 to a smaller model).",
  "root_cause_type": "generic",
  "root_cause_zh": "用于查询编码的嵌入模型与用于构建向量索引的模型输出维度不同，通常是由于模型切换（例如，从text-embedding-ada-002切换到较小的模型）。",
  "versions": [
    {
      "version": "openai==1.10.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "pinecone-client==3.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "chromadb==0.4.22",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "text-embedding-ada-002",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "all-MiniLM-L6-v2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "sentence-transformers==2.2.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Resizing the query vector by padding with zeros or truncating corrupts the embedding and leads to poor search results.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Re-indexing all documents with the new model is correct but often skipped due to time constraints; partial re-indexing causes inconsistency.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Assuming the vector database automatically handles dimension conversion leads to silent failures or errors.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Re-embed all documents using the same embedding model as the query. For example, if using text-embedding-ada-002 (1536 dimensions), ensure both index and query use that model.",
      "success_rate": 0.95,
      "how": "Re-embed all documents using the same embedding model as the query. For example, if using text-embedding-ada-002 (1536 dimensions), ensure both index and query use that model.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a dimension-agnostic vector database (e.g., ChromaDB with auto-detection) that can handle different dimensions by storing metadata and filtering at query time.",
      "success_rate": 0.8,
      "how": "Use a dimension-agnostic vector database (e.g., ChromaDB with auto-detection) that can handle different dimensions by storing metadata and filtering at query time.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用与查询相同的嵌入模型重新嵌入所有文档。例如，如果使用text-embedding-ada-002（1536维度），确保索引和查询都使用该模型。",
    "使用维度无关的向量数据库（例如，带有自动检测功能的ChromaDB），通过存储元数据并在查询时过滤来处理不同维度。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://platform.openai.com/docs/guides/embeddings",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-11-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}