Skip to content

Embedding

Briefly

Embedding is the transformation of text, images, or sound into a vector of numbers that reflects its meaning. Semantically similar objects receive close vectors.

What is it

Embedding is a 'semantic snapshot' of text. A special neural network called an embedder transforms a word, sentence, or entire document into a list of coordinates in the form of [0.23, -0.81, 0.45, ...]. The length of such a list can range from hundreds to thousands of numbers.

How 'semantic space' works

In the multidimensional space of embeddings:

  • the vectors for 'king' and 'monarch' are close to each other;
  • the vector for 'apple' is far from them;
  • 'cat' will be close to 'kitten', even though the letters in the words are different.

This is why searching by embeddings is called semantic: it searches by meaning, not by letters.

Why is it needed

Embeddings are the foundation of RAG. Without them, it is impossible to search for relevant fragments of documents. Each fragment of the knowledge base is transformed into a vector, and when a query is made, the system searches for the closest vectors to the query vector.

Who can do embeddings

  • OpenAI (text-embedding-3)
  • Cohere Embed
  • BGE, E5 (open models)
  • Sentence Transformers (locally)

See also