rag-systems
Skill0 starsChanged 2 months agoMITView on GitHub
Build retrieval that works: chunking strategy, embeddings, hybrid search, reranking and retrieval evals. Use when building RAG pipelines, chunking, embeddings, or vector search.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- reddygopalkrishna/developer-agent-skillstheir own version, first seen Nov 8, 2026
- KMaruthi2002/universal-llm-skillstheir own version, first seen Oct 25, 2026
- Mushfiqur-Rahman-Robin/coding-rulestheir own version, first seen Oct 13, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- reddygopalkrishna/developer-agent-skills★ 8same name
- KMaruthi2002/universal-llm-skills★ 1same name
- Mushfiqur-Rahman-Robin/coding-rules★ 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 repository16 other files it gives its agents.
- agent-architectureSkill
- agent-identitySkill
- agent-orchestrationSkill
- agent-safetySkill
- automation-reviewSkill
- composioSkill
- create-skillSkill
- document-generationSkill
- mcp-builderSkill
- n8nSkill
- prompt-engineeringSkill
- prompt-librarySkill
- report-automationSkill
- skill-linterSkill
- trigger-devSkill
- workflow-mappingSkill
The file
We split this skill into the rules it gives an agent
1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
1
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 46
Place the most critical retrieved passages at the very beginning and very end of the context window to combat the "Lost in the Middle" LLM …
“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-systems
Core Philosophy
Retrieval-Augmented Generation (RAG) is not simply splitting a PDF into 500-character chunks, embedding them with OpenAI, and dumping them into a vector database. Naive RAG produces fragmented context, keyword mismatch, and hallucinated answers. Production-grade RAG is a precision information retrieval pipeline that combines semantic chunking, hybrid search (dense embeddings + sparse BM25), cross-encoder reranking, and rigorous automated evaluation using the RAG Triad.
4-Step Production RAG Engineering Pipeline
Step 1: Chunking Strategy & Document Decomposition
- Avoid Arbitrary Fixed-Length Splitting:
- Fixed character counts cut mid-sentence, slicing critical context in half.
- High-Precision Chunking Archetypes:
- Semantic / Markdown Chunking: Split strictly along document boundaries (
#,##,###, code blocks). - Recursive Character Chunking with Overlap: Split by paragraph (`
- Semantic / Markdown Chunking: Split strictly along document boundaries (
), then sentence (
`), with 15–20% token overlap to preserve transitional context.
- Parent-Document / Small-to-Big Retrieval: Embed small chunks (128 tokens) for precise vector matching, but return the larger parent chunk (1,024 tokens) to the LLM context for generation.
Step 2: Hybrid Retrieval (Dense Vector + Sparse BM25)
- The Vector Blindspot:
- Dense embeddings excel at conceptual meaning, but fail completely on exact keywords, part numbers, error codes, and acronyms (e.g.
CVE-2024-38077orAWS-ERR-403).
- Dense embeddings excel at conceptual meaning, but fail completely on exact keywords, part numbers, error codes, and acronyms (e.g.
- Hybrid Search Architecture:
- Query both a dense vector index (e.g.
text-embedding-3-largeorbge-large-en) and a sparse keyword index (BM25 in OpenSearch / Elasticsearch).
- Query both a dense vector index (e.g.
- Reciprocal Rank Fusion (RRF):
- Combine dense and sparse results using RRF:
$$RRF(d) = \sum_{m \in M} rac{1}{k + r_m(d)}$$
- Where $k pprox 60$, and $r_m(d)$ is the rank of document $d$ in retrieval system $m$.
- Combine dense and sparse results using RRF:
$$RRF(d) = \sum_{m \in M} rac{1}{k + r_m(d)}$$
Step 3: Cross-Encoder Reranking
- The Retrieval-to-Context Funnel:
- Retrieve top 50 candidates via hybrid search.
- Pass candidates through a specialized Cross-Encoder Reranker (e.g. Cohere Rerank v3 or
bge-reranker-large). - Select strictly the top 3–5 highest-scoring passages to feed into LLM prompt context.
- Context Window Placement:
- Place the most critical retrieved passages at the very beginning and very end of the context window to combat the "Lost in the Middle" LLM attention phenomenon.
Step 4: The RAG Triad Evaluation & Continuous Benchmarking
- The 3 RAG Metrics (Ragas Framework):
- Context Relevance: Are the retrieved chunks strictly relevant to the query without extraneous noise?
- Groundedness (Faithfulness): Is the LLM's answer mathematically derivable exclusively from the retrieved context without hallucination?
- Answer Relevance: Does the generated response directly answer the user's initial question?
- Target Benchmark:
- Maintain Groundedness $\ge 95%$ and Context Relevance $\ge 85%$ across your production golden evaluation dataset.
Deliverable Format: RAG Architecture Specification (RAG-PIPELINE-SPEC.md)
# RAG System Architecture Specification: [Knowledge Base Name]
## 1. Document Ingestion & Chunking
- **Source Formats**: Markdown documentation, OpenAPI specs, PDF whitepapers
- **Chunking Strategy**: Markdown header-aware chunking (Max 512 tokens, 64 token overlap)
- **Parent-Document Retrieval**: Enabled (Parent chunk size: 2,048 tokens)
## 2. Embedding & Retrieval Topology
- **Embedding Model**: `text-embedding-3-large` (1536 dimensions)
- **Vector Database**: Qdrant / pgvector
- **Sparse Index**: BM25 enabled on text payload
- **Fusion Method**: Reciprocal Rank Fusion (RRF, k=60)
## 3. Reranking & Context Assembly
- **Reranker Model**: `cohere-rerank-v3` / `bge-reranker-large`
- **Funnel Mechanics**: Top 50 retrieved -> Reranked -> Top 5 injected into LLM
- **Attention Optimization**: Interleaved context ordering (Best passages first and last)
## 4. Evaluation Benchmarks (RAG Triad)
- **Evaluation Dataset**: 100 domain Q&A pairs
- **Current Groundedness Score**: 96.2%
- **Current Context Relevance**: 88.4%
- **Current Answer Relevance**: 94.1%Worked Example: Developer Documentation RAG
- Problem: Engineers asked for specific API endpoint parameters; standard vector search retrieved broad tutorial text instead of the parameter table.
- Solution: Implemented BM25 hybrid search with parent-document retrieval and Cohere Rerank.
- Outcome: Parameter accuracy jumped from 61% to 98%; developer support inquiries for documentation dropped 34%.
Verification Checklist
- Chunking respects semantic boundaries (headers/paragraphs) rather than arbitrary character splits.
- Hybrid retrieval combines dense vector embeddings with sparse BM25 search.
- Cross-encoder reranker filters the top candidate pool down to the top 3–5 passages.
- System evaluated using the RAG Triad (Context Relevance, Groundedness, Answer Relevance).
- Prompt explicitly instructs the model to cite sources and refuse to answer if context is absent.
Anti-Patterns
- Vector-Only Naivete: Expecting vector embeddings to match exact error codes or SKU strings without BM25.
- Context Stuffing: Dumping 40 raw retrieved chunks into the prompt, degrading LLM reasoning and ballooning costs.
- Zero Hallucination Audits: Shipping RAG into production without measuring groundedness against a golden test suite.
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.

