Skip to content
Technology, explained from the insideAI · Software · Digital payments
TayoTechTalk.

How AI Works

AI Embeddings Explained: How Search Finds Related Meaning

By Temitayo Solomon Gbadebo · November 24, 2026
An orange search query connects to three teal documents within a related cluster, with other document clusters farther away.

You search a help centre for “How can I get a copy of last month’s invoice?” The useful page is called “Download billing documents.” A search based only on overlapping words might struggle. A system that compares learned representations of meaning has another way to find it.

Those representations are called embeddings. They turn content into numbers that a computer can compare. In a well-matched search system, a question and a useful passage can receive similar representations even when their wording differs.

Our earlier guide to retrieval-augmented generation, or RAG, introduced this search step. Here, we will open that step up: what the numbers represent, how similarity is calculated, and why a close match is still only a candidate.

What is an AI embedding?

An embedding is an ordered list of numbers, also called a vector. Each position in the list is a dimension. A text embedding model can convert a sentence or passage into a fixed-size vector that another part of an application stores and compares.

Imagine a map on which related items tend to appear near one another. That is a useful starting point, but real embeddings usually have far more than the two dimensions on a printed map. They also do not come with neat labels such as “billing” for one coordinate and “delivery” for another. Meaning is spread across the representation, and the arrangement depends on the model and its task. Google’s embedding-space lesson explains both the geometric intuition and the limits of interpreting individual dimensions.

An embedding is therefore not a document ID, a word count or a written summary. An ID identifies a record. An embedding makes mathematical comparison possible. The original passage still needs to be stored or linked so that a reader, or an answering model, can use its actual wording.

How does the model learn a useful arrangement?

The arrangement comes from training. The training objective encourages representations that help with the chosen task. For a retrieval model, that can mean making a question more compatible with a relevant passage than with an irrelevant one. This is learned from examples rather than by manually assigning a coordinate to every concept.

The Sentence-BERT paper by Nils Reimers and Iryna Gurevych is an influential example: it trained sentence representations that could be compared efficiently using cosine similarity. It is one approach, not a claim that all embedding models have the same architecture or training data.

Generating an embedding with an already-trained model is an inference operation. It does not automatically retrain that model on your document. Google’s guide to obtaining embeddings describes how representations are learned during training and how surrounding context can change a word’s representation. This connects to our distinction between training and inference.

From a question to a search result

A common dense-vector search workflow has two stages. First, prepare the collection. Later, process each question. The Sentence Transformers semantic-search guide describes embedding both the searchable entries and the query into a compatible space.

  1. Prepare passages. Divide a long help centre into useful sections and keep each section’s text, title, source and version.
  2. Embed the passages. Run them through the chosen document-embedding configuration and store their vectors.
  3. Embed the question. Use the corresponding query configuration to produce a compatible vector.
  4. Compare and retrieve. Rank candidate vectors using the chosen similarity measure and return the linked passages.

“Compatible” matters. A model intended to match short questions with longer answers may use different instructions or processing for queries and documents. Sentence Transformers’ usage documentation provides separate query and document encoding methods for this reason. Using the right model name but the wrong input configuration can undermine retrieval.

This process can power a search box without any answer-generating chatbot. In RAG, a further step supplies selected passages to a language model. Finding a passage and writing an answer from it are different operations.

A small cosine-similarity example

One common comparison is cosine similarity. It compares the direction of two vectors. Vectors pointing in similar directions have a higher cosine similarity; their lengths alone do not determine the score.

To make the arithmetic visible, suppose our invoice question and three help pages have the following two-number vectors. These numbers are invented teaching examples, not outputs from a real embedding model or a search benchmark. Each vector has length 1. The two coordinates have no assigned topic labels.

ItemIllustrative vectorCosine similarity to question
Question: copy of last month’s invoice[1, 0]1.00, compared with itself
A: Download billing invoices[0.8, 0.6]0.80
B: Update your billing address[0.6, 0.8]0.60
C: Reset your account password[0, 1]0.00

Cosine similarity is the dot product divided by the product of the two vector lengths. For question and page A, the dot product is (1 × 0.8) + (0 × 0.6) = 0.8. Both lengths are 1, so dividing by 1 × 1 leaves 0.8. The same calculation gives 0.6 for B and 0 for C.

In this deliberately simple example, A ranks ahead of B and C. Nothing in the calculation has read the invoice policy or checked whether the requested month is available. The score describes a relationship between representations. It does not establish that the page answers every part of the question.

A cosine similarity of 0.80 also does not mean an 80% chance of correctness. Search products may transform similarity values or combine several rankings before returning a score. Microsoft’s vector-ranking documentation describes its scoring transformation. Always check what a returned score means before treating it as a probability or comparing it with a score from another system.

Three mistakes a similarity score cannot fix

Related topic, wrong answer. “How do I cancel my plan?” and “This plan cannot be cancelled during its minimum term” concern the same subject. A relevant passage may contain a refusal or an exception. Similarity alone does not tell you which action the policy permits. Read the retrieved text.

The exact identifier matters. A question about invoice INV-1042 must not be answered from INV-1043 simply because the documents look similar. Keyword search and structured filters are useful partners for vector search. Microsoft’s hybrid-search overview specifically identifies codes, names and dates as cases where exact matching can help.

The collection has no answer. If every stored page is irrelevant, one can still be the nearest. Asking for the top three results means “return the best available candidates,” not “prove that three suitable answers exist.” In our fictional help centre, a question about a missing historical invoice may need an explicit “not found” outcome.

Why replacing an embedding model is a data change

Vectors are meaningful within the representation system that produced them. Two models can each output the same number of coordinates without assigning them compatible meanings. Microsoft’s vector-query guidance recommends using the same embedding model for source documents and incoming questions.

For a typical application, changing the embedding model therefore means re-embedding the stored passages and building or updating the corresponding index, not simply pointing new questions at a different model. Record the model version, dimensions and query/document settings together. If a provider explicitly documents compatibility, use that guidance rather than assuming it.

There is also a separate search-engine trade-off. An exhaustive search compares against the whole eligible collection. An approximate nearest-neighbour index reduces the search work but can miss some of the closest vectors. That is a retrieval-speed trade-off, not a change in what the words mean. A poor result could come from the representation, the index settings or the documents themselves.

A practical way to check whether it works

For the fictional help centre, build a small set of questions with known relevant pages. Judge the returned text rather than only watching the similarity score:

  • Different wording: Does “get a copy of my bill” retrieve the invoice-download page?
  • A near miss: Does “change my billing address” bring back the address instructions rather than the invoice page?
  • An exact reference: Does an invoice-number filter exclude the wrong invoice?
  • A missing answer: Does a question outside the collection avoid becoming an unsupported answer?
  • A decisive condition: If an archived invoice requires a different process, does the retrieved passage include that condition?

Keep the expected page and the actual top results for each test. Repeat the same checks when documents, chunk boundaries, embedding models or search settings change. This makes it easier to see whether an apparent improvement really helped the questions readers ask.

Store the original text and useful metadata alongside the vector. Microsoft’s vector-search overview describes filtering on separate text and numeric fields. Dates, document status and access permissions should be enforced through the application’s data and access rules, not inferred from semantic closeness.

Embeddings make meaning comparable enough to help a search system find useful candidates. Their strength is flexible matching across different wording. Their boundary is just as important: a mathematical neighbour is not automatically the right source, a true statement or permission to act.