Intermediate2h14m

Semantic Caching for AI Agents

Instructors: Tyler Hutcherson, Iliya Zhechev

Redis logo

Earn an accomplishment with PRO · Updated Nov 27, 2025

  • Intermediate
  • 2h14m
  • 7 Video Lessons
  • 4 Code Examples
  • 1 Graded Assignment PRO
  • Earn an accomplishment with PRO
  • Updated Nov 27, 2025
  • Instructors: Tyler Hutcherson, Iliya Zhechev
  • RedisRedis
  • Learn more aboutMembership PRO Plan

What you'll learn

  • Understand how semantic caching reduces inference cost and latency by reusing model responses based on meaning instead of exact text.

  • Evaluate cache performance with metrics like hit rate, precision, and latency, and enhance it using techniques such as cross-encoders and LLM validation.

  • Build a faster AI agent by integrating semantic caching, minimize redundant calls, and deliver faster responses as the cache warms up.

Course recap

PRO

This course teaches how to build and optimize semantic caching systems for AI agents to reduce latency and cost. Unlike exact-match caches, semantic caches match queries by meaning using embeddings and vector search, returning cached responses for semantically similar (not identical) queries.

Concept map

Concepts in Semantic Caching for AI Agents and the courses that connect to themSemantic Caching for AI AgentsSemantic Caching for AI A…Semantic cachingEmbeddingsThreshold tuningCross-encoder rerankingLLM validationFuzzy matchingEvaluation metricsRetrieval Augmented GenerationRetrieval Augmented Gener…Prompt Compression and Query OptimizationPrompt Compression and Qu…Vector Databases and Embeddings ApplicationsVector Databases and Embe…Advanced Retrieval for AIAI Code ReviewConcepts in Semantic Caching for AI Agents and the courses that connect to themSemantic Caching for AI AgentsSemantic Cachin…Semantic cachingEmbeddingsThreshold tuningCross-encoder rerankingCross-encoder r…LLM validationFuzzy matchingEvaluation metricsEvaluation metr…

Key concepts

  • Semantic cachingCaching LLM responses indexed by query embeddings; returning cached results for semantically similar queries
  • EmbeddingsVector representations used to measure query similarity for cache matching
  • Threshold tuningFinding optimal distance threshold that maximizes F1 score (precision-recall balance)
  • Cross-encoder rerankingUsing models like ModernBERT to rescore cache hits for higher precision
  • LLM validationUsing a cheaper LLM to verify if a cache hit truly matches the query
  • Fuzzy matchingEdit-distance-based string matching for catching typos before semantic search
  • Evaluation metricsPrecision, recall, F1, cache hit rate for measuring cache effectiveness

Lesson highlights

  1. 1.Introduction — Why semantic caching matters for AI agents; cost and latency benefits
  2. 2.Basic Semantic Cache — Building a cache with embeddings and vector search
  3. 3.Cache Evaluation — Measuring precision, recall, F1 score, and cache hit rate
  4. 4.Enhancing Cache Effectiveness — Threshold sweep, cross-encoder reranking, LLM validation, fuzzy matching
  5. 5.Caching for AI Agents — Integrating semantic cache into an agent pipeline
  6. 6.Advanced Patterns — Multi-level caching, cache invalidation strategies
  7. 7.Conclusion

About this course

Join our new short course, Semantic Caching for AI Agents! Learn from Tyler Hutcherson, Applied AI Engineering Lead, and Iliya Zhechev, Senior Research Engineer at Redis.

In this course, you’ll build a semantic cache that makes your AI agents faster and more cost-effective by recognizing when different questions mean the same thing. For example, when someone asks “How do I get a refund?” and another asks “I want my money back,” your cache will reuse the answer instead of making another API call, reducing the need for redundant model calls.

In detail, you’ll learn to:

  • Build your first semantic cache from scratch – Build a working cache to see how each component works, then implement it using Redis’ open source tools.
  • Measure cache effectiveness with key metrics – Track cache hit rate, precision, recall, and latency to understand your cache’s real impact.
  • Enhance cache accuracy with advanced techniques – Use threshold tuning, cross-encoders, LLM validation, and fuzzy matching to make your cache more effective.
  • Build a fast AI agent with semantic caching – Integrate semantic caching into an AI agent that reuses results, skips redundant work, and gets faster over time.

Start building AI agents that respond faster and cost less to run.

Who should join?

Developers and ML engineers familiar with Python, embeddings, and basic LLM applications who want to optimize their AI systems’ latency and cost. Experience with basic caching concepts is helpful but not required.

Course Outline

7 Lessons・4 Code Examples
Unlock certificates

Elevate your learning experience with Pro

Upgrade to Pro and gain unlimited accomplishments on your resume

Learn More

Instructors

Tyler Hutcherson

Tyler Hutcherson

Applied AI Engineering, Manager at Redis

Iliya Zhechev

Iliya Zhechev

Senior Research Engineer at Redis

Course access is free for a limited time during the DeepLearning.AI learning platform beta!

Want to learn more about Generative AI?

Keep learning with updates on curated AI news, courses, and events, as well as Andrew’s thoughts from DeepLearning.AI!