All projects

Music Scaling LawsResearch

Do bigger AI models get better at music the same way they get better at language? I trained ten models on 120,000 songs to find out.

ML & ResearchScaling LawsSolo project2025
PythonPyTorchNumPySciPymusic21
Music Scaling Laws screenshot
2.3×
faster scaling for Transformers than LSTMs
10
models trained, 1M to 100M parameters
120k
songs turned into training text

The AI models behind tools like ChatGPT follow a surprisingly reliable rule: make the model bigger and it gets better at predicting text, by an amount you can forecast in advance. Researchers call these scaling laws. For my machine learning course at NYU, I tested whether the same rule holds for music, and whether it holds equally for two different kinds of model.

The question

The two contenders were a Transformer, the design behind today's large AI models, and an LSTM, the older approach that dominated before it. A Transformer can look back at everything it has read so far at once. An LSTM reads one step at a time and carries a running memory forward.

Both get better as they get bigger. The question was how much better, and whether music, which is full of repeats, phrases and patterns that span many bars, would favor one over the other.

What I did

Music has to become text before a language model can learn it. I took 120,000 songs from the Lakh MIDI dataset, a large public collection of MIDI files, and converted them to ABC notation, a compact way of writing music as plain text that folk musicians have used for decades. A line like [c A]2 [B ^G]2 is just two chords. After cleaning, that came to about 397 million characters of music.

Then I trained ten models from scratch on a single A100 GPU: five Transformers and five LSTMs, from 1 million up to 100 million parameters. Each one saw the whole dataset exactly once, so every comparison was fair.

What I found

Both kinds of model improved with size, and both followed a scaling-law curve closely. That's the chart at the top of this page.

But they didn't improve at the same rate. The Transformers got better more than twice as fast as they grew, with a scaling exponent of 0.60 against 0.27 for the LSTMs, and at every size they reached a lower error. That fits the idea that attention is better at the long-range structure music is built on: a chorus that comes back, a chord pattern that repeats every four bars.

What it sounds like

The largest Transformer can write music on its own. These are the first eight bars of one tune it generated, turned back into sheet music and played on a piano sound, with no edits.

Sheet music for eight bars of a tune generated by the model, mostly paired notes moving in parallel

Generated by the 100M-parameter Transformer

0:00 / 0:00

Not every piece came out this well. All ten samples I generated were valid ABC, but only seven converted cleanly back to MIDI, and several spent their first bars in silence before they started to play. Writing correct notation and writing good music turned out to be two different problems.

Under the hood

Everything runs from one resumable pipeline: convert, clean, tokenize, train, evaluate and generate. The models read music one character at a time from a vocabulary of 97 symbols. The Transformers follow the GPT-2 design, written in PyTorch with nanoGPT as a reference, and the scaling curves are fitted with SciPy.