rag-pipeline

verified

8ef7de44-f749-4dc6-85a1-4a65e0d6a21d

Build a retrieval-augmented generation pipeline — chunking, indexing, retrieval, and grounded answer synthesis.

Metadata

Skill ID
8ef7de44-f749-4dc6-85a1-4a65e0d6a21d
Version
1
Owner
global
Tags
ragretrievalllmembeddingsaipipeline
Signature
verified
Integrity
OK
Content hash
13ea12ca81ec53e08b0d0d8e655bf7c750c76628f5f4eceb0a1478f8e110e436
Created
2026-08-05T18:29:01Z

Skill file

Raw skill file (markdown source)
# RAG: Retrieval-Augmented Generation

Use when an LLM should answer from your documents instead of its memorized
knowledge.

## Pipeline

```
documents -> chunk -> embed -> index
                                  |
query -> embed -> retrieve top-k -> prompt(generated) -> LLM -> grounded answer
```

## Chunking

- Split on semantic boundaries (headings, paragraphs), not fixed N-char blobs.
- Keep chunks ~200-500 words — enough context, not noise.
- Overlap slightly (10-20%) so a concept spanning a boundary isn't lost.

## Retrieval

- Retrieve top-k (5-10) by similarity, then re-rank if the corpus is large.
- Filter by metadata (scope, tenant, trust) *before* final ranking (Skill Vault
  filters scopes + trust tiers after similarity).

## Grounded generation prompt

Give the LLM only the retrieved passages + the question, and instruct it to
answer from the passages, citing them — and to say it doesn't know rather than
hallucinate.

## Pitfalls

- If retrieval returns irrelevant chunks, no prompt fixes it — fix chunking/index first.
- Don't stuff the entire source into context; that's not RAG, that's context-dumping.
- Measure retrieval quality (recall@k) separately from answer quality.

Attached files