---
name: implementacion-busqueda-hibrida
description: Patrones para combinar búsqueda vectorial y por palabras clave en sistemas RAG y motores de búsqueda, con métodos de fusión como RRF, linear y cross-encoder para mejorar la recuperación de información.
license: MIT
metadata:
  id: 8b3867ab
  slug: implementacion-busqueda-hibrida
  titulo: "Implementación de Búsqueda Híbrida"
  servicio: IA-Ingenieria-MLOps
  categoria_recurso: IA-Generativa
  tipo: referencia
  nivel: avanzado
  idioma: es
  idioma_original: en
  acceso: gratis
  precio_eur: 0
  plataformas: [Claude Code, Codex CLI, OpenCode, Cursor, Gemini CLI]
  dependencias: [vector-db, bm25, sentence-transformers]
  licencia: { spdx: MIT, redistribuible: true, uso_comercial: true }
  fuente:
    repo: wshobson/agents
    url: https://github.com/wshobson/agents/tree/main/plugins/llm-application-dev/skills/hybrid-search-implementation
    commit: cc37bfd
    autor: wshobson
    nombre_original: hybrid-search-implementation
    duplicados_en: []
  seguridad: { veredicto: seguro, riesgo: bajo, escaneado: "2026-06-14", motor: "grep-estatico+auditor-llm" }
  ficha:
    que_hace: "Guia la implementacion de busqueda hibrida combinando embeddings vectoriales y busqueda por palabras clave para maximizar el recall en sistemas RAG."
    como_lo_hace: "Documenta arquitecturas de fusion (RRF, linear, cross-encoder, cascade) con patrones listos para usar y mejores practicas de ajuste empirico de pesos."
  content_hash: "8b3867aba4aaa0e651d04f28c51cf6248934799527e8192235310f3488911743"
  version: 1.0.0
---

# 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
