スキル一覧に戻る
vasilyu1983

ai-rag

by vasilyu1983

25🍴 6📅 2026年1月23日
GitHubで見るManusで実行

SKILL.md


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 (December 2025):

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

Claude should invoke 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."

Trend Awareness Protocol

IMPORTANT: When users ask recommendation questions about RAG or search, you MUST use WebSearch to check current trends before answering.

Trigger Conditions

  • "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 Searches

  1. Search: "RAG best practices 2026"
  2. Search: "[specific vector DB/embedding model] vs alternatives 2026"
  3. Search: "RAG trends January 2026"
  4. Search: "vector database new releases 2026"

What to Report

After searching, provide:

  • Current landscape: What vector DBs/embeddings are popular NOW (not 6 months ago)
  • Emerging trends: New RAG techniques gaining traction (graph RAG, agentic RAG)
  • Deprecated/declining: Approaches or tools losing relevance
  • Recommendation: Based on fresh data, not just static knowledge
  • 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)

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

Detailed Guides

Core RAG Architecture

  • Pipeline Architecture - End-to-end RAG pipeline structure, ingestion, freshness, index hygiene, embedding selection
  • Chunking Strategies - Chunking tradeoffs, semantic/late chunking (2026), evaluation approach, and production pitfalls
  • Index Selection Guide - Vector database configuration, HNSW/IVF/Flat selection, pgvectorscale benchmarks

Advanced Retrieval Techniques

  • Retrieval Patterns - Dense retrieval, hybrid search, ColBERT/late interaction, query preprocessing, reranking workflow
  • Contextual Retrieval Guide - Chunk context augmentation technique; validate impact on your corpus
  • Grounding Checklists - Context compression, hallucination control, citation patterns, answerability validation

Agentic & Advanced RAG (2026)

  • Agentic RAG Patterns - Loop-based RAG with self-correction, multi-hop reasoning, adaptive retrieval, GEAR architecture
  • Advanced RAG Patterns - Graph/multimodal RAG, GEAR, contextual memory, online evaluation, telemetry

Production & Evaluation

Implementation Patterns


Templates

System Design (Start Here)

Chunking & Ingestion

Embedding & Indexing

Retrieval & Reranking

Context Packaging & Grounding

Evaluation

Resources

Templates

Data


External Resources

See data/sources.json for:

  • Embedding models (OpenAI, Cohere, Sentence Transformers, Voyage AI, Jina)
  • Vector DBs (FAISS, Pinecone, Qdrant, Weaviate, Milvus, Chroma, pgvector, LanceDB)
  • Hybrid search libraries (Elasticsearch, OpenSearch, Typesense, Meilisearch)
  • Reranking models (Cohere Rerank, Jina Reranker, RankGPT, Flashrank)
  • Evaluation frameworks (RAGAS, TruLens, DeepEval, BEIR)
  • RAG frameworks (LlamaIndex, LangChain, Haystack, txtai)
  • Advanced techniques (RAG Fusion, CRAG, Self-RAG, Contextual Retrieval)
  • Production platforms (Vectara, AWS Kendra)

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

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です