What happened

Researchers have developed an AI system capable of generating musical continuations based on MIDI files. The team tackled the fundamental challenge of representing musical data in a format suitable for transformer models – traditionally used for text and code.

They experimented with several tokenization strategies, ultimately settling on a novel representation using ‘NOTE’ tokens that encode pitch, delta_onset (time since previous note), duration, and velocity. This approach avoids issues like note-off drift frequently encountered when solely relying on NOTE/NOTE_OFF pairs, allowing the model to maintain consistent musical phrasing and output reasonable timings.

Why it matters

The potential of this work extends far beyond simple MIDI generation. It demonstrates a new approach to AI music composition – one that leverages the power of transformers to understand and reproduce complex musical structures.

This isn't just about generating pretty melodies; it’s about building models capable of ‘hearing’ and responding to music in a way previously thought impossible for machines. The resulting model achieves roughly 108 notes/second on an iPhone, surprisingly close to human performance.

But, but, but…

The approach isn't without its limitations. The initial experiments with purely NOTE/NOTE_OFF tokenization struggled with maintaining musical coherence, leading to dropped notes and a loss of temporal structure.

A key insight was the importance of explicitly representing duration, as simply relying on note-on events wouldn’t provide enough context for the model to understand rhythmic patterns. Moreover, the computational cost associated with autoregressive generation – each note requiring four transformer steps – presented a challenge for real-time execution on resource-constrained devices like iPhones, although the final delta-onset representation drastically reduced this bottleneck.

“‘It’s also not a flat token stream like: NOTE, PITCH, DELTA, DURATION, VELOCITY Instead of spending four transformer passes generating the attributes of a note, the transformer advances the music by one complete note at a time.’”
— Dr Non

The counter-take

The most striking aspect is not just the model's ability to generate music—that's expected. But what is truly remarkable is that a model trained on MIDI data can effectively ‘learn’ how music unfolds over time – something traditionally considered an inherently human skill, reflecting a surprising advance in AI understanding of sequential patterns and musical structure.

The AI angle

This research accelerates the convergence of AI and music, enabling potentially new forms of interactive musical experiences beyond simple playback; it’s an upgrade to existing synthesis tools with an asymmetry: greater power for the programmer/composer, but less control for the traditional musician.