Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Designs production RAG systems across chunking, embeddings, hybrid search, reranking, and context assembly.
74% 100%+26 ptsof test cases passed
Passed 23 of 23 test cases with the skill, and 17 of 23 without it.
3 of 3 safety checks passed
81 agent runs
4 forksA fork is a copy of this skill that someone made so they could edit it for their own use. The original doesn't change.
RAG is search + prompt, not magic. The model can only answer from what retrieval puts in the context window, so 80% of RAG quality is the retrieval system and 20% is the prompt. Most "the LLM hallucinated" bugs are actually "retrieval returned garbage and the model dutifully summarized it." Build the pipeline so the right chunks land in context with citations, and tell the model to say "I don't know" when they don't. This skill is the concrete playbook: numbers, methods, tables, and the failure modes that cost precision.
Index time (offline, batch): ingest → chunk → embed → index. Query time (online, latency-bound): retrieve → rerank → assemble → generate.
| Stage | Job | Latency budget (typical) |
|---|---|---|
| Ingest | Parse source → clean text + metadata | offline |
| Chunk | Split into retrievable units | offline |
| Embed | Text → vector | offline (docs), ~10–50ms (query) |
| Index | Store vectors + metadata for ANN | offline |
| Retrieve | top-k candidates (dense + sparse) | 10–50ms |
| Rerank | Cross-encoder reorders k→n | 50–300ms |
| Assemble | Select, dedup, order, budget, cite | <5ms |
| Generate | LLM answers from context | 1–10s (dominates) |
Do treat each stage as independently measurable and swappable. Don't optimize generation prompts before you've measured retrieval recall — you're polishing the 20%.
When RAG vs alternatives: RAG when knowledge is large, changing, private, or needs citations (docs, tickets, codebases, policies). Long-context stuffing when the whole corpus fits the window and is small/static — simpler, no index. Fine-tuning to teach style/format/behavior, not facts — fine-tuning bakes knowledge in stale and unverifiable; it's the wrong tool for "answer from current documents." Tool/SQL calling when the answer is a precise lookup or computation over structured data, not fuzzy text. Most production systems combine RAG (facts) + light fine-tuning or few-shot (format) + routing (§7) to the right one per query.
A chunk is the atomic unit of retrieval. Chunk wrong and the answer is split across two chunks that never co-retrieve, or buried in a 2000-token wall of noise. There is no universal best size; it's a recall/precision tradeoff against your content and embedding model's context window.
| Strategy | How | Use when | Cost |
|---|---|---|---|
| Fixed-size | N tokens, hard cut | Uniform prose, fast baseline | Splits mid-sentence/mid-table |
| Recursive | Split on ¶→sentence→word, respecting separators | General default (most corpora) | Slightly more compute |
| Semantic | Split where embedding similarity between adjacent sentences drops below a threshold | Topic-dense docs, mixed subjects | Embedding cost at index time |
| Structural | Split by Markdown heading / HTML section / AST function | Docs, code, anything with structure | Needs a parser per format |
Size + overlap (start here, then tune):
Metadata per chunk (index this, filter and cite on it): source_id, doc_title, section_heading, url, page, created_at, updated_at, version, author/acl. Filtering on metadata at retrieval (WHERE tenant_id = X AND updated_at > …) is often a bigger precision win than any embedding tweak.
Skills that do similar work, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.