AI on a microcontroller
How small can a useful model get?
The question
How small can a useful AI model get?
What I built
A keyword-spotting model on a small microcontroller. It listens and recognises five words: on, off, up, down and stop. Recorded about 300 samples of each word from three people at home.
Final model: around 40 KB. Smaller than most photos on this site.
- Quiet room: 94% correct.
- Kitchen with the dishwasher on: 71%.
- Response: under 100 milliseconds.
The design process
Problem. Every voice assistant needs the cloud. The real question: what’s the smallest useful job that can stay on the device, private and instant?
Iterations.
- v1: ten words. Too many mix-ups.
- v2: five words, adult voices only.
- v3: five words with recordings from everyone in the house, including a two-year-old.
Testing. 100 spoken commands per version in a quiet room and with the dishwasher running.
Design decision. Five short, very different words. If the vocabulary is small, make each word sound nothing like the others.
What broke
My daughter’s voice. Trained on adults, it barely understood her. Added her samples (she was very happy to shout “STOP” 50 times) and it got much better for everyone.
What I learned
If it’s not trained on your users’ voices, it doesn’t work for your users. Tiny models make that very obvious, very fast.