Text classifier
A text classifier reads a short piece of text and files it under one of a few categories, the way a person sorting mail would. This support ticket is about billing. This comment should be removed. This lead is hot. You choose the categories. The model learns what each one looks like from examples you have already sorted, and nobody writes a rule. Sorting examples by hand like this is also paid work, and the data annotation roles listed on AITraining.jobs, whose founder also runs Nanotech, show what it pays.
The model you train here is a small GPT, the same kind of model as the ones behind chat assistants, built from scratch in your browser. It starts out as random numbers that know nothing about language, so everything it ends up knowing about your categories comes from your examples. Three ready-made classifiers show the idea on public data: a spam filter, a clickbait detector and a language router.
Your examples
Put one example on each line: the text, then a tab or a |, then its label.
i got charged twice for my subscription this month, can you refund one? | billing
keeps crashing every time i open the dashboard | bug
any plans to add a dark mode toggle? | feature request
Copying two columns from a spreadsheet and pasting them gives you the tab automatically. The label is whatever follows the last tab or | on the line, so the text itself may contain one.
- Labels: from 2 to 8, each at most 32 characters long.
- Examples per label: at least 10 before it will train, and as many as you can after that. How many you need depends on how different your labels look. On the spam filter's messages, where a run of digits gives most scams away, 25 per label already scored about 91 percent on examples the model never saw. On the example support tickets, where the difference is in the meaning, it scored about 53 percent with 25 per label, 62 with 50, 70 with 100 and 78 with all 197, and was still climbing. How many examples does a text classifier need? has the full measurements.
- Balance: it trains on as many examples of each label as your smallest label has, up to 500 each, so one thin label holds all the others back.
- Length: each line gets a 160-character window, label included, and a longer text is read from its end. Trim long texts to the part that decides the label.
- Contradictions: a text that appears under two different labels is dropped, and you are told how many were, because one input cannot have two right answers.
To see a working set first, press Load an example. It fills in 711 support tickets, 237 each for billing, bug and feature request.
Training
Training is a guessing game, played tens of thousands of times. The model reads one of your examples and guesses its label. Then it is shown the real label, and every one of its internal numbers, its parameters, is nudged slightly toward the answer that would have been right. Each step of the game covers 32 examples, and a run is 1,500 steps: 48,000 guesses in all.
Only the label is graded. The model reads the whole text, but it is marked only on the answer that comes after it, never on predicting the text itself, so all of its learning goes into the one decision you care about. It trains on your computer's graphics chip when your browser supports WebGPU, and on the processor when it does not.
Held-out score
Before training starts, a quarter of your examples, between 3 and 40 per label, is set aside, and the model never trains on them. While it trains, the live score is measured on those examples, and at the end it is scored on every one of them, so the score says what the model learned rather than what it memorized. Near copies, texts that differ by only a word or a number the way exported data often does, are always kept on the same side of that split, so they cannot inflate the score. The same paste always gives the same split, so two runs can be compared fairly.
What score to expect depends on your data. On the built-in example, sorting support tickets three ways, measured runs land in the mid to high seventies (ten runs, between 73 and 81 percent), where guessing would score 33.
Confidence
Every answer comes with how sure the model is, and that matters as much as the headline score. In one measured run on the example tickets, it was right on every ticket in the quarter it was most sure about and on 91.7 percent of its most confident half, against 79.2 percent overall. So a practical setup is to let the model file the cases it is sure about and pass the rest to a person. Treat the number as a ranking rather than a promise: 90 percent sure does not mean wrong exactly one time in ten.
Other ways to train one
- Google's Teachable Machine trains a model in your browser from your own examples, with no account, but its FAQ lists three kinds of training data: images, sounds and poses. A request for text projects has been open on its issue tracker since May 2022.
- Hugging Face AutoTrain trains text classifiers from a CSV file, free on your own hardware or billed by the minute on Hugging Face's, but its documentation now says: "This project is no longer maintained."
- Google's AutoML Text on Vertex AI is no longer supported, and MediaPipe Model Maker, a Python library with a text classifier, is deprecated.
- Apple's Create ML trains text classifiers on a Mac.
- SetFit, a Python library, gets good accuracy from very few examples because it starts from a model that has already learned a lot about language. Its authors report that with 8 labeled examples per class on one sentiment dataset, it was competitive with a much larger model fine-tuned on the full 3,000-example training set. If you only have a handful of examples and can run Python, it is the better tool.
- Naive Bayes, the classic word-counting classifier, takes a few lines of Python with scikit-learn and trains in well under a second. On the example support tickets it beat this page's model at every data size we measured: with all 197 training tickets per label it got 95.8 percent of the held-out tickets right, against 73 to 81 for the model. When your labels differ by the words people use, as these do, it is the more accurate tool.
What this page adds is the whole loop in one browser tab with nothing to install: your own labels, a model trained from scratch that you watch learning, and an honest score on examples it never saw.
Questions
Is there a Teachable Machine for text?
Not from Google: Teachable Machine handles images, sounds and poses, not text. This page does the same kind of thing for text. You give it examples, it trains a model in your browser, free and without an account, and it tells you how well that model does on examples it never saw.
Why train a classifier instead of asking ChatGPT to sort the text?
For a few dozen items, asking a chatbot is quicker. A classifier you train earns its place when the job repeats: it gives the same answer to the same text every time, costs nothing per answer, does not send your text anywhere, and comes with a measured score on your own held-out examples, so you know how often it is right before you rely on it. Research points the same way. A 2024 comparison found that smaller models fine-tuned for the task still beat large generative models used without task-specific training at text classification ( Bucher and Martini, 2024), and a 2023 study found that ChatGPT's labels can change when the wording of its instructions changes ( Reiss, 2023).
Does my data leave my browser?
No. Your examples are read, split and trained on inside this browser tab, and the trained model is saved in the browser too. Signing in is optional: if you do and save a run, only its details (such as its name, size and score) sync to your account, and the examples you pasted are left out on purpose. One thing to keep in mind: a downloaded model file contains your examples, so share it only where you would share them. The site's analytics count page visits and a few steps like starting a training run, never the text you type.
Can I use the trained model in my own app?
Not directly. You can test it on any text in the studio, and download it as a .nanotech file that opens again here, on this device or another, with its training history intact. The file holds the real trained weights, but in Nanotech's own format: there is no export to formats such as TensorFlow.js or ONNX, so calling the model from your own code is not something the site offers.
What kind of text works best?
Short texts whose categories use different words. Because this model starts from nothing and reads one character at a time, it learns from the words and spellings each category actually uses: billing tickets talk about charges and refunds, bug reports about crashes and freezes. Categories that use the same words and differ only in subtle meaning are much harder for it. We found this ourselves: a from-scratch sentiment classifier was built and left out of the studio, because on examples it had never seen it mostly fell back to guessing the more common answer.
How long does training take?
A few minutes on a laptop's graphics chip: a run is 1,500 steps, and the built-in spam filter, the same size of model, measures about four minutes including the live scoring. Without WebGPU it trains on the processor, which is slower. Progress is saved in the browser about every 45 seconds and whenever you pause, so you can stop and come back.
Is it free?
Yes. Training runs right in your browser, so there is no server doing the work and nothing to meter, and you do not need an account.