41. Advanced RAG (Beyond the Basics)

Overview and links for this section of the guide.

When Vector Search Fails

Vector search finds "semantic similarity." It is bad at:

  • Exact keyword matches: "Error 503" (vectors might map this near "Server Issue" but miss the specific error code doc).
  • Negation: "How do I NOT delete the database?" (vectors often ignore "NOT").
  • Temporal queries: "What was the policy in 2021?"

Advanced RAG Techniques

  • Hybrid Search: Combine BM25 (keyword) + Vector (semantic) with a reciprocal rank fusion algorithm.
  • HyDE (Hypothetical Document Embeddings): Ask the LLM to hallucinate an answer, embed that, and search for documents matching the hallucination.
  • Reranking: Retrieve 50 docs (cheap), then use a high-precision Cross-Encoder model to rank the top 5 (expensive but accurate) for the context window.

Where to go next