Redis's langcache-embed-v1 Cuts LLM Costs by Skipping Repeated AI Calls
Redis fine-tuned a ModernBERT embedding model specifically for LLM response caching, hitting 0.92 cosine AP on Quora and 800K downloads.
Takeaways
- langcache-embed-v1 is a 0.1B ModernBERT fine-tune built specifically for LLM semantic caching.
- Hits 0.92 cosine AP and 0.90 accuracy on Quora question-pair duplicate detection.
- Fine-tuned from Alibaba-NLP/gte-modernbert-base, 768 dims, 8192 token context.
- Ships with ONNX, Safetensors, and OpenVINO weights for CPU, GPU, or Intel runtimes.
- Integrated directly into RedisVL SemanticCache as the default vectorizer.
- Redis now recommends v3-small for faster inference and better matching.
Redis’s langcache-embed-v1 is a sentence-transformer model built specifically for semantic caching: deciding whether a new LLM prompt matches an earlier request closely enough to reuse its response. Hugging Face showed more than 798,000 downloads in its displayed count at publication, and Redis uses the model throughout its RedisVL examples.
A cache hit is a classification decision
A semantic cache embeds each incoming prompt, searches stored prompt vectors, and returns a previous response when the nearest match clears a configured threshold. Reusing an answer can remove an LLM request from the critical path, reducing latency and inference cost, as demonstrated by this caching example.
- Embed the incoming prompt.
- Find the nearest stored prompt using vector similarity.
- Return the cached response when the distance falls below the threshold.
- Otherwise, call the LLM and store the new prompt-response pair.
The main risk is a false positive. Two prompts can share vocabulary and intent while requiring different answers, causing a general-purpose embedding model to approve an incorrect cache hit. False negatives are less dangerous but reduce savings because the application makes an unnecessary model call. LangCache was tuned to improve precision while preserving enough recall to produce useful hit rates.
ModernBERT trained on duplicate questions
The model fine-tunes Alibaba-NLP/gte-modernbert-base, which is based on ModernBERT. It produces 768-dimensional vectors, accepts sequences up to 8,192 tokens, uses cosine similarity, and contains about 0.1 billion parameters.
Training used OnlineContrastiveLoss with the Quora Question Pairs dataset: 323,491 training examples and 53,486 evaluation examples. That dataset teaches the model to separate duplicate questions from pairs that merely look related.
The accompanying paper reports that compact models fine-tuned for one epoch on task-specific data exceeded the tested open and proprietary alternatives on precision and recall. Its authors also describe a synthetic-data pipeline for domains without enough labeled duplicate-question pairs. Redis used that approach for the sibling langcache-embed-medical-v1 model.
Quora scores need production validation
Redis reports the following results on the Quora evaluation split:
| Metric | Score |
|---|---|
| Cosine accuracy | 0.90 |
| Cosine F1 | 0.87 |
| Cosine precision | 0.84 |
| Cosine recall | 0.90 |
| Cosine average precision | 0.92 |
Precision measures how often approved matches are truly equivalent, while recall measures how many valid matches the model finds. Production results will depend on the application’s prompts, threshold, hidden context, and tolerance for an incorrect response. Teams should therefore treat the Quora scores as benchmark results rather than a deployment guarantee.
Two paths to deployment
The repository provides Safetensors, ONNX, and OpenVINO weights, allowing inference on CPUs, GPUs, and Intel accelerators without a separate conversion step. The standard Sentence Transformers interface loads the model directly:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("redis/langcache-embed-v1")
sentences = [
"Will the rupee rise after the 500 and 1000 note ban?",
"What are the implications of banning 500 and 1000 rupee notes?",
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
RedisVL can connect the same model to SemanticCache. The following configuration assumes a reachable Redis instance and creates the required search index during initialization:
from redisvl.extensions.cache.llm import SemanticCache
from redisvl.utils.vectorize import HFTextVectorizer
cache = SemanticCache(
distance_threshold=0.1,
vectorizer=HFTextVectorizer("redis/langcache-embed-v1"),
)
With cosine distance, a threshold of 0.1 accepts candidates with approximately 0.9 cosine similarity or higher. That value is an example, not a universal default. A useful threshold should come from labeled prompt pairs that reflect the application’s actual traffic.
RedisVL also uses the model in its embeddings cache, which stores computed vectors so repeated text does not need to be embedded again.
Where the model fits
| Workload | Expected fit | Reason |
|---|---|---|
| FAQ and support assistants | Strong starting point | Prompts resemble the short question pairs used for training. |
| Repeated agent requests | Requires validation | Tool arguments and hidden state can change the correct result. |
| Medical questions | Use a domain model | Specialized terminology can reduce cache precision. |
| Long-document retrieval | Poor fit | The model was trained for duplicate-question detection rather than passage ranking. |
| Cross-lingual matching | Unverified | The reported training and evaluation data do not establish multilingual quality. |
Support for 8,192-token inputs indicates the maximum accepted sequence length, not proven retrieval quality across long documents. RAG systems that rank large passages should evaluate embedding models trained for passage retrieval.
Guardrails before production
- Tune for false-positive cost. Build a labeled set of equivalent and non-equivalent prompts, then choose a threshold that meets the application’s precision target.
- Include relevant context. Scope cache entries by tenant, model version, system prompt, tools, retrieval corpus, permissions, and other state that can change the answer.
- Define expiration rules. Use time-to-live values or versioned namespaces for responses based on changing data, policies, or prompts.
- Protect sensitive data. Avoid sharing cache entries across users or tenants unless authorization rules explicitly permit it.
- Measure live quality. Track hit rate, distance distributions, latency, avoided model calls, and incorrect hits found through sampled review.
- Rebuild after model changes. Embedding spaces are model-specific, so switching models requires re-embedding stored prompts and rebuilding the index.
V3 changes the migration target
The v1 model card now labels the release outdated and points developers to langcache-embed-v3-small. Redis describes v3-small as offering faster inference, a smaller footprint, and improved semantic matching for cache workloads.
The older release remains common because RedisVL documentation and tutorials still reference it. New deployments should benchmark v3-small against v1 on representative prompt pairs, while existing deployments should plan a full re-embedding pass before changing models.
Specialization changes cache economics
The embedding model controls which LLM calls a semantic cache avoids and which cached responses it returns incorrectly. A compact model tuned for duplicate-question detection can run locally on a CPU, avoid per-request embedding API fees, and outperform larger general-purpose models on its target task. The production decision still rests on application-specific precision, measured savings, and disciplined cache isolation.