Text Ranking
sentence-transformers
Safetensors
xlm-roberta
cross-encoder
reranker
text-embeddings-inference
Instructions to use kiel2/Kiel-2-Rerank with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use kiel2/Kiel-2-Rerank with sentence-transformers:
from sentence_transformers import CrossEncoder model = CrossEncoder("kiel2/Kiel-2-Rerank") query = "Which planet is known as the Red Planet?" passages = [ "Venus is often called Earth's twin because of its similar size and proximity.", "Mars, known for its reddish appearance, is often referred to as the Red Planet.", "Jupiter, the largest planet in our solar system, has a prominent red spot.", "Saturn, famous for its rings, is sometimes mistaken for the Red Planet." ] scores = model.predict([(query, passage) for passage in passages]) print(scores) - Notebooks
- Google Colab
- Kaggle
metadata
tags:
- sentence-transformers
- cross-encoder
- reranker
base_model: BAAI/bge-reranker-base
pipeline_tag: text-ranking
library_name: sentence-transformers
Kiel-2-Rerank
Kiel-2-Rerank is a high-performance Cross-Encoder reranker based on BAAI/bge-reranker-base.
This is a Cross Encoder model that evaluates query-document text pairs jointly to compute precise relevance scores for semantic search and multi-stage retrieval pipelines.
Model Details
Model Description
- Model Type: Cross Encoder / Relevance Reranker
- Base Model: BAAI/bge-reranker-base
- Maximum Sequence Length: 512 tokens
- Number of Output Labels: 1 label (Regression / Logits score)
- Supported Modality: Text
Model Sources
- Documentation: Sentence Transformers Documentation
- Cross Encoder Guide: Cross Encoder Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face Hub: kiel2/Kiel-2-Rerank
Full Model Architecture
CrossEncoder(
(0): Transformer({'transformer_task': 'sequence-classification', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'scores', 'architecture': 'BertForSequenceClassification'})
)
Direct Usage (Sentence Transformers)
First, install the Sentence Transformers library:
Bash
pip install -U sentence-transformers
Then load your model and run inference:
Python
from sentence_transformers import CrossEncoder
# Load your custom reranker from the Hugging Face Hub
model = CrossEncoder("kiel2/Kiel-2-Rerank")
# Get relevance scores for pairs of inputs (query, document)
pairs = [
[
'" The public is understandably losing patience with these unwanted phone calls , unwanted intrusions , " he said at a White House ceremony .',
'" While many good people work in the telemarketing industry , the public is understandably losing patience with these unwanted phone calls , unwanted intrusions , " Mr. Bush said .'
],
[
'Federal agent Bill Polychronopoulos said it was not known if the man , 30 , would be charged .',
'Federal Agent Bill Polychronopoulos said last night the man involved in the Melbourne incident had been unarmed .'
],
]
scores = model.predict(pairs)
print(scores)
# Alternatively, rank an array of candidate texts against a single query
ranks = model.rank(
'The public is losing patience with unwanted phone calls.',
[
'While many good people work in telemarketing, the public is losing patience with unwanted intrusions.',
'Federal agents reported an unarmed suspect in the downtown incident.',
'Corporate earnings reports will be released at the close of the fiscal year.'
]
)
print(ranks)
Citation
Code snippet
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "[https://arxiv.org/abs/1908.10084](https://arxiv.org/abs/1908.10084)",
}