Skip to content
Skills Library
AI & agents · Building & coding

rag-expert

/rag-expert

Expert Retrieval-Augmented Generation: chunking, embeddings, vector/hybrid search, reranking, and grounded answers. Trigger keywords: RAG, retrieval, embeddings, vector database, chunking, reranking, hybrid search, BM25, grounding, citations, hallucination, context window, recall. Use to build or debug RAG pipelines and improve answer quality/faithfulness.

Licence
MIT
Last repository change
31.05.2026

Assessment and security

98/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene13 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 31.05.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Expert Retrieval-Augmented Generation: chunking, embeddings, vector/hybrid search, reranking, and grounded answers. Trigger keywords: RAG, retrieval, embeddings, vector database, chunking, reranking, hybrid search, BM25, grounding, citations, hallucination, context window, recall. Use to build or debug RAG pipelines and improve answer quality/faithfulness.

Original author description

Expert Retrieval-Augmented Generation: chunking, embeddings, vector/hybrid search, reranking, and grounded answers. Trigger keywords: RAG, retrieval, embeddings, vector database, chunking, reranking, hybrid search, BM25, grounding, citations, hallucination, context window, recall. Use to build or debug RAG pipelines and improve answer quality/faithfulness.

How it works

  1. When to Use
  2. When NOT to Use
  3. Core Principles
  4. Decision Guide
  5. Common Mistakes
  6. Examples
  7. See Also
Original SKILL.md headings · 78 lines, 616 words
SKILL.md preview
---
name: rag-expert
description: "Expert Retrieval-Augmented Generation: chunking, embeddings, vector/hybrid search, reranking, and grounded answers. Trigger keywords: RAG, retrieval, embeddings, vector database, chunking, reranking, hybrid search, BM25, grounding, citations, hallucination, context window, recall. Use to build or debug RAG pipelines and improve answer quality/faithfulness."
---

# RAG Engineering Expert

> Garbage retrieval in, hallucination out. Answer quality is bounded by what you retrieve, so fix retrieval before touching the prompt. Measure retrieval and generation separately.

## When to Use
- Building a RAG / "chat with your docs" / knowledge-assistant system.
- Tuning chunking, embeddings, retrieval, hybrid search, or reranking.
- Poor answers: missing context, wrong/irrelevant chunks, hallucinations, no citations.
- Choosing a vector store or designing metadata/filtering.

## When NOT to Use
- Prompt wording/format only → `prompt-engineering-expert`.
- Training/fine-tuning a model → `deep-learning-expert`.
- Eval harness/regression design → `llm-testing-expert`.
- Serving infra/API shape → `api-design-expert`.

## Core Principles

### 1. Ingestion & chunking
- Chunk on **semantic boundaries** (headings, paragraphs, code blocks), not fixed byte counts. Start ~256–512 tokens with ~10–15% overlap; tune per corpus.
- Preserve structure: keep tables/code intact, prepend section/title context to each chunk. Attach metadata (source, title, section, URL, timestamp, ACL) and a stable chunk ID for citations and filtering.

### 2. Retrieval quality (the highest-leverage area)
- Use a strong, task-matched embedding model; **query and document embeddings must come from the same model/version**. Re-index when you change models.
- **Hybrid search**: combine dense vectors with keyword/BM25 and fuse (e.g., RRF). Pure vector search misses exact terms — error codes, names, IDs, acronyms.
- Add a **cross-encoder reranker** over the top ~20 candidates and keep the top ~3–5. This is usually the biggest single quality win.
- Apply metadata filters (tenant, recency, doc type, ACL) — and enforce access control at retrieval, never just in the prompt.

### 3. Generation & grounding
- Pass only the reranked chunks that fit a sensible context budget (more is not better — it dilutes and raises cost/latency). Mark each with a source id.
- Instruct the model to answer **only** from context, **cite** sources, and say "I don't know" when context is insufficient. Return citations to the user for verifiability.

### 4. Evaluate & iterate
- Measure retrieval (recall@k, MRR, hit-rate) and generation (faithfulness/groundedness, answer relevance) **separately** on a labeled set. Low recall → fix chunking/retrieval/reranking; high recall but bad answers → fix the prompt/context budget.

## Decision Guide
| Symptom | Likely fix |
|---------|-----------|
| Right doc never retrieved | better embeddings, hybrid search, smaller/structured chunks |
| Retrieved but answer ignores it | reranker, fewer/cleaner chunks, stronger grounding prompt |
| Misses exact codes/names | add keyword/BM25 (hybrid) |
| Confident but wrong | enforce "answer only from context" + citations + "I don't know" |
| Slow/expensive | fewer chunks, cache embeddings, smaller reranker, pre-filter |

## Common Mistakes
- **Fixed-size character chunking** that splits sentences/tables → semantic chunking + overlap.
- **Mismatched query/doc embedding models** → silently poor recall.
- **Vector-only search** → misses exact-match terms; go hybrid.
- **No reranker** → top-k is noisy; cross-encoder rerank.
- **Stuffing 50 chunks into context** → dilution, cost, lost-in-the-middle; retrieve more, send few.
- **No citations / no "I don't know" path** → unverifiable, hallucination-prone.
- **ACL only in the prompt** → data leakage; filter at retrieval.

## Examples

**Retrieve → hybrid → rerank → grounded prompt**
```python
dense = store.search(embed(query), top_k=20, filter={"tenant": tid, "acl": user.groups})
sparse = bm25.search(query, top_k=20)
candidates = rrf_fuse(dense, sparse)                 # reciprocal-rank fusion
ranked = reranker.rank(query, dedupe(candidates))[:5]  # cross-encoder

context = "\n\n".join(f"[{i+1}] {c.text}\n(source: {c.meta['title']})"
                      for i, c in enumerate(ranked))
prompt = (
    "Answer using ONLY the context. Cite sources as [n]. "
    "If the answer is not in the context, say you don't know.\n\n"
    f"Context:\n{context}\n\nQuestion: {query}"
)
```

## See Also
- `prompt-engineering-expert` — structuring the grounded generation prompt.
- `llm-testing-expert` — measuring faithfulness and retrieval metrics.
- `sql-expert` — metadata filtering / `pgvector` storage.
- `api-design-expert` — streaming retrieval/answer endpoints.

Versions

RepositoryScoreLicence
This page · miaoge-ge/coding-agent-skills98MIT
personamanagmentlayer/pcl100Apache-2.0

Database snapshot: 13.11.2026 · package version 571f742e5e63 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90rag-systems
    Design retrieval-augmented generation pipelines—chunking, embeddings, retrieval, reranking, grounding, and evaluation. Use when building or improving doc Q&A, code search agents, or knowledge bases. Triggers: "RAG", "vector search", "embeddings", "retrieval", "knowledge base".
  • 100rag-architect
    Designs and implements production-grade RAG systems by chunking documents, generating embeddings, configuring vector stores, building hybrid search pipelines, applying reranking, and evaluating retrieval quality. Use when building RAG systems, vector databases, or…
  • 100rag-pipeline-designer
    Designs end-to-end retrieval-augmented generation (RAG) systems by making principled choices for chunking, embeddings, vector indexing, retrieval, reranking, prompt assembly, and offline evaluation. Use this skill when the user wants to build or improve a RAG pipeline, asks…
  • 100rag-architect
    Designs and implements production-grade RAG systems by chunking documents, generating embeddings, configuring vector stores, building hybrid search pipelines, applying reranking, and evaluating retrieval quality. Use when building RAG systems, vector databases, or…
  • 100rag-systems
    Designs, builds and debugs retrieval-augmented generation (RAG) - ingestion and parsing, chunking, embeddings, hybrid search with reranking, access control at retrieval time, grounded answers with citations, and retrieval and answer evaluation. Use when building search or Q&A…
  • 100rag-skills
    Use this skill when building, debugging, or improving Retrieval-Augmented Generation systems, including chunking, vector database selection, hybrid search, reranking, multimodal RAG, code documentation RAG, retrieval latency, and production RAG architecture.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.