Building Smarter AI Memory Systems: Lessons from a World Cup Chatbot
During this year’s World Cup, I developed Rune Score, a sports analytics chatbot designed to deliver quick and accurate insights. At first glance, Rune Score seems like a straightforward chatbot, but beneath the surface lies a sophisticated distributed system. It manages challenges such as maintaining fresh sports data, handling user rephrasing, preventing extraction failures, controlling LLM call costs, streaming data, managing memory, implementing fallbacks, and ensuring security. The insights gained from building Rune Score apply broadly to AI products that must balance speed, cost-efficiency, and accuracy.
Understanding Redis and RAG: Two Essential Technologies
Before diving deeper, it’s important to clarify two key technologies that power AI memory systems but are often unfamiliar outside tech circles. Redis is an open-source, in-memory data structure store widely used as a database, cache, message broker, and streaming engine. In AI applications, Redis functions as a rapid cache, storing one exact answer under a single precise label.
In contrast, RAG (retrieval-augmented generation) is a technique defined by AWS as augmenting large language models (LLMs) with external data sources, such as internal corporate documents. Rather than relying on exact labels, RAG searches a broader knowledge base based on semantic meaning rather than literal wording. Redis offers precision and low cost but is inflexible, while RAG provides flexibility and durability at a higher operational expense.
Why I Didn’t Start with RAG
When building Rune Score, my initial approach was not to implement a vector database with RAG but to leverage Redis as a simple cache. The cache operated under a straightforward rule: identical user requests receive identical keys, such as “Argentina vs. Spain” in a football matchup context. This approach yielded immediate cost and speed benefits.
As documented in my LinkedIn article on Rune Score, “without the cache, a fresh extraction and subsequent analysis could consume up to 23,000 input tokens, including scraped content, context, and history. With a cache hit on the same key, this number dropped to roughly 5,000 tokens.” This represents a 4.5-fold reduction in the most computationally expensive part of the pipeline, significantly reducing costs.
Reducing AI costs often comes down to minimizing repeated, unnecessary computations. For example, if multiple users ask the same question within a given timeframe, rerunning the entire expensive processing pipeline each time would waste resources and inflate costs.
Where Redis Breaks Down
Despite its advantages, Redis’s rigidity becomes a limitation in real-world use. People rarely phrase questions identically. For instance, one user might ask about “FC Barcelona vs Real Madrid,” while another might say “Barça – Madrid.” A strict Redis cache treats these as distinct queries, triggering duplicate work, missed answers, or redundant pipeline executions.
This is where RAG techniques shine, leveraging embeddings to understand semantic similarity. As Google Cloud explains in their documentation on vector search, “the closer objects are in embedding space, the more semantically similar they are; greater distances indicate higher semantic dissimilarity.” By searching by meaning rather than exact wording, a RAG-powered knowledge base can retrieve relevant answers even when queries are phrased differently.
The Part That Actually Breaks Quality
A crucial lesson, regardless of the technology, is that the primary bottleneck in RAG systems is not the retrieval mechanism itself but the quality of the input data. This aligns with the classic computing principle of garbage in, garbage out (GIGO): the quality of output depends entirely on the quality of input.
In Rune Score’s pipeline, any shortcuts taken in content extraction led to visibly degraded analysis downstream. Similarly, relying on a single relevance score to rank search results is fragile. Redis’s own engineering blog highlights that combining multiple retrieval methods—exact keyword matches, semantic meaning, and recency—into a unified ranking significantly improves the relevance of top results compared to any single method alone (Redis Engineering Blog).
RAG Costs More, and That’s Fine
In my Rune Score experiments, RAG reduced token consumption from 20,000 to 8,000 tokens per request, a 60% saving. Although this is less economical and slightly slower than the 80% reduction achieved by exact Redis cache hits, the tradeoff is justified. RAG offers tolerance for natural language variability, maintains memory beyond cache expiration windows, and provides an extensible architecture reusable across multiple projects.
The Bottom Line
Redis and RAG are not competing but complementary technologies that should be employed sequentially. The best engineering approach is not the one that’s theoretically perfect from the start but the one that allows rapid rollback if real-world metrics don’t meet expectations. Building a cheap, fast cache first provides valuable insights into actual user behavior, enabling smarter investment in more sophisticated retrieval systems only for use cases that a simple cache cannot effectively handle.
