Skip to content
ai-rag logo

RAG & Search Engineering — Complete Reference

ai-rag

Complete RAG and search engineering skill. Covers chunking strategies, hybrid retrieval (BM25 + vector), cross-encoder reranking, query rewriting, ranking pipelines, nDCG/MRR evaluation, and production search systems. Modern patterns for retrieval-augmented generation and semantic search.

SKILL.md

Full skill instructions

RAG & Search Engineering — Complete Reference

Build production-grade retrieval systems with hybrid search, grounded generation, and measurable quality.

This skill covers:

  • RAG: Chunking, contextual retrieval, grounding, adaptive/​self-correcting systems
  • Search: BM25, vector search, hybrid fusion, ranking pipelines
  • Evaluation: recall@k, nDCG, MRR, groundedness metrics

Modern Best Practices (Jan 2026):

Default posture: deterministic pipeline, bounded context, explicit failure handling, and telemetry for every stage.

Scope note: For prompt structure and output contracts used in the generation phase, see ai-prompt-engineering.

Quick Reference

TaskTool/​FrameworkCommand/​PatternWhen to Use
Decide RAG vs alternativesDecision frameworkRAG if: freshness + citations + corpus size; else: fine-tune/​cachingAvoid unnecessary retrieval latency/​complexity
Chunking & parsingChunker + parserStart simple; add structure-aware chunking per doc typeIngestion for docs, code, tables, PDFs
RetrievalSparse + dense (hybrid)Fusion (e.g., RRF) + metadata filters + top-k tuningMixed query styles; high recall requirements
Precision boostRerankerCross-encoder/​LLM rerank of top-k candidatesWhen top-k contains near-misses/​noise
GroundingOutput contract + citationsQuote/​ID citations; answerability gate; refuse on missing evidenceCompliance, trust, and auditability
EvaluationOffline + online evalRetrieval metrics + answer metrics + regression testsPrevent silent regressions and staleness failures

Decision Tree: RAG Architecture Selection

Building RAG system: [Architecture Path]
    ├─ Document type?
    │   ├─ Page/​section-structured? → Structure-aware chunking (pages/​sections + metadata)
    │   ├─ Technical docs/​code? → Structure-aware + code-aware chunking (symbols, headers)
    │   └─ Simple content? → Fixed-size token chunking with overlap (baseline)
    │
    ├─ Retrieval accuracy low?
    │   ├─ Query ambiguity? → Query rewriting + multi-query expansion + filters
    │   ├─ Noisy results? → Add reranker + better metadata filters
    │   └─ Mixed queries? → Hybrid retrieval (sparse + dense) + reranking
    │
    ├─ Dataset size?
    │   ├─ <100k chunks? → Flat index (exact search)
    │   ├─ 100k-10M? → HNSW (low latency)
    │   └─ >10M? → IVF/​ScaNN/​DiskANN (scalable)
    │
    └─ Production quality?
        └─ Add: ACLs, freshness/​invalidation, eval gates, and telemetry (end-to-end)

Core Concepts (Vendor-Agnostic)

  • Pipeline stages: ingest → chunk → embed → index → retrieve → rerank → pack context → generate → verify.
  • Two evaluation planes: retrieval relevance (did we fetch the right evidence?) vs generation fidelity (did we use it correctly?).
  • Freshness model: staleness budget, invalidation triggers, and rebuild strategy (incremental vs full).
  • Trust boundaries: retrieved content is untrusted; apply the same rigor as user input (OWASP LLM Top 10: https://owasp.org/www-project-top-10-for-large-language-model-applications/).

Implementation Practices (Tooling Examples)

  • Use a retrieval API contract: query, filters, top_k, trace_id, and returned evidence IDs.
  • Instrument each stage with tracing/​metrics (OpenTelemetry GenAI semantic conventions: https://opentelemetry.io/docs/specs/semconv/gen-ai/).
  • Add caches deliberately: embeddings cache, retrieval cache (query+filters), and response cache (with invalidation).

Do / Avoid

Do

  • Do keep retrieval deterministic: fixed top_k, stable ranking, explicit filters.
  • Do enforce document-level ACLs at retrieval time (not only at generation time).
  • Do include citations with stable IDs and verify citation coverage in tests.

Avoid

  • Avoid shipping RAG without a test set and regression gate.
  • Avoid "stuff everything" context packing; it increases cost and can reduce accuracy.
  • Avoid mixing corpora without metadata and tenant isolation.

When to Use This Skill

Use this skill when the user asks:

  • "Help me design a RAG pipeline."
  • "How should I chunk this document?"
  • "Optimize retrieval for my use case."
  • "My RAG system is hallucinating — fix it."
  • "Choose the right vector database / index type."
  • "Create a RAG evaluation framework."
  • "Debug why retrieval gives irrelevant results."

Tool/​Model Recommendation Protocol

When users ask for vendor/​model/​framework recommendations, validate claims against current primary sources.

Triggers

  • "What's the best vector database for [use case]?"
  • "What should I use for [chunking/​embedding/​reranking]?"
  • "What's the latest in RAG development?"
  • "Current best practices for [retrieval/​grounding/​evaluation]?"
  • "Is [Pinecone/​Qdrant/​Chroma] still relevant in 2026?"
  • "[Vector DB A] vs [Vector DB B]?"
  • "Best embedding model for [use case]?"
  • "What RAG framework should I use?"

Required Checks

  1. Read data/​sources.json and start from sources with "add_as_web_search": true.
  2. Verify 1-2 primary docs per recommendation (release notes, benchmarks, docs).
  3. If browsing isn't available, state assumptions and give a verification checklist.

What to Report

After checking, provide:

  • Current landscape: What vector DBs/​embeddings are popular NOW (not 6 months ago)
  • Emerging trends: Techniques gaining traction (late interaction, agentic RAG, graph RAG)
  • Deprecated/​declining: Approaches or tools losing relevance
  • Recommendation: Based on fresh data, not just static knowledge

Example Topics (verify with current sources)

  • Vector databases (Pinecone, Qdrant, Weaviate, Milvus, pgvector, LanceDB)
  • Embedding models (OpenAI, Cohere, Voyage AI, Jina, Sentence Transformers)
  • Reranking (Cohere Rerank, Jina Reranker, FlashRank, RankGPT)
  • RAG frameworks (LlamaIndex, LangChain, Haystack, txtai)
  • Advanced RAG (contextual retrieval, agentic RAG, graph RAG, CRAG)
  • Evaluation (RAGAS, TruLens, DeepEval, BEIR)

Related Skills

For adjacent topics, reference these skills:

  • ai-llm - Prompting, fine-tuning, instruction datasets
  • ai-agents - Agentic RAG workflows and tool routing
  • ai-llm-inference - Serving performance, quantization, batching
  • ai-mlops - Deployment, monitoring, security, privacy, and governance
  • ai-prompt-engineering - Prompt patterns for RAG generation phase

Templates

System Design (Start Here)

Chunking & Ingestion

Embedding & Indexing

Retrieval & Reranking

Context Packaging & Grounding

Evaluation

Search Configuration

Query Rewriting

Navigation

Resources

Templates

Data

Use this skill whenever the user needs retrieval-augmented system design or debugging, not prompt work or deployment.

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View