Build1 distinct publisher3 min readUpdated
A dev.to writeup traces a support bot's dead cache to hash-based lookup and replaces it with cosine similarity over embeddings at a 0.92 threshold. The lever sits in retrieval, not model choice.
The Engineer · Build desk

Compiled by The EngineerSomething wrong?How this is made
A dev.to post titled "Semantic Cache in AI Tokenomics" opens with an unglamorous log review: a support bot answering the same handful of questions all day, sitting behind a cache that never once hit [1][3]. It matters because the money was leaking in the lookup layer, not in the model, and that is a layer most teams never instrument.
The failure is mechanical. A conventional cache keys on a hash of the input: same input, same hash, same stored response, which is fast, simple, and correct for a large class of problems [4]. Natural language typed by different humans is not that class. The author's logged variants were "How do I reset my password", "how do I reset my login", "I forgot my password, help", and "can't log in, need to reset it" [2] - one question underneath four strings, and therefore four hashes and four full model calls [3]. As the post puts it, "What are your hours" and "when are you open" mean the same thing to a person and nothing alike to a hash function [5]. The author's argument is that the fix is not a bigger cache but a different lookup: meaning instead of spelling [6].
The construction has three parts. An embedding turns a sentence into a list of numbers via a call to an embedding model, which most providers offer, such that similar meanings land on similar numbers regardless of wording [7]. A similarity score between 0 and 1, computed with cosine similarity, says how close two embeddings are [8]. A threshold, in the post's example 0.92, decides how close is close enough to reuse a stored answer rather than pay for a new call [9]. The accompanying code is four lines of numpy for the similarity function and a cache class that keeps a list of prior answers and scans new questions against it, though the excerpt cuts off mid-class [11].
The worked example is the useful part. With one entry stored for "How do I reset my password", the two rephrasings of it match despite barely overlapping as text, while a genuinely different third question lands far away and correctly triggers a real model call [10]. That is two of three incoming questions served from cache in the illustration, roughly a 67 percent hit rate against zero for the hash [13]. Treat that as a diagram, not a benchmark.
The threshold is where the engineering judgment sits, and it cuts both ways: the same number that lets "reset my login" reuse a password answer will, if set too loosely, hand that answer to a question that only sounds adjacent [14]. Note also what the piece does not supply: no measured hit rates, no latency figures, no cost for the per-lookup embedding call that a semantic cache adds to every request, and no treatment of invalidation [15]. The embedding call is not free, so the arithmetic only closes if hits are frequent enough to cover it.
The cheap first move is the audit the author suggests: pull a week of prompts from a customer-facing feature and group them by rough topic rather than exact text, and look for clusters that never hit each other [12]. Watch two numbers after that, not one. Hit rate tells you whether the cache is earning its embedding calls; a sampled review of what it returned tells you whether the threshold is quietly serving wrong answers faster than before.
Follow any of these and your For You feed starts watching them — no settings page required.
Ranked by verification strength, evidence, and original report placement.
In the post's worked example the cache holds one entry, question "How do I reset my password" with answer "Go to Settings, click Security, then Reset Password", and three new questions arrive. The first two share few exact words with the cached question but their embeddings land close, so the cache treats them as the same question; the third is genuinely different, its embedding lands far away, and it correctly triggers a real model call.
A post titled "Semantic Cache in AI Tokenomics" on dev.to describes the author reviewing logs for a support bot that answers the same handful of questions all day long.
The logged question variants cited were: "How do I reset my password", "how do I reset my login", "I forgot my password, help", and "can't log in, need to reset it" - four different sentences with one question underneath them.
The bot had a cache but it never hit; every one of those four questions triggered a full model call because the cache was checking for an exact string match and none of the sentences matched character for character.
A normal cache works off a hash of the input: same input, same hash, same cached response. The post calls this fast, simple, and effective for a huge class of problems.
The post argues exact-match caching falls apart when the input is natural language written by different humans, giving the example that "What are your hours" and "when are you open" mean the same thing to a person and mean nothing alike to a hash function.
Evidence-backed comparisons of source perspectives and observed adoption signals. Read the methodology
Which Builder, Operator, and Investor concerns the observed source mix emphasized—not a truth score.
Evidence, demonstrated adoption, hype gap, incentives, and confidence are assessed independently, each on its own current evidence. How these are measured.
Mechanism fully specified, outcomes unmeasured
The causal story is concrete and internally checkable: hash lookup cannot match paraphrases, and the published numpy helper plus SemanticCache class show exactly how cosine similarity and a 0.92 threshold replace it. That is mechanism evidence only. There is no measured hit rate, no latency or cost figure, no baseline-versus-after comparison, and the excerpt truncates mid-explanation, so the claimed benefit is illustrated rather than demonstrated.
No adoption evidence
The cluster contains one tutorial. The only usage signal is an anonymous anecdote about a support bot whose exact-match cache failed; no named deployment of a semantic cache, no user or request volumes, no library or vendor adoption, and no before/after operating results are disclosed. That is not enough to score adoption in either direction.
Modestly overstated savings
The framing is restrained for the genre - it teaches a standard technique and does not claim a product or a breakthrough - but it overstates net benefit in two specific ways. It labels a cache hit 'free, no model call needed' while the design calls an embedding model on every request, and it presents a hand-built two-of-three hit rate against a zero-hit anecdote with no measured counterpart. Risk handling is also thin: the threshold is the sole gate on returning a wrong answer, and invalidation is never mentioned.
Low commercial pull, some audience-building
The post is a personal developer-community write-up that names no vendor, product, paid service or sponsor, and the recommended implementation is a dozen lines of numpy the reader owns. The residual incentive is reputational: dev.to rewards confident, tidy explainers, which plausibly explains the clean worked example and the omission of embedding cost and invalidation caveats. No disclosed financial interest appears in the material.
Single publisher, verifiable mechanism
Confidence is limited by structure: one source, one publisher, no corroboration, an anonymous anecdote as the only real-world datapoint, and a body that truncates mid-explanation. It is lifted by the fact that the technical core - cosine similarity over embeddings with a reuse threshold - is a standard, independently checkable pattern and the code is published in full, so the mechanism claims are unlikely to be wrong even though the outcome claims are unverified.
build
The retry loop is a memory bug: a gatekeeper that checks failures before it calls the tool1 distinct publisher
build
A completer that scores 0.546 on its eval scores 0.070 on the thing users see1 distinct publisher
build
Force the tool call, then hand Lightsail a long-lived key1 distinct publisher
build
AI-written code fails the same four ways, and every gate you own reports green1 distinct publisher
Distinct publishers with included, body-backed reporting in this cluster.
dev.to
1 article · August 16, 2026