All models

Sentence-BERT

BERT fine-tuned in a siamese setup so single sentences become comparable embeddings.

Language · 316 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (28 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
109.5M
Operations
316
Framework
PyTorch
Recurrent
No
Published
EMNLP 2019
Cited by
86 (as of 5 October 2026)
Authors
Nils Reimers, Iryna Gurevych
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m14414
Graph hash
a8fff0c18d0f5964473ee1d7b44d5e86d5c345241c2b909749fae430aab0d864
Skeleton hash
a80b85d274bb323c430b54bdd623eae351d2bbcc555fd16ae83ff983290cad0c
Architecture hash
4ad7dfe61bca7dcb53b3ad7ce6df57a3145902975fc7f11fa2a4ad4406d86c80
Diagram SHA-256
24f41d7c27442a6372e85e92cf5a696e4e01a4faea92d49b9e2ab1a09bd4e28e
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

Sentence-BERT, or SBERT, is a modification of the pretrained BERT network that uses siamese and triplet network structures to produce sentence embeddings that can be compared with cosine similarity. The problem it solves is cost: BERT scores a sentence pair only when both sentences are fed in together, so finding the most similar pair among 10,000 sentences takes about 50 million inference computations, around 65 hours. With SBERT each sentence is embedded once, and the same search drops to about 5 seconds while keeping BERT's accuracy.

The architecture adds a pooling operation to the output of BERT to get a fixed-size sentence embedding, and the default is the MEAN strategy, averaging all output vectors. For training, the two embeddings u and v and their element-wise difference |u − v| are concatenated and fed to a softmax classifier, which is used only during fine-tuning. The member captured here is bert-base-nli-mean-tokens: a BertModel followed by a mean-pooling module, which maps sentences and paragraphs to a 768 dimensional dense vector space. Its transformer module is set to a maximum sequence length of 128 tokens.

This checkpoint is the paper's NLI model, trained on the combination of SNLI, 570,000 sentence pairs labelled contradiction, entailment and neutral, and MultiNLI, 430,000 pairs. Fine-tuning used a 3-way softmax classifier objective for one epoch with a batch size of 16 and the Adam optimizer. The paper evaluates SBERT and SRoBERTa on semantic textual similarity and transfer learning tasks, where it outperforms other state-of-the-art sentence embedding methods. The Hub card now marks this original model as deprecated, saying it produces sentence embeddings of low quality and pointing to newer sentence-transformers models.

Key idea. Siamese fine-tuning of BERT with pooled sentence embeddings, so semantic similarity search over 10,000 sentences falls from about 65 hours to about 5 seconds at BERT-level accuracy.

  • Sentence-BERT
  • SBERT
  • sentence-transformers
  • bert-base-nli-mean-tokens
  • sentence embeddings
  • semantic similarity
  • semantic search
  • bi-encoder
  • Reimers
  • UKPLab

AI-written summary, checked automatically against its sources; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{reimers2019sentencebertsentenceembeddingsusing,
      title={Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks}, 
      author={Nils Reimers and Iryna Gurevych},
      year={2019},
      eprint={1908.10084},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/1908.10084}, 
}