IESE AI Club
Memory
& RAG
What AI keeps, and how it finds the right page.
04
Rajas Bhagat
Where we are
Today: what the agent keeps and looks up.
The case
Your case: Pedala raises a €4M Series A
You are a summer associate at Fondo Norte.
Price sheet 2025superseded
Price sheet 2026current
Battery contractVoltCell
Customer surveyQ2 2026
Board minutes15 Sep 2026
Investor FAQlong, general
The data room. We open it after memory.
All fictional
The desk
The model only sees its desk.
The desk (context window) is small. The oldest pages fall off. After the chat, it is cleared.
The notebookPart 1 · Memory
Memory is the associate’s notebook
The desk is cleared after every chat. The notebook keeps what matters across chats.
MemoryPart 1 · Memory
Four kinds of memory
Skills from Thursday 02 are memory too: how we do things.
All fictional
Memory loopPart 1 · Memory
Write, store, recall, update or forget
Remember this: recall is a search. Part 2 is all about search.
Memory storesPart 1 · Memory
Where to keep the notebook
RisksPart 1 · Memory
Memory can go wrong
RuleAsk before you remember. Make forgetting easy.
Exercise 1Part 1 · Memory
Sort the memory cards
NoteKnowledge base = documents to search later. That is Part 2.
All fictional
The data roomPart 2 · RAG
It has never seen this data room.
The notebook holds what we learned. The data room holds what others wrote.
Two waysPart 2 · RAG
Two ways to fill the desk
RuleSmall data room: put it all on. Big data room: bring the right pages.
RAG in one linePart 2 · RAG
RAG: from closed book to open book
Retrieval-augmented generation (RAG): look it up, then answer.
Before anyone asksPart 2 · RAG
Cut the files into labelled pages
Prepare the pages (indexing). It happens once, before any question.
All fictional
Meaning mapPart 2 · RAG
Similar ideas sit close together
Meaning map (embeddings): the question lands, and the nearest pages win (top-k).
Exercise 2Part 2 · RAG
Closed book, then open book
| E1 | What does Pedala charge per month for the standard plan? |
| E2 | If Pedala ends the battery contract after six months, what does it cost? |
| E3 | Does Pedala own any patents? |
Attach six files. Ask again.
All fictional
Five stagesPart 2 · RAG
Five places RAG can go wrong
→
→
→
→
1 Indexing2 Pre-retrieval3 Retrieval4 Post-retrieval5 Generation
A bad cut loses the answer
Cut at the headings. Labels say which price sheet is current.
All fictional
1 Indexing2 Pre-retrieval3 Retrieval4 Post-retrieval5 Generation
Improve the question before you search
The contract never says “cancel”. Rewrite the question in its words (query rewrite).
1 Indexing2 Pre-retrieval3 Retrieval4 Post-retrieval5 Generation
Search by words and by meaning
Keyword search finds exact words. Meaning search finds ideas. Merge both (hybrid).
1 Indexing2 Pre-retrieval3 Retrieval4 Post-retrieval5 Generation
Pick the best pages for the desk
20 pages → best 3 (reranking) → only the useful lines (compression).
1 Indexing2 Pre-retrieval3 Retrieval4 Post-retrieval5 Generation
Answer only from the desk
Point to the page. “Not in the data room” is a correct answer.
Exercise 3Part 2 · RAG
Fix five questions in the RAG Lab
All fictional
AdvancedPart 3 · Together
RAG that checks its own work
Check the pages. If they are weak, search again.
Beyond RAGPart 3 · Together
From pages to a graph that learns
Step 4 is memory again: the notebook as a graph. Author’s view: Sosa (2025).
Context engineeringPart 3 · Together
Everything meets on one desk
Context engineering = deciding what goes on the desk, and what stays off it.
ClosePart 3 · Together
The desk is small.
Memory decides what we keep. RAG brings the right pages.
Next: Agent Orchestration, 5 Nov
Backuptechnique map
Five stages, every technique
| Stage | Question it answers | Techniques | Lab |
1 Indexing prepare the pages | How do we cut, label and store files so each page can be found? | Chunking (fixed, section, semantic, propositions) · chunk-size tests · contextual headers · Contextual Retrieval · metadata · question generation · hierarchical or graph index | L1, L2 |
2 Pre-retrieval improve the question | How do we turn the question into a better search? | Query rewrite · step-back · sub-questions · HyDE · routing | L3 |
3 Retrieval search | How do we find the candidate pages? | Meaning search (dense) · keyword search (BM25) · hybrid with reciprocal rank fusion · metadata filter · top-k · small-to-big | L3 |
4 Post-retrieval pick the best pages | Which pages go on the desk, in what order and size? | Rerank · compression · relevant segment extraction · neighbour chunks · ordering | L4 |
5 Generation answer from the pages | How does the model answer from the desk? | Context injection · cite and quote · abstain · support check | L5 |
Advanced modular, agentic | When to retrieve, how to check, how to improve? | Adaptive routing · Self-RAG · CRAG · agentic RAG · Graph RAG · feedback · RL · long context vs RAG · evaluation | — |
Backup
Big desk or good search?
PUT IT ALL ON · long contextSmall, stable data room
- Simple: nothing to build.
- Anthropic: under about 200,000 tokens, put it all in the prompt.
- With enough budget, long context beat RAG on average (Li et al. 2024).
BRING THE RIGHT PAGES · RAGBig, changing or permissioned
- RAG costs much less (Li et al. 2024).
- Models use the middle of a long context less well (Liu et al. 2023, older models).
- Many teams combine both (Self-Route).
BackupAnthropic, Sep 2024
Contextual Retrieval: fewer misses
Share of relevant pages missing from the top 20 (Anthropic’s own test sets).
Baseline5.7%
+ contextual embeddings3.7% · −35%
+ contextual BM252.9% · −49%
+ reranking1.9% · −67%
BackupGao et al. 2024
Where the stage names come from
NAIVE RAGIndexing → Retrieval → Generation
The basic pipeline.
ADVANCED RAG+ pre-retrieval, + post-retrieval
Improve the index and the question first. Rerank and compress after.
MODULAR RAGAdaptive and agentic
Routing, checks, loops, retrieval as a tool.
Our choiceWe show Indexing as its own stage because it runs before anyone asks. Pre-retrieval = the question side.
Backup
How the RAG Lab works
DATAThe six Pedala files
Fictional. Built into the page. No network, no account.
SEARCHA teaching simulation
Keyword scores plus a small synonym table that imitates meaning search.
VERDICTWhat reached the desk
Evidence on the desk ✓ · evidence missing ✗ · correctly said “not in the data room” ✓.
Sourceschecked 29 October 2026
Sources · RAG and graphs
Technique catalogue adapted from all-rag-techniques by Fareed Khan (MIT licence), via github.com/Shubhamsaboo/all-rag-techniques. Ideas adapted; no code copied.
Gao et al. 2024, RAG survey (stage names) · arxiv.org/abs/2312.10997
Sosa 2025, RAG, Graph RAG, Agentic Graphs, Agentic Learning Graphs (author’s comparison) · medium.com/@josefsosa
Lewis et al. 2020, Retrieval-Augmented Generation · arxiv.org/abs/2005.11401
Anthropic 2024, Contextual Retrieval · anthropic.com/news/contextual-retrieval
Cormack, Clarke, Büttcher 2009, Reciprocal Rank Fusion · cormack.uwaterloo.ca
Gao et al. 2022, HyDE · arxiv.org/abs/2212.10496
Zheng et al. 2023, Step-back prompting · arxiv.org/abs/2310.06117
Chen et al. 2023, Dense X Retrieval · arxiv.org/abs/2312.06648
Asai et al. 2023, Self-RAG · arxiv.org/abs/2310.11511
Yan et al. 2024, Corrective RAG · arxiv.org/abs/2401.15884
Liu et al. 2023, Lost in the Middle · arxiv.org/abs/2307.03172
Edge et al. 2024, GraphRAG · arxiv.org/abs/2404.16130 · github.com/microsoft/graphrag
Sarthi et al. 2024, RAPTOR · arxiv.org/abs/2401.18059
Li et al. 2024, RAG or long context, Self-Route · arxiv.org/abs/2407.16833
Anthropic 2024, Building effective agents · anthropic.com/engineering
Singh et al. 2025, Agentic RAG survey · arxiv.org/abs/2501.09136
Claude docs, Prompting best practices · platform.claude.com
Pinecone docs, Filter by metadata · docs.pinecone.io
LangChain, ParentDocumentRetriever · reference.langchain.com
Es et al. 2023, RAGAS · arxiv.org/abs/2309.15217 · metric docs
Barnett et al. 2024, Seven failure points · arxiv.org/abs/2401.05856
Sourceschecked 29 October 2026
Sources · Memory and products