llm-rag-retrieval-internals

llm-rag-retrieval-internals is a skill for Claude Code, Codex from j4flmao/agent-skills. It costs 168 tokens per session (2,295 once invoked), scanned A, original, MIT.

A guide to building retrieval-augmented generation systems, which let an AI find relevant information from a collection before producing an answer. It covers vector indexes, including graph-based and compressed search methods.

In plain words
What is it for?
Designing vector databases and search indexes for systems that retrieve relevant documents or data before generating responses.
Why use it?
It explains how to organize and search large collections of embedded text so retrieval can be designed around speed, space use, and result quality.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Designing vector databases and search indexes for systems that retrieve relevant documents or data before generating responses.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/j4flmao/agent-skills/rag-architecture
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add j4flmao/agent-skills --skill rag-architecture
Clone the repo
git clone --depth 1 https://github.com/j4flmao/agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for llm-rag-retrieval-internals

README.md
[![agentmods](https://agentmods.dev/badge/skills/j4flmao/agent-skills/rag-architecture/github.svg)](https://agentmods.dev/skills/j4flmao/agent-skills/rag-architecture)
Your own site
<a href="https://agentmods.dev/skills/j4flmao/agent-skills/rag-architecture"><img src="https://agentmods.dev/badge/skills/j4flmao/agent-skills/rag-architecture/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for llm-rag-retrieval-internals

Your own site · 80×15
<a href="https://agentmods.dev/skills/j4flmao/agent-skills/rag-architecture"><img src="https://agentmods.dev/badge/skills/j4flmao/agent-skills/rag-architecture.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 168 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,295 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00168 $0.02295
Opus 5.5 $0.00067 $0.00918
Sonnet 5.5 $0.00034 $0.00459
Haiku 4.5 $0.00017 $0.00230

Measured today against content hash f8f87cd6a5fd, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

llm-rag-retrieval-internals scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/ai/llm-engineering/rag-architecture/SKILL.md · 155 lines

How it starts

The opening of the file, as written. The whole thing — 155 lines — stays where its author put it; the contents beside it link to each section on GitHub.

RAG Retrieval Internals

Purpose

Retrieval quality caps RAG quality: the generator cannot use a passage that was never retrieved. This skill explains how approximate nearest neighbour (ANN) indexes trade recall for speed and memory, how to tune them, and how to build the repo-standard pipeline: hybrid retrieval (dense + BM25), fusion, cross-encoder reranking, and measured end-to-end evaluation.

Agent Protocol

Trigger

"HNSW", "IVF", "product quantization", "efSearch", "nprobe", "ANN recall", "hybrid search", "reciprocal rank fusion", "reranker", "Self-RAG", "DSPy".

Input Context

  • Corpus size (vectors), embedding dimension, update rate.
  • Latency SLO, memory budget, required recall@k.
  • Current pipeline and failure examples (missed passages, wrong answers).

Output Artifact

Index choice and parameters, hybrid/rerank pipeline, evaluation plan with retrieval and answer metrics.

Response Format

Corpus: {N} vectors × {d} dims  Memory budget: {GB}
Index: {HNSW|IVF-Flat|IVF-PQ|flat} params: {M, efConstruction, efSearch | nlist, nprobe, m, nbits}
Hybrid: dense top-{k1} + BM25 top-{k2} -> RRF(k=60) -> rerank top-{n}
Metrics: recall@{k} vs exact, nDCG@{n}, answer faithfulness

Completion Criteria

  • ANN recall measured against exact (flat) search on a sample.
  • Hybrid retrieval and reranking in place (repo rule).
  • Chunking is structure-aware or parent-child, not blind fixed-size (repo rule).
  • Labeled eval set for retrieval and generation.

Index Families

Index Memory Build Query Updates Use when
Flat (exact) N·d·4 B None O(N·d) Trivial < ~100k vectors, ground truth
HNSW Vectors + graph (~M·2 links/node at layer 0) Slow-ish Sub-linear, empirically ~log N hops Inserts OK, deletes awkward Default for low-latency, high recall in RAM
IVF-Flat Vectors + centroids k-means training Scans nprobe/nlist of data Needs retraining on drift Large corpora, batch updates
IVF-PQ m·nbits/8 bytes per vector Training Fast table lookups (ADC) Retrain on drift Billion-scale, memory-bound
DiskANN-style Graph on SSD Slow Few SSD reads Varies Larger than RAM

Read the full file on GitHub · 155 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today Changed · +99 lines · +168 tokens per session f8f87cd6a5fd
  2. 1mo ago First seen · 56 lines · 0 tokens per session scan A 816bcd328fa9

Subscribe to this mod's changes

llm-rag-retrieval-internals is a skill published in the GitHub repository j4flmao/agent-skills (34 stars, last pushed today), licensed MIT. It adds 168 tokens to every session and 2,295 once invoked, about $0.0007 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

rag-expert

Design retrieval-augmented generation systems: chunking, embeddings, vector and hybrid search, reranking, grounding and evaluation. Use when the user mentions RAG, retrieval, semantic search, embeddings, vector databases, pgvector, Chroma, Qdrant, Pinecone, chunking or reranking, wants an assistant answering over…

personamanagmentlayer/pcl · 97 tokens

vector-databases

Vector database engineering covering Pinecone, Weaviate, Chroma, Qdrant, pgvector, and FAISS — including embedding pipeline design, HNSW index parameter tuning, hybrid dense+sparse (BM25) search, metadata filtering, namespace and tenant sharding, and RAG retrieval patterns for production knowledge systems.

LuuOW/meridian-mcp · 71 tokens

rag

Use when building grounded Q&A over your own corpus — chunk, retrieve hybrid, rerank, ground, cite chunk ids, refuse when the sources fall short — or when the right document is retrieved but the answer is still wrong, invented, or unmeasured. NOT operating the store itself — collection schema, HNSW efsearch…

ericrisco/rsc-harness · 79 tokens

faiss

Facebook's library for efficient similarity search and clustering of dense vectors. Supports billions of vectors, GPU acceleration, and various index types (Flat, IVF, HNSW). Use for fast k-NN search, large-scale vector retrieval, or when you need pure similarity search without metadata. Best for high-performance…

OpenLAIR/dr-claw · 66 tokens

faiss

Facebook's library for efficient similarity search and clustering of dense vectors. Supports billions of vectors, GPU acceleration, and various index types (Flat, IVF, HNSW). Use for fast k-NN search, large-scale vector retrieval, or when you need pure similarity search without metadata. Best for high-performance…

Orchestra-Research/AI-Research-SKILLs · 66 tokens

rag-retrieval-audit

Diagnose missing evidence in a RAG pipeline with labeled queries, chunk/trace inspection, Recall@K/MRR/nDCG, and stage-isolated failure taxonomy. Use when retrieval looks fine but answers fail, or when index/chunk/filter/rerank changes need before/after proof.

alivirgo/Major-AI-Skills · 66 tokens