hybrid-search-implementation
它能做什么
这个技能会教你如何混合两种搜索方式:一种是理解含义的搜索(向量搜索),另一种是查找精确词语的搜索(关键词搜索)。这样可以让你更全面地找到所需信息。
适用场景
- ✓在构建基于文档回答问题的系统时。
- ✓当你需要搜索既能匹配含义,又能匹配特定术语时。
- ✓如果纯粹基于含义的搜索遗漏了你知道确实存在的重要结果时。
技能链接
https://github.com/wshobson/agents/blob/main/plugins/llm-application-dev/skills/hybrid-search-implementation/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我怎样才能把含义搜索和关键词搜索结合起来,以提升搜索结果?”
每周 5 个新技能,1 分钟读完。
工作原理
思路是同时把你的查询发送给两个搜索系统。一个负责理解含义,另一个负责查找精确的词语。然后把两边的结果合并起来,得到最佳答案。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Hybrid Search Implementation
Patterns for combining vector similarity and keyword-based search.
When to Use This Skill
- Building RAG systems with improved recall
- Combining semantic understanding with exact matching
- Handling queries with specific terms (names, codes)
- Improving search for domain-specific vocabulary
- When pure vector search misses keyword matches
Core Concepts
1. Hybrid Search Architecture
Query → ┬─► Vector Search ──► Candidates ─┐
│ │
└─► Keyword Search ─► Candidates ─┴─► Fusion ─► Results
2. Fusion Methods
| Method | Description | Best For |
|---|---|---|
| RRF | Reciprocal Rank Fusion | General purpose |
| Linear | Weighted sum of scores | Tunable balance |
| Cross-encoder | Rerank with neural model | Highest quality |
| Cascade | Filter then rerank | Efficiency |
Templates and detailed worked examples
Full template library and detailed worked examples live in references/details.md. Read that file when you need the concrete templates.
Best Practices
Do's
- Tune weights empirically - Test on your data
- Use RRF for simplicity - Works well without tuning
- Add reranking - Significant quality improvement
- Log both scores - Helps with debugging
- A/B test - Measure real user impact
Don'ts
- Don't assume one size fits all - Different queries need different weights
- Don't skip keyword search - Handles exact matches better
- Don't over-fetch - Balance recall vs latency
- Don't ignore edge cases - Empty results, single word queries
常见问题
什么是向量搜索?
它是一种能理解词语和短语含义的搜索,即使用词不同,也能找到讨论同一主题的文本。
什么是关键词搜索?
它是传统的搜索方式,会查找你输入的精确词语。
什么是“融合”(fusion)?
它是把两种搜索(向量搜索和关键词搜索)的结果合并起来的过程,从而得到更准确的最终结果列表。
详情
作者的原始描述
Combine vector and keyword search for improved retrieval. Use when implementing RAG systems, building search engines, or when neither approach alone provides sufficient recall.
repo: wshobson/agents
热度
- GitHub 星标
- 41k
- 排名
- #6721
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …