MLGuerrillaStart M1 →
Free · in beta·intermediate·M13·37 min read·Prereq: The Model as a Component (M4) and Datasets & Evaluation (M1). AI Product Framing (M7) supplies the ticket sort, the bouquet photo check and the phone line this module builds on.

Classification

Jump to the lab →

The capability

What a classifier is

A classifier takes one input and returns one answer from a list you wrote down before the call, and it attaches a number that says how sure it is.

The words doing most of the work in that sentence are "a list you wrote down before the call". You decide the possible answers ahead of time, whether that's five support categories, or damaged against fresh, or spam against legitimate, and the component picks one of them and can't return anything else. Everything later in this module is only possible because you fixed the answers up front like that.

The input side is simpler than most people expect. It might be a ticket, a photo, twenty seconds of audio or a few seconds of video, and whichever one it is, the component reads exactly one of them per call. So when the input changes, the shape of the component stays the same.

What comes back is a score on every label, and that score is what you'll care about most. "Refund, 0.91" is a different kind of thing from "Refund", because your code can compare 0.91 against a threshold. That's what lets you act automatically on some cases, hand others to a person, and leave the rest alone.

Four inputs feed one component: a support ticket, a photo, an audio waveform and a strip of video frames. The component holds a fixed list of five labels. Out of it comes a score for every label, reading 0.91 for refund, 0.06 for damaged, 0.02 for delivery change, 0.01 for where is my order and 0.00 for other, with refund marked as the winner. A note underneath says the labels are fixed before the call and the model cannot return anything outside the list.
The same shape whatever the input is. The label list is written first, and the model's job is to put a number on each one.

What a classifier can't do is answer outside the list. If a ticket comes in about something nobody planned for, what you get back is the closest label it has, and if the model's behaving, that label will have a low score attached to it. Section 4 is where you design for that, and it's the reason every taxonomy ends up carrying a bucket for the things you didn't think of.

Why this is a capability of its own

When a model generates text, the output is left open. M3 showed a model producing text one token at a time, and then M4 spent a whole section getting that text into a shape your code could parse. A classifier closes the output space before the call even happens, and closing it that early is what everything downstream depends on.

First of all, it gives you a number you can put a threshold on. You can write a rule around "Refund, 0.91" in a way you never could around "Refund" on its own, or around a sentence of explanation either.

It also gives you a confusion matrix, because once the labels are fixed, every mistake has a name, and the name is always some version of this class predicted when that class was true. Section 7 goes through one of those in detail.

It gives you metrics that match the decision you're making, which here means precision and recall for each class, each one weighted by what that class's errors cost you.

And it gives you a much wider choice of models than generation does. Whatever kind of input you have, the options go from a hand-written rule all the way up to a frontier model, across four orders of magnitude of cost, and most of those options only exist because the output is closed.

Where it shows up

Classification is the most common job in a production AI system, and most of the time it's running somewhere nobody sees it.

  • A spam filter that reads an email and returns spam or legitimate.
  • Content moderation, which reads a post or an image and returns one policy category.
  • A defect check on a production line that reads a camera frame and returns pass or fail.
  • A wake word detector that reads a rolling second of microphone audio and returns heard or not heard.
  • A triage step in front of an expensive pipeline, which reads a request and decides which of four handlers gets it. That's the one M14 covers, and it's a classifier with cost sitting on the other side of the decision.

Every one of those is the same component with a different list of labels and a different kind of input, so this module builds it once and then reuses it.

Keep reading

The rest of this lesson is free with an account

Create a free account to read the remaining 13 sections. It takes about twenty seconds and there's nothing to pay. The same account opens the slide decks and CV reviews.

  1. 02Three decisions at the flower company
  2. 03The seam every option sits behind
  3. 04The label set is the design
  4. 05What counts as one case
  5. 06Pick the option your data can support
  6. and 8 more

That's the last one written so far

Pick your next module from the board.

All modules →