23 Daily — According to entrepreneur.com, the author built Rune Score, a sports analytics chatbot, during this year’s World Cup. While it appears simple externally, internally it functions as a distributed system managing real-time sports data freshness, user query variations, extraction reliability, LLM call costs, streaming, memory, fallbacks, and security. The author shares two key AI techniques to ensure tools run quickly, cost-effectively, and retain accurate knowledge—applicable broadly to AI products.
Redis Caching Improves Performance and Cost Efficiency
The first technique introduced is Redis, an open-source in-memory data store widely used as a database, cache, and message broker. The author implemented a Redis cache with a simple labeling rule: identical requests map to the same key, such as the football match "Argentina vs Spain." As documented on LinkedIn, without caching, one fresh extraction and analysis could consume up to 23,000 input tokens; with caching hitting the same key, this reduces to about 5,000 tokens, lowering the cost by 4.5 times.
However, Redis caching uses exact matches, so differing user phrasings like "FC Barcelona vs Real Madrid" versus "Barça – Madrid" are treated as distinct requests, potentially causing duplicate computation.
RAG Technique Adds Flexibility and Memory to Caching
To address this, the author employed Retrieval-Augmented Generation (RAG), which uses semantic embeddings to search a broader knowledge base instead of exact text matching. Google's documentation states that closer objects in embedding space indicate greater semantic similarity. This allows retrieval of past answers even when queries are phrased differently.
The author highlights that the main bottleneck of RAG systems is input data quality—the classic “garbage in, garbage out” principle. The system combines exact keyword matches, semantic search, and recency into a unified ranking to enhance relevance.
Experiments showed RAG retrieval reduces token usage from 20,000 to 8,000—a 60% reduction. Though this is less economical and slightly slower than the 80% reduction from Redis cache hits, it provides better tolerance for phrasing variation and a reusable architecture beyond single products.
Editor's take: Combining Redis and RAG Provides Balanced Flexibility and Efficiency for AI Applications
The author views Redis and RAG not as competing choices but as sequential steps. First, building a fast, inexpensive Redis cache to learn real user demands, then investing in RAG for cases where caching structurally falls short. This approach allows balancing cost and performance with quick rollbacks if metrics underperform. For entrepreneurs, adopting such staged optimization strategies can help develop efficient, durable AI tools.