Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 03 · AI · Past the basics · about 20 min to read

Play it as a journeyTutor comes with a plan

Groups nobody labelled: k-means and PCA

Tokens and Embeddings
Tokens and Embeddings · Open board

The board where words become lists of numbers, so that similar meanings sit close together. This lesson finds the groups in such a cloud of points when nobody has said what the groups are.

Lesson 25 of 83 in AI

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 2008: a map of Europe that nobody drew
  • Unsupervised learning: data with no answer column
  • A centroid and k-means: the recipe, worked by hand
  • Inertia: one number for how tight the groups are
  • Choosing k: ask for 1, 2, 3 and watch the inertia
  • PCA: find the one direction along which the data spreads most
  • When clustering lies: it always returns k groups
  • Why k-means stops, and where it stops
  • The silhouette score: does a point belong to its group?
  • PCA from the covariance
  • Where this shows up
  • The whole lesson in code

Terms it explains: supervised learning, unsupervised learning, centroid, k-means, Inertia, elbow rule, Principal component analysis, principal component, "Why scale features first?", Common mistakes, local best, k-means++, eigenvectors, eigenvalues, 2+(p[1]-q[1]), analogy arithmetic, BPE, cosine similarity, dense vector, dimension d, embedding, embedding matrix, positional encoding, semantic search, static vs contextual embedding, token, token ID, tokenizer, vector database, vector space, vocabulary.

Lab

One sentence, one tokenizer, a vocabulary you can grow. How many tokens does it cost?

Drag How many pieces it knows left to right, then open the tab Another script, and an emoji, and watch How many tokens.

Open Tokens and embeddings

Related papers

Review AI