JustujuAI, layer by layer.Open in the interactive map

Retrieval-augmented generation (RAG)

Look up relevant documents first, then give them to the model to answer from.

Layer 7 · Orchestration & Tooling · Run time · Draft, awaiting expert review, reviewed 2026-09-28

Read first: How a model predicts the next token.

D1 · StoryFor young children and total beginners

When you're unsure of an answer, what do you do before replying?

If you ask a friend a question about your school, they might check the school website before answering.

RAG makes the AI look things up first instead of guessing from memory.

Like: Checking the website before answering.

D2 · PictureFor curious beginners

Documents are split into chunks and turned into vectors (embeddings) stored in an index.

At question time the question is embedded too; the closest chunks are retrieved, often combined with keyword search and re-ranked, and placed in the prompt.

The model answers from that context, ideally with citations. Quality depends mostly on retrieval: if the right chunk isn't found, the model can't use it.

Answering with retrieval

  1. Question
  2. Embed: to a vector
  3. Search: vector + keyword
  4. Re-rank: best chunks
  5. Prompt: chunks + question
  6. Answer: with citations

Like: An open-book exam.
Where it breaks: In an open-book exam you choose what to read. In RAG the model only sees what retrieval hands it, and it can still blend in its own, possibly wrong, memory.

D3 · PlayFor motivated learners

Before the model sees anything, retrieval decides what it reads. The documents are cut into chunks, every chunk is scored against the question, and only the top few are pasted into the prompt.

Here the score is simple word overlap, weighted so rare words count for more (TF-IDF). Real systems use embeddings, which match meaning rather than exact words, but the shape is the same: rank, cut, paste.

Change the chunk size and how many chunks are kept, then read the box at the bottom. That box is everything the model gets. If the answer is not in it, the model cannot give it.

Try the interactive version in the map.

Things to try

D5 · FrontierFor experts

Open problems: agentic retrieval where the model decides what to search, long-context models versus retrieval, measuring faithfulness to sources, and poisoning of indexed content.

Sources

  1. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (2020)
  2. Retrieval-Augmented Generation for Large Language Models: A Survey (2023-12-18)