What is an embedding?

An embedding is a series of numbers that represents the meaning of a text, so that two texts with similar meaning get similar series.

4 min read

A computer does not understand that "opening hours" and "what time are you open?" mean the same thing: the words are different. An embedding solves that problem. It is a series of numbers that represents the meaning of a text, calculated by a specialized model, so that two texts with similar meaning get similar series of numbers.

How it works, simply

Imagine a map where each sentence is placed according to what it means. Questions about opening hours would end up in one corner, questions about prices in another, questions about returns somewhere else again. An embedding is a text's address on that map. The map does not have two dimensions but several hundred, or even a few thousand, which lets it capture fine nuances.

To know whether two texts are about the same thing, you then only need to measure the distance between their addresses. It is a fast calculation that the computer can repeat across thousands of passages in a fraction of a second.

Where the idea comes from

The idea of representing words by numbers according to their context is old in linguistics: you know a word by the company it keeps. It took off in practice in 2013 with word2vec, a method published by a Google team led by Tomas Mikolov, which calculated one vector per word. Current models go further: they calculate an embedding for a whole sentence or paragraph, taking word order and context into account.

What embeddings do in an AI assistant

Embeddings are at the heart of semantic search, which lets an assistant find the right passage in your documents even if the visitor does not use the same words. It works in two stages:

  1. During preparation, each document in the knowledge base is split into passages, and each passage gets its embedding. These vectors are stored in a vector database
  2. With every question, the question in turn gets an embedding, and the system looks for the passages whose vectors are closest. These passages are passed to the language model, which writes the answer

This is the first step of RAG. If it retrieves the wrong passages, even the best model will give an answer that misses the point.

Embeddings across languages

Multilingual embedding models place texts in different languages on the same map. A Dutch question about the "opzegtermijn" then lands close to a French passage about the "délai de préavis" (notice period). That is what lets a Belgian assistant answer in three languages from a single version of the documents, provided the technical terms are checked.

This matching works well for everyday vocabulary. It can be less reliable for in-house abbreviations, offer names or administrative terms specific to a region. A glossary that puts these terms side by side in the documents helps the search.

Limits to keep in mind

  • Meaning, not facts. An embedding says that two texts are about the same subject, not that one correctly answers the other. A passage about in-store returns will be close to a question about online returns, even if it does not apply to them
  • Splitting matters. A passage that is too long mixes several topics and becomes blurred; a passage that is too short loses its context. Documents structured in clear sections give better results
  • Numbers and codes are poorly represented. A product reference or item number is better found by a classic search on the exact words
  • Changing embedding model means recalculating every vector, because two models do not place texts on the same map

That is why many systems combine embedding search with keyword search: the first finds the meaning, the second the exact terms.

Embeddings, training and confidentiality

Calculating an embedding does not change the model or train it on your documents. The text is sent to the embedding model, which returns the series of numbers. As with any data passed to a provider, the processing terms must be known, especially if the documents contain personal information. The simplest approach remains not to load personal data into a public knowledge base.

And in KernChat?

KernChat does not use embeddings at present. The sources of a knowledge space go as they are into the model's context window, in the priority order set by the organization, and every sentence that relies on a source cites it. When the sources do not all fit within the set limit, a ranking by words shared with the question lets the closest ones in first. This choice keeps the answer faithful to the full text of the documents, without depending on splitting them into passages, and suits the size of an SME's documentation.

To go further

Frequently asked questions

Does an embedding train the model on my documents?
No. Calculating an embedding does not change the model: the text is sent to the embedding model, which returns a series of numbers. The provider's processing terms still need checking, as with any data passed on.
What is the difference between embeddings and keyword search?
Keyword search finds texts containing the same words. Embeddings find texts with the same meaning, even when worded differently or in another language. Many systems combine both.

See it on your own cases

Everything starts with a one-hour audit of your questions, your documents and your tools. Then we propose the level that fits.

Request a demo