RAGFine-TuningFrameworks

Sentence Transformers Documentation — Embeddings, Rerankers and Sparse Encoders

by Hugging Face

IntermediateDocumentationFree~5-8 hours to work through the usage and training guides; ongoing as API reference

The reference for training your own embedding, reranker and sparse retrieval models — not just calling someone else's.

Start LearningAdded Aug 7, 2026 · Updated Aug 7, 2026

Overview

The docs are organized into a Getting Started section (installation via uv, pip, Conda or source, a quickstart, and migration guides covering v2.x through v5.4+) followed by three parallel tracks — Sentence Transformer, Cross Encoder and Sparse Encoder — that each run Usage, Pretrained Models, Training Overview, Training Examples, and Dataset and Loss overviews, closing with a full Package Reference. The training examples are real worked pipelines rather than API stubs: STS, NLI, MS MARCO, Matryoshka representation learning, multilingual training, knowledge distillation and unsupervised learning for bi-encoders; STS, NLI, MS MARCO, reranker and distillation recipes for cross-encoders; and SPLADE-style training for sparse models. The library exposes 20+ losses for embedding models, 10+ for rerankers and 10+ for sparse encoders, plus encode_query and encode_document, the Router module for asymmetric models, multi-process encoding, and embedding quantization. It is current: v5.0 (July 2025) introduced sparse encoders, v5.4 added first-class multimodal support across text, image, audio and video along with a modularized CrossEncoder supporting generative rerankers, v5.5 shipped the train-sentence-transformers Agent Skill plus EmbedDistillLoss and ADRMSELoss, and v5.7.0 was released on 6 August 2026. Maintained by Hugging Face under Apache-2.0 with 19k GitHub stars, it drives over 15,000 pretrained models on the Hub, including most of the MTEB leaderboard.

At a Glance

Topic
RAG
Level
Intermediate
Format
Documentation
Cost
Free
Duration
~5-8 hours to work through the usage and training guides; ongoing as API reference
Provider
Hugging Face
Hands-on
Yes — code/exercises
Certificate
None

What You’ll Learn

  • Compute dense, sparse and multimodal embeddings and score similarity between all pairs
  • Fine-tune a bi-encoder on your own domain data with an appropriate loss function
  • Train a CrossEncoder reranker to re-score the top-k results from first-stage retrieval
  • Build SPLADE-style sparse encoders that stay interpretable and work with inverted indexes
  • Choose among 20+ embedding losses, 10+ reranker losses and 10+ sparse encoder losses
  • Apply Matryoshka representation learning to shrink embedding dimensions without retraining
  • Use encode_query, encode_document and the Router module for asymmetric retrieval models
  • Quantize embeddings to int8 or binary and measure the retrieval quality you actually lose

Highlights

  • Covers the whole retrieval stack — bi-encoder, cross-encoder reranker and sparse encoder — behind one shared training API
  • Genuinely current: v5.7.0 shipped 6 August 2026, following sparse encoders in v5.0 and multimodal support in v5.4
  • Training pages are copy-and-swap worked examples (STS, NLI, MS MARCO, Matryoshka, distillation), not reference stubs
  • 19k GitHub stars, Apache-2.0, and 15,000+ compatible pretrained models on the Hugging Face Hub
  • Documents the parts most RAG tutorials skip: dataset formats, loss selection, and embedding quantization trade-offs

Who It’s For

Best For

  • RAG engineers whose retrieval quality has plateaued on off-the-shelf embedding models
  • ML engineers who need a domain-specific embedding or reranker rather than a general one
  • Search engineers evaluating dense versus sparse versus hybrid retrieval
  • Anyone picking a model off the MTEB leaderboard who wants to know what the numbers mean

Prerequisites

  • Working Python and PyTorch familiarity — the training pages assume you can read a training loop
  • Basic understanding of embeddings, vector similarity and top-k retrieval
  • A GPU is assumed for the fine-tuning examples, though inference runs fine on CPU

FAQ

What is Sentence Transformers Documentation — Embeddings, Rerankers and Sparse Encoders?

Official documentation for Sentence Transformers (SBERT), the Python library for using and training embedding models, cross-encoder rerankers and sparse encoders. Written for RAG and search engineers whose retrieval quality has plateaued on off-the-shelf embeddings. After working through it you can fine-tune a domain-specific bi-encoder, train a reranker to re-score top-k candidates, and pick a loss function on evidence rather than guesswork.

Is Sentence Transformers Documentation — Embeddings, Rerankers and Sparse Encoders free?

Sentence Transformers Documentation — Embeddings, Rerankers and Sparse Encoders is free to access.

What level is Sentence Transformers Documentation — Embeddings, Rerankers and Sparse Encoders for?

Sentence Transformers Documentation — Embeddings, Rerankers and Sparse Encoders is aimed at a intermediate audience. Recommended background: Working Python and PyTorch familiarity — the training pages assume you can read a training loop, Basic understanding of embeddings, vector similarity and top-k retrieval, A GPU is assumed for the fine-tuning examples, though inference runs fine on CPU.

How long does Sentence Transformers Documentation — Embeddings, Rerankers and Sparse Encoders take?

Expect roughly ~5-8 hours to work through the usage and training guides; ongoing as API reference. Most learners work through it at their own pace.

What will I learn from Sentence Transformers Documentation — Embeddings, Rerankers and Sparse Encoders?

You'll learn: Compute dense, sparse and multimodal embeddings and score similarity between all pairs; Fine-tune a bi-encoder on your own domain data with an appropriate loss function; Train a CrossEncoder reranker to re-score the top-k results from first-stage retrieval; Build SPLADE-style sparse encoders that stay interpretable and work with inverted indexes; Choose among 20+ embedding losses, 10+ reranker losses and 10+ sparse encoder losses; Apply Matryoshka representation learning to shrink embedding dimensions without retraining; Use encode_query, encode_document and the Router module for asymmetric retrieval models; Quantize embeddings to int8 or binary and measure the retrieval quality you actually lose.

Topics

embeddingsrerankerssentence-transformerssemantic-searchsparse-retrieval

Sources

This page was written from 4 sources, 3 on domains other than sbert.net.

  1. 1.sbert.netsbert.netvendor
  2. 2.github.comsentence transformers
  3. 3.github.comreleases
  4. 4.pypi.orgsentence transformers