---
title: "Training and Finetuning Reranker Models with Sentence Transformers"
description: "Sentence Transformers can finetune reranker (cross-encoder) models on domain data."
url: "https://swe.quest/articles/training-and-finetuning-reranker-models-with-sentence-transformers-56e6eabec0c38454"
canonical: "https://huggingface.co/blog/train-reranker"
source: "Hugging Face"
published: "2025-03-26"
difficulty: "medium"
kind: "How-to"
reading_minutes: 24
tags: ["model-training","search","rag","python"]
---

# Training and Finetuning Reranker Models with Sentence Transformers

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2025-03-26, 24 min read, How-to. Original: [https://huggingface.co/blog/train-reranker](https://huggingface.co/blog/train-reranker)

## Summary

Sentence Transformers can finetune reranker (cross-encoder) models on domain data. The guide covers each training component: dataset loading and column-format rules, hard-negative mining with mine\_hard\_negatives, loss functions such as BinaryCrossEntropyLoss and CachedMultipleNegativesRankingLoss, training arguments, evaluators and the CrossEncoderTrainer. A small ModernBERT-base reranker finetuned on GooAQ with mined hard negatives outperforms the 13 most commonly used public rerankers on that evaluation data, including models 4x larger. The large variant beats all general-purpose rerankers tested there, which makes the case for domain finetuning in retrieve-and-rerank pipelines.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Search](https://swe.quest/tags/search.md) (Backend & APIs)
- [RAG & retrieval](https://swe.quest/tags/rag.md) (AI & ML)
- [Python](https://swe.quest/tags/python.md) (Languages)

## Prerequisites

- Python ([easy posts on Python](https://swe.quest/tags/python.md?difficulty=easy))
- embedding models and semantic search ([easy posts on Search](https://swe.quest/tags/search.md?difficulty=easy))
- Hugging Face datasets
- neural network training basics ([easy posts on Model training](https://swe.quest/tags/model-training.md?difficulty=easy))

## Keywords

Sentence Transformers, CrossEncoder, ModernBERT, GooAQ, Hugging Face Datasets, FAISS, BinaryCrossEntropyLoss

## Related posts

- [Introducing the Ettin Reranker Family](https://swe.quest/articles/introducing-the-ettin-reranker-family-7e39cb92c1c0a726.md): Hugging Face · 2026-05-19 · Medium · 30 min read · Search, Model training, Inference & serving, Evaluation, Python
  Six Sentence Transformers CrossEncoder rerankers (17M to 1B parameters) built on the Ettin ModernBERT encoders are released with their data and full training recipe.
- [Training and Finetuning Embedding Models with Sentence Transformers](https://swe.quest/articles/training-and-finetuning-embedding-models-with-sentence-transformers-d6dcb3eebe384143.md): Hugging Face · 2024-05-28 · Medium · 14 min read · Model training, Python, Machine learning, Search, Evaluation
  Sentence Transformers v3 trains and finetunes embedding models through a SentenceTransformerTrainer that combines Hugging Face datasets, a loss function, optional training arguments and evaluators.
- [Training and Finetuning Multi-Vector Embedding Models with Sentence Transformers](https://swe.quest/articles/training-and-finetuning-multi-vector-embedding-models-with-sentence-transformers-454449569f0d4793.md): Hugging Face · 2026-08-26 · Medium · 27 min read · Model training, Search, Python, RAG & retrieval
  Sentence Transformers v6.0 adds a MultiVectorEncoder model type for ColBERT-style late-interaction retrieval, with a full training stack covering models, datasets, losses, training arguments, evaluators and the trainer.
- [Train and Fine-Tune Sentence Transformers Models](https://swe.quest/articles/train-and-fine-tune-sentence-transformers-models-49bc0c36b2cdc22e.md): Hugging Face · 2022-08-10 · Medium · 11 min read · Model training, Machine learning, Python, Search
  Sentence Transformers models map text to fixed-size embeddings by running a pre-trained Transformer and pooling its token embeddings, and training them depends on matching the dataset format to the right loss.
- [Training and Finetuning Multimodal Embedding & Reranker Models with Sentence Transformers](https://swe.quest/articles/training-and-finetuning-multimodal-embedding-reranker-models-with-sentence-4630fc81c2fcf375.md): Hugging Face · 2026-04-16 · Medium · 17 min read · Model training, Computer vision, Search, RAG & retrieval, Python
  Finetuning Qwen3-VL-Embedding-2B with Sentence Transformers for Visual Document Retrieval raised NDCG@10 from 0.888 to 0.947.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
