Skip to content
MAMasterAI Now
6 / 1115 dk okumaSeviye: Intermediate5 kart

3B Vektör Uzayı

Anlam geometriye dönüşür: her kelime uzayda bir yöndür.

⚠ Bu aşamanın 3% kadarı Türkçe diline çevrildi; kalan kartlar İngilizce gösteriliyor. Bir hata mı gördün? Çeviri düzeltmeleri memnuniyetle karşılanır.

Okuma ilerlemesi0%
Card 1 — coordinates for meaningKart 1 / 5

Embeddings turn meaning into coordinates

A word becomes a list of numbers. Similar words land nearby.

An embedding is a fixed-length list of numbers that represents a piece of text. "King" might become 768 decimals. Nothing in any single number means anything — the position of the point in that 768-dimensional space is the meaning.

Analogy
A map without an agenda

Latitude and longitude together locate a city. Individually they are meaningless. Embeddings are the same: nobody hand-assigns "dimension 42 = royalness". The model discovers useful directions by itself during training, driven only by which words appear in similar contexts.

The training objective is deceptively simple: words that appear in similar contexts should end up with similar vectors. That single pressure, applied at web scale, produces a space where "doctor" is near "nurse", "treasury" is near "ministry", and where translation pairs align across languages.

NoteContext changes the vector

Older embeddings (word2vec, GloVe) gave one vector per word, so "bank" had to be the average of river and money. Modern transformers produce contextual embeddings: the vector for "bank" depends on the whole sentence around it.

Sonraki kart için tek bir hızlı kontrol

What makes two words end up close together in an embedding space?

5 bilgi kontrolü

🔒

Oyun alanı kilitli

Simülasyonu açmak için 5 kartın tamamını ve bilgi kontrollerini bitir.

Read the full stage transcript (all 5 cards, no JavaScript required)
Card 1 — coordinates for meaning

1. Embeddings turn meaning into coordinates

A word becomes a list of numbers. Similar words land nearby.

An embedding is a fixed-length list of numbers that represents a piece of text. "King" might become 768 decimals. Nothing in any single number means anything — the position of the point in that 768-dimensional space is the meaning.

Analogy
A map without an agenda

Latitude and longitude together locate a city. Individually they are meaningless. Embeddings are the same: nobody hand-assigns "dimension 42 = royalness". The model discovers useful directions by itself during training, driven only by which words appear in similar contexts.

The training objective is deceptively simple: words that appear in similar contexts should end up with similar vectors. That single pressure, applied at web scale, produces a space where "doctor" is near "nurse", "treasury" is near "ministry", and where translation pairs align across languages.

NoteContext changes the vector

Older embeddings (word2vec, GloVe) gave one vector per word, so "bank" had to be the average of river and money. Modern transformers produce contextual embeddings: the vector for "bank" depends on the whole sentence around it.

Knowledge check: What makes two words end up close together in an embedding space?

  • a. They start with the same letters
  • b. They tend to appear in similar contexts across the training corpus← correct
  • c. A human editor placed them there

Distributional semantics: you can judge a word by the company it keeps. Embeddings are the geometric consequence of that principle.

Card 2 — the ruler

2. Cosine similarity: measure angles, not distance

Direction carries meaning. Magnitude usually carries something else — like document length.

cos(θ) = (A · B) / (‖A‖ · ‖B‖)
The dot product of A and B divided by the product of their lengths: a number from −1 to 1.

Euclidean distance grows with vector length, so a long document that merely repeats its topic would look "far" from a short document that says the same thing. Cosine similarity ignores length by normalising both vectors to unit length, then reading off the angle. 1.0 means identical direction.

Cosine scoreInterpretationTypical action
0.95 – 1.00Essentially the same meaningCollapse as duplicate
0.75 – 0.95Strongly relatedExcellent retrieval hit
0.40 – 0.75Related topicInclude as extra context
0.00 – 0.40UnrelatedDiscard
Good to knowA free optimisation

If you L2-normalise every vector before storing it, cosine similarity becomes a plain dot product — one multiply-add per dimension instead of a division and two square roots. Every vector database does exactly this.

Knowledge check: Why is cosine similarity usually preferred over Euclidean distance for text embeddings?

  • a. It is faster to compute in all cases
  • b. It compares direction only, so length differences like document verbosity do not distort the score← correct
  • c. It always returns positive numbers

Magnitude in embedding space tends to track frequency and length, not meaning. Normalising removes that nuisance variable.

Card 3 — the illusion

3. Nobody really has 3 dimensions

We draw three axes because we have three eyes worth of intuition. The model uses 768 or more.

The 3D visualiser is a lie told for your benefit. Real embeddings live in 768, 1536 or 4096 dimensions, and we compress them down to three with a projection (PCA, UMAP, t-SNE) purely so human vision can see clusters. The projection preserves neighbourhoods approximately — never trust exact distances in a 3D plot.

Analogy
Shadows on a wall

Hold a wire sculpture up to a lamp and you see its shadow. Two sculptures that look different can cast the same shadow, and two shapes that look close on the wall may be far apart in depth. Projection is a shadow: useful, revealing, and lossy.

High dimensions also behave counter-intuitively: volume concentrates in a thin shell, almost all vectors become nearly orthogonal to each other, and distance metrics lose contrast. This is the curse of dimensionality, and it is why brute-force search and naive density estimates fall apart after a few dozen dimensions.

Watch outPractical consequence

Because distances compress in high dimensions, a cosine score of 0.82 and 0.85 may be practically identical. Never hard-code a threshold you copied from a blog post — calibrate it on your own data by eyeballing the top 20 hits.

Knowledge check: What does reducing a 768-dimensional embedding to 3 dimensions for visualisation cost you?

  • a. Nothing, the projection is lossless
  • b. Information — distances and clusters are only approximately preserved← correct
  • c. The original vectors are deleted

Projection compresses ~1536 numbers of information into 3. It is a visual aid, not a measurement tool.

Card 4 — geometry of meaning

4. Analogy arithmetic and nearest neighbours

king − man + woman ≈ queen. Why does that work at all?

In a well-trained space, the direction from "man" to "woman" encodes gender, and it is roughly the same vector everywhere: king − man + woman ≈ queen. The relationship itself becomes a direction you can add and subtract. This is called linear analogy structure.

py
queen = embed('king') - embed('man') + embed('woman')

# find the closest real vectors to the result
neighbours = vector_store.search(queen, top_k=5)
# -> queen (0.86), monarch (0.71), princess (0.68), ...
  • Nearest neighbours answer "what is this about?" — the basis of semantic search and recommendation.
  • Clustering groups the space into topics without any labels (k-means, HDBSCAN).
  • Anomaly detection flags points with no close neighbours — useful for fraud and content moderation queues.
  • Instruction quality: retrieval-augmented generation (RAG) works because the query vector lands near the answer chunk vector.
NoteA caution

Embeddings inherit the statistics of their training data, including stereotypes. "Doctor" clustering with men and "nurse" with women is a mirror of the corpus, not a fact about the world. Fairness audits belong at this layer.

Knowledge check: What does `king − man + woman ≈ queen` demonstrate about an embedding space?

  • a. Semantic relationships can appear as consistent directions you can add and subtract← correct
  • b. The model understands royal history
  • c. Embeddings are ordered alphabetically

Linear structure in the space mirrors relational structure in the data. It is an emergent property of the training objective, not a programmed rule.

Card 5 — at scale

5. How vector search actually works

You cannot compare 100 million vectors one by one. Enter approximate search.

Exact nearest-neighbour search over millions of vectors is too slow for a web request. Approximate Nearest Neighbour (ANN) indexes trade a tiny amount of recall for orders-of-magnitude speed. The dominant family is HNSW (Hierarchical Navigable Small World): a multi-layer graph where you take long hops at the top and fine hops at the bottom.

Analogy
Flights, then trains, then walking

To reach a café in another city you fly to the nearest hub, take a train to the district, then walk street by street. HNSW stores that hierarchy of connections, which is why searching 100 million vectors can touch a few hundred nodes instead of all of them.

IndexSuperpowerWeakness
HNSWFast queries, excellent recallHeavy memory use, slow to build
IVF-PQTiny memory footprint via quantisationLower recall, needs a training step
Flat / brute forcePerfect recall, dead simpleO(n) per query — small sets only
Good to knowPutting it together: RAG

A retrieval-augmented generation pipeline embeds your documents once, embeds the user question at request time, retrieves the top-k nearest chunks, and pastes them into the prompt. You just built the whole idea: tokens → embeddings → similarity → context → answer.

NoteNext up

Stage 7 opens the transformer hood. If embeddings are coordinates, attention is the mechanism that lets every token look at every other token and decide what matters.

Knowledge check: Why do vector databases use approximate indexes such as HNSW?

  • a. To trade a small amount of recall for enormous speed gains over exact search← correct
  • b. Because embeddings are stored lossily anyway
  • c. Because cosine similarity cannot be computed exactly

At web scale exact search is too slow. ANN returns nearly all of the true nearest neighbours in a fraction of the time.