Start course

Week 1 · Day 4 of 10

Retrieval: answers from your own documents (RAG)

Students can index a company's own documents, answer questions grounded in them, cite the sources, and say so when the answer isn't there.

Robert introduces today: what you'll learn, what you'll build, and why it matters. About two minutes.
In pink: what day 4 adds to the app.
Day 4 adds Your documents to the student's app, which already has Your user, FastAPI app, Model, Typed JSON, Tools.
1LearnEmbeddings, retrieval and citations

Embeddings and similarity, chunking, Postgres with pgvector from Python, the retrieve-then-generate pattern, citations, and saying "I don't know" when the sources don't cover a question.

How it worksStep 1 of 5

How your app answers from your documents

  1. Chunks
Your documents are split into short passages.
Try it liveRuns on a real model

Try it live

Ask this course a question

Answers come only from this site's own content, found by embeddings and cited. Ask something the course doesn't cover and it should say it doesn't know.

Claude Haiku 5.5 through the AI Gateway
Check your understanding3 questions
  1. What does an embedding capture?

  2. Why split documents into chunks before indexing them?

  3. Retrieval finds nothing relevant to the question. What should the app do?

2BuildCited answers from your documents

Index a folder of documents, answer questions over them with citations, and refuse when the answer is not in the sources.

Done when: your app answers from your documents and shows where each answer came from.

3CapstoneLoad your real documents

Load your own real documents.

4HomeworkWrite 15 test questions

Write ten questions your documents should answer and five they shouldn't, with the right responses. They become tomorrow's test set.

For teachers: the day 4 teaching kit.