From model to app, the review.
From model to app in twelve concepts and seven new questions, from measuring on the phone to an app that works offline and says where it goes wrong. If an answer doesn't add up, under the explanation you'll find the chapter to read again.
The key concepts.
- Accuracy
The share of right answers over all the test examples. It's the simplest score, but with imbalanced classes it's misleading, and on its own it doesn't tell you which mistakes the model makes.
- Confusion matrix
A table that crosses the right answers with the ones the model gave. The hits sit on the diagonal and the mix-ups sit off it, for example sick taken for healthy.
- Precision and recall
Precision tells you how often the model is right when it says yes. Recall tells you how many of the real cases it manages to find. Usually when one goes up the other goes down.
- Quantization
Writing the weights with simpler numbers, for example 8-bit integers instead of 32-bit decimals. The model gets about four times smaller and faster, and it usually loses little.
- Calibration
Running about a hundred real examples through the model before quantizing it, to find the range of values between the layers and put the steps in the right place.
- Pruning
You remove the weights and channels that matter little. The result is a smaller and faster model.
- Distillation
A small model, the student, learns to imitate the answers of a big model, the teacher. It often does better than the same small model trained on its own.
- Inference engine
The program that reads a model file and does the math on the device, choosing between CPU, GPU and NPU. LiteRT, Core ML, ONNX Runtime and ExecuTorch are engines.
- PWA
Progressive web app. A web page that you add to your home screen, that opens full screen and works without a network too, without going through the app stores.
- Service worker
A small program the browser installs next to a page. It saves pages, files and models and hands them back even without a network.
- Federated learning
Many devices improve the same model without sending out their own data. Each one learns locally and sends only the changes to the weights.
- Bias
When a model gets things wrong more often with one group of people, for example voices with an accent or darker skin. It usually happens because that group was rare in the data.
7 questions that weren't in the lessons.
They bring the course's lessons together. After each answer there's the explanation and the place to read again. The review doesn't change the map.
-
An app warns you when the boiler makes a strange noise. The people using it complain about too many useless alerts. Which number needs to go up?
Useless alerts are false alarms. Precision tells you how often the model is right when it says yes. Moving the threshold makes it go up, and recall goes down a little. Explained in 06.01, chapter 3 →
-
After 8-bit quantization, the overall accuracy drops by half a point. Can you relax?
The total can hide a class that loses almost everything. The confusion matrix of the quantized model shows you, class by class, where it started getting things wrong. Explained in 06.02, chapter 4 →
-
A big model is good at telling whether a review is positive, but it's too heavy for the phone. You have a few labeled reviews and thousands without labels. What do you try?
Distilling doesn't need new labels. The teacher answers with its percentages even on examples with no answer, and the small student learns from all of them. Explained in 06.03, chapter 4 →
-
You want your model to run on the phone's NPU. What do you do when you convert it?
NPUs are built for math with 8-bit integers, and many can't work with decimal numbers at all. And for now, a web page can't reach the NPU. Explained in 06.02, chapter 3 →
-
You exported the model from PyTorch to ONNX. Before you measure the milliseconds, what do you check?
Every conversion can change the answers. Run the same hundred examples through both models and compare the outputs. If they don't match, first check how you prepare the input. Explained in 06.04, Go deeper →
-
You have a new model that's more accurate on the computer. Before you publish it in your PWA, what do you do?
A model that's more accurate on the computer can be slower or heavier in your pocket. The numbers that matter come from the reference phone, before you publish. Explained in 06.05, chapter 4 →
-
Your gesture model has 94 percent accuracy. With left-handed people it drops to 70. What do you write in the app?
Transparency means saying where the model goes wrong, with real numbers. And the group that falls behind tells you which examples are missing from the dataset. Explained in 06.06, chapter 6 →