Frontier Foundry

Retrieval-Augmented Generation

The Library · Context Engineering & Memory

Fetching relevant documents at question time and putting them in the prompt.

Also called: RAG, retrieval-augmented, retrieval augmented, vector database, vector search, hybrid search, reranker, reranking. In the glossary.

Retrieval-Augmented Generation is cooling this week (×0.14 against the eight weeks before). What is moving.

How it works, as a machineThe Records Office · pages

Follow one page from the filing hall to an answer that cites its source, in a county records office and its filing hall.

  1. Cut the page
  2. Stamp the section
  3. File it twice
  4. Ask and fuse the ranks
  5. Check the figures
Play Retrieval-Augmented Generation

Retrieval-Augmented Generation in plain words

Retrieval-augmented generation looks up relevant documents when a question arrives and places them in the prompt. The model then answers from that text and not from memory alone. It gives a model current and private facts without retraining, and the answer is only as good as what was fetched.

An analogy

An open-book exam with a librarian. The student has not memorised the shelves; for each question the librarian pulls a few pages and lays them on the desk. Hand over the wrong pages and even a strong student writes a confident wrong essay.

How Retrieval-Augmented Generation connects

10 typed relations in the knowledge graph

Builds on

  • Context Engineering: The ten chunks are what is put on the reader desk: the context.
  • Embeddings: The vector drawer is an embedding index; the same vectors serve search.

Built on by

  • Context Engineering: The card catalog is retrieval run as an agent loop: search, read, search again.
  • Deep Research Agents: Each searcher retrieves from an index and reads what comes back, over and over.
  • Embeddings: The pins nearest a question are the passages a retrieval-augmented answer is built from.
  • Fine-Tuning: Facts that change belong in retrieval, so the weights only carry behavior and format.
  • Knowledge Graphs: The walk is a retrieval path: vector search finds the seeds, the links do the rest.

Made possible by

  • Knowledge Graphs: Links between entities let retrieval follow a path where likeness alone finds nothing.

An alternative to

  • Fine-Tuning: A fact can be looked up when the question arrives, or trained into the weights beforehand.
  • Long Context: Put everything in the window, or fetch only what the question needs.

Often in the same sources

Embeddings, Long Context

See Retrieval-Augmented Generation in the knowledge graph

Who is behind Retrieval-Augmented Generation

people, labs, products and models

People

  • Jerry Liu (built): LlamaIndex: document parsing and retrieval pipelines for agents.

What the sources say

3 parts · 10 sources · updated 2026-11-27

Retrieval-augmented generation fetches relevant pieces of a document set at question time and puts them in front of the model. The sources describe a pipeline: documents are cut into chunks and filed by meaning and by exact words; a question fetches a short list, merged and reranked; the model answers from it and a check can refuse figures it cannot trace. Its limits are a short desk, a chunk size no one gets right for every query, and answers that can come from the wrong page.

The stacks: cut, label, file

Before any question arrives, the pages are cut into chunks, each chunk is labelled with where it came from, and each is filed twice: by meaning (a vector) and by exact words (BM25). What is cut and labelled here decides what can ever be fetched.

  1. The chunk cutter packs paragraphs into pieces of about 2,000 characters and never splits a table.
  2. The label stamp writes the rulebook, page and section path on each chunk so it can be cited and its section rebuilt.
  3. The index drawers file each chunk twice: as a dense vector for meaning and as a BM25 entry for exact words.
about 2,000 characters
Size a chunk is packed to before it is cut, in one rulebook assistant (reported by the builders) Nina Žižakić
around 4,000 chunks
Chunks in the index built from about 270 PDFs and 6,000 pages (reported by the builders) Nina Žižakić
512 characters, 64 overlap
Fixed chunking recipe described as a common best practice (reported by a talk) Abed Matini
up to 6x
Storage reduction from truncating an embedding from 768 to 128 dimensions (reported by the model maker) Google DeepMind
about 75 papers per second
Embedding speed of a 0.6B model on one L4 GPU in a 5,000-paper pilot (reported by the builders) Hugging Face
  • The indexing job packs paragraphs into chunks of about 2,000 characters and never splits a table across two chunks; section headers are found with regular expressions. Nina Žižakić
  • Chunks do not overlap, so a section is simply its chunks put back in order; every chunk carries a section path, used for citations and to fetch the whole section later. Nina Žižakić
  • Each chunk gets metadata: rulebook name, page, section path and chunk index, so a citation card can link to the PDF and a section or rulebook can be put back together. Nina Žižakić

When it breaksThe table that lost its rows. The first indexer took plain text from the PDF, which did not keep tables whole: a field spanning several rows came out misaligned, so the agent could fetch the wrong row or column, and fees are in tables. Nina Žižakić

Open questionIs there a right chunk size to fix at indexing time?

  • Yes: split at a fixed size such as 512 characters with a 64-character overlap and keep it. Abed Matini
  • No: the best size depends on the query, so index several sizes and merge; the oracle gap over any fixed size is 20 to 40 percent. Yuval Belfer

The search desk: fetch both lists, fuse

A question reaches the desk. Two drawers answer: the vector drawer by meaning, the keyword drawer by exact words. Their ranked lists are merged and re-ordered, and only a few chunks go to the reading desk.

  1. The search desk asks both drawers in one call, fuses the two top-50 lists by rank and keeps the top 10.
top 50 + top 50 to 30 to 10
Candidates per list, kept after fusion, and given to the agent (reported by the builders) Eleonora Drykina
92% to 97%
Hit rate of hybrid search over dense only on 63 retrieval questions (reported by the builders) Eleonora Drykina
+47% predicted, +17% measured
Combined improvement of three retrieval techniques predicted from isolated runs against the improvement measured together, over 450 configurations (reported by the authors) Hugging Face
about 10 million tokens
Corpus size around which BM25 overtakes a file-system agent in a 450-fold scaling study (reported by the authors) Hugging Face
4x cost, equal accuracy
Vector-only search against agentic search on about 20 bug tasks in one code repository (reported by the presenter) Jess Wang
more than 110,000 papers
Papers whose embeddings a hybrid search service keeps (reported by the builders) Hugging Face
  • Dense search is good for meaning, but rulebook codes, message names and exact identifiers look like noise to an embedding; BM25 is the mirror image: exact tokens work, paraphrases do not. Eleonora Drykina
  • Both searches run in one Qdrant call and are merged with reciprocal rank fusion, which needs no calibration of the scores of the two lists. Eleonora Drykina
  • For a product or medical assistant exact keywords and numbers matter more than the nearest meaning, so semantic and keyword search are used together. Abed Matini

When it breaksTwenty-six searches, no answer. A vector-only coding agent returned chunk after chunk and searched again; in one run it made 26 searches and still could not piece together how three functions interacted across a file. The calls piled up into about four times the cost. Jess Wang

Open questionDoes an agent that greps files replace the ranked index?

  • On about 20 bug tasks agentic search matched vector search in accuracy at a quarter of the cost, because lone chunks lacked the surrounding logic. Jess Wang
  • At scale ranking wins: BM25 overtakes a file-system agent around 10 million tokens, and agentic reasoning works best after ranked discovery, not in place of it. Hugging Face

The reading desk: read, widen, check

The reader gets the few chunks on its desk and writes an answer from them. When they do not hold the answer it asks for a whole section; a last check refuses any figure that matches no registered source.

  1. The reader answers from the ten chunks, and asks for a whole section when they do not hold it.
  2. The citation stamp refuses any number in the answer that matches no registered source.
  3. The answer card shows the answer with the rulebook, section and page of each source, so the reader can open it.
2 to 4 calls
Search calls most questions need; the prompt asks the agent to reconsider before the sixth (reported by the builders) Eleonora Drykina
38 seconds
Median time to answer, the cost of letting the agent search more than once (reported by the builders) Eleonora Drykina
10,981 citations
Citations a verifying filter refused in the builders evaluations (reported by the speaker) Vinoo Ganesh
less powerful
What strict citation checking costs: the platform answers less than people want, because a figure it cannot trace is refused or stripped (the speaker's own words) Vinoo Ganesh
about 3,810 wrong numbers
Share of those refused citations that were plainly wrong numbers (reported by the speaker) Vinoo Ganesh
more than 30 million documents
SEC filings processed so that figures can be registered as citations (reported by the speaker) Vinoo Ganesh
  • Every answer must cite the exact rulebook, section and page, and the assistant must not answer from the model general knowledge of other payment schemes. Nina Žižakić
  • The agent has four tools from narrow to wide: search chunks, retrieve a whole section in order of section path, retrieve a whole small rulebook, and list the rulebooks. Eleonora Drykina
  • A rulebook above roughly 100k tokens is not dumped into the context: the tool hands back a section list, and a section name that does not match returns the available names so the agent retries. Eleonora Drykina

When it breaksThe wrong source, the wrong number. Attaching sources after the fact does not help when retrieval pulled the wrong source (a blog with a wild price), or the right source and the wrong number: a 17 in a filing may be millions, billions or yen, or an earlier year. Vinoo Ganesh

Sources

10 in all

More in Context Engineering & Memory

The Library: the whole area
  • Context EngineeringDeciding what goes into a model's limited context window, when, and in what form.
  • Long ContextModels that read very long inputs (hundreds of thousands to millions of tokens).
  • EmbeddingsVectors that place similar meanings near each other, used for search and clustering.
  • Agent MemoryLetting agents keep and recall information across sessions.
  • Prompt EngineeringWriting instructions and examples that steer a model's behavior.
  • Prompt CachingReusing computation for repeated prompt prefixes to cut cost and latency.
  • Knowledge GraphsStoring facts as linked entities so agents can traverse relationships.