Skip to content

Vector Similarity Search: First Intuition

Why this matters

The full Modern Data Management 2 lesson introduces embeddings, vector databases, similarity search, approximate nearest neighbors, HNSW, IVF, PQ, and RAG.

This page gives the basic idea first:

content -> meaning-shaped numbers -> search by closeness

Vector similarity search is useful when exact keyword matching is too brittle. A reader might ask:

How can an LLM find notes about approximate search?

The best study-guide passage might not contain those exact words. It might say:

HNSW speeds up vector search.

Vector search tries to find that kind of meaning match.

Mental model

Imagine each study-guide passage becomes a point on a map.

Nearby points have similar meanings. Faraway points have different meanings.

question -> point on the same map
stored passages -> other points on the map
search -> nearest points

The map is not drawn by a person. An embedding model creates it by turning text into vectors.

For intuition, use tiny two-number vectors:

Text Teaching vector
"How does approximate search work?" [0.9, 0.8]
"HNSW speeds up vector search." [0.8, 0.9]
"PCA reduces dimensions by preserving variance." [0.2, 0.7]
"MongoDB stores JSON-like documents." [0.1, 0.1]

These numbers are fake teaching numbers. Real embeddings have many more dimensions and are not written by hand.

The point is simpler:

similar meaning -> nearby vectors
different meaning -> farther vectors

Core ideas

  • An embedding is a numeric representation of content.
  • A vector is a list of numbers.
  • An embedding model creates vectors from text, images, audio, or other content.
  • Similarity search compares a query vector with stored vectors.
  • Search results should return the original passage or payload, not only the vector.
  • Vector search can match meaning even when exact words differ.
  • Vector search is not magic understanding; it depends on the embedding model and the stored content.
  • The full lesson later explains why large vector collections need approximate search.

Walkthrough

Start with study-guide passages

Suppose the study guide stores these passages:

ID Passage
A SQL validates structured questions.
B MongoDB stores JSON-like documents.
C PCA reduces dimensions by preserving variance.
D HNSW speeds up vector search.
E RAG retrieves context for an LLM.

A keyword search for:

approximate search

might miss passage D if the passage does not say "approximate".

Vector search asks a different question:

Which passages are closest in meaning to this query?

Turn content into vectors

An embedding model turns each passage into a vector.

Teaching version:

Passage Teaching vector
SQL validates structured questions. [0.2, 0.1]
MongoDB stores JSON-like documents. [0.1, 0.1]
PCA reduces dimensions by preserving variance. [0.2, 0.7]
HNSW speeds up vector search. [0.8, 0.9]
RAG retrieves context for an LLM. [0.7, 0.6]

The vector values are not meant to be read directly. They are useful because they let the system compare content numerically.

Embed the query too

The query must go through the same kind of embedding process.

"How can an LLM find notes about approximate search?"
-> [0.9, 0.8]

Now the system can compare one query vector with the stored passage vectors.

Rank by closeness

A simplified ranking might look like this:

Rank Passage Why it is near
1 HNSW speeds up vector search. strongly about vector search
2 RAG retrieves context for an LLM. related to LLM retrieval
3 PCA reduces dimensions by preserving variance. also uses vectors, but different topic
4 SQL validates structured questions. database topic, not semantic vector search
5 MongoDB stores JSON-like documents. storage topic, weak match

The result is not:

vector [0.8, 0.9]

The useful result is:

HNSW speeds up vector search.

That is why vector databases store vectors together with payloads or references to the original content.

Keyword search and vector search ask different questions

Keyword search asks:

Do these words or tokens appear?

Vector search asks:

Is this meaning nearby in embedding space?

Both can be useful.

If you need an exact column name, product code, or legal phrase, keyword search can be better. If you need a meaning match where words vary, vector search can help.

Vector search depends on representation

Vector search only compares the vectors it receives.

If the embedding model does not place two meanings near each other, the vector database cannot fix that by itself. If the stored passages are too vague, outdated, or missing, search will still return weak evidence.

Plain version:

embedding model + stored content -> what similarity can mean

Term Decoder

Term Friendly meaning
content the original text, image, audio, or item
embedding numeric representation of content
vector list of numbers
embedding model model that turns content into embeddings
query vector embedding of the user's search question
stored vector embedding saved in the database
payload original content or useful metadata returned with a match
similarity search finding stored vectors close to a query vector
semantic search search by meaning, not only exact words
embedding space the map-like space where vectors can be compared

Common traps

The vector itself is not the useful answer

A search result should return the passage, document, product, image, or metadata behind the vector.

Vector search is not the same as keyword search

Keyword search matches terms. Vector search compares numeric representations of meaning.

Nearby does not mean guaranteed correct

Nearby vectors are candidates. They can still be irrelevant, incomplete, outdated, or misleading.

The embedding model controls the meaning map

The vector database searches the representation it is given. Better search starts with useful embeddings and useful stored content.

Tiny teaching vectors are not real embeddings

Real text embeddings usually have hundreds or thousands of dimensions. The two-number examples are only for intuition.

Check yourself

What is an embedding?

A numeric representation of content, designed so related meanings can be compared.

Why does the query need to be embedded?

The database compares vectors, so the query must become a vector in the same kind of embedding space as the stored content.

What should a vector search result return besides a vector?

The original content, a pointer to it, or metadata that makes the match useful.

Why might vector search find a passage that keyword search misses?

The passage can be close in meaning even when it does not use the exact query words.

What controls whether two meanings end up near each other?

The embedding model and the content representation it creates.

Next

Next: Vector Search Indexes: Why ANN Exists

The next bridge explains why comparing a query against every stored vector becomes too slow at scale, and why vector databases use approximate search.

Source anchors

  • Supports: study-guide/docs/lessons/04-modern-data-management-2.md
  • Source file: notebooks/Module2/04-Modern Data Management 2.pdf
  • Key source concepts prepared here: embeddings, vectors, vector databases, payloads, semantic search, similarity search, query vectors, stored vectors