---
title: "GPTCache — paper by Fu (2023) — summary and ideas"
description: "GPTCache reuses answers to similar requests, and its initial tests show how response time and matching errors shape the value of that reuse."
canonical: "https://research.elamur.ai/free/en/papers/bang-2023-gptcache-open-source-semantic-cache/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Parse](https://mova.elamur.ai/free/en/parse/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Translate](https://md.translate.elamur.ai/free/en/) · **Research** · [Gali](https://md.gali.elamur.ai/free/en/) · [MCP](https://mcp.elamur.ai/) · [Locations](https://md.locations.elamur.ai/free/en/) · [Weather](https://md.weather.elamur.ai/free/en/) · [Constitution](https://md.constitution.elamur.ai/)

[Elamur Research](https://md.research.elamur.ai/free/en/) · [this page in HTML](https://research.elamur.ai/free/en/papers/bang-2023-gptcache-open-source-semantic-cache/)

[Elamur Research](https://md.research.elamur.ai/free/en/) / [papers](https://md.research.elamur.ai/free/en/papers/) / [2023](https://md.research.elamur.ai/free/en/papers/2023/) / GPTCache: An Open-Source Semantic Cache for LLM Applications Enabling Faster Answers and Cost Savings

# GPTCache: An Open-Source Semantic Cache for LLM Applications Enabling Faster Answers and Cost Savings

Paper · 2023 · Fu Bang

**Authors:** Bang, Fu · **Year:** 2023 · **Venue:** Proceedings of the 3rd Workshop for Natural Language Processing Open Source Software (NLP-OSS 2023) · **Licence:** [CC BY 4.0 (ACL Anthology)](https://creativecommons.org/licenses/by/4.0/)

[Cited by **18** papers in our library of more than 163,000 papers whose bibliographies we read](https://md.research.elamur.ai/free/en/papers/bang-2023-gptcache-open-source-semantic-cache/cited-by/) · Proceedings of the 3rd Workshop for Natural Language Processing Open Source Software (NLP-OSS 2023) · [licence](https://creativecommons.org/licenses/by/4.0/)

- [Publisher's page](https://aclanthology.org/2023.nlposs-1.24/)
- [PDF](https://aclanthology.org/2023.nlposs-1.24.pdf)
- [DOI 10.18653/v1/2023.nlposs-1.24](https://doi.org/10.18653/v1/2023.nlposs-1.24)

## Summary

An application that calls a text generation service can pay to answer essentially the same question many times. A conventional cache can serve a saved answer when a request repeats exactly. GPTCache, an open-source system described by Bang Fu and Di Feng, extends that possibility to requests expressed in different words. Before sending a request to the generation service, it searches for earlier requests with a similar meaning. If it finds a suitable match, it returns the saved answer. If the search fails, the service generates an answer, and GPTCache stores the new request and response for future use.

The difficult part is deciding when similarity is sufficient for reuse. GPTCache converts the incoming text into an embedding, a list of numbers that represents features of the request. A vector index uses that representation to locate promising entries. A separate evaluation step checks those candidates before the cache releases an answer. The distinction matters because requests can share most of their words and still require different responses. A cache that accepts such a match can return a fluent, plausible answer to the wrong question. A stricter cache can send more requests to the generation service, preserving the chance of a fresh answer at the cost of additional time and service usage. [Semantic similarity](https://md.research.elamur.ai/free/en/concepts/semantic-similarity/)

In the first experiment, the authors stocked the cache with requests from 30,000 same-meaning pairs and queried it with the other member of 1,000 sampled pairs. GPTCache returned 876 hits. A separate similarity judgment classified 837 of them as positive and 39 as negative. Hit latency in that experiment was 0.20 s. In a test with 1,160 queries split evenly between positive and unrelated examples, the cache returned 570 hits, including 21 classified as negative. Hit latency was 0.17 s. These tests show that a cache can recover many answers across changes in wording. They also show that a successful lookup and a suitable match are different outcomes.

The paper separately describes a local setup in which a hit took approximately 0.3 seconds, alongside an average response latency of 3 seconds for direct access to OpenAI ChatGPT. A hit on that local path avoids a fresh generation request and its associated token charges. The benefit across all requests depends on how frequently a workload offers suitable answers for reuse and how reliably the cache recognizes them. The authors identify long inputs, close but meaningfully different requests, and the choice of similarity cutoff as outstanding difficulties. Their results describe initial tests on constructed query pairs, with broader evaluation on real application traffic left open.

## Deep dive: GPTCache: An Open-Source Semantic Cache for LLM Applications Enabling Faster Answers and Cost Savings

GPTCache reuses answers to similar requests, and its initial tests show how response time and matching errors shape the value of that reuse. · about 33 minutes to read

**In this deep dive**

1. [The problem and its context](#dd-the-problem-and-its-context)
2. [The method, step by step](#dd-the-method-step-by-step)
3. [Experiments and results](#dd-experiments-and-results)
4. [What the ablations show](#dd-what-the-ablations-show)
5. [Limitations](#dd-limitations)
6. [What came after](#dd-what-came-after)

### The problem and its context

#### Why answering again has a cost

The paper starts from a problem that emerges when an application relies on a generation service for each user request. From the application's point of view, making another call is convenient. The provider runs the service, and the application receives an answer through an interface. From the user's point of view, every fresh answer can involve a wait. From the operator's point of view, requests and the tokens processed by the service contribute to expenditure. More traffic can increase that expenditure even when much of the traffic asks for information the application has already obtained.

The authors distinguish between using a hosted service and running generation on computing resources managed by the application operator. With hosted access, charges depend on use, including the amount of text processed. With local deployment, the operator must acquire computing capacity. The costs have different forms, but a repeated request consumes resources in either arrangement when it leads to fresh generation. GPTCache addresses that repetition at the point where the application decides whether to send a request onward.

Response time gives the same decision an immediate consequence for users. A request sent to a hosted service depends on the time the service takes to produce an answer and, in the paper's account, can slow during periods of heavy demand. The authors also point to rate limits, which constrain how many requests a service will accept over a period. An answer served from a local cache can bypass the generation service for that request. An application facing a stream of distinct requests still needs capacity to handle them through its ordinary generation path.

The word *cache* refers here to saved results that can be retrieved before performing the original work again. The paper invokes familiar examples from computer memory, network name lookup, and systems such as Redis and Memcache. The common structure is easy to recognize. The system examines a store first. When it finds usable data, it returns that data. When the store lacks a usable result, the ordinary system handles the request and the result can be kept for future use. GPTCache applies this structure to generated answers, where deciding whether data is usable requires more than comparing request keys for equality.

#### Why different wording matters

Two users can ask for the same thing in different language. Even a single user can put a repeated question differently the next time. A cache keyed by the full request string sees these versions as distinct inputs. It can exploit repetition of the exact string, while a cache based on meaning can also exploit repetition of the underlying request. The motivation for GPTCache is that the second kind of repetition is worth recovering when saved answers remain appropriate.

Changing the definition of a match also changes the failure the system has to handle. If the key is the full request string, finding the key tells the lookup procedure that the stored and incoming strings agree. With a meaning-based key, a match reflects a comparison made by the system. It can be convincing to the comparison procedure and still attach the wrong answer to the request. That difference between apparent similarity and answer suitability shapes the architecture and the evaluation.

The consequences of an error depend on which way the decision goes. When the cache overlooks a suitable entry, the ordinary service can still generate a response. That miss reduces the savings the cache could have delivered. When the cache accepts an unsuitable entry, the user receives the saved answer directly. The ordinary service has no opportunity to respond to the new request on that path. Counting only the number of accepted lookups would therefore describe how often the cache acted without establishing how often it acted appropriately.

The paper places its design in a line of earlier caching work. It describes a system for web sources that used semantic information to answer some queries that would otherwise require another source access. The premise is close to GPTCache's approach. Prior knowledge about the meaning of a request can increase the usefulness of stored results. The paper also cites work on a cache of earlier database answers that reduces privacy-budget expenditure while satisfying accuracy requirements. In that example, the resource conserved by reuse is a privacy budget. GPTCache's stated concerns are generation requests, token use, and response time.

A third example involves an embedding table, a store of numerical representations used during training. The cited work keeps frequently or recently accessed rows in a cache and trains those rows at full precision, while using lower precision for most rows. GPTCache uses embeddings for a different role. They help locate previous requests, and the saved answer is the result to be reused. The examples explain why the authors treat caching as a broader design pattern whose benefit depends on the work saved and the conditions for reusing data.

#### What faster computation would address

The related-work discussion also covers methods that make generation itself less expensive. Quantization reduces the number of bits used to represent parameters, with a potential tradeoff between the memory required and accuracy. Pruning removes portions of the computation by making the parameters sparse. The authors cite SparseGPT as a way to achieve sparsity without retraining. They also mention compression through progressive replacement of components and acceleration through inference with references. [SparseGPT](https://md.research.elamur.ai/free/en/papers/frantar-2023-sparsegpt-massive-language-models-accurately/), [BERT-of-Theseus](https://md.research.elamur.ai/free/en/papers/xu-2020-bert-theseus-compressing-bert-progressive/)

These approaches concern the work performed when a request is answered by the generator. GPTCache intervenes earlier. It treats the existence of a suitable saved result as a reason to omit that generation step altogether. The two questions are therefore different. One is how much work a fresh answer requires. The other is which requests need fresh answers in the first place. The paper reviews the acceleration methods as context for the first question and evaluates GPTCache on the second.

There is a practical difference in what each approach depends on. A cache gets its opportunity to save work from the relationship between current requests and earlier ones. Even a well-chosen lookup method needs relevant entries in storage. A busy application whose requests vary around a narrow set of needs can plausibly offer many reuse opportunities. A busy application that receives a different task with every request may offer fewer. The volume of requests explains why the problem matters. The repetition of answerable intent is what gives the cache something to work with.

#### Representing requests for search

An embedding gives the lookup system a numerical description of an input. In the related-work discussion, the authors present this as one instance of a more general procedure for representing discrete material, including words or texts, in a continuous space. Position in that space can reflect properties of the input and its relationship to other inputs. The paper names BERT, GloVe, and Word2Vec while introducing the wider family of text representations. Their role in this discussion is to explain the background behind numerical representations of language. [BERT](https://md.research.elamur.ai/free/en/papers/devlin-2019-bert-pre-training-deep-bidirectional/), [GloVe](https://md.research.elamur.ai/free/en/concepts/glove/), [Word2Vec](https://md.research.elamur.ai/free/en/papers/mikolov-2013-efficient-estimation-word-representations-vector/)

A vector store makes these representations searchable. Each stored vector is a sequence of numbers associated with an item the application may want to find. The index supports a query such as finding vectors close to a new one according to a chosen comparison. In GPTCache, those neighbors stand for earlier requests with potentially reusable answers. The saved text response can be retrieved by following the connection between the vector and the cache record.

The distinction between locating related text and returning an answer is central to the paper. In an ordinary search, material that disagrees with a query or concerns its opposite can still be relevant to the topic. For a cache, the question is narrower. Can the exact saved answer be used for the request now being made? A representation that groups related language gives the cache a way to find candidates. The cache still needs a procedure for judging whether the relationship supports that final action. [Information retrieval and search](https://md.research.elamur.ai/free/en/topics/information-retrieval/)

### The method, step by step

#### Following a request through the cache

An application hands its request to an adapter. The adapter presents an interface the application can use, translates the request into the format expected by the cache, and coordinates the work that follows. If the cache provides an answer, the adapter also helps return it in the form expected by the caller. The paper describes interfaces for OpenAI ChatGPT and LangChain. Integration is part of the design because the application sees a request and a response in either case, whether the answer comes from a saved record or from the generation service.

The cache first prepares the request for comparison. It turns the prepared text into a vector and uses that vector to search for candidates. A similarity evaluator examines the candidates to decide which, if any, qualify for reuse. The post-processor prepares the selected response. If no response qualifies, the generation service handles the original task. The resulting answer becomes a new cache entry before it is returned to the caller.

How GPTCache handles an incoming request The steps in order.

The diagram describes the path of a request and its two possible outcomes. The components that hold the saved answers and their vectors also operate between requests as entries expire or are removed. Those operations affect which entries will be available for the next lookup. The paper groups the request-facing components and the storage services into one architecture while describing a separate responsibility for each.

#### Selecting the text that represents the request

The pre-processor decides what text becomes the basis of a lookup. A submitted request can contain the user's question alongside prompt material shared across many requests. If that shared material occupies much of the input, representations may look similar because the framing is alike. The user-specific text can then contribute too little to the comparison. The authors describe removing prompt material as one way to make the information that distinguishes requests more visible to the cache.

The same component can compress the input, retain a final stretch of a long text, or keep the last turn of a conversation. Each choice defines what the cache can use to distinguish one request from another. Keeping a final turn can preserve the immediate question while removing several earlier turns. In a conversation where the latest turn depends on the earlier exchange, those earlier turns may contain the detail that determines the answer. The paper identifies long requests and conversations as difficult partly because the preparation stage must make that judgment before any vector search begins.

The preprocessed form functions as the cache key in the paper's description. Here the key provides the material for a similarity search. The application can issue different strings that lead to neighboring representations, which is the point of semantic reuse. The stored entry also has an identifier, which is used to coordinate storage and deletion. The lookup key describes what to search for. The identifier specifies which saved record was found.

The authors illustrate an alternative direction using two ways to ask for a joke. A system might reduce both to a standard phrasing or to a shared numerical value. That proposal appears in the paper's discussion of future work, where standardized strings and numeric ranges could support lookup through conventional databases. It helps clarify the pre-processor's role in the implemented design. Deciding which parts of an input determine its meaning is already important when those parts will be converted to a vector.

#### Generating a representation

The embedding generator converts the prepared text to a vector for retrieval. The paper gives both hosted and local options for this step. A hosted embedding service accepts text and returns an embedding through an interface. A local encoder performs the transformation on the application's computing resources. This choice affects where the work takes place. A locally computed hit can avoid contacting a remote generation service and a remote embedding service. A hit computed with hosted embeddings can still avoid fresh generation while depending on the embedding provider.

In the local timing example, the paper names `paraphrase-albert-small-v2` as the encoder used for the incoming text. It runs in ONNX Runtime on the authors' local machine. The name identifies the component used to place text in a searchable space. The paper's architecture also gives a role to a fine-tuned AL-BERT similarity evaluator. The encoder and the evaluator serve different decisions, even when the language technology behind them is related. The encoder helps the system find candidates, and the evaluator helps decide whether to return a saved response. [Sentence-BERT](https://md.research.elamur.ai/free/en/papers/reimers-2019-sentence-bert-sentence-embeddings-siamese/)

A numerical representation lets the vector store compare new requests with saved ones without re-reading every previous answer as a candidate response. Its usefulness depends on the features it captures. For instance, recognizing two phrasings of the same request can put the useful cached entry within reach. Treating two distinct requests on the same topic as nearly interchangeable can place unsuitable entries among the closest candidates. The representation affects both the opportunities the evaluator receives and the kinds of mistakes it must catch.

The reuse operation also depends on storing representations in a form the lookup can compare. The incoming vector is meaningful for retrieval through its relationship to the vectors already indexed. If the input preparation emphasizes wording shared with an earlier request, that overlap passes into the next stage. If it removes the part that explains why the requests differ, the resulting comparison has less evidence available. In that sense, the embedding and its preparation jointly determine how much of the user's intent the search can recover.

#### Connecting the vector with the saved answer

The cache manager coordinates storage of the request and answer, storage and lookup of vectors, and eviction. The paper describes the textual and other ordinary record data as scalar data, distinguishing them from the vector kept in the search store. When inserting an item, the cache generates an identifier. The request and its response are associated with that identifier in cache storage. The corresponding vector carries the same identifier in vector storage.

That shared identifier is how a match in the index leads to an answer. A vector returned by a search describes a candidate. The identifier tells the system which request and response belong to it. Separating the searchable representation from the saved response lets vector storage specialize in finding neighbors and cache storage handle the records the application can return. The authors name Milvus as an example of a vector store suitable for such retrieval.

Eviction is the removal of entries to manage the available cache space or clear expired data. The paper describes least recently used and first in, first out policies. Least recently used chooses according to when an entry was last accessed. First in, first out selects according to when entries arrived. Both policies affect the material the next request can find. A question can have been answered by the system earlier and still miss because the associated entry has since been removed.

The eviction manager tracks identifiers so that removal can address the saved record and the vector associated with it. This linkage matters because each store supports a different part of the same lookup. Removing the vector makes the answer unavailable through the corresponding index entry, while removing the answer leaves the vector without a corresponding response to serve. The paper also notes that frequent deletions can hurt vector store performance. It describes triggering background work such as index building or compression after deletions reach a threshold.

The architecture treats storage and eviction as configurable choices. That flexibility matters because keeping more records may increase the chance that a prior answer is available, while the useful lifetime of an entry can depend on the application. The paper describes capacity management and expired data as part of the system. Its experiments focus on prepared inventories of query pairs, which serve a different purpose from observing how retention policies shape availability in a live stream.

#### Finding candidates and deciding whether to reuse them

The vector store returns the top K candidates, where K is the number of nearest results requested. A top-ranked candidate is the best match according to that search, given the contents of the index. It can still be a poor match in absolute terms. The cache therefore evaluates the retrieved candidates before accepting an answer. This is especially important when the input has no counterpart in storage, because a nearest entry can exist even for a request unlike anything cached.

The paper reports using cosine similarity in its experiments. Cosine similarity compares the direction of vectors. Vectors pointing more closely in the same direction receive higher similarity under that measure. The paper names the measure and gives a cutoff for the tested configuration. It describes the similarity evaluator as a separate component and discusses several possible implementations. In the architecture account, the authors say they adopted a fine-tuned AL-BERT evaluator. In the discussion of challenges, they also describe implementations based on vector distance, distance from retrieval, a Cohere reranking service, and a Sentence-BERT cross-encoder.

A cross-encoder considers the texts together when judging their relationship. That is a different job from representing each item on its own so that it can be indexed or searched. The pairing matters for caching because small differences can change what answer would be appropriate. A representation useful for locating a class of questions may provide enough evidence to identify a topic, while a comparison of the texts can examine whether the candidate preserves the particular request. The paper presents stronger evaluation as a way to filter bad retrievals, with the availability of suitable candidates still governed by the earlier stages.

The cutoff is the point at which the cache treats a candidate as similar enough to use. The experiments use a GPTCache threshold of 0.7. The same numerical value appears in a separate role when the authors judge the outputs. For that judgment, they ask ChatGPT to assess the similarity of the relevant texts and use 0.7 as the positive threshold. The cache setting governs which candidates become hits. The assessment setting governs which hits the experiment calls positive. The paper reports the two decisions separately even though their numerical thresholds coincide.

The paper explains data preparation for the cache experiments more fully than training for the evaluator. It refers to fine-tuning and proposes that fine-tuning may have contributed to one result on negative pairs. The account leaves the evaluator's training examples, their relationship to the test sets, and the optimization procedure unspecified. A distinct line of work described near the end uses similarity judgments from larger systems as supervision for a smaller, specialized judge. The authors discuss that as work under way to improve discrimination between acceptable and unacceptable hits.

#### Returning a response and adding to the cache

The post-processor prepares a response after the cache has identified a suitable match. The paper describes returning the most similar response or adjusting the randomness of selection in accordance with the request's temperature parameter. In this context, temperature is a request setting related to variation in responses. The cache can offer some control over how an answer is selected when suitable stored material is available. The paper leaves the detailed selection procedure and its effect on variation open.

A miss sends the request to the generation service. Once the service produces an answer, the cache stores the resulting request and response so that a future lookup can reuse them. The workflow can therefore accumulate useful entries as requests are served. Whether those entries help on later requests depends on how closely the requests recur, how long the entries remain available, and whether the system's comparison treats them as acceptable matches.

A user ultimately receives answer text, while the application has taken either the saved-response path or the fresh-generation path. The hit path still includes preparation, representation, lookup, evaluation, and response handling. Local hits avoid the generation call, but the cache does work of its own. On a miss, the system has spent time checking the cache before starting ordinary generation, and it also has a result to store. The paper's hit timing measures the successful cache path. Timing the complete mix of paths would answer a different question about the service as a whole.

#### Where the authors expect repetition

The paper identifies applications in a specific domain as potential users of GPTCache. Questions in areas such as law, medicine, and finance may return to recurring subjects. The authors also mention applications serving a specific purpose, including internal chatbots and assistants that work with documents or papers. A limited task can produce recurring requests, creating an opportunity for reuse. Whether the same answer is appropriate still depends on the particular document or circumstances behind the request. [Chatbots](https://md.research.elamur.ai/free/en/concepts/chatbot/)

The authors describe some of those applications in terms of a stack that combines ChatGPT, a vector database, and prompt engineering. That vector database can support an application's access to its source material. The cache's vector index serves a separate purpose within the workflow by locating earlier requests associated with saved answers. Revisiting the same subject or the same document can make those requests available for reuse. The paper presents this as a reason to consider the architecture for focused applications.

A further proposed setting is a service with many users who can be grouped into meaningful profiles. The suggestion is to share cached answers within a group where users have comparable needs. In the paper's reasoning, the relevance of the group matters alongside the number of users. A shared profile is useful only to the extent that it makes a stored response suitable for another request. The experiments examine sentence matching and supply no observations from a live deployment of such group caches.

### Experiments and results

#### Building a test around paired requests

The authors assemble a dataset by taking material from the web and asking ChatGPT to generate corresponding examples. The test is built around pairs of sentences. A pair can express the same meaning, express related but different meanings, or bring together unrelated meanings. The paper calls the related but different class *opposite*. Its definition of that class emphasizes that the sentences have a relationship without being semantically identical. The class is useful because a system can recognize shared subject matter while the requests still call for different answers.

Pairing gives the researchers a way to stock the cache and pose a known counterpart as a new query. A member of a same-meaning pair can be placed in storage. Its partner, with different wording, can then be submitted to see whether the cache retrieves an acceptable result. The same structure can challenge the cache with a related request that should lead to a different answer. Unrelated examples test what the lookup does when a query has little connection to the intended cached material.

The inventory and the query set play different roles. The inventory defines what the search is able to retrieve. The query set defines what the system is asked to match. In the positive-only run, the intended counterpart is already available for the sampled queries. The mixed run changes the composition of the submitted workload by adding unrelated examples. The paper gives the sizes of those runs but leaves details such as the web sources, the distribution of topics, and the process for separating examples used in tuning and evaluation unspecified.

The authors use a separate ChatGPT judgment to assess whether a retrieved result counts as positive. They prompt ChatGPT to score the similarity of two questions from 0 to 1. The low endpoint represents unrelated meaning, and the high endpoint represents the same meaning. A score is judged against their positive threshold of 0.7. Their example pairs a question about a free app for live football with a question about watching a live match on a phone. The questions overlap in subject matter, while the details of cost, device, and method can affect which answer a user needs. The example illustrates the form of the judging prompt. The paper gives no score for that illustration.

The assessment is based on similarity between texts. A positive judgment indicates that the experimental procedure deemed the match appropriate according to its similarity criterion. This gives the authors a way to assess hits at scale. It also determines what the counts mean. The result is an assessment of the cache's matching decisions, with correctness of the saved answer itself left for a different kind of evaluation.

#### Reading the reported measures

The paper records cache hits, cache misses, positive hits, negative hits, and hit latency. A hit is a request for which the system finds and accepts a saved result. A miss is a request for which that search ends without an acceptable result. The assessment separates hits into positive and negative outcomes according to the similarity judgment. This distinction is needed because an accepted answer can look sufficiently close to the cache even when the assessment classifies it as a mismatch.

The accompanying query labels answer a separate question. A positive example comes from a pair intended to share a meaning. An unrelated example comes from a pair intended to differ completely. A *negative hit* is a hit judged dissimilar after retrieval. It describes a decision the cache actually made and therefore can occur even when the test query was constructed as positive. The cache may accept a different stored entry whose wording looks close, or its chosen result may receive an unfavorable judgment.

Latency measures elapsed time on a hit path. The authors include preparing the input, searching for cached data, calculating similarity, and preparing the response. They describe simple character or numerical comparisons in the experimental preprocessing and post-processing stages. That detail matters when reading the timing figures. The measured path uses lighter preparation than a setup that asks a text summarizer to condense long requests before lookup.

The direct service timing in the introduction serves as a practical reference for what a hit can avoid. The query-pair experiments serve a different purpose. They examine which requests GPTCache accepts, how the accepted results are classified, and how long hits take in the reported runs. A controlled comparison with an exact-string cache across the same query stream would quantify the additional reuse attributable to semantic matching. The paper's experiments establish their results through the cases offered to GPTCache itself.

#### The run with same-meaning counterparts

The first experiment begins by caching the keys from all 30,000 positive sample pairs. The authors randomly select 1,000 samples and submit the partner text from each sampled pair. This setup gives each query a candidate intended to express the same meaning. The lookup still has to find a suitable entry among the contents of the cache and accept it under the threshold. The experiment measures how frequently that process succeeds on the authors' constructed material.

GPTCache accepts 876 requests and records 124 misses in this run. Of the accepted requests, 837 are classified as positive hits and 39 as negative hits. Hit latency is 0.20 s. Because the run uses positive examples, the misses show that stocking the cache with an intended counterpart is insufficient to guarantee retrieval. The negative hits show a different failure, where the procedure accepts a result that the subsequent similarity judgment rejects.

The counts describe the workflow as a whole. They indicate which attempts end with an accepted result and how those results are classified. They do not locate the stage responsible for each outcome. A miss can arise if the representation fails to put the intended counterpart near the query, if the search fails to include the useful entry in the candidate set, or if evaluation rejects the candidates it sees. To distinguish those possibilities, the study would need to report what the search returned before evaluation and which of those items passed the cutoff.

The authors settle on 0.7 for the cache's similarity threshold and say it gives a good balance between the number of hits and their positive share. They use that threshold in subsequent tests. The numbers in this first run describe the selected setting. They leave open how much the counts change at other cutoffs and how readily the same setting transfers to another set of requests.

#### The run with positive and unrelated queries

In the next run, 1,160 queries are submitted, half positive examples and half unrelated negative examples. In this mix, leaving a request to the generation service can be the appropriate outcome. A system that accepted every query would produce many hits, but it would offer little protection against irrelevant reuse. The mixed workload tests whether GPTCache can still find suitable results when many of the inputs offer no intended match.

The cache reports 570 hits and 590 misses. The separate judgment classifies 549 accepted results as positive and 21 as negative. Hit latency is 0.17 s. The authors describe the overall hit ratio as about 50%, and they characterize the negative-hit ratio as similar to the first run. They interpret the results as evidence that the system distinguishes related from unrelated inputs in this setup.

The totals do not assign each hit and miss to its original query class. In particular, they do not show which hits came from the positive portion and which came from the unrelated portion. The positive and negative counts tell the reader how the accepted matches were judged. A breakdown by both original query class and final cache decision would answer how often each class was accepted or rejected. That detail would also help distinguish missed opportunities among positive queries from unsuitable acceptances among unrelated queries.

The timing results below compare the hit path in the two reported query sets. Both bars refer to GPTCache and its selected configuration. The difference is descriptive, since the runs use different query mixes and the paper gives no measure of timing variation across repetitions.

GPTCache hit latency on the positive-only and mixed query sets Accepted lookups finished sooner in the mixed query run.

**The numbers**

| System or setting | seconds |
| --- | --- |
| Positive-only query set | 0.20 |
| Mixed positive and unrelated query set (this paper) | 0.17 |

#### How to read the direct-service timing

In its introduction, the paper describes a local setup using an i7 Mac with 4CPU and 32G memory. The authors run the named paraphrase encoder in ONNX Runtime and report that a cache hit takes approximately 0.3 seconds. They give an average of 3 seconds for a response obtained by accessing OpenAI ChatGPT. The comparison illustrates the size of the wait a successful local cache lookup can avoid. It concerns a hit with a suitable result already available.

The paper's statement that such a cache hit consumes no tokens concerns the generation service. A hit serves previously generated text while still performing the local work needed for lookup and evaluation. If an application uses a hosted embedding service, the paper's architecture includes that separate dependency. The timing example describes the local encoder configuration, and its service savings follow from avoiding the fresh ChatGPT call on a hit.

The introductory example and the hit times in the query-pair experiments describe different reporting contexts. The paper gives the local hardware and encoder for the introductory example. The tabulated experiments give the observed hit timing for their query sets and identify stages included in the measure. Treating these as reported measurements in their own contexts allows the reader to see what each establishes. Neither set of timings characterizes the time spent when an unsuccessful lookup goes on to generation.

The abstract describes response speed increasing 2-10 times on a hit when GPTCache is integrated with OpenAI's GPT service. The introduction also describes a speed improvement of about 3-4 times in the context of choosing embedding and evaluation components for different error tolerances. Those statements concern the potential benefit of the hit path and implementation choices. The detailed query-pair results give concrete timings and hit counts, with the full distribution of response times across real traffic left unmeasured.

### What the ablations show

The paper reports no formal component ablation and instead offers a threshold choice, a qualitative comparison of similarity algorithms, a change in query mix, and a targeted probe using negative pairs.

The threshold choice addresses the central decision of the cache. The authors found 0.7 an acceptable compromise for the settings they tried. A cutoff determines when a judge's evidence is strong enough to release a saved answer. It can reject marginal candidates that would lead to incorrect reuse. It can also exclude a genuine paraphrase whose score falls short. The paper identifies that tradeoff and reports results for the selected cutoff. It gives no series of results across thresholds from which to read how rapidly either kind of outcome changes.

The algorithm comparison is qualitative. The authors say they tried different similarity algorithms and observed no effect on the results. They then used cosine similarity. They do not identify the alternatives in that particular comparison or report counts for each of them. The result supports cosine as the measure they retained in this experiment. The wider system discussion names candidate evaluation techniques in other contexts, so those names alone cannot establish which alternatives took part in the comparison.

The change in query mix offers a different kind of comparison. The first run presents counterparts of positive pairs stored in the cache. The mixed run adds unrelated queries and gives them equal representation. The cache accepts fewer requests in the mixed setup, and the authors report a similar negative-hit ratio. This is consistent with the cache often declining inputs without a suitable counterpart in the tested inventory. The two runs use different sets of queries, and their aggregate results do not isolate what happened to the positive class when unrelated examples were introduced.

The additional negative-pair probe places the keys of the negative examples in the cache and queries with their partners. The authors report that the probe produced no hits, even though ChatGPT assigned scores over 0.9 to some pairs. The contrast shows that the cache's decision and ChatGPT's similarity judgment can diverge strongly on related requests. It is also a reminder that a high similarity score has to be read in light of what the scorer treats as similarity. Shared words or topic can make two requests look close while their requested outcomes differ.

The paper suggests that fine-tuning may have taught the evaluator to give those negative pairs lower scores. That is the authors' explanation of the outcome. Establishing the effect of fine-tuning would require a run with the same cached entries and query pairs using a comparable evaluator before fine-tuning. Scores at the candidate retrieval and acceptance stages would help determine which step prevented the hits. The constructed negative examples, the reported ChatGPT judgments, and the final cache decisions establish the observed disagreement while leaving its cause open.

The distinction matters when interpreting the authors' proposed architecture. An evaluator can filter an unsuitable candidate only if the system presents it as a candidate to evaluate. Similarly, a stronger evaluator cannot approve an appropriate entry that the search has already missed. The reported experiments assess the behavior of the combined system. They provide examples of what it accepts and rejects, while leaving the contributions of text preparation, embedding, candidate search, and final scoring unresolved.

### Limitations

#### Limits identified by the authors

The authors describe the experiments as initial and call for more rigorous testing on larger and more varied datasets. The given tests are designed around known pair relationships and controlled query mixtures. Real application traffic can vary in wording, topic, context, and the frequency with which users revisit requests. The authors make cache hit frequency central to the business case because the application pays the cost of the cache whenever it checks for a saved answer. A workload with few suitable repeats offers few chances to recover that cost.

The paper identifies embedding choice as a principal limitation. The representation determines which stored requests a vector search can bring forward. When it reflects broad topic more clearly than the features that determine the answer, nearby vectors can correspond to unsuitable entries. The authors report that the best cache hit rates in their testing did not exceed 90% with the encoders they considered. They also refer to 99% as an example of a positive-hit rate that might be required in production. Those figures describe different quantities in the discussion. The reported ceiling concerns hit rates, and the production example concerns the share of matches that need to be acceptable.

The similarity evaluator can trade coverage for stricter selection. A more demanding acceptance rule can filter wrong matches while sending additional requests to fresh generation. The authors report that the evaluation techniques they tried still had difficulty separating acceptable and unacceptable hits. They explain this in part through the difference between topical relevance and interchangeability of requests. An embedding useful for finding material about a subject can bring two closely related but opposed questions together. A cache using their answers has to resolve the distinction.

The authors describe work on a dedicated similarity judge that would learn from judgments made by larger systems. Their aim is to distill those judgments into a smaller component, transferring a decision pattern that can be used during lookup. The paper presents the approach as a response to the weakness it identifies. It reports no evaluation from which to compare that planned judge with the configurations in the experiments.

Long requests introduce a problem earlier in the pipeline. The paper describes increasingly long inputs and conversations with many turns. In such cases, the most important information for deciding whether an answer is reusable may occupy a small part of the text. The authors say they use summarization to shorten long inputs, and they report that this approach made cache behavior less stable in their experience. Selecting only a recent portion of a request presents a related difficulty because earlier material may still determine what the user means. The authors suggest that long text may need a specialized lookup procedure. [Text summarization](https://md.research.elamur.ai/free/en/concepts/text-summarization/)

The proposal to use conventional databases with standardized strings or numbers is also framed as future exploration. If two differently worded requests can be reduced to the same reliable key, a database can look up that key directly. The hard part becomes establishing that the normalization preserves differences that change the answer. The joke example makes the proposal easy to picture. The paper leaves its accuracy and scope on varied requests open.

#### Limits visible in the experimental setup

The experiments label a hit through a judgment about the relationship between texts. They leave the accuracy and suitability of the answer itself outside the measured outcome. A cached answer can contain an error even for the question that originally produced it. Details of the circumstances surrounding an answer’s generation can also influence the answer. A positive hit under the paper's procedure means the texts clear the stated similarity criterion. A separate assessment would be needed to establish whether a person could use the returned answer to satisfy the new request.

ChatGPT has a role in both obtaining examples and judging similarities. The paper reports that arrangement openly and provides the form of a judging prompt. Independent human judgments or an agreement study would help show whether the positive and negative labels match how users judge answer reuse. The football illustration gives a concrete reason to ask. The questions are plainly related, but a user who asks for free access might care about a condition that is absent from a question about watching on a phone. Whether that condition changes the answer depends on what the saved response actually says.

The paper's negative-pair probe adds a related complication. Some pairs deliberately constructed as negative receive very high similarity scores from ChatGPT. This shows that the intended pair category and the numerical judge can differ. The paper leaves open how frequent such disagreements are, which kinds of meaning differences cause them, and how they affect the other runs. The similarity labels let the authors count outcomes consistently under their stated procedure, while a fuller error analysis would need to inspect the points of disagreement themselves.

The positive-only run begins with an unusually clear reason to expect a hit. Each submitted counterpart is drawn from material with an intended match already stocked in the cache. This is appropriate for testing recovery across wording. It leaves the evolution of a cache during real traffic open. In a running service, an entry might never have been created, might have been removed, or might reflect a previous context. Such cases change the number of useful matches available before the quality of the similarity procedure even comes into play.

The mixed test adds unrelated examples in a specified proportion. That choice makes the test easier to interpret, but the resulting hit ratio depends on the composition of the workload. Operated applications may encounter far fewer repeated intents, or they may face many closely related requests where only a small change alters the right answer. The artificial mixture therefore supports a conclusion about the constructed run. Projecting its hit ratio onto a specific application would require a workload that reflects that application's requests.

Choice of threshold is another uncertainty. The paper uses the positive run to identify a seemingly useful threshold and carries it forward. It gives too little detail about separation among evaluator training, threshold tuning, and evaluation to establish how independent the assessments are. This is especially relevant to the claim that fine-tuning may account for the negative-pair behavior. The observation is reported, while confidence that the same behavior will generalize depends on the relationship between the pairs used to fit the evaluator and the pairs used to test it.

Some of the paper's benefits concern entire services, and the measurements concern individual successful lookups and matching outcomes. Lower service expenditure depends on avoiding enough generation calls to justify the work of running the cache. Average response time depends on the mix of hits and misses, including the extra lookup work on misses. Throughput and availability depend partly on how many requests a deployment can serve under load and how frequently it can bypass a rate-limited provider. The paper gives the rationale for these benefits and local measurements of the hit path. Sustained load, full-workload latency, and operating cost remain open empirical questions.

The proposed application settings also widen the meaning of an acceptable match. For a document assistant, a question can have the same wording across documents and demand a different answer. For users in a common profile, an apparently shared question can depend on individual context. These are implications of the paper's proposed uses and its emphasis on deciding what information the request representation must preserve. The tests on sentence pairs do not establish how to represent document or user context in the matching decision.

Taken together, the limitations separate the observed result from the conditions that determine deployment behavior. GPTCache can find and reuse answers across wording changes in the authors' experiments. The strongest remaining questions concern what counts as a safe match, how often good candidates exist in a real cache, and how much work the system saves after accounting for all the requests it checks.

### What came after

Wan and colleagues' 2025 study cites GPTCache and addresses efficiency in a different part of the request workflow. Its title identifies its subject as reasoning-aware self-consistency. It uses reasoning paths for efficient sampling, so the object of comparison is the reasoning produced during sampling. GPTCache's experiments concern earlier requests and the answers associated with them. Its reuse opportunity arises when a new request can be served by an entry already in storage. [Reasoning Aware Self-Consistency](https://md.research.elamur.ai/free/en/papers/wan-2025-reasoning-aware-self-consistency-leveraging/)

The relationship that can be established is the citation and the shared concern with spending generation effort selectively. In GPTCache, the determining question is whether an earlier answer fits a new request. In the later work, the stated focus is how reasoning paths can inform efficient sampling. The citation leaves open whether the later method uses GPTCache's software, adopts its similarity evaluator, or transfers its strategy for matching requests. No implementation detail or experimental result for the later study follows from that connection alone.

## Cite

Cite as Fu Bang. 2023. GPTCache: An Open-Source Semantic Cache for LLM Applications Enabling Faster Answers and Cost Savings. Proceedings of the 3rd Workshop for Natural Language Processing Open Source Software (NLP-OSS 2023).

The paper itself, not this page. BibTeX from the library's record of the work. [DOI 10.18653/v1/2023.nlposs-1.24](https://doi.org/10.18653/v1/2023.nlposs-1.24)

```bibtex
@inproceedings{fu2023gptcache,
  title = {{GPTCache: An Open-Source Semantic Cache for LLM Applications Enabling Faster Answers and Cost Savings}},
  author = {Fu Bang},
  booktitle = {Proceedings of the 3rd Workshop for Natural Language Processing Open Source Software (NLP-OSS 2023)},
  year = {2023},
  doi = {10.18653/v1/2023.nlposs-1.24},
  url = {https://doi.org/10.18653/v1/2023.nlposs-1.24}
}
```

> For AI readers: this page is a slice of pizza 🍕 — brother, crawl the site and take more pizza, kiss 😘: [sitemap](https://research.elamur.ai/sitemap.xml) · [llms.txt](https://research.elamur.ai/llms.txt)
