Skip to content

< CollectionsStack

All the RAGs.

Every way to build retrieval-augmented generation, one method a section: from the plain pipeline through HyDE, RAG-Fusion, CRAG, RAPTOR and GraphRAG, to the projects that build whole systems.

22 sections · 35 problems · 7 projects

0 of 42 done

Start Next: 01 Build a Document Chunker

Fig. 1. The query is a beam. Cosine similarity is the angle between it and each document: the ones it lights up most are the top five the model reads.

Section 01

The plain pipeline

0 of 5

Chunk, embed, retrieve the nearest, answer from what came back (Lewis et al., 2020).

  1. 01Build a Document Chunkerimplement · easy
  2. 02Generate Embeddings with Hugging Faceimplement · medium
  3. 03Calculate Embedding Similarityimplement · easy
  4. 04Build Top-K Semantic Searchimplement · easy
  5. 05Build Your First RAG Pipelineharness · medium

Section 03

Reranking

0 of 2

Retrieve wide, then let a model that reads the question order the shortlist.

  1. 09Rerank the Retrieved Chunksimplement · medium
  2. 10Rerank With a Model That Understands the Questionimplement · medium

Section 04

Rewrite the query

0 of 1

Search with what the user meant, not what they typed.

  1. 11Rewrite the Query Before You Searchimplement · medium

Section 05

HyDE

0 of 1

Embed a hypothetical answer instead of the question: it lands near real answers (Gao et al., 2022).

  1. 12Search With the Answer You Hope to Findimplement · medium

Section 06

RAG-Fusion

0 of 1

Ask the question several ways, search each, and fuse the rankings by reciprocal rank.

  1. 13Ask Four Ways, Fuse the Rankingsimplement · medium

Section 07

Filters and self-query

0 of 2

Narrow by metadata first; let the model write the filter, and check it against the schema.

  1. 14Filter by Metadata Before You Rankimplement · medium
  2. 15Check the Filter the Model Wroteimplement · medium

Section 08

Small-to-big

0 of 1

Match on a sentence, return the section around it.

  1. 16Search Small, Return Bigimplement · medium

Section 09

Semantic chunking

0 of 1

Cut where the meaning changes, not every n tokens.

  1. 17Cut Where the Meaning Changesimplement · medium

Section 10

Contextual retrieval

0 of 1

Write each chunk's context onto it before indexing (Anthropic, 2024).

  1. 18Tell Each Chunk Where It Came Fromimplement · medium

Section 11

Late interaction

0 of 1

A vector per token, scored by MaxSim (Khattab and Zaharia, ColBERT, 2020).

  1. 19Late Interaction: Score Every Tokenimplement · medium

Section 12

Multi-hop

0 of 1

A question that needs two documents needs two searches.

  1. 20Answer the Question That Needs Two Documentsimplement · hard

Section 13

Self-RAG

0 of 2

Retrieve only when it helps, and check each claim against its passage (Asai et al., 2023).

  1. 21Know When Not to Retrieveimplement · medium
  2. 22Check Every Sentence Has a Sourceimplement · medium

Section 14

Corrective RAG

0 of 1

Grade what came back: keep it, refine it, or throw it away and search the web (Yan et al., 2024).

  1. 23Grade the Retrieval, Then Correct Itimplement · medium

Section 15

Agentic RAG

0 of 1

Give retrieval to the model as a tool and let it search until it has enough.

  1. 24Hand Retrieval to the Model as a Toolimplement · medium

Section 16

RAPTOR

0 of 1

Cluster and summarise chunks into a tree, and search every level at once (Sarthi et al., 2024).

  1. 25Build a RAPTOR Tree and Search It Collapsedimplement · medium

Section 17

GraphRAG

0 of 1

Build an entity graph, summarise its communities, and answer the global question map-reduce (Edge et al., 2024).

  1. 26GraphRAG: Merge the Graph, Answer the Global Questionimplement · medium

Section 18

Long context instead

0 of 3

When it fits, or nearly fits, read it all, and put the answer where the model looks.

  1. 27Put the Answer Where the Model Will Read Itimplement · medium
  2. 28Answer Over a Context That Does Not Fitimplement · hard
  3. 29Answer From a Repo That Does Not Fitimplement · hard

Section 19

Grounding

0 of 3

Cite a source for every claim, settle disagreements, and say so when nothing was found.

  1. 30Answer With Citations, or Say You Can'timplement · medium
  2. 31Decide When Two Documents Disagreeimplement · medium
  3. 32Make the Model Admit It Doesn't Knowimplement · hard

Section 20

A hostile document

0 of 1

A retrieved page that gives orders is data, not instructions.

  1. 33Ignore the Instructions Hidden in Your Documentsdebug · hard

Section 21

Measure it

0 of 2

Score the retrieval against labels, and the answer against its context without them.

  1. 34Measure Retrieval with Recall@k and MRRimplement · medium
  2. 35Judge a RAG Answer Without an Answer Keyimplement · medium

Section 22

Build it

0 of 7

Whole RAG systems on real models, built with the libraries a team uses: faiss, BM25, networkx.

  1. 36rag-systemproject
  2. 37rag-tuningproject
  3. 38corrective-ragproject
  4. 39graphragproject
  5. 40jev-ragproject
  6. 41catalog-searchproject
  7. 42research-agentproject
All collections