If you search for "how to return a faulty product" in an online shop's archive and the right document is titled "Warranty returns procedure", a traditional keyword search may not find it: the words do not match. A semantic search, on the other hand, does find it, because it compares meaning rather than individual words. Behind this ability lies a fundamental concept of modern artificial intelligence: embeddings.
From text to vectors
An embedding is a list of numbers, a vector, that represents a piece of text: a word, a sentence, a paragraph or an entire document. These numbers are not random. They are produced by a model trained so that texts with similar meanings get vectors close to each other, and texts with different meanings get vectors far apart.
To get an idea, imagine a map. Each sentence is a point. "The flight was cancelled" and "The airline called off the departure" end up very close together; "The cake is in the oven" sits somewhere else entirely. In reality the map does not have two dimensions but hundreds or thousands, and each dimension captures some nuance of meaning in a way that does not always have a simple human interpretation.
How closeness is measured
To find out how similar two texts are, their vectors are compared. The most widely used measure is cosine similarity, which essentially checks whether the two vectors "point" in the same direction. The result is a number: the higher it is, the closer the texts are in meaning.
The beauty of this approach is that no hand-written linguistic rule is needed. Synonyms, paraphrases and even translations into other languages can turn out to be close, if the model producing the embeddings was trained on multilingual data.
How a semantic search works
The process has two stages.
Preparing the archive
- Documents are split into chunks of reasonable length, such as paragraphs or sections.
- An embedding is computed for each chunk.
- Vectors and texts are stored in a suitable archive, often called a vector database, designed to find the nearest vectors quickly among millions.
Querying
- The user's question is turned into an embedding with the same model.
- The system searches the archive for the chunks with the closest vectors.
- It returns the results ranked by similarity.
Keywords or meaning?
| Aspect | Keyword search | Semantic search |
|---|---|---|
| What it compares | The words present | Meaning |
| Synonyms and paraphrases | Often misses them | Finds them |
| Codes, acronyms, exact numbers | Very precise | Can be imprecise |
| Explainability | Easy to see why a result appears | Less immediate |
The two techniques are not mutually exclusive. Many systems use hybrid search: they combine keyword results, excellent for product codes or item numbers, with semantic results, better for freely phrased questions.
Where embeddings are used
- Corporate document archives: finding procedures, contracts or minutes without remembering their exact titles.
- Customer support: matching a request with the most relevant answer in the knowledge base.
- Recommendations: suggesting articles or products similar to those already liked.
- Duplicate detection: recognising reports or tickets describing the same problem in different words.
- Automatic grouping: organising thousands of comments or reviews by theme.
- RAG systems, in which a language model answers based on documents retrieved precisely through semantic search.
The choices that matter
Chunk size
Chunks that are too long mix different topics and the vector becomes an imprecise average. Chunks that are too short lose context. A small overlap is often left between consecutive chunks so that an idea is not cut in half.
The embedding model
Different models work better on different languages, sectors and text lengths. A generic model may confuse specialist technical terms. It is worth trying more than one on your own documents with a small set of questions whose answers you know.
Consistency
Documents and questions must be transformed with the same model: vectors produced by different models are not comparable. If you change model, the entire archive must be recomputed.
Permissions
A semantic search system must respect the same permissions as the original archive: if a user cannot open a document, they should not even see it appear among the results.
Limitations
Embeddings capture similarity of meaning, not truth or currency. An outdated but well-written document can turn out to be the most relevant. Closeness can also be misleading: "the contract includes the penalty" and "the contract does not include the penalty" are very similar texts with opposite meanings. That is why semantic search should be accompanied by metadata such as the document's date, version and validity status.
In short
- An embedding is a numerical vector representing the meaning of a text.
- Texts with similar meanings have close vectors, usually measured with cosine similarity.
- Semantic search finds relevant documents even when they share no words with the query.
- Hybrid search combines keywords and meaning to get the best of both.
- Chunk size, model choice, permissions and metadata determine the quality.