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
Update README.md
Browse files
README.md
CHANGED
|
@@ -3,18 +3,18 @@ tags:
|
|
| 3 |
- sentence-transformers
|
| 4 |
- cross-encoder
|
| 5 |
- reranker
|
| 6 |
-
- generated_from_trainer
|
| 7 |
-
- dataset_size:5000
|
| 8 |
-
- loss:BinaryCrossEntropyLoss
|
| 9 |
base_model: BAAI/bge-reranker-base
|
| 10 |
pipeline_tag: text-ranking
|
| 11 |
library_name: sentence-transformers
|
| 12 |
---
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
A high-performance Cross-Encoder reranker fine-tuned from `BAAI/bge-reranker-base`.
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
## Model Details
|
| 20 |
|
|
@@ -29,17 +29,25 @@ This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.h
|
|
| 29 |
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
|
| 30 |
- **Cross Encoder Guide:** [Cross Encoder Documentation](https://www.sbert.net/docs/cross_encoder/usage/usage.html)
|
| 31 |
- **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
|
|
|
|
| 32 |
|
| 33 |
### Full Model Architecture
|
| 34 |
```text
|
| 35 |
CrossEncoder(
|
| 36 |
(0): Transformer({'transformer_task': 'sequence-classification', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'scores', 'architecture': 'BertForSequenceClassification'})
|
| 37 |
)
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
# Load your custom reranker from the Hugging Face Hub
|
| 42 |
-
model = CrossEncoder("
|
| 43 |
|
| 44 |
# Get relevance scores for pairs of inputs (query, document)
|
| 45 |
pairs = [
|
|
@@ -65,11 +73,9 @@ ranks = model.rank(
|
|
| 65 |
]
|
| 66 |
)
|
| 67 |
print(ranks)
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
}
|
| 72 |
-
Training HyperparametersPer Device Train Batch Size: 4Gradient Accumulation Steps: 8 (Effective batch size = 32)Learning Rate: 2e-05Number of Epochs: 1Warmup Steps: 0.1Mixed Precision: FP16 EnabledOptimizer: adamw_torch_fusedTraining LogsEpochStepTraining Loss0.16251.75220.32500.41950.48750.35220.641000.36460.81250.36390.961500.3551Total Training Time: 5.2 minutesFramework VersionsPython: 3.13.15Sentence Transformers: 5.7.0Transformers: 5.16.1PyTorch: 2.11.0+cu128Accelerate: 1.14.0Datasets: 4.8.5Tokenizers: 0.23.1Additional ResourcesTraining and Finetuning Reranker Models with Sentence Transformers: Comprehensive guide for training custom Cross-Encoders.CitationBibTeXCode snippet@inproceedings{reimers-2019-sentence-bert,
|
| 73 |
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
|
| 74 |
author = "Reimers, Nils and Gurevych, Iryna",
|
| 75 |
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
|
|
@@ -77,4 +83,4 @@ Training HyperparametersPer Device Train Batch Size: 4Gradient Accumulation Step
|
|
| 77 |
year = "2019",
|
| 78 |
publisher = "Association for Computational Linguistics",
|
| 79 |
url = "[https://arxiv.org/abs/1908.10084](https://arxiv.org/abs/1908.10084)",
|
| 80 |
-
}
|
|
|
|
| 3 |
- sentence-transformers
|
| 4 |
- cross-encoder
|
| 5 |
- reranker
|
|
|
|
|
|
|
|
|
|
| 6 |
base_model: BAAI/bge-reranker-base
|
| 7 |
pipeline_tag: text-ranking
|
| 8 |
library_name: sentence-transformers
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# Kiel-2-Rerank
|
|
|
|
| 12 |
|
| 13 |
+
**Kiel-2-Rerank** is a high-performance Cross-Encoder reranker based on `BAAI/bge-reranker-base`.
|
| 14 |
+
|
| 15 |
+
This is a [Cross Encoder](https://www.sbert.net/docs/cross_encoder/usage/usage.html) model that evaluates query-document text pairs jointly to compute precise relevance scores for semantic search and multi-stage retrieval pipelines.
|
| 16 |
+
|
| 17 |
+
---
|
| 18 |
|
| 19 |
## Model Details
|
| 20 |
|
|
|
|
| 29 |
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
|
| 30 |
- **Cross Encoder Guide:** [Cross Encoder Documentation](https://www.sbert.net/docs/cross_encoder/usage/usage.html)
|
| 31 |
- **Repository:** [Sentence Transformers on GitHub](https://github.com/huggingface/sentence-transformers)
|
| 32 |
+
- **Hugging Face Hub:** [kiel2/Kiel-2-Rerank](https://huggingface.co/kiel2/Kiel-2-Rerank)
|
| 33 |
|
| 34 |
### Full Model Architecture
|
| 35 |
```text
|
| 36 |
CrossEncoder(
|
| 37 |
(0): Transformer({'transformer_task': 'sequence-classification', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'logits'}}, 'module_output_name': 'scores', 'architecture': 'BertForSequenceClassification'})
|
| 38 |
)
|
| 39 |
+
Direct Usage (Sentence Transformers)
|
| 40 |
+
First, install the Sentence Transformers library:
|
| 41 |
+
|
| 42 |
+
Bash
|
| 43 |
+
pip install -U sentence-transformers
|
| 44 |
+
Then load your model and run inference:
|
| 45 |
+
|
| 46 |
+
Python
|
| 47 |
+
from sentence_transformers import CrossEncoder
|
| 48 |
|
| 49 |
# Load your custom reranker from the Hugging Face Hub
|
| 50 |
+
model = CrossEncoder("kiel2/Kiel-2-Rerank")
|
| 51 |
|
| 52 |
# Get relevance scores for pairs of inputs (query, document)
|
| 53 |
pairs = [
|
|
|
|
| 73 |
]
|
| 74 |
)
|
| 75 |
print(ranks)
|
| 76 |
+
Citation
|
| 77 |
+
Code snippet
|
| 78 |
+
@inproceedings{reimers-2019-sentence-bert,
|
|
|
|
|
|
|
| 79 |
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
|
| 80 |
author = "Reimers, Nils and Gurevych, Iryna",
|
| 81 |
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
|
|
|
|
| 83 |
year = "2019",
|
| 84 |
publisher = "Association for Computational Linguistics",
|
| 85 |
url = "[https://arxiv.org/abs/1908.10084](https://arxiv.org/abs/1908.10084)",
|
| 86 |
+
}
|