rag-pipeline
Skill11 starsChanged 6 months agoMITView on GitHub
Use when building retrieval-augmented generation. Covers chunking strategy, embedding choice, vector stores, hybrid + reranking retrieval, prompt assembly, and evaluating retrieval and answer quality.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- Red-empty-potato/ai-agent-skillstheir own version, first seen Aug 29, 2026
- brightdata/skillstheir own version, first seen Jun 25, 2026
- Sir-chawakorn/sanook-clitheir own version, first seen Jun 21, 2026
- yiweiwan/skillstheir own version, first seen May 12, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- brightdata/skills★ 263same name
- Sir-chawakorn/sanook-cli★ 9same name
- yiweiwan/skills★ 1same name
- Red-empty-potato/ai-agent-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository14 other files it gives its agents.
- data-cleaningSkill
- experiment-trackingSkill
- exploratory-data-analysisSkill
- feature-engineeringSkill
- hyperparameter-tuningSkill
- imbalanced-dataSkill
- llm-finetuningSkill
- ml-debuggingSkill
- model-evaluationSkill
- model-servingSkill
- pandas-patternsSkill
- pytorch-training-loopSkill
- reproducible-mlSkill
- sklearn-pipelinesSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
Start at ~500-1000 tokens with ~10-15% overlap.
- Distinctive: line 30
Prefer semantic/structural boundaries (headings, paragraphs) over fixed char counts.
- Distinctive: line 31
Keep metadata (source, title, section, URL) on every chunk for citations and filtering.
- Distinctive: line 65
Keep a fixed eval set; track scores via experiment-tracking as you tune chunking/k.
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
RAG Pipeline
Overview
RAG grounds an LLM in your data by retrieving relevant context at query time. Most RAG quality problems are retrieval problems, not generation problems — if the right chunk isn't retrieved, no prompt can save the answer. Optimize retrieval first.
When to use
- The model must answer over private/large/changing documents.
- You need citations and reduced hallucination.
- Fine-tuning is overkill or data changes too often.
Pipeline stages
- Ingest & chunk documents.
- Embed chunks → vector store.
- Retrieve (dense + sparse) for a query.
- Rerank top candidates.
- Assemble prompt with context + citations.
- Generate and evaluate.
Chunking
- Start at ~500-1000 tokens with ~10-15% overlap.
- Prefer semantic/structural boundaries (headings, paragraphs) over fixed char counts.
- Keep metadata (source, title, section, URL) on every chunk for citations and filtering.
Embeddings & store
- Choose an embedding model by your domain + the MTEB leaderboard; match it at query and index time.
- Normalize vectors; use cosine similarity.
- Vector stores: pgvector (already have Postgres), Qdrant/Weaviate/Milvos (scale), FAISS (local/offline).
Hybrid retrieval + reranking (the biggest quality lever)
# 1. Dense (semantic) + 2. Sparse (BM25 keyword) -> union
dense_hits = vstore.search(embed(query), k=20)
sparse_hits = bm25.search(query, k=20)
candidates = dedupe(dense_hits + sparse_hits)
# 3. Cross-encoder rerank for precision
from sentence_transformers import CrossEncoder
reranker = CrossEncoder("cross-encoder/ms-marco-MiniLM-L-6-v2")
ranked = sorted(candidates,
key=lambda c: reranker.predict([(query, c.text)]),
reverse=True)[:5]Prompt assembly
- Insert only the top-k reranked chunks; respect the context window.
- Instruct: "Answer only from the context; if it's not there, say you don't know."
- Require inline citations to chunk metadata so answers are auditable.
Evaluation (measure both halves)
- Retrieval: recall@k, MRR, hit-rate on a labeled query→chunk set.
- Answer: faithfulness/groundedness, answer-relevance, context-precision (e.g., RAGAS).
- Keep a fixed eval set; track scores via experiment-tracking as you tune chunking/k.
Pitfalls
- Dense-only retrieval misses exact keywords/IDs — add BM25.
- Chunks too large dilute relevance; too small lose context.
- Mismatched embedding models at index vs query time.
- No reranker → low precision context → confident wrong answers.
- No retrieval eval → you tune blind.
Hand-off
A retriever + generator with a measured retrieval/answer score that model-serving exposes behind an API.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

