MuVERA: Multi-Vector Retrieval via Fixed Dimensional Encodings
Project description
MuVERA
A Python implementation of Multi-Vector Retrieval via Fixed Dimensional Encoding Algorithm.
Converts multi-vector embeddings (point clouds) into fixed-dimensional single vectors, enabling the use of existing single-vector search infrastructure (MIPS, ANN, etc.) as-is.
Why this library?
The original MuVERA algorithm is described in a research paper and implemented in C++ within Google's graph-mining repository. While a Python reference exists, it exposes low-level config objects and separate functions for queries vs. documents, making it cumbersome to integrate into real workflows.
This library wraps the full algorithm behind a single Muvera class with a minimal, intuitive interface — initialize once, then call encode_documents() and encode_queries(). No config dataclasses, no encoding-type enums, no manual seed juggling. Just NumPy arrays in, NumPy arrays out.
Installation
pip install muvera
Development install:
git clone https://github.com/craftsangjae/muvera-python.git
cd muvera-python
pip install -e .
Quick Start
import numpy as np
from muvera import Muvera
# Initialize encoder
encoder = Muvera(
num_repetitions=10,
num_simhash_projections=4,
dimension=128,
seed=42,
)
# Encode documents (batch)
# shape: (num_documents, num_vectors_per_doc, embedding_dim)
documents = np.random.randn(100, 80, 128).astype(np.float32)
doc_fdes = encoder.encode_documents(documents) # (100, output_dimension)
# Encode queries (batch)
queries = np.random.randn(10, 32, 128).astype(np.float32)
query_fdes = encoder.encode_queries(queries) # (10, output_dimension)
# Compute similarity (dot product)
scores = query_fdes @ doc_fdes.T # (10, 100)
Parameters
| Parameter | Default | Description |
|---|---|---|
num_repetitions |
20 | Number of FDE repetitions. Higher values improve accuracy but increase output dimension |
num_simhash_projections |
5 | Number of SimHash projections. Number of partitions = 2^n |
dimension |
16 | Input embedding dimension |
projection_type |
"identity" |
"identity" or "ams_sketch" |
projection_dimension |
None | Projected dimension when using AMS Sketch |
fill_empty_partitions |
True | Whether to fill empty partitions with the nearest vector |
final_projection_dimension |
None | Final dimension reduction via Count Sketch |
seed |
42 | Random seed for reproducibility |
Benchmark
End-to-end retrieval on NanoFiQA2018 (4598 documents, 50 queries) using raphaelsty/neural-cherche-colbert (dim=128):
=====================================================================================
RESULTS
(zeta-alpha-ai/NanoFiQA2018)
=====================================================================================
Retriever | Index (s) | Query (ms) | Recall@25
-------------------------------------------------------------------------------------
ColBERT (Native MaxSim) | 240.04 | 836.94 | 0.8400
ColBERT + Muvera FDE | 77.29 | 69.48 | 0.7600
=====================================================================================
FDE achieves 90% of native MaxSim recall while being 12x faster at query time. See examples/colbert_nanobeir.py to reproduce.
Acknowledgments
This library was inspired by sionic-ai/muvera-py, the first Python implementation of the MuVERA algorithm. Their faithful port of the C++ reference made it possible to validate correctness and understand the algorithm deeply. This project builds on that foundation with a simplified API designed for easier integration.
References
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file muvera_python-0.1.2.tar.gz.
File metadata
- Download URL: muvera_python-0.1.2.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
956fe0541165e23f3196f4ef6bc9ed37593c2a31f9be2b8c397bc06cc5e4cf17
|
|
| MD5 |
ad1586ec95005f7fc1a8b14ba7db168c
|
|
| BLAKE2b-256 |
0b7a01b8e48cd99fa15e6416818fd3727f4c509c91398379c3d84acaf705c2d5
|
Provenance
The following attestation bundles were made for muvera_python-0.1.2.tar.gz:
Publisher:
publish.yml on craftsangjae/muvera-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
muvera_python-0.1.2.tar.gz -
Subject digest:
956fe0541165e23f3196f4ef6bc9ed37593c2a31f9be2b8c397bc06cc5e4cf17 - Sigstore transparency entry: 953891039
- Sigstore integration time:
-
Permalink:
craftsangjae/muvera-python@e7b61a5b850eb0e18e1aa0323564a40da72f0693 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/craftsangjae
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e7b61a5b850eb0e18e1aa0323564a40da72f0693 -
Trigger Event:
push
-
Statement type:
File details
Details for the file muvera_python-0.1.2-py3-none-any.whl.
File metadata
- Download URL: muvera_python-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c26c861e9390d0dae3cbbd05753ef11f7c1fa9325b479526f393cb90b9028027
|
|
| MD5 |
e4a304aee20eb3a45083aec6e347bc03
|
|
| BLAKE2b-256 |
75e435aafb2aaf95d8b5218196ad3f42acd907c30f76033f50408210f29995ed
|
Provenance
The following attestation bundles were made for muvera_python-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on craftsangjae/muvera-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
muvera_python-0.1.2-py3-none-any.whl -
Subject digest:
c26c861e9390d0dae3cbbd05753ef11f7c1fa9325b479526f393cb90b9028027 - Sigstore transparency entry: 953891061
- Sigstore integration time:
-
Permalink:
craftsangjae/muvera-python@e7b61a5b850eb0e18e1aa0323564a40da72f0693 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/craftsangjae
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e7b61a5b850eb0e18e1aa0323564a40da72f0693 -
Trigger Event:
push
-
Statement type: