FDEInterviews logo
EMNLP-IJCNLP 2019

Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks

The 2019 paper that made BERT usable for semantic search: one vector per sentence, compared by cosine, turning a 65-hour job into 5 seconds.

Breakdown by FDE Interviews · 11 min read · Updated

About the original · 2019
AUTHORS
Reimers, Gurevych
FROM
UKP Lab, Technische Universität Darmstadt
PUBLISHED
Aug 2019 · EMNLP-IJCNLP 2019
CITED BY
21,383Semantic Scholar · Oct 2026
IN THIS BREAKDOWN · 10 SECTIONS

You can read 20% of this breakdown.

01

The paper in one minute

In 2019 BERT was the best model for judging whether two sentences mean the same thing, but it did that by reading both sentences together in one pass. That is fine for one pair. For search it is a disaster: to find the most similar pair among 10,000 sentences you need about 50 million passes, which the authors measured at roughly 65 hours on a V100 GPU. Finding the closest of Quora's 40 million questions to a new one would take over 50 hours per query.

The obvious shortcut was to run BERT on each sentence alone and use its output as a sentence vector. The authors tested that and found it was bad. Averaging BERT's outputs scored 54.8 on a set of similarity benchmarks, and the popular [CLS] token vector scored 29.2, both below simply averaging old GloVe word vectors at 61.3.

Their fix was Sentence-BERT. Two copies of BERT with shared weights each read one sentence, their outputs are averaged into one vector per sentence, and the network is fine-tuned on sentence pairs labeled as entailing, contradicting or unrelated so that the vectors line up with meaning. After that, each sentence is encoded once, and comparing any two is a cosine similarity, a few multiplications.

The 65-hour search dropped to about 5 seconds, and the vectors beat every earlier sentence embedding method. Every embedding model behind a vector database today follows this design.

THE IDEA, VISUALLY
CROSS-ENCODER: BERT AS PUBLISHED Sentence A Sentence B BERT reads both score Every pair is a full model pass. 10,000 sentences: 49,995,000 passes about 65 hours BI-ENCODER: SENTENCE-BERT Sentence A BERT shared weights mean pooling u Sentence B BERT shared weights mean pooling v cosine(u, v) each sentence encoded once, vectors stored 10,000 passes + cosine: about 5 seconds Most similar of 40M Quora questions: from 50 hours per query to milliseconds with an index.
The trade at the center of every search system. A cross-encoder compares two texts directly and accurately; a bi-encoder turns each text into a vector once, so comparison becomes cheap arithmetic.
Research notes: the problem, approach and results
65 h → 5 s

to find the most similar pair among 10,000 sentences, BERT against SBERT on a V100

29.2

average similarity score of raw BERT's [CLS] vector, below averaged GloVe word vectors at 61.3

~7points

lost against a cross-encoder on argument topics never seen in training

THE PROBLEM

BERT compared two sentences by reading them together, so finding similar pairs in 10,000 sentences took 50 million model passes, and its single-sentence vectors were poor.

THE IDEA

Fine-tune BERT in a twin (siamese) setup so each sentence maps to one vector on its own, and similar sentences land close together under cosine similarity.

THE RESULT

Better sentence embeddings than any earlier method on seven similarity benchmarks, and search that runs in seconds instead of days.

02

Why it matters to an FDE

Every retrieval system you build rests on the trade-off this paper measured.

Embeddings are a compromise, and the paper says how big. When both were trained on the same data, the BERT cross-encoder still beat SBERT on the similarity benchmark (88.8 against 86.1 for the large models). On a harder task, judging whether two arguments make the same claim with the same reasoning on a topic never seen in training, SBERT fell about 7 points behind. A vector built without seeing the other text cannot weigh every word against it.

So production search has two stages. Retrieve candidates with embeddings, because only vectors make search over millions of documents cheap, then rerank the top few dozen with a cross-encoder, because only it reads the query and document together. That pipeline is the direct consequence of this paper's numbers, and recommending it is one of the most common pieces of advice you will give.

Not every model's output is a good embedding. Raw BERT vectors were worse than 2014-era word averages for similarity. A model that is excellent at one task can produce vectors that are poor for search. Use a model trained for embeddings, and test it on the customer's own queries before trusting a public leaderboard.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 49 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦2 results tables
  • ?5 interview questions with answers
  1. 03Key takeaways

    The ideas to keep, both architectures side by side, the cost arithmetic and misreadings

    Free account
  2. 04How it works

    The architecture, three training objectives and the ablations behind today's defaults

    Premium
  3. 05The numbers that matter

    The benchmark results, the cross-encoder comparison and the speed table, with sources

    Premium
  4. 06Try it yourself

    Index 100,000 texts and price the cross-encoder alternative with the paper's numbers

    Premium
  5. 07Where it breaks

    The limits the authors measured, and the ones that show up in enterprise retrieval

    Premium
  6. 08Using it on a deployment

    Choosing an embedding model, building the two-stage pipeline, and managing re-embedding

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →