Reranking
What is Reranking?
Reranking takes initial search results and sorts them based on how closely they match the real meaning behind a user's query. This helps ensure that the most useful information appears first. It also lets you pass only the best and most relevant results to the LLM, keeping the context concise and meaningful.
Rerank your first documents
Try out the example to understand how reranking can improve your search results.
from mixedbread import Mixedbread
mxbai = Mixedbread(api_key="YOUR_API_KEY")
response = mxbai.rerank(
model="mixedbread-ai/mxbai-rerank-large-v2",
query="Who is the author of To Kill a Mockingbird?",
input=[
"To Kill a Mockingbird is a novel by Harper Lee published in 1960. It was immediately successful, winning the Pulitzer Prize, and has become a classic of modern American literature.",
"The novel Moby-Dick was written by Herman Melville and first published in 1851. It is considered a masterpiece of American literature and deals with complex themes of obsession, revenge, and the conflict between good and evil.",
"Harper Lee, an American novelist widely known for her novel To Kill a Mockingbird, was born in 1926 in Monroeville, Alabama. She received the Pulitzer Prize for Fiction in 1961.",
"Jane Austen was an English novelist known primarily for her six major novels, which interpret, critique and comment upon the British landed gentry at the end of the 18th century.",
"The Harry Potter series, which consists of seven fantasy novels written by British author J.K. Rowling, is among the most popular and critically acclaimed books of the modern era.",
"The Great Gatsby, a novel written by American author F. Scott Fitzgerald, was published in 1925. The story is set in the Jazz Age and follows the life of millionaire Jay Gatsby and his pursuit of Daisy Buchanan.",
],
top_k=3,
return_input=False,
)
print(response.data)Available Reranking Models
Choose the right reranking model for your use case:
| Model Card | Description |
|---|---|
| mxbai-rerank-xsmall-v1 | Most compact reranking model for semantic search. Delivers good performance with minimal resource requirements. |
| mxbai-rerank-base-v1 | Balanced size and performance for boosting search relevance. Easily integrates into existing keyword-based search systems. |
| mxbai-rerank-large-v1 | Flagship model for high-accuracy semantic reranking. Excels at complex and domain-specific queries. |
| mxbai-rerank-base-v2 | State-of-the-art, multilingual reranking with reinforcement learning. Handles long contexts and diverse use cases. |
| mxbai-rerank-large-v2 | Flagship second-generation model with best-in-class accuracy and speed. Excels at long contexts, complex queries, and multilingual tasks. |
Check out the API Reference for more information.
Embeddings
Leverage Mixedbread's Embeddings API to access state-of-the-art models for vector generation.
Overview
Utilize the Mixedbread Parsing API to transform complex documents (PDFs, DOCX, etc.) into clean, structured text elements or chunks. Improve data quality for RAG, embedding generation, and information extraction with our layout-aware parsing capabilities.