← Lessons

quiz vs the machine

Silver1100

Machine Learning

The Sentence Embeddings

Compressing a whole sentence into one vector you can search and compare.

4 min read · intro · beat Silver to climb

Beyond single words

A sentence embedding represents an entire sentence or short passage as one fixed length vector. This lets you measure how similar two pieces of text are by comparing vectors, which powers search, clustering, and retrieval.

How they are produced

Modern sentence encoders run the text through a transformer and then pool the token vectors into one.

  • Mean pooling averages all token vectors.
  • CLS pooling takes the vector of a special leading token.

Naive averaging of word embeddings is a weak baseline; trained encoders such as Sentence BERT produce far stronger vectors.

Why a dedicated model helps

A plain language model is tuned to predict tokens, not to make whole sentence vectors comparable. Sentence encoders are fine tuned with pairs of similar and dissimilar sentences so that the pooled vector lands in a space where distance tracks meaning.

What you can do with them

Once each sentence is a vector you can rank candidates by similarity, group them, or feed them to a downstream classifier. The same vector serves many tasks without retraining.

Key idea

Sentence embeddings pool token outputs into a single comparable vector, and a model fine tuned on sentence pairs gives a space where distance reflects meaning.

Check yourself

Answer to earn rating on the learn ladder.

1. What does pooling accomplish in a sentence encoder?

2. Why fine tune a model specifically for sentence embeddings?