Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 02 · AI · From a model to an app · about 18 min to read

Watch: Vector databases and RAG, end to end
▶ VideoPlay it as a journeyTutor comes with a plan

RAG (Retrieval-Augmented Generation)

RAG
RAG · Open board

The RAG board from the How LLMs Work track. It draws a question going out to a library before it ever reaches the model. This lesson is the story of a lawyer who skipped that step, and of the paper that had already shown what to do instead.

Before you start. You need Tokens & Embeddings, which turned any piece of text into a point in space, positioned so that two texts about the same thing land near each other: that nearness is the only machinery this lesson uses. Text is measured in tokens there, chunks of roughly three quarters of a word. You also need one fact from From Transformer to LLM: a model’s knowledge is baked into its dials during training and does not change afterwards.

Lesson 16 of 83 in AI

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • May 2023: the six cases that were not there
  • The closed-book exam: a machine answering from memory alone
  • May 2020: retrieval-augmented generation, a machine handed the page first
  • The swap: the knowledge sits in the vector store, not in the model
  • Vocabulary mismatch: the question and its answer share no words
  • The context window: the desk only fits a few dozen chunks
  • How big is a million paragraphs?
  • Checking a thousand instead of a million
  • What the full desk costs
  • The clerk’s search goes blind
  • The fixes the firm adds
  • When an answer comes back wrong
  • All of it in code

Terms it explains: How LLMs Work, closed-book exam, chunk, vector store, retrieval-augmented generation, vocabulary mismatch, context window, multiply-and-adds, HNSW, IVF, approximate nearest-neighbour, hybrid search, query rewriting, re-ranking, Metadata filters, Ordering, Citations, Retrieval hit-rate, Faithfulness, chunking strategy, cosine similarity, embedding, grounding, nearest-neighbour / ANN, pgvector/Pinecone/Chroma, RAG, retrieval hit-rate & faithfulness, top-k, vector database.

Lab

The returns desk cuts its policy into pieces and hands the model the best few. How big should a piece be, and how many should go in?

Drag How many words in each piece from 5 to 200 and watch Answers that arrived whole climb while the tokens grow.

Open The chunk size

Related papers

Review AI