Français
Applied AI · Intermediate 🟡 · Session 4
📝 Trainer's guide
← Back to course 📄 Markdown source

Trainer’s Guide — Session 4 (Intermediate level)

RAG: give memory to the model

Program: Applied AI — Yann Isola Duration: 2 hours Audience: professionals who have followed sessions 1 to 3 (embeddings, context window, prompting) Source module: Module 3, part 1


1. Educational objectives

At the end of the session, each participant should be able to:

  1. Explain why the knowledge of an LLM (Large Language Model) is limited: frozen at the cut-off date, public only, stored in a compressed manner and with losses in the weights of the model.
  2. Describe the principle of RAG (Retrieval-Augmented Generation): transform each question into an “open book exam”.
  3. Draw the two pipelines: ingestion (offline) and query (online), with their respective stages.
  4. Make chunking decisions: chunk size, overlap, structure cutting, entire tables.
  5. Diagnose a RAG failure by separating retrieval errors from generation errors.
  6. Select and evaluate a robust intervention—multi-query, HyDE, reranking, or an evidence gate—without ignoring latency, cost, or privacy.

2. Prerequisites and materials

Element Detail
Participant prerequisites Session 1 (embeddings: meaning becomes geometry), Session 2-3 (context, prompting)
Training material Video projector, session slides, interactive web page webpage/index.html (works offline)
Participant materials Laptop recommended for exercises 2 and 3 (paper possible)
Documents to print Worksheet, quiz, and six rotating exit tickets

Pre-session check: open webpage/index.html; exercise the pipeline simulator, chunking visualizer, and robust-RAG cascade. No internet connection is required.


3. Timed course (120 minutes)

Block A — The problem: a frozen memory (0:00 → 0:20, 20 min)

Time Activity Slides
0:00–0:05 Home + express reminder Session 1: “meaning becomes geometry” (embeddings) 1–3
0:05–0:15 The three limits of the memory of an LLM 4–7
0:15–0:20 Mini-demo: question about a fictitious internal fact → the model cannot know 8

Trainer notes:

  1. Fixed: knowledge stops on the training cutoff date (knowledge cutoff). Anything later does not exist for the model.
  2. Public: the model was trained on public data. Your internal documents, contracts, procedures, tickets — never seen before.
  3. Lossy: even public knowledge is stored with loss in the model weights. Analogy: the model has “read” Wikipedia, but it cannot recite it word for word, like you after reading a book ten years ago.

Block B — The principle of RAG and the two pipelines (0:20 → 0:55, 35 min)

Time Activity Slides
0:20–0:30 Definition of RAG + overview of both pipelines 9–11
0:30–0:40 Ingestion pipeline (offline): slice → vectorize → index 12–14
0:40–0:50 Query pipeline (inline): vectorize the question → retrieve k chunks → assemble the prompt → generate 15–17
0:50–0:55 Interactive demo: pipeline simulator on web page 17

Trainer notes:

INGESTION (offline, once)
Documents → Chunking → Embedding each chunk → Vector index

QUERY (online, for each question)
Question → Question embedding → Retrieve the k closest chunks
        → Assemble the prompt (instruction + chunks + question) → Generate
  1. The question becomes a vector.
  2. The index returns 4 chunks: two extracts from the internal regulations, an extract from the 2025 teleworking agreement, an extract from the onboarding guide.
  3. The assembled prompt: “Answer only from the following context. [4 chunks] Question: …”
  4. The model generates a response citing the telework agreement.

Break (0:55 → 1:05, 10 min)


Block C — Chunking decisions and metadata (1:05 → 1:30, 25 min)

Time Activity Slides
1:05–1:15 Chunking: size, overlap, structure, tables 18–21
1:15–1:20 Metadata: source, section, date, access level 22
1:20–1:30 Exercise 1 in pairs: strategy for cutting up a real document

Trainer notes:

  1. Size: typically 300 to 800 tokens ⚠ (reminder: 1 token ≈ 0.75 words in English, a little less in French ⚠). Too small = the chunk loses its context (“he” — who is that, “he”?). Too big = the chunk mixes several subjects and its embedding becomes a fuzzy average.
  2. Overlap: make the chunks overlap by 10 to 20% ⚠ so as not to cut information right at the border.
  3. Split by structure: titles, sections, paragraphs — never in the middle of a sentence. A chunk = ideally a unit of meaning.
  4. Whole tables: never cut a table in two. A table row without its header is unreadable (example: “42 | 15% | yes” — what are we talking about?).

Block D — Hybrid search, robust RAG, and failure modes (1:30 → 1:50, 20 min)

Time Activity Slides
1:30–1:35 Hybrid search: vectors + keywords 23–24
1:35–1:44 Robust-RAG intervention ladder + interactive cascade 25–29
1:44–1:49 Diagnosis, evidence gate, and refusal 30–33
1:49–1:50 Decide: answer, reformulate, or refuse 33

Trainer notes:


Block E — Quiz, summary, and exit tickets (1:50 → 2:00, 10 min)

Time Activity
1:50–1:57 Quiz: 11 multiple-choice questions
1:57–1:59 Summary: six ideas to retain
1:59–2:00 Exit tickets

Six ideas to retain:

  1. LLM memory is frozen, public, and lossy; RAG creates an open-book exam.
  2. Two pipelines: offline ingestion and online query.
  3. Chunking is the first lever: overlap, structural boundaries, and whole tables.
  4. Hybrid search combines vectors for meaning with keywords for exact strings.
  5. Robust RAG means reformulate → retrieve broadly → rerank → gate on evidence.
  6. When RAG fails, inspect the chunks first, then answer or refuse.

4. Exit tickets (six questions)

Give each learner one rotating question. Answers should fit in one or two sentences.

Ticket 1. Name the three limits of a language model’s knowledge without RAG. Expected: frozen at the training cutoff, limited to training data, and stored lossily in weights.

Ticket 2. How do ingestion and query pipelines differ? Expected: ingestion prepares the index offline; the query pipeline runs for each user request.

Ticket 3. Why should a table not be split during chunking? Expected: a row without its headers loses meaning.

Ticket 4. A RAG answer is wrong. What is your first diagnostic action? Expected: inspect the retrieved chunks and confirm the expected document exists in the index.

Ticket 5. Why combine vector and keyword search? Expected: vectors capture meaning; lexical search retrieves exact codes and strings.

Ticket 6. Why is a positive model self-assessment insufficient to open the evidence gate? Expected: the same model can repeat its error; require verifiable citations and thresholds calibrated on an external evaluation set.


5. Anticipated difficulties and responses

Difficulty Response
“Why not put every document in the prompt?” Context is limited; extra text adds noise, latency, and cost. Retrieval selects relevant passages.
Confusing chunk and query embeddings They must use the same embedding model and geometric space.
“Fine-tuning does the same thing” Fine-tuning changes behavior; it is not an updatable factual store with citations and access control.
“More stages always mean better RAG” False. Each stage must fix a measured failure while respecting latency, cost, and privacy budgets.
“The model says its answer is grounded” Self-assessment is not external evidence. Require citations, verification, and an annotated evaluation set.
“RAG eliminates hallucinations” It can reduce them; retrieval and generation can still fail.

6. Extensions