BAAI / bge-reranker-base
Milvus Integrated
Task: Reranking
Modality: Text
Similarity Metric: N/A
License: Apache 2.0
Dimensions:
Max Input Tokens: 512
Price: Free
Introduction to bge-reranker-base
bge-reranker-base
is a cross-encoder model optimized for reranking tasks. Built on the foundation of RetroMAE architecture, it effectively captures semantic relationships within textual data, allowing for more accurate and relevant search result rankings. This model generates 768-dimensional embeddings and is fine-tuned to rerank results by considering both query and document content, making it highly suitable for applications like search engines, question answering, and document retrieval. We recommend using/fine-tuning them to re-rank top-k documents returned by embedding models.
For more information about reranking and rerankers, read the below blogs.
- What Are Rerankers and How They Enhance Information Retrieval
- Optimizing RAG with Rerankers: The Role and Trade-offs
How to re-rank results with bge-reranker-base
There are two primary ways to use the bge-reranker-base
model to re-rank your results:
- PyMilvus: the Python SDK for Milvus that seamlessly integrates with the
bge-reranker-base
model. - FlagEmbedding: the official Python SDK offered by BAAI.
Re-ranking results with bge-reranker-base
via PyMilvus
from pymilvus.model.reranker import BGERerankFunction
rf = BGERerankFunction(
model_name="BAAI/bge-reranker-base",
device="cpu"
)
query = "What event in 1956 marked the official birth of artificial intelligence as a discipline?"
documents = [
"In 1950, Alan Turing published his seminal paper, 'Computing Machinery and Intelligence,' proposing the Turing Test as a criterion of intelligence, a foundational concept in the philosophy and development of artificial intelligence.",
"The Dartmouth Conference in 1956 is considered the birthplace of artificial intelligence as a field; here, John McCarthy and others coined the term 'artificial intelligence' and laid out its basic goals.",
"In 1951, British mathematician and computer scientist Alan Turing also developed the first program designed to play chess, demonstrating an early example of AI in game strategy.",
"The invention of the Logic Theorist by Allen Newell, Herbert A. Simon, and Cliff Shaw in 1955 marked the creation of the first true AI program, which was capable of solving logic problems, akin to proving mathematical theorems."
]
results = rf(
query=query,
documents=documents,
top_k=3,
)
For more information, refer to the PyMilvus Documentation.
Re-ranking results with bge-reranker-base
via FlagEmbedding Python SDK
from FlagEmbedding import FlagReranker
reranker = FlagReranker('BAAI/bge-reranker-base', use_fp16=True)
query = "What event in 1956 marked the official birth of artificial intelligence as a discipline?"
documents = [
"In 1950, Alan Turing published his seminal paper, 'Computing Machinery and Intelligence,' proposing the Turing Test as a criterion of intelligence, a foundational concept in the philosophy and development of artificial intelligence.",
"The Dartmouth Conference in 1956 is considered the birthplace of artificial intelligence as a field; here, John McCarthy and others coined the term 'artificial intelligence' and laid out its basic goals.",
"In 1951, British mathematician and computer scientist Alan Turing also developed the first program designed to play chess, demonstrating an early example of AI in game strategy.",
"The invention of the Logic Theorist by Allen Newell, Herbert A. Simon, and Cliff Shaw in 1955 marked the creation of the first true AI program, which was capable of solving logic problems, akin to proving mathematical theorems."
]
results = reranker.compute_score([[query, document] for document in documents])
Start Free, Scale Easily
Try the fully-managed vector database built for your GenAI applications.
Try Zilliz Cloud for Free