Retrieval-Augmented Generation (RAG) system design patterns, chunking strategies, embedding models, retrieval techniques, and context assembly. Use when designing RAG pipelines, improving retrieval quality, or building knowledge-grounded LLM applications.
⭐3stars🔀0forks📁View on GitHub🕐Updated Jan 3, 2026⬇️1downloads
This Claude skill provides a comprehensive technical framework for designing and optimizing Retrieval-Augmented Generation (RAG) systems. It covers the entire pipeline from document ingestion and chunking strategies to embedding selection and multi-stage retrieval, enabling developers to build high-performance, knowledge-grounded LLM applications with improved accuracy and reduced hallucination.
Use Cases
Designing enterprise-grade RAG pipelines to ground AI responses in proprietary company documentation.
Optimizing retrieval relevance by implementing hybrid search (dense + sparse) and advanced re-ranking techniques.
Selecting and implementing specialized chunking strategies for complex data types like source code, legal contracts, or structured tables.
Evaluating and benchmarking RAG system performance using metrics like faithfulness, answer correctness, and retrieval recall.
Implementing advanced query transformation patterns such as HyDE (Hypothetical Document Embeddings) to improve semantic search results.
name
rag-architecture
description
Retrieval-Augmented Generation (RAG) system design patterns, chunking strategies, embedding models, retrieval techniques, and context assembly. Use when designing RAG pipelines, improving retrieval quality, or building knowledge-grounded LLM applications.
What type of content?
├── Code
│ └── AST-based or function-level chunking
├── Tables/Structured
│ └── Keep tables intact, chunk surrounding text
├── Long narrative
│ └── Semantic or recursive chunking
├── Short documents (<1 page)
│ └── Whole document as chunk
└── Mixed content
└── Recursive with type-specific handlers
Chunk Overlap
Without Overlap:
[Chunk 1: "The quick brown"] [Chunk 2: "fox jumps over"]
↑
Information lost at boundary
With Overlap (20%):
[Chunk 1: "The quick brown fox"]
[Chunk 2: "brown fox jumps over"]
↑
Context preserved across boundaries
Recommended overlap: 10-20% of chunk size
Chunk Size Trade-offs
Smaller Chunks (128-256 tokens) Larger Chunks (512-1024 tokens)
├── More precise retrieval ├── More context per chunk
├── Less context per chunk ├── May include irrelevant content
├── More chunks to search ├── Fewer chunks to search
├── Better for factoid Q&A ├── Better for summarization
└── Higher retrieval recall └── Higher retrieval precision
Embedding Models
Model Comparison
Model
Dimensions
Context
Strengths
OpenAI text-embedding-3-large
3072
8K
High quality, expensive
OpenAI text-embedding-3-small
1536
8K
Good quality/cost ratio
Cohere embed-v3
1024
512
Multilingual, fast
BGE-large
1024
512
Open source, competitive
E5-large-v2
1024
512
Open source, instruction-tuned
GTE-large
1024
512
Alibaba, good for Chinese
Sentence-BERT
768
512
Classic, well-understood
Embedding Selection
Need best quality, cost OK?
├── Yes → OpenAI text-embedding-3-large
└── No
└── Need self-hosted/open source?
├── Yes → BGE-large or E5-large-v2
└── No
└── Need multilingual?
├── Yes → Cohere embed-v3
└── No → OpenAI text-embedding-3-small
LLM Attention Pattern:
┌─────────────────────────────────────────────────────────┐
│ Beginning Middle End │
│ ████ ░░░░ ████ │
│ High attention Low attention High attention │
└─────────────────────────────────────────────────────────┘
Mitigation:
1. Put most relevant at beginning AND end
2. Use shorter context windows when possible
3. Use hierarchical summarization
4. Fine-tune for long-context attention
Advanced RAG Patterns
Query Transformation
Original Query: "Tell me about the project"
│
┌─────────────────┼─────────────────┐
▼ ▼ ▼
┌─────────┐ ┌──────────┐ ┌──────────┐
│ HyDE │ │ Query │ │ Sub-query│
│ (Hypo │ │ Expansion│ │ Decomp. │
│ Doc) │ │ │ │ │
└─────────┘ └──────────┘ └──────────┘
│ │ │
▼ ▼ ▼
Hypothetical "project, "What is the
answer to goals, project scope?"
embed timeline, "What are the
deliverables" deliverables?"
HyDE (Hypothetical Document Embeddings)
Query: "How does photosynthesis work?"
│
▼
┌───────────────┐
│ LLM generates │
│ hypothetical │
│ answer │
└───────────────┘
│
▼
"Photosynthesis is the process by which
plants convert sunlight into energy..."
│
▼
┌───────────────┐
│ Embed hypo │
│ document │
└───────────────┘
│
▼
Search with hypothetical embedding
(Better matches actual documents)
Self-RAG (Retrieval-Augmented LM with Self-Reflection)