02 · See it in action
Follow the steps
- Choose one embedding model and use it for both documents and queries.
- Embed a small set of sentences about distinct topics.
- Compare cosine similarity to rank candidates.
- Inspect a synonym case, an unrelated case and a negated sentence.
Worked example
Illustrative vectors only:
A = [1, 0] B = [0.8, 0.6] C = [0, 1]
cosine(A, B) = 0.8
cosine(A, C) = 0
Real embeddings have more dimensions.
Read the example once, then explain each part aloud in your own words. If it includes Python, you can understand the idea first and run the code later in a local Python environment. Code is shown as text; this page does not execute it.
Sign in to save your reading progress.
Sign in