4.4.12 · D3Alignment, Prompting & RAG

Worked examples — Vector databases and embeddings

2,449 words11 min readBack to topic

Before touching a single number, let us re-earn the three symbols we lean on the whole way down.

Figure — Vector databases and embeddings

Look at the figure: slides from (arrows on top of each other, angle ), through (arrows at a right angle, ), down to (arrows pointing exactly opposite, ). That single dial is what every example below reads off.


The scenario matrix

Every situation this topic throws at you is one of these cells. The examples that follow are tagged with the cell they cover, so by the end no scenario is left unseen.

# Case class What's special sim value you expect Example
A Generic positive ordinary partial overlap Ex 1
B Same direction, different length one is a scaled copy exactly Ex 2
C Orthogonal share no components Ex 3
D Opposite direction one is a negative multiple Ex 4
E Negative but not opposite some slots disagree Ex 5
F Degenerate zero vector one vector is all zeros undefined (÷0) Ex 6
G Pre-normalized inputs already unit length dot product is sim Ex 7
H Euclidean vs cosine agree unit vectors, ranking Ex 8
I Real retrieval, top- word problem, pick winner rank by sim Ex 9
J Exam twist: cross-model different embedders meaningless — trap Ex 10

The examples

Figure — Vector databases and embeddings

Summary dial

Reading the whole matrix back onto the cosine dial:

opposite sim = -1

obtuse -1 to 0

orthogonal sim = 0

acute 0 to 1

identical sim = 1

zero vector = undefined

Cells A–E fill the dial from to ; F is the one place off the dial (undefined); G–J are the same dial read for engineering and exam contexts.

Recall Which cell is each?

sim exactly , raw dot product large ::: Cell B — same direction, different length sim exactly with nonzero norms ::: Cell C — orthogonal / unrelated formula gives ::: Cell F — degenerate zero vector, undefined two different embedding models compared ::: Cell J — meaningless, must re-embed with one model unit vectors, distance ranks same as cosine ::: Cell H —


Connections