WeCodeAcademy

Embeddings: Meaning as Numbers

An embedding represents a word (or sentence, or image) as a list of numbers so that similar things get similar numbers. Closeness is measured with cosine similarity: 1 means pointing the same way, 0 unrelated. Search engines and AI assistants use embeddings to find text with a similar meaning even when the words differ.

These tiny vectors were written by hand (real ones have hundreds of numbers learned from data) but the arithmetic is the real thing.

Examplepython
Open in editor »
Quick check

A cosine similarity close to 1 means...

Your turn: write the code

Print the cosine similarity of 'queen' and 'apple' rounded to 3 decimals.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.