This page describes how Memorystore for Redis supports storing and querying vector
data for generative AI applications, such as Retrieval Augmented Generation
(RAG) and LangChain, by using vector search capabilities.

> [!IMPORTANT]
> **Important:** To use vector search, your instance must use Redis, version 7.2. To use this feature, either [create](https://docs.cloud.google.com/memorystore/docs/redis/create-manage-instances.md.txt) or [upgrade](https://docs.cloud.google.com/memorystore/docs/redis/upgrade-redis-version.md.txt) an instance so that it uses this version.

## Use vector search for generative AI with LangChain

Vector search on Memorystore for Redis is compatible with the open-source LLM
framework [LangChain](https://python.langchain.com/docs/get_started/introduction).
Using vector search with LangChain lets you build solutions for the
following use cases:

- RAG
- LLM cache
- Recommendation engine
- Semantic search
- Image similarity search

## Benefits of vector search for generative AI in Memorystore for Redis

The advantage of using Memorystore to store your generative AI
data, compared to other Google Cloud databases is its speed. Vector search on
Memorystore for Redis leverages multi-threaded queries, resulting in high query
throughput (QPS) at low latency.

## Approaches to using vector search for generative AI in Memorystore for Redis

Memorystore also provides two distinct search approaches to help
you find the right balance between speed and accuracy. The Hierarchical
Navigable Small World (`HNSW`) option delivers fast, approximate results --- ideal
for large datasets where a close match is sufficient. If you require absolute
precision, then the `FLAT` approach produces exact answers, though it might take
slightly longer to process.

If you want to optimize your application for the fastest vector data read and
write speeds, then Memorystore for Redis is likely the best option for you.