BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Redis 8 Targets AI Applications with New Data Type for Vector Similarity

Redis 8 Targets AI Applications with New Data Type for Vector Similarity

Listen to this article -  0:00

Redis has recently announced the addition of Vector Set, a data type designed for vector similarity and a new option for AI applications. This new data type marks the first major contribution from Salvatore Sanfilippo (aka ‘antirez’), the creator of Redis, since rejoining the company.

Vector Sets are a new data type similar to Sorted Sets but have string elements associated with a vector instead of a score, making it possible to add items and retrieve a subset of the added items that are most similar to a specified vector. Filtered search capabilities are also supported, allowing vector similarity and scalar filters at the same time. Sanfilippo explains in his blog:

The goal of the new data structure is, in short, to create a new "Set alike" data type, similar to Sorted Sets, where instead of having a scalar as a score, you have a vector, and you can add and remove elements the Redis way, without caring about anything except the properties of the abstract data structure Redis implements, ask for elements similar to a given query vector (or a vector associated to some element already in the set), and so forth.

Vector Sets are based on the hnsw.c implementation of the HNSW data structure, with extensions for speed and functionality. Rowan Trollope, CEO of Redis, praises Sanfilippo’s contribution:

His expertise has led to the creation of an API that is both simple and intuitive, reflecting Redis’s philosophy of delivering high-performance solutions with minimal complexity.

Vector databases are critical for applications backed by GenAI to retrieve semantically relevant information to enrich the context of LLMs (RAG). Other use cases include semantic caching for chatbots, recommender systems, and face recognition. Mirko Ortensi, product manager at Redis, explains in a separate article how to use Vector Sets for face recognition. Ortensi writes:

Face recognition is all about vectors. It’s about modeling known faces using a specialized embedding model, storing them in Redis, and performing face recognition by running a vector search of a test identity against the vectors stored in the database.

Source: Mirco Ortensi

Sanfilippo adds:

I decided that a fundamental requirement for implementing vector similarity was to also reimplement from scratch HNSWs (you can see my implementation in hnsw.c), because that was going to be my core data structure, and I didn’t want to grab some random code from GitHub and be happy with it.

With a focus on high-speed performance, Sanfilippo introduced not only modifications to HNSW but also multithreading for all vector similarity requests, along with support for both 8-bit and binary quantization. He highlights the main difference in his implementation:

The most interesting part of Vector Sets is the data model and the API supporting it. Many databases propose vector similarity as a kind of index, but that’s Redis, and things in Redis are data structures: no exception this time.

Vector Sets are not the only new Redis feature: LangCache, a semantic caching service for AI apps and agents, is designed to reduce costly, latency-prone calls to LLMs by caching their responses.

Vector Sets are available in preview with Redis 8 RC1 under RSALv2 or SSPLv1 license.

 

About the Author

Rate this Article

Adoption
Style

BT