GuidesUnderstanding AI

Embeddings explained simply

By the Banzai Labs teamUpdated on 2 min read

trail shoerunning sneakerunpaid invoicepayment reminderSportPaymentClose meanings, close pointsTexts
Each text becomes a point. Two texts with close meanings land next to each other.

The principle

An embedding model reads a text and returns a vector: a few hundred to a few thousand numbers. No single number means anything. Together, they place the text in a space where distance measures difference in meaning.

From text to nearest neighbour
  1. A textA product page, a paragraph, a question.
  2. The modelIt returns a vector.
  3. The comparisonA similarity score, often cosine.
  4. The nearestTexts with a close meaning.

What it is for

  • Semantic searchFind an answer even when it is phrased differently.
  • RAGRetrieve the useful passages before answering. See RAG.
  • RecommendationSuggest similar products or articles.
  • ClassificationSort tickets or reviews by topic, without written rules.

Rules to know

  • One model for documents and questions.
  • Split long texts: one vector summarises ten pages badly.
  • Keep the original text next to the vector, so you can cite it.

Vectors are stored in a vector database.

Frequently asked questions

How is it different from keyword search?
Keyword search finds “running sneaker” only if those words are written. Embeddings also bring it close to “trail shoe”.
Can two embedding models be mixed?
No. Documents and questions must go through the same model. Changing model means recomputing everything.
Is it expensive?
Computing embeddings usually costs far less than generating text. The heaviest item is often storage and keeping it up to date.

Read next

All guides