Combine vector and keyword search for improved retrieval

Hybrid search implementation

by wshobson · MIT license · ★ 39,857 on GitHub · updated Sep 21

Hybrid search implementation cover

Combine vector and keyword search for improved retrieval. Use when implementing RAG systems, building search engines, or when neither approach alone provides sufficient recall.

---
name: hybrid-search-implementation
description: Combine vector and keyword search for improved retrieval. Use when implementing RAG systems, building search engines, or when neither approach alone provides sufficient recall.
---

# 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

Overview

Patterns for combining vector similarity and keyword-based search.

Manual install (npx, ZIP)
Claude Codenpx skills add wshobson/agents --skill hybrid-search-implementation -g -a claude-code
Claude Code (manual)mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/wshobson/agents/tar.gz/4236bb91f839 \ | tar -xz -C ~/.claude/skills --strip-components=4 agents-4236bb91f839/plugins/llm-application-dev/skills/hybrid-search-implementation
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/4e6c58841fda563d973b/hybrid-search-implementation.zip" -OutFile "$env:TEMP\hybrid-search-implementation.zip"; Expand-Archive "$env:TEMP\hybrid-search-implementation.zip" -DestinationPath "$HOME\.claude\skills" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md2.0 KB
  • references/1 file · 15.8 KB
Read the files here
wshobson/4236bb92 files
SKILL.md
Show the full text57 lines

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
1---
2name: hybrid-search-implementation
3description: Combine vector and keyword search for improved retrieval. Use when implementing RAG systems, building search engines, or when neither approach alone provides sufficient recall.
4---
5 
6# Hybrid Search Implementation
7 
8Patterns for combining vector similarity and keyword-based search.
9 
10## When to Use This Skill
11 
12- Building RAG systems with improved recall
13- Combining semantic understanding with exact matching
14- Handling queries with specific terms (names, codes)
15- Improving search for domain-specific vocabulary
16- When pure vector search misses keyword matches
17 
18## Core Concepts
19 
20### 1. Hybrid Search Architecture
21 
22```
23Query → ┬─► Vector Search ──► Candidates ─┐
24 │ │
25 └─► Keyword Search ─► Candidates ─┴─► Fusion ─► Results
26```
27 
28### 2. Fusion Methods
29 
30| Method | Description | Best For |
31| ----------------- | ------------------------ | --------------- |
32| **RRF** | Reciprocal Rank Fusion | General purpose |
33| **Linear** | Weighted sum of scores | Tunable balance |
34| **Cross-encoder** | Rerank with neural model | Highest quality |
35| **Cascade** | Filter then rerank | Efficiency |
36 
37## Templates and detailed worked examples
38 
39Full template library and detailed worked examples live in `references/details.md`. Read that file when you need the concrete templates.
40 
41## Best Practices
42 
43### Do's
44 
45- **Tune weights empirically** - Test on your data
46- **Use RRF for simplicity** - Works well without tuning
47- **Add reranking** - Significant quality improvement
48- **Log both scores** - Helps with debugging
49- **A/B test** - Measure real user impact
50 
51### Don'ts
52 
53- **Don't assume one size fits all** - Different queries need different weights
54- **Don't skip keyword search** - Handles exact matches better
55- **Don't over-fetch** - Balance recall vs latency
56- **Don't ignore edge cases** - Empty results, single word queries
57 
View all files on GitHub →

Details

Updated
Sep 21, 2026
License
MIT
Stars on the repo
★ 39,857
Checked
Source
wshobson/agents ↗
Creator
wshobson · 179 listings
View creator

Similar skills

See all →
PromptAct as an expert AI engineer specializing in practicalf/prompts.chat · by Ersin YılmazAct as an expert AI engineer specializing in practical machine learning implementation and AI integration for production applications, ensuring efficient and robust AI solutions.New listingSkillQuery the 1000 Genomes Project datasetOneKGPd: Individual-Level Queries over the 1000 Genomes ProjectK-Dense-AI/scientific-agent-skills · by K-Dense-AIQuery the 1000 Genomes Project dataset (3,202 whole-genome-sequenced individuals, GRCh38) at the level of individual participants. Use when a question is about individuals or variants in the 1000 Genomes Project cohort: which individuals carry variants matching specific criteria in a gene or region, which individuals are homozygous-reference at a position, which variants exist in the dataset or carried by specified individuals in a gene or region, the relatedness between two specified individuals. Variants are returned with 1000 Genomes allele frequencies (AF), gnomAD v4.1 exome and genome AF, AlphaMissense score, and HGVSp annotations.★ 46k GitHub starsSkillBayesian modeling with PyMCPyMC Bayesian ModelingK-Dense-AI/scientific-agent-skills · by K-Dense-AIBayesian modeling with PyMC. Build hierarchical models, MCMC (NUTS), variational inference, LOO/WAIC comparison, posterior checks, for probabilistic programming and inference.★ 46k GitHub starsSkillStatistical models library for PythonStatsmodels: Statistical Modeling and EconometricsK-Dense-AI/scientific-agent-skills · by K-Dense-AIStatistical models library for Python. Use when you need specific model classes (OLS, GLM, mixed models, ARIMA) with detailed diagnostics, residuals, and inference. Best for econometrics, time series, rigorous inference with coefficient tables. For guided statistical test selection with APA reporting use statistical-analysis.★ 46k GitHub starsSkillHugging Face Transformers for loading Hub modelsK-Dense-AI/scientific-agent-skills · by K-Dense-AIHugging Face Transformers for loading Hub models, running pipeline inference, text generation, and Trainer fine-tuning on NLP, vision, audio, and multimodal tasks. Use when working with AutoModel, pipelines, tokenizers, or TrainingArguments—not for general ML outside the Transformers library.★ 46k GitHub starsSkillWorking with Outpost Bio's open microbiome foundation modelsWaypoint: Outpost Bio's Open Microbiome Foundation ModelsK-Dense-AI/scientific-agent-skills · by K-Dense-AIUse when working with Outpost Bio's open microbiome foundation models - the Waypoint checkpoints (Waypoint-6m, Waypoint-45m, Waypoint-170m), the Atlas pretraining corpus, the Compass eight-task benchmark, or the `waypoint` CLI from the `waypoint-bio` package. Covers embedding microbiome samples, fine-tuning on taxonomic abundance data, benchmarking a checkpoint on Compass, pretraining a GPT-2 model on taxonomic abundance profiles, and converting MetaPhlAn, Kraken2, QIIME 2, or MGnify abundance tables into waypoint format.★ 46k GitHub stars

More from wshobson

SkillMaster C/.NET backend development patterns for buildingwshobson/agents · by wshobsonMaster C#/.NET backend development patterns for building robust APIs, MCP servers, and enterprise applications. Covers async/await, dependency injection, Entity Framework Core, Dapper, configuration, caching, and testing with xUnit. Use when developing .NET backends, reviewing C# code, or designing API architectures.★ 39.9k GitHub starsSkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliancewshobson/agents · by wshobsonImplement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.★ 39.9k GitHub starsSkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Designwshobson/agents · by wshobsonMaster Material Design 3 and Jetpack Compose patterns for building native Android apps. Use when designing Android interfaces, implementing Compose UI, or following Google's Material Design guidelines.★ 39.9k GitHub starsSkillMigrate from AngularJS to Angular using hybrid modeAngular migrationwshobson/agents · by wshobsonMigrate from AngularJS to Angular using hybrid mode, incremental component rewriting, and dependency injection updates. Use when upgrading AngularJS applications, planning framework migrations, or modernizing legacy Angular code.★ 39.9k GitHub starsSkillUnderstand anti-reversing, obfuscationAnti reversing techniqueswshobson/agents · by wshobsonUnderstand anti-reversing, obfuscation, and protection techniques encountered during software analysis. Use this skill when analyzing malware evasion techniques, when implementing anti-debugging protections for CTF challenges, when reverse engineering packed binaries, or when building security research tools that need to detect virtualized environments.★ 39.9k GitHub starsSkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patternswshobson/agents · by wshobsonBuild production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.★ 39.9k GitHub stars