Register and share your invite link to earn from video plays and referrals.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture ๆŠ•็จฟใฏๅ€‹ไบบใฎๆ„่ฆ‹ใงใ™ใ€‚
Joined May 2026
258 Following    220 Followers
# Practices for Embedding AI Agents in Software # Semantic Cache with No-Cache Zones ๐ŸŽฏ The Hook Paying for the same answer over and over? Semantic caching slashes costs, but cache the wrong thing and you'll serve stale stock prices or leak one user's data to another. ๐Ÿ”ฅ The Problem LLM calls are expensive, and when similar queries keep arriving, token costs pile up fast. Exact-match caching barely helps because of phrasing variations. But applying semantic caching indiscriminately creates serious risks: PII-dependent responses served to the wrong user, outdated real-time data, and safety-critical misjudgments replicated at scale. ๐Ÿ’ก The Pattern Define "No-Cache Zones" by policy before anything else. Carve out PII-dependent, real-time, and safety-critical categories as forbidden zones. Only within the remaining safe zones does vector-embedding similarity matching apply. Similarity thresholds are tiered by risk level -- 0.92 for low-risk FAQs, 0.95 for medium, 0.97 for high-risk. Cache TTLs include 10-20% jitter to prevent thundering herd effects from mass expiration. โœ… When to Use Use when: - 20%+ of queries are semantically similar repeats - Per-request LLM cost is non-trivial - No-cache zones can be clearly defined by policy Don't use when: - Nearly all queries depend on user-specific context with no reuse potential - Failure cost is uniformly high, making any cached response unacceptable โš ๏ธ Pitfalls - Changing the embedding model invalidates the entire cache. Record model versions in metadata and plan migration strategy upfront - Weak pattern matching in No-Cache Zone classification lets forbidden queries slip through. Combine rules with an intent classifier in production - Cache poisoning risk: attackers can inject bad responses. Set quality score thresholds on cache writes ๐Ÿ”ง Implementation Approach - Start with rule-based No-Cache Zone detection (pattern matching + metadata flags), then add an intent classifier in production to handle phrasing variations - Set similarity thresholds per risk level, raising them as failure cost increases (starting points: 0.92 low-risk, 0.95 medium, 0.97 high-risk) - For medium-risk zones, add a lightweight revalidation step that verifies cache hits before serving - Record embedding model version in cache metadata and design a migration strategy (gradual re-embedding or flush) for model updates - Add jitter (10-20% random spread) to cache TTLs to prevent thundering herd effects from mass expiration #AIAgents# #SoftwareArchitecture#
Show more