Generative AI

Advanced Generative AI: Short- and Long-Term Memory with RAG and LangGraph

Design, measure and deploy an assistant's memory: the conversation, long-term memory for each customer and the company's knowledge with RAG. 20 labs with a local model, PostgreSQL with pgvector and Redis in Docker Compose, based on the official documentation.

Advanced · 25 hours · 20 lessons · Course language: Spanish and English

An advanced generative AI course devoted to memory. You check how the context window gets cut and measure the real cost of remembering: full history, trimming and summary, with tokens, times and the mistakes each one makes. You write structured and running summaries, use the state as working memory and store sessions in Redis that expire on their own. You build long-term memory with LangGraph's Store: you extract memories from conversations, consolidate them when the customer's data changes, tell semantic, episodic and procedural memory apart, write them in the hot path or in the background with a Redis queue, and forget them by relevance, expiration or the right to be forgotten. You set up the company's knowledge with RAG: idempotent ingestion, pgvector in depth (HNSW, filters, halfvec), hybrid search with PostgreSQL full text, EmbeddingGemma prompts, multi-query and reranking, all measured with a golden set. You bring the three memories together in a LangGraph assistant, add a semantic cache, evaluate with pytest and a judge model, and deploy a memory service and the complete assistant in Docker Compose. Every command is explained and every result is real. The lessons, quizzes and videos are in English; the lab project keeps its original Spanish names and Spanish sample data, and every lesson explains them. The first 3 lessons are free and include a video.

What you will learn

  • Measure and choose the short-term memory strategy by tokens, time and errors
  • Write summaries and working memories that don't lose data
  • Build long-term memory with the Store: extract, consolidate and forget
  • Design semantic, episodic and procedural memory, in the hot path or in the background
  • Tune pgvector: HNSW indexes, filters with iterative scans and halfvec
  • Improve retrieval with hybrid search, query rewriting and reranking, measured with a golden set
  • Combine conversation, customer memory and knowledge in a LangGraph assistant
  • Evaluate and deploy memory in production with pytest, a semantic cache and Docker Compose

Skills

Agent memory, Context management, LangGraph Store, Checkpointers, Redis, RAG, pgvector, Hybrid search, Reranking, Semantic cache, RAG evaluation, Docker Compose

Program

Module 1: An LLM's memory (free lessons)

The context window, checkpointers and the cost of remembering.

Project: A measured comparison of three memory strategies.

  1. An LLM's memory and your environment: A model that doesn't remember, the context window that gets cut without warning and the tokens of each turn.
  2. Short-term memory with checkpointers: Threads in PostgreSQL, conversations across processes, what's stored in SQL and how to delete it.
  3. The cost of remembering everything: Full history, trimming and summary, measured in tokens, time and correct answers.

Module 2: Advanced short-term memory

Summaries that don't lose data, working memory and sessions in Redis.

Project: A running summary in LangGraph and sessions that expire on their own.

  1. Summaries that don't lose data: Free and structured summaries, a running summary with RemoveMessage and trimming without breaking pairs.
  2. Working memory: Notes in the graph state and ContextEditingMiddleware, with their limits.
  3. Sessions in Redis: RedisSaver with expiration, a comparison with PostgreSQL and persistence after a restart.

Module 3: Long-term memory

The Store from the inside, extraction and consolidation, memory types, writing and forgetting.

Project: A memory worker with a Redis queue and the right to be forgotten.

  1. The Store from the inside: Namespaces, semantic search, filters and the tables and vectors in PostgreSQL.
  2. Extracting and consolidating memories: Memories with a schema from a conversation and decisions to add, update or delete.
  3. Semantic, episodic and procedural memory: Profiles, solved cases as examples and instructions the agent rewrites.
  4. Writing memories: hot path or background: An agent tool against a worker with Redis Streams, including its crash.
  5. Forgetting: Similarity, recency and importance, expiration with TTL and the right to be forgotten verified in SQL.

Module 4: RAG as knowledge memory

Ingestion, pgvector in depth, hybrid search, retrieval improvements and RAG with memory.

Project: An assistant that combines the three memories, with citations.

  1. Ingestion for RAG: Text splitters, idempotent ingestion with hashes and evaluation with a golden set.
  2. pgvector in depth: Exact search and HNSW, ef_search, filters with iterative scans and halfvec.
  3. Hybrid search: PostgreSQL full text in Spanish, Reciprocal Rank Fusion and exact codes.
  4. Improving retrieval: EmbeddingGemma prompts, context headers, multi-query and reranking, measured.
  5. RAG with memory in LangGraph: A source router, evidence grading, the customer profile and answers with citations.

Module 5: Memory in production

Semantic cache, evaluation and the memory service in Docker Compose.

Project: A quality suite and a memory service in containers.

  1. Semantic cache: redisvl in Redis, thresholds and false hits, times and answers per user.
  2. Evaluating memory: pytest for retrieval and memory, a validated judge model and a quality gate.
  3. The memory service in Docker Compose: An API, a worker with a consumer group, restarts and the right to be forgotten.

Module 6: Final project

Fibrandes's complete assistant, in Docker Compose.

Project: A support assistant with short- and long-term memory, RAG, a cache and the right to be forgotten.

  1. Final project: Fibrandes's assistant: The three memories, a semantic cache, ingestion and evaluation as tasks, and Docker Compose.

Prerequisites

  • Python with functions, classes and virtual environments
  • Having completed Intermediate LangGraph or knowing StateGraph, MessagesState and create_agent
  • Docker Desktop with at least 8 GB of memory (10 GB is better) and uv (lesson 1 sets up the environment)

Next courses

  • Advanced LangGraph: Agents in Production · Advanced · 25 hours
    Take your LangGraph agents to production: the runtime from the inside, durable execution, fault tolerance, multi-agents, custom middleware, guardrails, MCP, v3 streaming, Agent Server, Docker, security, observability and evaluation. 20 labs with a local model in Docker, based on the official documentation.
  • Coding Agents with Codex and Claude · Advanced · 25 hours
    Program with AI agents like a professional team: Claude Code, OpenAI Codex and your own agents with the Claude Agent SDK.

See all courses