Learn how embeddings, cosine similarity, dot product, and Euclidean distance are used in RAG and semantic search.
Ready to see vector similarity applied in a real system? Learn how RAG uses vector search to retrieve relevant document chunks → · Why similarity scores matter in RAG pipelines →
In modern AI applications like ChatGPT and custom enterprise search engines, software doesn't just look for exact word matches. Instead, it understands the meaning of your query. This is called Semantic Search, and it relies entirely on vector math.
Predefined Dataset Sandbox: This page uses curated, predefined examples to stay free and fast without needing paid API tokens. Under the hood, it queries a real API to retrieve actual vector similarity values for these pairs. Use the sandbox below to see how these metrics respond!
Select a comparison example below to dynamically calculate similarity scores across different metrics.
Select a curated demo pair from the explorer list on the left, or click the Random Preset button to populate values.
warning Only predefined pairs are supported. Random text will return an unsupported demo pair message.
This sandbox uses predefined vector examples so it can stay free. It does not compare arbitrary text and does not call paid embedding APIs. The goal is to teach how vector similarity metrics behave.
An embedding is a vector created from text by an AI model.
Measures whether two vectors point in a similar direction.
Vector search finds items whose vectors are close to a query vector.
Explanation: A vector is a list of numbers that represents something, like a word, sentence, or document.
Why it matters: Vector databases compare these number lists to find similar meaning.
Explanation: An embedding is a vector created from text by an AI model.
Why it matters: Embeddings let software compare meaning, not just exact words.
Explanation: A dimension is one number inside the vector.
Why it matters: This demo uses simplified vectors, but real embedding systems use much larger ones.
Explanation: Measures whether two vectors point in a similar direction.
Why it matters: This is often the easiest metric for understanding semantic similarity.
Explanation: Measures how far apart two vectors are.
Why it matters: Useful when you care about physical distance in vector space.
Explanation: Measures alignment and strength between two vectors.
Why it matters: Some vector search systems use dot product for fast similarity scoring.
Explanation: Semantic similarity means similarity in meaning, not spelling.
Why it matters: This is the core idea behind embeddings and vector search.
Explanation: String similarity means the words look similar as text.
Why it matters: This demo should show that spelling similarity is not the same as meaning similarity.
Explanation: Vector search finds items whose vectors are close to a query vector.
Why it matters: This is how many AI search and recommendation systems work.
Explanation: RAG means Retrieval-Augmented Generation. It retrieves relevant documents before asking an AI model to answer.
Why it matters: Vector similarity is often used to find the relevant chunks.
Explanation: The vector created from the user's search or question.
Why it matters: The system compares this vector against document vectors.
Explanation: The vector created from a stored document, paragraph, or chunk.
Why it matters: Documents with vectors close to the query vector are likely relevant.
Explanation: A chunk is a smaller piece of a larger document.
Why it matters: RAG systems usually search chunks, not whole documents.
Explanation: The nearest neighbor is the closest vector to the query vector.
Why it matters: Vector databases use nearest-neighbor search to find relevant results.
Explanation: A vector with many dimensions.
Why it matters: The UI is simplified, but the concept is the same.
Explanation: This tool uses predefined educational examples, not live AI embeddings.
Why it matters: The site stays free and does not call paid AI APIs for every user.
Large documents are divided into smaller, logical text chunks (paragraphs or sections) so search results can point to highly specific passages.
An AI embedding model processes each text chunk, turning it into a high-dimensional vector containing numeric representations of the chunk's meaning.
These vector embeddings are stored along with their original text inside indexing databases (like Pinecone, Qdrant, or Weaviate) optimized for quick lookup.
When a user enters a question, the application passes that text to the exact same embedding model to obtain a real-time 'query embedding' vector.
The vector database runs cosine similarity or dot product calculations to identify and retrieve the database chunks closest to the query vector.
The app builds a prompt combining the user question and the retrieved text passages, prompting the LLM to write an accurate, context-grounded answer.
Traditional search systems (like SQL LIKE queries or basic text filters) match exact
characters. If terms share several letters, character-matching algorithms consider them similar. But
meaning-based embeddings focus on context and relationships.
Words look almost identical text-wise, but describe completely unrelated things:
We have predefined these exact pairs in our sandbox dataset. Filter the list to see how cosine similarity drops to near zero for spelling-similar words with separate meanings.
Official guide explaining semantic vector embeddings, dimensionalities, API usage, and distance metrics.
Translate complex high-dimensional spaces to lower ones using Google's introductory machine learning curriculum.
A deep, developer-friendly guide detailing vector embedding algorithms, applications, and indexes.
Clear explanation of vector semantic structures, vector spaces, and how AI representations differ from raw strings.
Detailed system documentation describing how similarity metrics operate inside a production-grade vector database.
This application is an educational demo utilizing predefined example pairs from a server dataset. It
does not calculate embeddings for arbitrary user text input in real-time, nor does it make calls to
paid external services like OpenAI or Cohere APIs. In real production search applications, you would
run a dedicated embedding model (such as text-embedding-3-small) to generate vectors,
then index them into a production vector database.
In real Retrieval-Augmented Generation (RAG) systems, text and unstructured data are converted into high-dimensional vector embeddings. Vector databases compare these vectors using similarity or distance metrics to retrieve the most semantically relevant content. This sandbox is a simplified 2D visual version of what happens in high-dimensional embedding search.
Models (e.g. text-embedding-3) transform text chunks into lists of float coordinates. Direction represents semantic meaning, while length represents frequency or magnitude.
Cosine Similarity is standard for text comparison because it isolates semantic direction. Euclidean Distance measures absolute geometric separation.
High cosine similarity (close to 1.0) indicates that the query vector and the document vector point in a very similar semantic direction. The document is highly relevant.
A cosine similarity around 0.0 means the vectors are orthogonal (perpendicular). There is no measurable semantic alignment between the search query and the target content.
Negative cosine similarity values (approaching -1.0) mean the vectors point in opposing directions in this simplified space, representing contradictory meaning or topics.