技能 embedding-strategies
📦
embedding-strategies
低風險
優化語義搜尋的嵌入模型
選擇正確的嵌入模型和分塊策略對檢索品質至關重要。此技能提供模板和最佳實踐,用於實現高品質的向量搜尋管道。
支援: Claude Codex Code(CC)
1
下載技能 ZIP
2
在 Claude 中上傳
前往 設定 → 功能 → 技能 → 上傳技能
3
開啟並開始使用
測試它
正在使用「embedding-strategies」。 為法律文件搜尋系統推薦嵌入模型。我需要高準確度並且可以使用 API 服務。
預期結果:
- 推薦:text-embedding-3-large(3072 維)或 voyage-2(1024 維)
- text-embedding-3-large:最佳準確度,處理 8191 個 token,非常適合長法律條款
- voyage-2:專門用於法律/程式碼,1024 維,4000 個 token 限制
- 考慮按章節標題分塊法律文件以保留條款上下文
正在使用「embedding-strategies」。 我應該如何為 RAG 系統分塊技術文件?
預期結果:
- 策略:使用按標題的語義分塊結合遞迴字元分割
- 建議的分塊大小:512 個 token,50 個 token 重疊
- 將程式碼範例保留為完整分塊
- 新增將分塊連結到原始章節的上下文中繼資料
安全審計
低風險v5 • 1/21/2026
All static findings are false positives. C2 keyword alerts triggered by hash hex strings. Weak crypto alerts from hash substrings. External command alerts from ASCII flow diagrams using arrows. Hardcoded URL alerts are legitimate documentation links. No malicious code, command execution, or data exfiltration patterns found.
2
已掃描檔案
818
分析行數
0
發現項
5
審計總數
未發現安全問題
審計者: claude 查看審計歷史 →
品質評分
38
架構
100
可維護性
87
內容
21
社群
90
安全
91
規範符合性
你能建構什麼
建構 RAG 系統
透過為您的文件語料庫選擇適當的嵌入模型和分塊策略來實現檢索增強生成。
優化語義搜尋
透過選擇與您的內容類型匹配的嵌入模型並實現適當的分塊和預處理來提高搜尋相關性。
建立嵌入管道
建構可擴展的管道,處理文件、分塊內容、生成嵌入,並為向量資料庫準備記錄。
試試這些提示
選擇嵌入模型
I need to choose an embedding model for my [use case: code search / multilingual documents / legal contracts]. My priorities are [priority: accuracy / cost / speed]. I have [constraints: limit on dimensions / need open source / need API access]. Recommend 3 models with rationale.
實現分塊策略
Help me implement chunking for my [data type: technical documentation / conversational data / code]. I need to handle [requirement: preserve context / maintain semantic boundaries / limit chunk size]. Provide Python code for [strategy: token-based / sentence-based / recursive character] chunking.
建構嵌入管道
Create a Python pipeline that [input: processes documents from source / generates embeddings / stores in vector database]. Include [feature: batching / progress tracking / metadata handling]. Use [model: OpenAI embeddings / sentence-transformers].
評估檢索品質
My embedding-based retrieval has [problem: low recall / inconsistent results / poor precision]. My setup uses [model details]. Analyze potential causes and suggest improvements for [metric: precision at k / recall / ndcg].
最佳實務
- 將嵌入模型與內容類型匹配:程式碼、散文或多語言
- 標準化嵌入以進行可靠的餘弦相似度比較
- 分塊時使用 token 重疊以保留跨邊界的上下文
避免
- 在同一索引中混合不同的嵌入模型
- 忽略 token 限制並在思考中途截斷內容
- 跳過預處理,讓雜訊降低嵌入品質
常見問題
我應該從哪個嵌入模型開始?
一般使用從 text-embedding-3-small 開始。它平衡了成本和品質。如果您需要更高的準確度,請切換到 text-embedding-3-large,或針對程式碼和法律內容使用 voyage-2。
我該如何選擇分塊大小?
512 個 token 是大多數使用案例的良好起點。根據您的內容複雜度和模型 token 限制進行調整。重疊 50 個 token 以維持跨分塊的上下文。
我可以使用本地嵌入模型嗎?
可以。Sentence-transformers 支援 BAAI/bge-large-en-v1.5 和 intfloat/multilingual-e5-large 等模型。這些可在本地執行,非常適合開源或離線場景。
我該如何評估嵌入品質?
使用 precision@k、recall@k、MRR 和 NDCG@k 指標。使用已知相關文件進行測試,並將檢索結果與基準真值進行比較。
我應該標準化嵌入嗎?
可以。在使用餘弦相似度之前標準化嵌入。大多數現代嵌入模型預設產生標準化向量,但本地模型可能需要顯式標準化。
我應該應用什麼預處理?
移除過多的空白、標準化 unicode 字元,並過濾特殊字元。保持內容語義有意義。程式碼或結構化資料可能需要特定領域的清理。
開發者詳情
作者
wshobson授權
MIT
儲存庫
https://github.com/wshobson/agents/tree/main/plugins/llm-application-dev/skills/embedding-strategies引用
main
檔案結構
📄 SKILL.md