SDE & MLE Prep

Embeddings

Q: What are embeddings and how are they learned?

Dense low-dimensional vectors where geometric closeness reflects semantic similarity.

  • word2vec (skip-gram / CBOW with negative sampling), GloVe (co-occurrence factorization), contextual embeddings from transformers (BERT, sentence-transformers).
  • Two-tower / contrastive models (CLIP, dual encoders): pull matching pairs together, push negatives apart (InfoNCE loss); used for retrieval and recommendations.
  • Categorical ids (users, items) → embedding tables learned end-to-end.
  • Serve with approximate nearest neighbour indexes (HNSW, IVF-PQ); measure cosine similarity.