Skip to content

    Word Embeddings (Word2Vec)

    AI · Intermediate

    Definition

    Word embeddings represent words as dense vectors so similar words are close together.

    Gives models a numeric sense of meaning.

    Diagram

    king − man + woman …

    Flowchart

    Train on large textPredict neighbors (skip-gram)Learn vectorsCompare with cosine similarity

    Example: Vector arithmetic

    king, man, woman = [5, 3], [2, 1], [2, 4]
    print([k - m + w for k, m, w in zip(king, man, woman)])

    Output: [5, 6]

    Key points

    • Contextual embeddings (BERT) vary by sentence
    • Typical size 100–1000 dims

    Interview questions

    Static vs contextual embeddings?

    Static give one vector per word; contextual change with surrounding text.

    More AI topics