How to perform Retrieval Augmented Generation (RAG) with Redis?

Last updated 04, May 2024

Question

How to perform Retrieval Augmented Generation (RAG) with Redis?

Answer

Pairing Large Language Models with vector databases enables models to access external contextual knowledge. This contextual knowledge is crucial for providing accurate and context-aware responses, preventing the model from generating incorrect or incomplete answers. By storing and indexing vectors that model unstructured data, Redis ensures that the LLM can retrieve relevant information quickly and effectively, enhancing its response quality.

To perform RAG with Redis, you need a Redis client library with support to vector search. Current libraries enabling vector search are:

Besides the standard client libraries, RAG-based applications can be powered by the following libraries and frameworks.

  • The RedisVL client library is explicitly designed to offer the best experience working with vectors and provides powerful vector searches with complex filtering support.
  • If you are used to working with ORM abstractions, Redis OM .NET provides high-level abstractions and supports storing and querying vectors in Redis.
  • If you are used to working with Java Spring, you can learn to build a Spring AI app that uses Redis as its vector database.
  • If Python is the language of choice, you can use LangChain and a Redis RAG template to create LLM-powered chat applications.

Finally, you can take the course Redis as a Vector Database to learn to use Redis as a vector database, perform vector searches, and build a GenAI-assisted chatbot using RAG.

References