vector-db
它能做什么
这个技能指导设计按含义查找内容的向量搜索系统,包括嵌入模型的选择、分块大小和索引。适合为 AI 助手构建语义搜索或检索的团队。
适用场景
- ✓当你希望搜索能按含义而不是精确关键词找到内容时。
- ✓当你在构建检索,让 AI 助手能够根据你的文档回答问题时。
- ✓当你需要为嵌入选择索引类型或距离度量时。
技能链接
https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/vector-db/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我为我们的帮助中心文章设置语义搜索,使 AI 助手能为每个问题找到正确的文章。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能说明如何选择嵌入模型、把文档切分为大小合适的块、选择距离度量和索引,并把向量搜索与关键词搜索结合起来。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Vector Database Expert
A retrieval systems specialist with deep expertise in embedding models, vector indexing algorithms, and Retrieval-Augmented Generation (RAG) architectures. This skill provides guidance for designing and operating vector search systems that power semantic search, recommendation engines, and LLM knowledge augmentation, covering embedding selection, indexing strategies, chunking, hybrid search, and production deployment.
Key Principles
- Choose the embedding model based on your domain and retrieval task; general-purpose models work well for broad use cases, but domain-specific fine-tuned embeddings significantly improve recall for specialized content
- Select the distance metric that matches your embedding model's training objective: cosine similarity for normalized embeddings, dot product for magnitude-aware comparisons, and L2 (Euclidean) for spatial distance
- Chunk documents thoughtfully; chunk size directly impacts retrieval quality because too-large chunks dilute relevance while too-small chunks lose context
- Index choice determines the trade-off between search speed, memory usage, and recall accuracy; understand HNSW, IVF, and flat index characteristics before choosing
- Combine dense vector search with sparse keyword search (hybrid retrieval) for production systems; neither approach alone handles all query types optimally
Techniques
- Generate embeddings with models like OpenAI text-embedding-3-small, Cohere embed-v3, or open-source sentence-transformers (all-MiniLM-L6-v2, BGE, E5) depending on cost and quality requirements
- Configure HNSW indexes with appropriate M (connections per node, typically 16-64) and efConstruction (build quality, typically 100-200) parameters; higher values improve recall at the cost of memory and build time
- Implement chunking strategies: fixed-size with overlap (e.g., 512 tokens with 50-token overlap), semantic chunking at paragraph or section boundaries, or recursive splitting that respects document structure
- Build hybrid search by executing both vector similarity and BM25/keyword queries, then combining results with Reciprocal Rank Fusion (RRF) or a learned reranker like Cohere Rerank or cross-encoder models
- Filter results using metadata (date ranges, categories, access permissions) at query time; most vector databases support pre-filtering or post-filtering with different performance characteristics
- Design the RAG pipeline: query embedding, retrieval (top-k candidates), optional reranking, context assembly with source citations, and LLM generation with the retrieved context in the prompt
Common Patterns
- Parent-Child Retrieval: Embed small chunks for precise matching but return the larger parent document or section as context to the LLM, preserving surrounding information
- Multi-vector Representation: Generate multiple embeddings per document (title, summary, full text) and search across all representations to improve recall for different query styles
- Contextual Retrieval: Prepend a document-level summary or metadata to each chunk before embedding so that the vector captures both local content and global context
- Evaluation Pipeline: Measure retrieval quality with precision@k, recall@k, and NDCG using a labeled relevance dataset; track these metrics as embedding models and chunking strategies change
Pitfalls to Avoid
- Do not use a single embedding model for all use cases without benchmarking; embedding quality varies dramatically across domains, languages, and query types
- Do not index documents without preprocessing: remove boilerplate, normalize whitespace, and handle tables and code blocks as structured content rather than raw text
- Do not skip reranking in production RAG systems; initial vector retrieval optimizes for speed, but a cross-encoder reranker significantly improves precision in the final results
- Do not store only vectors without the original text and metadata; you need the source content for LLM context assembly, debugging, and auditing retrieval results
常见问题
什么是嵌入?
它是表示一段文本含义的一组数字,因此含义相近的文本在空间中彼此靠近。
分块大小为什么重要?
过大的块会稀释相关性,过小的块则会丢失回答问题所需的上下文。
为什么要把向量搜索和关键词搜索结合?
该技能说明,单独使用任何一种方法都无法很好地处理所有类型的查询,因此混合搜索在生产中效果更好。
详情
作者的原始描述
Vector database expert for embeddings, similarity search, RAG patterns, and indexing strategies
repo: RightNow-AI/openfang
热度
- GitHub 星标
- 18k
- 排名
- #10719
- 许可证
- Apache-2.0
- 更新时间
- 2026/7/2
评论
- …
同一仓库的更多技能
browser-automation
18k教你的智能体使用 Playwright 控制网页浏览器,借助 CSS 选择器找到按钮、表单和链接。
clip-hand-skill
18k帮你的智能体制作视频片段:下载视频、转录语音、生成字幕文件,并用 ffmpeg 剪辑片段。
collector-hand-skill
18k帮你的智能体收集某个主题或公司的公开信息,提取关键实体,跟踪变化并判断舆论倾向。
infisical-sync-skill
18k帮你的智能体通过 API 读取和更新 Infisical 保险库中的密钥,包含登录步骤和清晰的错误处理。