Skip to content

Commit

Permalink
Merge pull request #62 from RedisInsight/main
Browse files Browse the repository at this point in the history
Releasing the RAG tutorial
  • Loading branch information
ViktarStarastsenka authored Jun 13, 2024
2 parents 8a921cf + 4a34424 commit 5fe66ed
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,34 @@
},
"children": [
{
"type": "internal-link",
"type": "group",
"id": "redis_use_cases",
"label": "Redis Use Cases",
"summary": "A collection of several common use cases for Redis.",
"label": "Redis basic and RAG use cases",
"args": {
"initialIsOpen": true,
"path": "/uc/intro.md"
}
"initialIsOpen": false
},
"children": [
{
"type": "internal-link",
"id": "redis_use_cases_basic",
"label": "Basic Redis use cases",
"summary": "A collection of common use cases for Redis.",
"args": {
"initialIsOpen": true,
"path": "/uc/intro.md"
}
},
{
"type": "internal-link",
"id": "redis_use_cases_rag",
"label": "Redis and RAG use cases",
"summary": "A get started guide to using Redis as part of a RAG use case.",
"args": {
"initialIsOpen": true,
"path": "/uc/rag.md"
}
}
]
},
{
"type": "group",
Expand Down
51 changes: 51 additions & 0 deletions src/uc/rag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
### Using Redis for Retrieval Augmented Generation (RAG) use cases

RAG is a method that enhances the capabilities of generative AI models by integrating them with Redis vector databases.
This approach allows the AI to retrieve relevant information in real-time, improving the accuracy and relevance of generated content.
Redis, with its high performance and versatile data structures, is an excellent choice for implementing RAG.
Here's an overview of how Redis can be leveraged in a RAG use case.

### The role of Redis in RAG

Redis provides a robust platform for managing the data retrieval process in RAG.
It supports the storage and retrieval of vectors, which are essential for handling large-scale, unstructured data and performing similarity searches.
Here are some key features and components of Redis that make it suitable for RAG:

1. **Redis as a vector database**: The following set of tutorials provide examples of how to use Redis as a vector database:
- [Basic vector search ](redisinsight:_?tutorialId=vss-vectors-basic)
- [Advanced vector search](redisinsight:_?tutorialId=vss-vectors-adv-hash)

1. **Redis Vector Library (RedisVL)**: This library is designed to enhance the development of generative AI applications by efficiently managing vector data. It allows the storage of embeddings (vector representations of text) and facilitates fast similarity searches, which are crucial for retrieving relevant information in RAG.

1. **Integration with AI frameworks**: Redis integrates seamlessly with various AI frameworks and tools. For instance, combining Redis with LangChain, a library for building language models, enables developers to create sophisticated RAG pipelines. This integration allows for efficient data management and retrieval operations that support real-time AI applications.

1. **High performance and scalability**: Redis is known for its low latency and high throughput, which are essential for real-time applications. Its in-memory data store ensures quick access to data, making it ideal for applications requiring rapid data retrieval and generation.

1. **Spring AI and Redis**: Using Spring AI with Redis simplifies the process of building RAG applications. Spring AI provides a structured approach to integrating AI capabilities into applications, while Redis handles the data management aspect, ensuring that the RAG pipeline is efficient and scalable.

### Benefits of Using Redis for RAG

- **Efficiency**: The in-memory data store of Redis ensures that retrieval operations are performed with minimal latency, which is crucial for real-time applications.
- **Scalability**: Redis can handle large volumes of data and scale horizontally, making it suitable for applications with growing data needs.
- **Flexibility**: The support for various data structures and integration with different AI frameworks in Redis allows for flexible and adaptable RAG pipelines.

### Build a RAG application with Redis

To build a RAG application with Redis, the following are some general steps:

1. **Set up Redis**: Start by setting up a Redis instance and configuring it to handle vector data. [Redis Cloud](https://redis.io/try-free/?utm_source=redisinsight&utm_medium=main&utm_campaign=tutorials) is a great way to get started quickly. The RedisVL library will be instrumental here, as it provides the necessary tools for storing vector embeddings and simplifying vector search.

1. **Embed and store data**: Convert your data into vector embeddings using a suitable model (e.g., BERT, GPT). Store these embeddings in Redis, where they can be quickly retrieved based on vector searches.

1. **Integrate with a generative model**: Use a generative AI model that can leverage the retrieved data. The model will use the vectors stored in Redis to augment its generation process, ensuring that the output is informed by relevant, up-to-date information.

1. **Query and generate**: Implement the query logic that retrieves relevant vectors from Redis based on the input prompt. Feed these vectors into the generative model to produce augmented outputs.

In summary, Redis offers a powerful and efficient platform for implementing Retrieval Augmented Generation. Its vector management capabilities, high performance, and seamless integration with AI frameworks make it an ideal choice if you are looking to enhance your generative AI applications with real-time data retrieval.

### Resources

- [RAG defined](https://redis.io/glossary/retrieval-augmented-generation/?utm_source=redisinsight&utm_medium=main&utm_campaign=tutorials).
- [RAG overview](https://redis.io/kb/doc/2ok7xd1drq/how-to-perform-retrieval-augmented-generation-rag-with-redis?utm_source=redisinsight&utm_medium=main&utm_campaign=tutorials).
- [Redis Vector Library (RedisVL)](https://redis.io/docs/latest/integrate/redisvl/?utm_source=redisinsight&utm_medium=main&utm_campaign=tutorials) and [introductory article](https://redis.io/blog/introducing-the-redis-vector-library-for-enhancing-genai-development/?utm_source=redisinsight&utm_medium=main&utm_campaign=tutorials).
- [RAG with Redis and SpringAI](https://redis.io/blog/building-a-rag-application-with-redis-and-spring-ai/?utm_source=redisinsight&utm_medium=main&utm_campaign=tutorials)
1 change: 1 addition & 0 deletions src/vss/learn-more.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

### Tutorials

* [Redis and RAG](redisinsight:_?tutorialId=redis_use_cases_rag)
* [Redis as a vector database quick start guide](https://redis.io/docs/latest/develop/get-started/vector-database/?utm_source=redisinsight&utm_medium=main&utm_campaign=tutorials)
* [Redis University course number RU402: Redis as a vector database](https://redis.io/university/courses/ru402/?utm_source=redisinsight&utm_medium=main&utm_campaign=tutorials)

0 comments on commit 5fe66ed

Please sign in to comment.