Show HN: I trained a 125M model to autocomplete piano on-device

561 points · 113 comments on HN · read original →

Points and comments are a snapshot, not live.

Trained a 125M-parameter transformer for real-time piano autocomplete on iPhone, using a novel MIDI tokenization.

The model runs at ~108 notes/second on an iPhone 15. Key improvements came from a compound note representation (embedding sum of event_type, pitch, delta, duration, velocity) that generates one entire note per transformer pass, aggressive data cleaning (300 million note events), and DPO post-training using Gemini 3.5 Flash for pairwise evaluation. The author found that scaling noisy data harmed performance, note-on/off representations caused drift, and scheduled sampling increased validation loss but improved rollout quality.

What commenters are saying

Commenters were enthusiastic, calling the project 'magic' and 'awesome.' Several suggested next steps: generating full accompaniment from a melody, adding bar/measure tokens for rhythm, or outputting MIDI back to a device. One user noted the parallels to François Pachet's 2003 Continuator. A minor discussion compared MIDI's persistence as a protocol. The author engaged directly, noting DPO used only ~700 preference examples and took 12 minutes to train.