Training and Finetuning Reranker Models with Sentence Transformers
Sentence Transformers is a Python library for using and training embedding and reranker models for a wide range of applications, such as retrieval augmented generation, semantic search, semantic textual similarity, paraphrase mining, and more. In this blogpost, I’ll show you how to use it to finetune a reranker model (also known as a cross-encoder) that beats all existing options on exactly your data. This method can also train extremely strong new reranker models from scratch.
Finetuning reranker models involves several components: datasets, loss functions, training arguments, evaluators, and the trainer class itself. I’ll have a look at each of these components, accompanied by practical examples of how they can be used for finetuning strong reranker models.
Lastly, in the Evaluation section, I’ll show you that my small finetuned tomaarsen/reranker-ModernBERT-base-gooaq-bce reranker model that I trained alongside this blogpost easily outperforms the 13 most commonly used public reranker models on my evaluation dataset. It even beats models that are 4x