Vector databases in Rust

Are there any vector databases that are written in pure Rust?

I'm looking for a crate that I can add to my app which will let me create a vector databases locally.

I know Pinecone put out an article talking about how they built a vector database in Rust but they only provide a hosted solution, which I want to avoid because 1) I don't want someone to start billing me for every embedding I store or query I make, 2) a lot of the information I'm dealing with is sensitive and I don't want it leaving the computer.

2 Likes

qdrant is open source and written in Rust.

4 Likes

That looks promising, but I'd still need to manage a qdrant server alongside my app, wouldn't I?

If possible, I'm looking for an experience similar to sqlite, except for vector databases rather than SQL. Using plain files on disk makes things easy to back up and move around, plus it avoids pulling in heavy dependencies like Tokio or a HTTP/gRPC client.

.

3 Likes

I see, unfortunately you'd need to interact with qdrant through either HTTP or gRPC. They have a Rust client, but I can understand that you don't want to deal with the overhead of it all. I don't know any vector database you can embed with ease like you can sqlite. For smaller "on my machine" kind of corpora I tend to store them as torch objects to disk, load them when needed into memory and just do a brute force k-NN lookup. That won't scale though and you probably already hit the limit where waiting becomes painful with this approach :slightly_smiling_face:

2 Likes

What about sled, a modern embedded database written in Rust

I don't think sled will work for what I'm doing. It's a key-value store (kinda like Redis or BTreeMap<String, Vec<u8>>) whereas I'm looking for a vector database that can be used with embeddings.

A vector database stores blobs of text using a vector of numbers as it's key. This vector of numbers is kinda like the "meaning" of the text so when you make a query like "equivalent of NPM for Rust" it might find that "Rust uses cargo as it's package manager" is the closest match.

That way you can build a search engine that uses the semantic meaning of the query, rather than just looking for pieces of text that contain the search term. It's super useful when generating prompts for an AI model.

4 Likes

If you want something that is similar to sqlite, what about sqlite-vss? I haven't gotten around to personally testing but it does look interesting. No idea on performance though.

edit: Not pure rust...forgot about that part.

2 Likes

If you do not insist on pure rust, the rust-binding for faiss like faiss crates.io maybe works with you.


Update: ​I did not notice that this was an old post from about a month ago. Sorry for digging it up.​

1 Like

You could have a look at

They all provide fast, approximate search over a large set of vectors using HNSW indexing. I believe the data is loaded into memory and dumped to/read from disk using serde, although granne supports memory-mapped files.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.