On-Device 125M Transformer Model for Real-Time Piano Autocomplete
A developer trained a 125M-parameter transformer model that autocompletes piano performances in real time directly on-device. The system runs on an iPhone 15, generating approximately 108 notes per second based on MIDI keyboard inputs. This project demonstrates the feasibility of running generative music models locally on mobile hardware, offering low-latency assistance for musicians without relying on cloud servers. It highlights the growing capability of on-device AI to handle complex, real-time creative tasks. The application functions similarly to code autocompletion tools like GitHub Copilot, using a user's initial MIDI notes as a prompt to generate continuations. The model is optimized for iOS using Apple's Core ML framework to leverage on-device hardware.
## BACKGROUND
Core ML is Apple's machine learning framework designed to integrate and optimize models on iOS devices by leveraging the CPU, GPU, and Neural Engine. Music generation models, such as Google's Music Transformer, typically use event-based representations of MIDI data to capture musical structure and long-term coherence.