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 21 min to read

Play it as a journeyTutor comes with a plan

People who bought this: recommenders and time series

Tokens and Embeddings
Tokens and Embeddings · Open board

: the board where things become lists of numbers, so that similar things sit close together. A recommender does this to shoppers and items, and this lesson shows how.

In early 2003 three Amazon engineers, Greg Linden, Brent Smith and Jeremy York, published a short paper in IEEE Internet Computing. Its title was “Amazon.com Recommendations: Item-to-Item Collaborative Filtering”. The abstract says their method gave recommendations in real time and scaled to very large data sets. That is the problem of every shop with an app.

A shopper opens the app. The shop has 1,000,000 items, a teaching value. The screen has room for 20. Someone must pick those 20 in a fraction of a second. The same shop must also decide, every evening, how much stock to order for next week. Both jobs are guesses from past numbers, and this lesson covers both.

By the end you will be able to build a “people who bought this also bought” list from purchase data, explain how two-tower retrieval picks a few hundred items out of millions, and forecast next week’s orders with a score you can trust.

The history (optional)

The Linden, Smith and York paper appeared in IEEE Internet Computing, volume 7, issue 1, pages 76 to 80, in 2003. It compared three older approaches with its own item-to-item method. In 2019 Google published “Sampling-Bias-Corrected Neural Modeling for Large Corpus Item Recommendations” at the RecSys conference. It describes a two-tower retrieval system built for YouTube, which serves tens of millions of videos. Nothing later in this lesson depends on these dates.

Before you start. A dot product multiplies two lists slot by slot and adds the results, as Vectors, Dot Products and Matrix Multiply showed. Softmax turns a list of scores into chances that add to 1, as The Maths Floor, Part 2: Probability, Softmax and Temperature showed. A table of ratings can be rebuilt from a few hidden tastes, and that count is its rank, as Rank, SVD and the shape of data showed. A score is honest only when it is measured on rows the model never saw, as Honest scores: cross-validation, leakage and bias-variance showed.

Lesson 40 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

  • Collaborative filtering: recommend from what other shoppers bought
  • Cosine similarity: how alike two columns are
  • Two-tower retrieval: one list of numbers per shopper, one per item
  • Time series: numbers that arrive in order
  • Walk-forward testing: never let a forecast see tomorrow
  • Item-to-item, run
  • Matrix factorisation, run
  • Two towers, run
  • Forecasting, run

Terms it explains: collaborative filtering, cosine similarity, item-to-item, tower, two-tower model, time series, naive forecast, seasonal naive forecast, MAE, walk-forward test, Common mistakes, analogy arithmetic, BPE, 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