AiStream

ResearchGitHub

Alex Meiburg put a language model in his keyboard: it lights up the keys you are about to type

A Waterloo mathematics professor rewrote part of the firmware of his ASUS keyboard to run a small neural network on it. With each letter typed, it predicts the next one and lights it up in red, with no computer involved.

By Ichai Wizman6 min read

Alex Meiburg, an assistant professor of applied mathematics at the University of Waterloo, where he works on quantum information, modified the firmware of his keyboard, an ASUS ROG Azoth. The keyboard now runs a small language model: with each letter typed, it calculates the most likely next letters and lights those keys up in red, while the others stay blue. Everything is calculated inside the keyboard, and it works even when unplugged from the computer.

Alex Meiburg@TimerootI overwrote my keyboard's firmware so that it runs a tiny character-level language model to predict the next key you'll hit. It has per-key backlight LEDs and just lights up the ones you're likely to hit. All inference local on the microprocessor - works without the computer too!2173266.9K

The video, posted on September 9, has been viewed more than 300,000 times. He types slowly, with one finger, so that you can see the keys change. The keyboard's small screen, in the top right corner, shows the letter typed and the ones it predicts.

The next day, he answered the most frequent questions: it is not meant to be useful, only to look nice, and the model learns nothing from what you type, so it cannot remember a password.

What is inside the keyboard

The ROG Azoth is a wireless gaming keyboard with a light under each key and a small screen. It runs on a Nordic nRF52840 chip, a processor running at 64 MHz with 1 MB of memory. Alex Meiburg wanted to keep all the normal functions of the keyboard, which left between 50 and 100 KB for the model. He aimed for 1 millisecond of computation per letter.

The very tight memory constraints mean that even just storing an English dictionary is too big.

He did not rewrite the keyboard's firmware entirely. He decompiled the ASUS firmware with Ghidra, a tool that translates a program back into readable code, and he replaced two of its functions: the one that draws the screen and the one that sends colors to the lights. On each frame, his code reads the pressed keys, steps the model forward, draws the screen and colors the keys. To install his version, he uses the ASUS update tool, and he found the USB command that puts the keyboard into update mode.

He built the first version in less than 24 hours, on September 8 and 9, according to his repo's history. The first attempt, a simple frequency count over the last three letters, took up 1,458 bytes. A few hours later, a real neural network was running on the keyboard. The commits carry the line "Co-Authored-By: Claude": he built the project with Claude Code.

The model

It is a recurrent neural network, a GRU, which reads text letter by letter and keeps in memory what it has already seen. The version in the video weighs 62,720 bytes and knows 32 symbols. He trained it on a computer, with 20 public domain English books taken from Project Gutenberg and some Python code, about 20 million characters in total.

After the video, he trained stronger versions, which know 72 symbols (letters, digits, punctuation, capitals) and use two memories: one that steps forward with each letter, one that steps forward with each word.

ModelSizeRight letter as first choiceRight letter among the top three
nn_64k62 KB54%75%
nn_460k468 KB63%82%

The large model does not fit in what the ASUS tool accepts to install. Alex Meiburg discovered that this tool confirms writes beyond a certain memory address, then silently discards them. So he had the keyboard write into its own 490 KB of free space. He proved that it works, but he has not yet installed the large model in the version he publishes, which is still the one from the video.

When the small model is asked to write on its own by always picking the most likely letter, it goes in circles: "the strange of the strange of the strange". For lighting up keys, this is not a problem, as long as the right letter is among the most likely ones.

What people said

when I say LLMs are really really really fancy T-9 dialers, this is what I mean

You're supposed to look at the screen when you type.

A reader suggested a key that automatically types the predicted letter. Alex Meiburg had thought of it, with Shift+Tab: the keyboard would send exactly the same signal as if you had pressed the key yourself, and the computer would not see the difference.

Doing it yourself

The code is on GitHub, with the reverse engineering notes, the training scripts and the details of the experiments. There is no ready-to-install file: you need a ROG Azoth with version V04_00_13 of the ASUS firmware, Python, PyTorch, an Nvidia graphics card for training and an ARM compiler. The repo has no license, so the code cannot be freely reused without his permission.

He broke his keyboard's firmware several times during the project. The keyboard keeps a separate bootloader that updates do not touch: you bring it up by plugging the keyboard in while holding Fn, B and L, then the ASUS software restores the original version.

The ASUS ROG Azoth, with its small screen in the top right corner.
The ASUS ROG Azoth, with its small screen in the top right corner.

Specifications

azoth-nn
KeyboardASUS ROG Azoth, firmware V04_00_13
ProcessorNordic nRF52840, Cortex-M4F at 64 MHz, 1 MB of flash memory
LightsAbout 120 RGB LEDs, one per key, driven over I²C
ScreenOLED 256 × 64 pixels, 16 levels of gray
MethodASUS firmware decompiled with Ghidra, two functions replaced (screen and lights), image rebuilt then installed with the ASUS update tool
Model in the videoSingle-layer GRU, 112 units, 32 symbols, 8-bit weights, 62,720 bytes
Later modelsTwo GRUs (per letter and per word), 72 symbols, 62 KB or 468 KB
Computation per letterAbout 38,600 multiplications (62 KB), 360,000 (468 KB)
TrainingPyTorch on a graphics card, 20 Project Gutenberg books and Python code, about 20 million characters, distilled from a 1.9 million parameter LSTM
Accuracy54% or 63% as first choice, 75% or 82% among three
LearningNone from what the user types
Codegithub.com/Timeroot/azoth-nn, no license

Sources

Read the source

Up next