Embeddings

Discrete entities as dense vectors — words, users, products, documents — cosine similarity, and why a 2D projection distorts the geometry it claims to show.

Embeddings
▶ lab

A discrete entity — word, user, product, document — becomes a dense vector that is a parameter of some model, learned on a proxy task. The geometry encodes what that task rewarded, not "meaning".

Q · Two products sit close together in embedding space and a stakeholder asks whether that means they are "similar". Similar according to what, and who decided?
Embedding Training

Lookup tables as parameters, a contrastive signal from observed pairs against sampled negatives, and the consequence: rare entities get noise, and the table is part of the model artifact and must be versioned with it.

Q · What does the training signal for an embedding actually consist of, why does a rare entity end up with a meaningless vector, and what has to ship with the weights for the vectors to be usable?
Cosine Similarity
▶ lab

The dot product divided by the norms: the angle between two vectors, ignoring their length. Right when magnitude is noise, wrong when magnitude is signal — and at scale, nearest neighbours are an index problem, not a formula.

Q · The team switched the similarity function from cosine to Euclidean distance and the neighbours changed. Which one is right, and what does each throw away?
Embedding Projection Caveats
▶ lab

A 2D plot of high-dimensional vectors is a lossy projection. PCA keeps variance, not neighbourhoods; t-SNE and UMAP keep local structure and invent global structure. The clusters, distances and neighbours in the picture are not the ones the model uses.

Q · The projection shows two clean clusters and a stakeholder wants to act on them. What does the plot preserve from the space the model actually computes in, and what did it make up?
Embedding Drift
▶ lab

Retraining an embedding model produces a new coordinate system. Vectors stored from the old model are incompatible with it — a version mismatch, not a quality problem — and the vocabulary and the entities drift underneath as well.

Q · The embedding model was retrained and the stored vectors were left in place. What is now wrong, how would you detect it, and what does a safe rollout of a new embedding space look like?