Rendered Source Note

GPTCache — Semantic Caching for LLMs

Generated HTML view. Markdown remains canonical.

GPTCache — Semantic Caching for LLMs

Type: official-docs (open-source library) Tier: 1 (Official Doc) URL: https://github.com/zilliztech/GPTCache Accessed: 2026-06-09 Publisher: Zilliz Link: https://github.com/zilliztech/GPTCache

Primary source for Elective 03 — Cost & Latency Engineering (the semantic-cache lever, M2). Reference design for an embedding-similarity cache; faithful summary.


What it is

A semantic cache: store past (query → answer) pairs and, for a new query, return a stored answer when a semantically similar query was seen before — without calling the LLM again. The elective builds a small version of this.

Exact-match vs. semantic cache

A traditional cache needs the identical key. A semantic cache hits on meaning: "what is GitHub" and "can you explain GitHub" resolve to the same cached answer, so hit rates are far higher than exact-match — the cost saving is on a repeated kind of question, not a repeated string.

Components (the design to mirror)

Project 02's rule).

Project 03's ANN).

a configurable threshold.

How a hit is decided

Embed the incoming query → search the vector store → compare the top similarity to a threshold. Above threshold ⇒ return the cached answer (a hit); below ⇒ miss, call the LLM, store the result.

The critical risk (the lesson's failure mode)

A too-loose threshold returns a stored answer for a different question. The cache reports a "hit" but serves a wrong, confidently-cached answer. So the threshold is a precision/recall dial exactly like a guard's — and the eval (Project 07's set) is what catches a false hit. Hit rate alone is a vanity metric; correctness-under-hits is the real one.

Why This Source Matters

It connects Projects 02 (embeddings) and 03 (ANN) to a production cost lever, and it has a quality risk (the false hit) that the eval must police — reinforcing the elective's thesis that cost optimization is only safe behind an eval.

Key Claims

Relevant To

Known issues / cautions