Skip to content

Module 3: Activities

Carlos Lizarraga-Celaya edited this page Oct 1, 2026 · 14 revisions

Total Recall: Memory Architectures and Retrieval-Augmented Generation

a. Self-Check Prompts (~30 minutes)

Before moving on, answer the three prompts in a notes document or on a piece of paper. These won't be submitted or graded, they're meant to help you recall what you've learned. If you're unsure how to answer, revisit the relevant reading before continuing.

Prompt 1 - Parametric vs. Non-Parametric Memory

In your own words, explain the difference between parametric and non-parametric memory. Give one concrete example from a professional domain (healthcare, legal, education, etc.) where non-parametric memory would be essential.

Prompt 2 - Six-Stage RAG Pipeline

Name each of the six functional stages of a RAG pipeline with a brief description of what happens at each stage.

Prompt 3 — Conversational Memory Patterns

A debugging assistant runs sessions of 40 or more turns, and users often refer to decisions made 25 turns earlier. Which memory pattern (Buffer, Window, Summary, or Hybrid) would you choose? Name one detail that your choice might lose, and how you would detect that loss.

Prompt 4 — Retrieval Optimization

Your corpus contains the same policy paragraph copied into many documents, and answers keep citing that paragraph four times. Which retrieval setting would you change first, and which RAGAS metric would you expect to improve?

Prompt 5 - RAGAS Diagnostic Interpretation

Your RAG system scores high on context recall but low on faithfulness. Is the problem in retrieval, generation, or both? Identify the specific failure mode this indicates, and describe one remediation you would try first.

b. Guided Lab Exercise — A RAG Agent with Memory (~2 hrs)

PLATFORM SETUP — READ BEFORE STARTING
All lab work runs in Google Colab (free tier). You will need: (1) a Google account to access Colab; (2) access to two models: an embedding model, which turns text into vectors, and a language model, which writes the answers and also scores them in the RAGAS step. The default setup uses an OpenAI API key, which requires a small amount of prepaid credit (typically under US $2 for this module). The notebook also explains a free alternative using open-source models.

In this lab, you will build a retrieval-augmented agent: a LangChain agent, like the one you built in Module 2, whose main tool searches a collection of documents. You will then give it conversational memory so it can answer follow-up questions.

Open the lab notebook: Module-3-Lab.ipynb

Notebook Flow Summary

The notebook walks you through the six RAG stages and then adds memory, in five steps:

  1. Load documents with PyPDFLoader (Stage 1), keeping page-level metadata.
  2. Split and index the documents with RecursiveCharacterTextSplitter (Stage 2; chunk size is measured in characters), embed them (Stage 3), and store them in a Chroma vector store (Stage 4).
  3. Build a retrieval tool that returns the top k = 4 passages with their sources (Stage 5), and give it to a create_agent agent that writes grounded answers (Stage 6). Test it on the five evaluation queries.
  4. Extend to multiple documents by adding a second corpus, and observe how retrieval precision changes.
  5. Add conversational memory. Attach a checkpointer to the agent, ask a follow-up question that depends on an earlier turn (for example, "What about the second document?"), and record what the agent remembers. Then start a new thread_id and confirm that the memory does not carry over.

All detailed instructions, checks, and logging prompts are embedded in the notebook.

c. Hands-On Project: Retrieval Optimization Experiment (~1.75 hrs)

In this project, you will continue in the same notebook and run a controlled experiment on your RAG agent. You will change one setting at a time, keep everything else fixed, and measure the effect with RAGAS.

What to do

  1. Run 1 — Baseline: chunk_size = 256 characters, chunk_overlap = 25, similarity search, k = 4.
  2. Run 2 — Larger chunks: chunk_size = 512 characters; everything else as in Run 1.
  3. Run 3 — MMR retrieval: return to chunk_size = 256 and switch to MMR with lambda_mult = 0.5.
  4. Run 4 (optional) — Metadata filtering: baseline settings plus a filter that restricts retrieval to one source document.
  5. Score each run. The notebook computes four RAGAS scores — faithfulness, answer relevance, context precision, and context recall — on the same five-question test set, which includes reference answers.
  6. Complete the Experiment Log in the notebook: one row per run, with the setting you changed, the four RAGAS scores, the average number of input tokens per query, and one sentence explaining why the scores changed.
  7. Interpret the results for a non-technical stakeholder. In one paragraph, recommend a configuration and explain what the RAGAS scores mean in plain language.
WHAT TO SUBMIT
Add to GitHub: one .ipynb file containing the guided lab (Steps 1–5) and the project (Experiment Log and interpretation), with all cells executed and output visible. Filename: Module3_Lab_[YourName].ipynb.

d. Peer Discussion: RAG Corpus Design for Your Domain (~30 minutes)

Part 1: Discussion Post (~20 min)

Now that you have hands-on experience building and tuning a RAG pipeline, apply what you learned to your own domain. Post to the Module 3 Discussion Forum addressing the following:

Section 1 — Domain and Document Sources

Identify a specific domain where you would deploy a RAG system (your field of study, workplace, or a domain you're familiar with). List 2–3 document sources you would ingest into the knowledge base. For each source, specify: the document type (e.g., PDF reports, HTML documentation, spreadsheets, slide decks), approximate volume (number of documents or pages), and how frequently the content is updated.

Section 2 — Document Characteristics and Pipeline Challenges

Identify at least one characteristic of your documents that would require special handling in the RAG pipeline. Examples: dense tables or structured data that would be destroyed by naive text splitting; documents with headers/sections where semantic boundaries don't align with fixed character counts; mixed-format content (code + prose, or images with captions); domain-specific jargon that general-purpose embeddings may not represent well; multilingual content; legal or regulatory language where precise wording matters.

Explain how this characteristic would affect your chunking or retrieval strategy — referencing what you observed in your hands-on experiment.

Section 3 — Configuration Choices Informed by Your Experiment

Based on your experiment results, specify: (1) the chunking configuration you would start with and why; (2) the retrieval method (similarity search, MMR, or metadata-filtered) you would choose and what property of your corpus motivates that choice. Your justification must reference a specific observation from your experiment (e.g., "In Run 3, MMR improved scores on multi-faceted queries — my domain involves similar queries because...").

Part 2: Peer Reply (~10 min)

Reply to at least one classmate's post. Your reply must do one of the following:

  • Identify a chunking or retrieval risk: Based on the document characteristics they described, identify a specific failure mode their proposed configuration might encounter. Explain why that failure mode is likely given their corpus properties.
  • Suggest an alternative approach: Propose a different chunking strategy, retrieval method, or preprocessing step that could better handle one of their document characteristics. Explain the tradeoff your suggestion introduces.
WHAT TO SUBMIT
Discussion Initial Post: submitted in LMS Discussion thread. Addresses all three sections. Due before the reply deadline.
Peer Reply: substantive engagement (≥100 words) identifying a risk or suggesting an alternative. Due by the module deadline.

Created: 05/14/2026 (C. Lizárraga)
Updated: 09/30/2026 (M. Yung)

Clone this wiki locally