4.4.12 · D1Alignment, Prompting & RAG

Foundations — Vector databases and embeddings

2,104 words10 min readBack to topic

The parent note Vector databases and embeddings throws a lot of notation at you in one breath: , , , , , . If any of those made you pause, this page is for you. We build each one from absolutely nothing, anchor it to a picture, and only then let the next symbol lean on it.


1. A number line, then a plane — what "space" means

Now glue two number lines together at right angles — one horizontal, one vertical. Any point now needs two numbers to pin it down: how far right, how far up. That pair, like , is a location on a flat sheet (a plane).

Figure — Vector databases and embeddings

WHAT we just did: we upgraded from "one number = one position on a line" to "two numbers = one position on a plane." WHY the topic needs it: an embedding is a long list of numbers, not just two. But the leap from 1 number to 2 is the same leap as from 2 to 768 — you just keep adding axes. If you understand the plane, you understand the idea; the rest is scale.


2. The arrow: what a vector is

Look at the figure above: the arrow labelled starts at the origin and its tip lands at . Two facts about an arrow matter to us:

  • Direction — which way it points.
  • Length — how far it reaches.

3. Coordinates and the subscript

WHY we need this: we cannot write out 768 separate letters. The subscript lets us say "the -th number of " once and mean all of them. It is bookkeeping, nothing deeper.


4. Dimension and the space


5. The summation symbol

Worked unrolling, so it is never mysterious again. For : That is the entire meaning — a loop that adds. WHY the topic needs it: dot products and norms both add up many small pieces, and writing by hand is absurd. says it in three symbols.


6. Length of an arrow: the norm

Figure — Vector databases and embeddings

Pythagoras says: (long side) = (across) + (up). So the length is

WHY the topic needs it: two documents about dogs — a tweet and a whole essay — can point the same direction but have very different lengths. To compare meaning we must be able to measure and then cancel out length. The norm is the measuring stick. More in Vector Norms.


7. The angle between two arrows

Figure — Vector databases and embeddings

WHY the topic needs it: the angle is the similarity signal. Look at the figure: the two mint arrows point almost the same way (tiny , very similar), while the coral arrow points off at a wide (unrelated). Turning "angle" into "a number between and " is the job of cosine, next.


8. Cosine: turning an angle into a similarity number

You don't need trigonometry to use it, because — as the parent shows — cosine can be computed straight from the coordinates via the dot product, without ever finding the angle first. That is the magic of the next symbol.


9. The dot product

Tiny example: .

The deep fact (proven in Dot Product) is that this arithmetic secretly equals length-times-length-times-cosine:

WHY this matters so much: rearrange it and you get the whole parent page's centerpiece, We divide by both lengths precisely to cancel magnitude (from §6) and leave only direction (from §7–8). The dot product is the cheap, coordinate-only route to the angle — no trigonometry needed. Databases love it because it is just "multiply and add," which hardware does at blazing speed.


10. Reading — counting the work

Here = how many stored vectors, = length of each vector. To compare a query against all stored vectors, each comparison touches numbers → total operations. For and that is nearly a trillion operations per query — too slow. That single realisation is why the parent introduces approximate search (HNSW and ANN Indexes); just means the work grows far more gently as explodes.


How these foundations feed the topic

Number line and plane

Vector = arrow

Component a-sub-i

Summation sigma

Dimension d and R-to-the-d

Norm = length

Dot product

Angle theta

Cosine of angle

Cosine similarity

Big-O cost N times d

Vector databases and embeddings

Read it top-down: the arrow idea splits into how we address its numbers (index → sum), how big the space is (dimension → cost), and how we measure it (norm, dot, angle → cosine → similarity). All roads meet at the parent topic.


Equipment checklist

Cover the right side and answer out loud; reveal to check.

A vector is, geometrically, a
an arrow from the origin to the point , carrying a direction and a length.
What does mean?
The -th number in the list ; e.g. for .
What is in ?
The number of coordinates (axes) — how many numbers make up each vector.
Unroll
.
Compute the norm and say what it measures
; it measures the arrow's length (its reach from the origin).
What does the angle tell us about two vectors?
How aligned their directions are: = same direction, = perpendicular/unrelated, = opposite.
Why report instead of itself?
It maps the angle to where bigger = more similar, which is the intuitive direction for a similarity score.
Compute for
.
State the identity linking dot product, norms, and angle
.
Rearrange it to get cosine similarity
— divide the dot product by both lengths.
What does mean for exact k-NN?
Comparing a query to all stored vectors, each of length , costs about operations — too slow for huge .

Connections