1 of 48

Welcome to 6.S093!

Memory and RAG

January 23rd, 2026

Eduardo Baena / Konstantina Yaneva

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

2 of 48

About Me

  • Eduardo Baena
  • Researcher in AI for Space Wireless Infrastructure
  • Sundai Hacker
  • Philabs Co Founder

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

3 of 48

The Dream

Imagine your ideal SM AI Agent that…

  • Writes amazing SM posts
  • Replies to comments
  • Remembers what work and what it didn’t
  • Learns and improves over time

Image created with Nano Banana

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

4 of 48

Objective: Reality

Image created with Nano Banana

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

5 of 48

Why can’t we just retrain?

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

6 of 48

Why can’t we just retrain?

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

7 of 48

Context Engineering (CE)

CE is the deliberate design of everything that enters the LLM's context window to achieve desired behavior

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

8 of 48

RAG: A Context Engineering Technique

Retrieval-Augmented Generation (RAG) is one specific technique within CE

The analogy

  • Without RAG: Student takes exam from memory only
  • With RAG: Student can consult notes

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

9 of 48

RAG: A Context Engineering Technique

Retrieval-Augmented Generation (RAG) is one specific technique within CE

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

10 of 48

What is an Embedding?

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

11 of 48

What is an Embedding?

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

12 of 48

Embedding Space

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

13 of 48

Embedding Space

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

14 of 48

RAG: Simple breakdown

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

15 of 48

What is a Vector Database?

A vector database stores embeddings and enables similarity search

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

16 of 48

What is a Vector Database?

A vector database stores embeddings and enables similarity search

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

17 of 48

Indexing: Why It Matters

Problem: Comparing query to ALL vectors is slow: O(n)

Solution: Indexing organizes vectors for faster search: O(log n)

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

18 of 48

Indexing: Why It Matters

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

19 of 48

Similarity Metrics: How to Compare?

Three main ways to measure (semantic) similarity

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

20 of 48

Similarity Metrics: How to Compare?

Three main ways to measure (semantic) similarity

Start with cosine similarity it's the most common and works well for text.

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

21 of 48

Metadata Filtering

Metadata allows filtering results by attributes:

Example query: Find ML posts with ≥50 likes from last month

  • Filter by metadata: likes >= 50 AND date > '2024-12-01'
  • Then rank by semantic similarity to ML

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

22 of 48

Hands On: Vector Database Options

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

23 of 48

The Complete RAG Pipeline

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

24 of 48

Step 1: Setup Database and Store Documents

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

25 of 48

Step 2: Index Documents

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

26 of 48

Step 3: Search by Similarity

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

27 of 48

Step 4: Build Prompt with Retrieved Context

This is the Augment step: injecting retrieved docs into the prompt

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

28 of 48

Step 5: Generate with LLM

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

29 of 48

Welcome to RAG World

BASIC RAG CONCEPTS THAT YOU SHOULD KNOW

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

30 of 48

Chunking

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

31 of 48

Chunking

Bad chunking example:

  • Document: The meeting is on Tuesday at 3pm in Room 101.
  • Chunk 1: The meeting is on Tuesday
  • Chunk 2: at 3pm in Room 101 

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

32 of 48

Chunking Strategies

https://gustavo-espindola.medium.com/chunk-division-and-overlap-understanding-the-process-ade7eae1b2bd

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

33 of 48

Chunking for Social Media Posts

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

34 of 48

Precision and Recall: Trade-off

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

35 of 48

Precision and Recall: When to Prioritize

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

36 of 48

Keywords VS Embeddings

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

37 of 48

Hybrid Search: Best of Both Worlds

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

38 of 48

Hybrid Search: Best of Both Worlds

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

39 of 48

RAG vs Memory: What's the Difference?

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

40 of 48

Memory Extension 1: Outcome-Aware Retrieval

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

41 of 48

Memory Extension 2: Human-in-the-Loop (HITL)

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

42 of 48

Memory Extension 3: Temporal Evolution

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

43 of 48

RAG Challenges

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

44 of 48

SoA: Infinite Context?

RLM @ MIT

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

45 of 48

Key Takeaways

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

46 of 48

Key Takeaways

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

47 of 48

RAG & Memory

Questions?

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club

48 of 48

Now: lunch break!

Sundai Club Team

January, 2025

Mini test for today's lecture.

Please fill in to get the attendance!��https://forms.gle/PAYNjtQUnm1Pbzxz8

MIT 6.S093 How to ship almost anything with AI

iap.sundai.club

sundai_club