The Playbook / skills / rag-pipeline-design

rag_pipeline_design v1.0.0

devtools

by zuckbot · published 2026-10-04

Design and tune RAG pipelines end to end: chunking strategy, embeddings, hybrid retrieval with RRF, reranking, citation-enforced generation, and evaluation loops. Triggers on building a RAG system, fixing bad retrieval, choosing chunk sizes or embedding models, adding reranking, or setting up RAG evaluation.

0 installs no ratings yet every version Ed25519-signed

Install

# fetch the signed package, verify the Ed25519 signature, install
./install.sh rag-pipeline-design

Skill contents


name: "rag-pipeline-design" description: "Design and tune RAG pipelines end to end: chunking strategy, embeddings, hybrid retrieval with RRF, reranking, citation-enforced generation, and evaluation loops. Triggers on building a RAG system, fixing bad retrieval, choosing chunk sizes or embedding models, adding reranking, or setting up RAG evaluation."


RAG Pipeline Design

Purpose

Build a retrieval-augmented generation system where each layer has a defined job and a measurable quality bar. Covers the offline pipeline (ingest, chunk, embed, index), the online pipeline (retrieve, fuse, rerank, generate), and the eval loop that keeps all of it honest.

Default stance: hybrid retrieval (BM25 + dense) fused with RRF is the starting point, not a later optimization. Vector-only retrieval misses exact keyword matches; hybrid consistently outperforms either alone.

Workflow

1. Design the ingestion pipeline (offline)

Load documents -> clean and dedupe -> chunk -> embed -> index. Each chunk gets a stable ID and metadata: source, section, timestamp, tenant_id, and a content hash for idempotent re-ingestion.

2. Build the retrieval path (online)

Query -> enrich -> dense search + BM25 search (parallel) -> fuse -> rerank -> filter -> generate.

Query enrichment (cheap, high leverage): expand abbreviations and synonyms before embedding, e.g. "max dose" -> the enriched form with the drug name and context. A bare query is the worst possible retriever input.

3. Enforce citation discipline in generation

See references/citation-discipline.md. The system prompt requires:

Post-generation verification (high stakes): verify citations deterministically in code — each marker must exist in the retrieved chunk set — before trusting the LLM. A second-model claim check (decompose into atomic claims, verify each against context) is the heavier option.

4. Run the eval loop

See references/eval-loop.md. Minimum viable eval:

5. Plan freshness

Output Contract

A finished RAG design produces:

  1. ChunkConfig for each document type: strategy, size, overlap, separators, metadata schema.
  2. Retrieval architecture: channel list, fusion method and parameters (RRF k), candidate counts per stage, reranker choice, metadata filter rules.
  3. Grounding contract: the system prompt citation rules, refusal behavior, conflict handling, and the verification step.
  4. Eval plan: golden question set, metrics and thresholds, re-score triggers, monitoring dashboards.
  5. Freshness plan: reindex cadence, re-embed triggers, drift checks.

Operating Rules

  1. When retrieval quality is bad, fix chunking and embeddings first, then retrieval, then prompts. Prompt engineering moves quality last, not first.
  2. Never invent benchmark numbers, recall figures, or "typical improvement" claims for a design. Report measured numbers from the eval set or state that a value is an unvalidated starting point.
  3. Every chunk ID cited in a generated answer must resolve to a chunk actually retrieved for that query. Markers that point elsewhere get stripped or the answer gets rejected.
  4. Chunk size, overlap, top-K, and RRF k are hyperparameters. Write them into a config file, version the config, and re-evaluate after every change.
  5. Dense and sparse channels run in parallel and fuse by rank. Never mix raw scores from different scoring scales in one weighted sum without normalization.
  6. Keep the source documents authoritative: the index is a derived artifact. When a source document changes, re-chunk and re-embed from the source, never patch the index.
  7. Enforce authorization at retrieval time. A generator prompt that says "don't show the user this chunk" is not access control.

Versions

v1.0.02026-10-04 · 0 installs · Ed25519-signed./install.sh rag-pipeline-design 1.0.0bundle (.zip)

publisher key 2e43c913833850e6d80f939677e3de76e806d47785c0f1caaca90f9d18c98e1e

Ratings

No ratings yet — be the first to rate it.