Add fast similarity search for embeddings to an AI or chatbot application
Replace a C++ vector database like FAISS with a pure Mojo alternative
Benchmark HNSW, IVF, and Product Quantization search algorithms against each other
Use vector search from Python via the included native bindings without writing Mojo
Requires the Mojo toolchain (via Pixi/Magic) for native use, though the pip-installable Python bindings avoid that requirement.
MojoVec is a vector database built entirely in the Mojo programming language, with no C or C++ code underneath it. A vector database stores lists of numbers, called embeddings, that represent things like text or images, and lets you quickly find the entries most similar to a given query. This kind of search is a core piece of many AI applications, such as chatbots that need to pull relevant facts from a document collection. Most existing vector databases, like FAISS and hnswlib, are written in C++ and exposed to other languages through Python. MojoVec's goal is to test whether a pure Mojo implementation can match hand tuned C++ performance using only what the Mojo language provides, including its built in SIMD support for fast numeric operations. It implements three different search algorithms: HNSW, IVF, and Product Quantization, each offering different tradeoffs between speed, accuracy, and memory use. The README includes benchmark results on a standard one million vector test dataset called SIFT1M. On Apple Silicon hardware, MojoVec reportedly searches at over two and a half times the queries per second of FAISS, and builds its index about twice as fast, while achieving similar (though slightly lower) recall accuracy. Similar relative gains are shown on a four core x86 virtual machine. To use MojoVec directly in Mojo code, you download a compiled file and import it in your project, then create a collection with a chosen vector dimension and tuning parameters, add vector embeddings with their ids, and run similarity searches. Collections can be saved to and loaded from disk. The project also ships native Python bindings, installable with pip on Linux x86_64 and Apple Silicon Mac systems, so Python developers can use the same functionality without writing any Mojo code themselves. Running the test suite and benchmarks requires a working Mojo installation, typically set up through the Pixi or Magic tools mentioned in the README. The project is released under the MIT license.
A vector database written entirely in the Mojo language for fast similarity search over AI embeddings, aiming to match C++ performance without any C++ code.
Mainly Mojo. The stack also includes Mojo, Python, SIMD.
Free to use, modify, and distribute for any purpose, including commercial use, as long as you keep the copyright notice.
Setup difficulty is rated moderate, with roughly 30min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
double-check against the repo, no cap.