Skip to main content

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

muvera_python-0.1.1.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

muvera_python-0.1.1-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file muvera_python-0.1.1.tar.gz.

File metadata

  • Download URL: muvera_python-0.1.1.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for muvera_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1e6d365e20b2ade19e1b54ee1b25dd5669afab38cc409e5d0fe75a3958bf6339
MD5 e13f4f29c69f56ee6d85b66a294121b0
BLAKE2b-256 b4a3ebafe70d419fb8baa1d1afa0047359d64a95c09669d702ab11be42dc3977

See more details on using hashes here.

Provenance

The following attestation bundles were made for muvera_python-0.1.1.tar.gz:

Publisher: publish.yml on craftsangjae/muvera-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file muvera_python-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: muvera_python-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for muvera_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8614e90e088a20d39dd68219165eb8c95313015cb948be2ac372db2ce7c09b71
MD5 c0afb9ec3930f1e9e3bf352cc04fb71f
BLAKE2b-256 bc4aaa34ad9dbeda1db7bb9e2fc424a1164441d7a6a48132f8580bcc6525bf32

See more details on using hashes here.

Provenance

The following attestation bundles were made for muvera_python-0.1.1-py3-none-any.whl:

Publisher: publish.yml on craftsangjae/muvera-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page