|
| 1 | +--- |
| 2 | +Title: Redis LangCache |
| 3 | +alwaysopen: false |
| 4 | +categories: |
| 5 | +- docs |
| 6 | +- develop |
| 7 | +- ai |
| 8 | +description: Store LLM responses for AI apps in a semantic cache. |
| 9 | +linkTitle: LangCache |
| 10 | +hideListLinks: true |
| 11 | +weight: 30 |
| 12 | +--- |
| 13 | + |
| 14 | +Redis LangCache is a fully-managed semantic caching service that reduces large language model (LLM) costs and improves response times for AI applications. |
| 15 | + |
| 16 | +## LangCache overview |
| 17 | + |
| 18 | +LangCache uses semantic caching to store and reuse previous LLM responses for repeated queries. Instead of calling the LLM for every request, LangCache checks if a similar response has already been generated and is stored in the cache. If a match is found, LangCache returns the cached response instantly, saving time and resources. |
| 19 | + |
| 20 | +Imagine you’re using an LLM to build an agent to answer questions about your company's products. Your users may ask questions like the following: |
| 21 | + |
| 22 | +- "What are the features of Product A?" |
| 23 | +- "Can you list the main features of Product A?" |
| 24 | +- "Tell me about Product A’s features." |
| 25 | + |
| 26 | +These prompts may have slight variations, but they essentially ask the same question. LangCache can help you avoid calling the LLM for each of these prompts by caching the response to the first prompt and returning it for any similar prompts. |
| 27 | + |
| 28 | +Using LangCache as a semantic caching service has the following benefits: |
| 29 | + |
| 30 | +- **Lower LLM costs**: Reduce costly LLM calls by easily storing the most frequently-requested responses. |
| 31 | +- **Faster AI app responses**: Get faster AI responses by retrieving previously-stored requests from memory. |
| 32 | +- **Simpler Deployments**: Access our managed service using a REST API with automated embedding generation, configurable controls, and no database management required. |
| 33 | +- **Advanced cache management**: Manage data access and privacy, eviction protocols, and monitor usage and cache hit rates. |
| 34 | + |
| 35 | +LangCache works well for the following use cases: |
| 36 | + |
| 37 | +- **AI assistants and chatbots**: Optimize conversational AI applications by caching common responses and reducing latency for frequently asked questions. |
| 38 | +- **RAG applications**: Enhance retrieval-augmented generation performance by caching responses to similar queries, reducing both cost and response time. |
| 39 | +- **AI agents**: Improve multi-step reasoning chains and agent workflows by caching intermediate results and common reasoning patterns. |
| 40 | +- **AI gateways**: Integrate LangCache into centralized AI gateway services to manage and control LLM costs across multiple applications.. |
| 41 | + |
| 42 | +### LLM cost reduction with LangCache |
| 43 | + |
| 44 | +{{< embed-md "langcache-cost-reduction.md" >}} |
| 45 | + |
| 46 | +## LangCache architecture |
| 47 | + |
| 48 | +The following diagram displays how you can integrate LangCache into your GenAI app: |
| 49 | + |
| 50 | +{{< image filename="images/rc/langcache-process.png" alt="The LangCache process diagram." >}} |
| 51 | + |
| 52 | +1. A user sends a prompt to your AI app. |
| 53 | +1. Your app sends the prompt to LangCache through the `POST /v1/caches/{cacheId}/search` endpoint. |
| 54 | +1. LangCache calls an embedding model service to generate an embedding for the prompt. |
| 55 | +1. LangCache searches the cache to see if a similar response already exists by matching the embeddings of the new query with the stored embeddings. |
| 56 | +1. If a semantically similar entry is found (also known as a cache hit), LangCache gets the cached response and returns it to your app. Your app can then send the cached response back to the user. |
| 57 | +1. If no match is found (also known as a cache miss), your app receives an empty response from LangCache. Your app then queries your chosen LLM to generate a new response. |
| 58 | +1. Your app sends the prompt and the new response to LangCache through the `POST /v1/caches/{cacheId}/entries` endpoint. |
| 59 | +1. LangCache stores the embedding with the new response in the cache for future use. |
| 60 | + |
| 61 | +See the [LangCache API reference]({{< relref "/develop/ai/langcache/api-reference" >}}) for more information on how to use the LangCache API. |
| 62 | + |
| 63 | +## Get started |
| 64 | + |
| 65 | +LangCache is currently in preview: |
| 66 | + |
| 67 | +- Public preview on [Redis Cloud]({{< relref "/operate/rc/langcache" >}}) |
| 68 | +- Fully-managed [private preview](https://redis.io/langcache/) |
| 69 | + |
| 70 | +{{< multitabs id="langcache-get-started" |
| 71 | + tab1="Redis Cloud" |
| 72 | + tab2="Private preview" >}} |
| 73 | + |
| 74 | +{{< embed-md "rc-langcache-get-started.md" >}} |
| 75 | + |
| 76 | +-tab-sep- |
| 77 | + |
| 78 | +### Prerequisites |
| 79 | + |
| 80 | +To use LangCache in private preview, you need: |
| 81 | + |
| 82 | +- An AI application that makes LLM API calls |
| 83 | +- A use case involving repetitive or similar queries |
| 84 | +- Willingness to provide feedback during the preview phase |
| 85 | + |
| 86 | +### Access |
| 87 | + |
| 88 | +LangCache is offered as a fully-managed service. During the private preview: |
| 89 | + |
| 90 | +- Participation is free |
| 91 | +- Usage limits may apply |
| 92 | +- Dedicated support is provided |
| 93 | +- Regular feedback sessions are conducted |
| 94 | + |
| 95 | +### Data security and privacy |
| 96 | + |
| 97 | +LangCache stores your data on your Redis servers. Redis does not access your data or use it to train AI models. The service maintains enterprise-grade security and privacy standards. |
| 98 | + |
| 99 | +### Support |
| 100 | + |
| 101 | +Private preview participants receive: |
| 102 | + |
| 103 | +- Dedicated onboarding resources |
| 104 | +- Documentation and tutorials |
| 105 | +- Email and chat support |
| 106 | +- Regular check-ins with the product team |
| 107 | +- Exclusive roadmap updates |
| 108 | + |
| 109 | +For more information about joining the private preview, visit the [Redis LangCache website](https://redis.io/langcache/). |
| 110 | + |
| 111 | +{{< /multitabs >}} |
0 commit comments