1if "free money" in mail:2 folder = "spam"3else:4 folder = "inbox"SPAMINBOXword scoresfreeprizenoteslunchlabelsgroupsrewardsSee you atlunchtomorrow.?
Sky mat: AI, the goal · gold mat: machine learning, one way to reach itTeal block: the model, with the word scores it learnedEnvelopes: emails · salmon tag = spam, green tag = not spam, blue ? = no label yetEverything stands on the AI mat: the goal of machines doing tasks that need intelligence. At the back, a hand-written rule and the two folders it sorts into. On the gold machine-learning mat, six labelled emails (the training data) and the model, which keeps one learned score per word. The rule catches "free money" but misses "free prize". Training sends each labelled email through the model and back, and the word scores fill in; the model then sorts emails it has never seen. In front: the three kinds of learning, and a card a generative model writes one predicted word at a time. The word-score learner is a real, runnable program, but a toy. Real spam filters weigh words by probability (a method called naive Bayes) and learn from thousands of emails.

AI and rules

  1. Artificial intelligence (AI) is the broad goal of getting machines to do tasks that seem to need intelligence, such as understanding speech, recognising faces or sorting email. Our task here: keep spam, unwanted junk email, out of the inbox.

Learning from examples

Kinds of learning

What happens

;; step 1/10 · ai
AI        the goal: machines doing tasks needing intelligence
examples  understanding speech, recognising faces,
          playing games, translating, sorting email
our task  sort each new email:
            spam      unwanted junk  -> spam folder
            not spam  normal mail    -> inbox

The word-score learner is a real, runnable program, but a toy. Real spam filters weigh words by probability (a method called naive Bayes) and learn from thousands of emails. Language models really predict tokens (whole words or pieces of words) and choose among many likely ones. The words in the last step are an illustration, not the output of a real model.