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-python

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.3.tar.gz (12.2 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.3-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: muvera_python-0.1.3.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

Hashes for muvera_python-0.1.3.tar.gz
Algorithm Hash digest
SHA256 85a146f9bcfcfe0197856ac9fbfb64bd84b194695446569d6ea59c9b1a5fbbe9
MD5 0bb03016f6e0f28a684776673ef0d481
BLAKE2b-256 28148ba1a6c95a794ffd287730a5e60d0fd89abc5817534c7aba352cc6947680

See more details on using hashes here.

Provenance

The following attestation bundles were made for muvera_python-0.1.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: muvera_python-0.1.3-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

Hashes for muvera_python-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b7bc59e2adf308c083bc16fa785c858953a65d6826e3b942af621f8f9ed3dadd
MD5 4c932d8a251d06012ffe714756564292
BLAKE2b-256 f0345b37ea4076131e6a9ab42a41f4f73a8d9dcae12b54ba75e878fc7cd8bd0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for muvera_python-0.1.3-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