Hybrid Search Implementation

Use when combining vector and keyword search for RAG or search systems, especially for exact terms, codes, names, and domain-specific vocabulary.

9 stars 3 forksAI, LLMs & Agents

Install

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add sandbaseai/workbuddy-skill --skill hybrid-search-implementation
Manual install
git clone --depth 1 https://github.com/sandbaseai/workbuddy-skill.git /tmp/workbuddy-skill
mkdir -p ~/.claude/skills
cp -r /tmp/workbuddy-skill/skills/hybrid-search-implementation ~/.claude/skills/hybrid-search-implementation

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# Hybrid Search Implementation

将语义召回与精确匹配结合起来:向量检索理解含义,关键词检索保留名称、代码、错误号和专有术语。混合检索的目标是提升可测的召回与回答质量,同时控制延迟、成本、权限和索引生命周期。

## 使用边界

- 开始前确认语料来源、许可证、租户/ACL、字段权重、索引版本、embedding/分词器版本、延迟和成本目标。
- 默认只读检查查询、索引配置、候选结果、分数和评测数据;验证使用脱敏或合成语料及隔离索引。
- 不擅自抓取受限内容、改变 ACL、重建/删除索引、上传用户数据或进行生产 A/B;这些操作需要明确授权与回滚方案。
- query、候选文本、metadata 和点击日志可能含敏感信息;长期证据只保存最小字段、哈希和聚合结果。

## 架构与权限

典型流程为 `query → dense + sparse candidates → hard filters → fusion → optional rerank → threshold/dedup → results`。租户、ACL、发布状态和数据保留条件必须在候选返回前作为硬过滤执行;模型不能决定用户权限,也不能通过 query 或 metadata 绕过过滤。

为每个结果保留 source/version/chunk ID、dense rank/score、sparse rank/score、融合分数、过滤原因和索引版本。分数来自不同检索器,不能未经校准直接相加;先记录排序和分布,再选择融合方法。

```python
def hybrid_retrieve(query, tenant_id, *, limit=20):
    filters = {"tenant_id": tenant_id, "status": "published"}
    dense = vector_index.search(query, filters=filters, limit=limit)
    sparse = keyword_index.search(query, filters=filters, limit=limit)
    fused = reciprocal_rank_fusion([dense, sparse], k=60)
    fused = remove_duplicate_sources(fused)
    return rerank(query, fused[:limit], limit=8)
```

## 融合与查询路由

- **RRF**:按各列表名次融合,适合没有可靠跨检索器分数校准的初始基线。
- **加权融合**:在固定评测集上校准 dense/sparse 权重,并按查询类型验证;不要把权重硬编码成通用真理。
- **级联**:先用便宜的硬过滤/关键词缩小候选,再进行向量或 cross-encoder 重排;记录漏召回风险。
- **查询路由**:精确 ID/代码、自然语言问题、短词、拼写变体和多语言查询可采用不同候选数或权重,但路由规则需可解释、可回归。

对空 query、单词 query、长 query、拼写错误、同义改写、数字/代码、无结果、重复结果、跨语言和注入文本分别测试。结果不足时返回低置信度或澄清,不以增加 top-k 或编造内容掩盖召回失败。

## 重排、阈值与上下文
Read the full skill on GitHub

Details

Skill name
hybrid-search-implementation
Path
skills/hybrid-search-implementation/SKILL.md
License
MIT
Repo updated
8 September 2026

FAQ

What does the Hybrid Search Implementation skill do?

Use when combining vector and keyword search for RAG or search systems, especially for exact terms, codes, names, and domain-specific vocabulary.

How do I install the Hybrid Search Implementation skill?

skills CLI (Claude Code, Cursor, Codex and more): npx skills add sandbaseai/workbuddy-skill --skill hybrid-search-implementation. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is Hybrid Search Implementation popular?

It lives in sandbaseai/workbuddy-skill, which has 9 GitHub stars and 3 forks.

Related skills

Browse the most popular Claude skills, all ai, llms & agents skills, or write your own with the skills generator.