KI & Agents
VectorsCosine SimilarityRAGGemini

Embeddings – Finding Related Content

Embeddings help search find related content even when the wording differs, by representing queries and passages as comparable numerical vectors.

LKLukas Kopischke
Last updated on

You search for “forgot password”, but the relevant help article is called “restore account access”. A search that only matches those words might miss it. How can it still find the right content?

Embeddings help search find related content across different phrasings. A trained model turns queries and passages into numerical vectors. A mathematical comparison then identifies candidates whose content might match the query. This extends word matching with a measure of semantic proximity. The application still needs to check whether a result is useful, correct and appropriate for the user's context.

Key takeaway

Embeddings make semantic proximity computable. They help find relevant candidates, but a numerical score cannot establish relevance or correctness on its own.

How text becomes comparable numbers

An embedding model learns relationships between texts during training. It can therefore connect related phrasings even when they share few words. For each input, it calculates a . The length of that list is the number of dimensions.

Imagine a space where related content points in similar directions. “Forgot password” and “restore account access” might be closer together than “change delivery address”. Unlike a map, this space often has hundreds or thousands of dimensions. Individual coordinates generally cannot be read as properties such as “password” or “problem”. The relationship comes from the whole vector.

Context matters. “I sat on the river bank” and “I transferred money to my bank” use the same word for different things. An embedding represents the particular text, rather than one fixed word meaning for every situation.

How this becomes a search system

For documentation search, first divide content into meaningful passages and store their embeddings. At query time, calculate only the new query vector and compare it with the stored vectors:

  1. Prepare content: Store the vector for a password-reset passage alongside its text and source link.
  2. Represent the query: Embed “forgot password” with the same model and a compatible search configuration.
  3. Find candidates: Rank passages by their comparison scores.
  4. Select results: Filter by additional criteria such as language, freshness or product version.

Passage size affects retrieval. A whole article may mix several topics; a single sentence may lose essential context. Useful passages address one coherent question and retain enough information to make sense on their own.

Exact identifiers such as “ERR-1042” still benefit from lexical search. Both methods can be combined: keywords match the exact spelling, while embeddings find related formulations. Intuitive Search explains the first building block.

What a similarity score tells you

A common comparison is . It compares vector direction independently of length. Its range is −1 to +1, with higher scores indicating more similar directions. A score of 0.8 does not mean “80 percent identical meaning”.

For search, ranking is the first concern: does the password-reset guide appear before the delivery-address article? There is no universal threshold for a good result. You need representative queries and judgments about which passages should answer them. Compare only vectors from the same model with compatible configurations and the same number of dimensions.

Topic similarity can also conceal a crucial difference. “I like coffee” and “I do not like coffee” both concern coffee but contradict each other. A high score may identify an interesting candidate without confirming its statement. The same applies to outdated instructions and factually incorrect text.

Where embeddings help

TaskContribution from embeddingsWhat else is needed
Search documentationFind related phrasingsCheck relevance and version
Recommend similar articlesSuggest related topicsConsider quality and reader interests
Group texts by topicBring related content togetherReview and name the groups
Find an exact product numberAdd thematic contextExact identifier matching
Check contradictions or factsRetrieve related statementsEvaluate statements and evidence

Retrieval in RAG

In , embedding search can retrieve passages from a knowledge collection. A language model then writes an answer using that context. The vectors themselves contain neither readable source text nor a finished answer; the retrieved passages must be loaded too.

Answer quality therefore also depends on retrieving the right sources. A high similarity score cannot compensate for a missing or unsuitable passage. An agent executing a specific function is a separate capability: Web MCP explains how to expose those tools.

Test similarity yourself

Try “forgot password”, “restore account access” and “change delivery address” below. Calculate embeddings and check which pair ranks highest. Then compare the two coffee sentences: does topical proximity remain high despite the contradiction? This experiment compares short texts; it does not evaluate an entire documentation search system.

The initial saved examples retain their original German and English words and vectors. Translating a word while keeping its old vector would misrepresent the data. The saved file records neither its model nor its generation date, so treat it as an illustrative starting point. New inputs require a fresh calculation using the selected AI backend; the interface distinguishes saved, changed and newly calculated results. No API key is required to inspect saved comparisons; new cloud requests require a configured backend, while local inference requires prepared model files and a suitable device.

Compare textsEmbedding comparison
Explore related phrasings, ambiguous words and contradictory statements.
Compare texts

New custom calculations send inputs to Google Gemini.

Saved bilingual examples · model: Gemini. Change the texts to calculate a new comparison.

Compare similarity

Higher = more similar direction (−1 to +1). The slider compares only the first coordinates; it does not generate new embeddings.

Apfel ↔ Apple

0.794

Apfel ↔ Banane

0.717

Apple ↔ Pizza

0.658

Banane ↔ Pizza

0.641

Apfel ↔ Pizza

0.618

Apple ↔ Banane

0.588

Pairs are ranked by similarity. Scores are not percentages and do not establish identical meaning.

Further detail: Metrics and dimensions

Cosine compares directions. Euclidean distance measures direct distance, while Manhattan distance sums absolute coordinate differences. For both distances, smaller values indicate greater proximity. Their values cannot be compared directly with cosine scores, and vector length affects them too.

Mathematisches Modell
cos⁡(θ)=A⋅B∥A∥ ∥B∥\cos(\theta) = \frac{A \cdot B}{\|A\|\,\|B\|}

The dimensions slider uses only the first coordinates of existing vectors. It does not generate new embeddings. This can change the ranking. Some models are specifically trained to work with shortened vectors. Arbitrary truncation is not a general quality improvement: choose dimensions according to the model and actual retrieval tasks.

  • Collect representative queries and record which passages should answer them.
  • Split documents into coherent passages and preserve text, source and metadata.
  • Use a compatible model and configuration for documents and queries.
  • Test synonyms, ambiguous terms, contradictions and exact identifiers.

Primary sources