█

AI/TLDR

Buy me a coffee
Buy me a coffee

mxbai-rerank

Open-source reranking models that reorder retrieved passages by relevance

Rerank, Search & HybridOpen source
Language
Python
License
Apache-2.0
$pip install -U mxbai-rerank
IN SHORT

What is mxbai-rerank?

mxbai-rerank is Mixedbread's family of open-source reranking models. A reranker takes a query and a list of documents that an earlier retrieval step returned, then scores and reorders those documents by how well they actually answer the query. It sits in the Rerank, Search & Hybrid category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Python and licensed Apache-2.0.

Overview

mxbai-rerank is Mixedbread's family of open-source reranking models. A reranker takes a query and a list of documents that an earlier retrieval step returned, then scores and reorders those documents by how well they actually answer the query. This second pass usually improves the quality of results in a RAG or search pipeline.

It is aimed at developers who already have a retrieval system (vector search, BM25, or a hybrid of both) and want better ordering before passing context to an LLM. The Python package wraps the v2 models so you can load a model and call rank() in a few lines, without building scoring logic yourself.

Within the rerankers and hybrid search category, it acts as the relevance-scoring layer that sits between first-stage retrieval and the final answer. The v2 models support over 100 languages, long context up to 8k tokens, and ranking of code, SQL, and function calls. A managed API is also available for production use.

What it does

  • Cross-encoder rerank() that scores and reorders documents against a query
  • Two v2 model sizes: base-v2 (0.5B) for speed and large-v2 (1.5B) for accuracy
  • Multilingual support across 100+ languages out of the box
  • Long-context input up to 8k tokens (configurable via max_length, up to 32k on v2)
  • Optional per-query instructions to guide ranking (e.g. for code snippets)
  • Flash Attention 2 used automatically when installed for faster inference

Getting started

Install the package, then load a v2 model and call rank() with your query and the documents your retriever returned.

Install

Install the package from PyPI.

bashbash
pip install -U mxbai-rerank

Rerank documents

Initialize a reranker with a model id, then pass your query and candidate documents to rank(). It returns the documents reordered by relevance.

pythonpython
from mxbai_rerank import MxbaiRerankV2

# Initialize the reranker
reranker = MxbaiRerankV2("mixedbread-ai/mxbai-rerank-base-v2")  # or large-v2

query = "Who wrote 'To Kill a Mockingbird'?"
documents = [
    "'To Kill a Mockingbird' is a novel by Harper Lee published in 1960.",
    "The novel 'Moby-Dick' was written by Herman Melville.",
    "Harper Lee was born in 1926 in Monroeville, Alabama."
]

results = reranker.rank(query=query, documents=documents)
print(results)

Guide ranking with an instruction (optional)

Pass an instruction to steer how documents are scored, which helps for technical or code-focused queries.

pythonpython
results = reranker.rank(
    query=query,
    documents=documents,
    instruction="Figure out the best code snippet for the user query."
)

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Add a second-stage reranking pass to a RAG pipeline so the most relevant chunks reach the LLM
  • Improve ordering of hybrid search results that combine vector and keyword retrieval
  • Rank code or SQL snippets for technical and developer-facing search
  • Serve multilingual search where queries and documents span many languages

How mxbai-rerank compares

mxbai-rerank alongside other open-source rerank, search & hybrid tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Elasticsearch★ 78.9kDistributed search and analytics engine with a built-in vector database for dense/sparse embeddings and hybrid keyword-plus-semantic retrieval.
Meilisearch Cloud★ 60.1kManaged cloud for the Meilisearch engine, combining fast full-text search with hybrid, semantic, and multimodal vector search.
Typesense Cloud★ 27.2kManaged hosting for the Typesense search engine, offering typo-tolerant keyword search plus vector and semantic search via a simple API.
Tantivy★ 16.5kA fast full-text search engine library in Rust that provides BM25 keyword search for the lexical half of hybrid retrieval.
FlagEmbedding★ 12.4kBAAI's retrieval toolkit that provides the BGE embedding and cross-encoder reranker models used widely in RAG pipelines.
Vespa★ 7.2kA search and serving engine that natively combines vector, keyword (BM25), and structured search with built-in ranking for large-scale retrieval.
DigUp★ 6.6kAn on-device Mac app that searches photos, PDFs, recordings, videos and code by what is in them, combining EmbeddingGemma 2 vectors run on llama.cpp with a keyword index.
mxbai-rerank★ 55Open-source reranking models that reorder retrieved passages by relevance