Back to section lessons
Free overview · intro · Lesson 1 of 9

From a label to the next word

See how autocomplete chooses between “rain” and “snow” using three entries from a weather diary.

A small language model starts with a question: which word is likely to come next? Before training a network, try a predictor that counts familiar continuations. Its result gives you something to compare the trained model against.

A small example

A weather diary has three entries: “light rain”, “light rain” and “light snow”. You type the first word, “light”. How might autocomplete pick the second? Rain appeared twice and snow once. Choosing the more frequent ending gives “rain”.

From a count to a prediction

Add “light snow” once. The score is now 2–2, so the rule has no single winner. One more “light snow” makes it 2–3 and autocomplete will suggest “snow”.

The counter describes what people wrote in the diary. It could still rain tomorrow. And if the next entry starts with “heavy”, the counter has no examples for that opening. That is a useful test for a trained model that can use similarities between phrases.

Done reading?

Mark the lesson as read to move your track progress forward.

Now build your own version

Write a probability calculation for different counts. Check whether it handles rare words and changing vocabulary sizes.

Try for free