←

How AI works

What's R2??

Notes are numbers

Top row: swaramMiddle: Western nameBottom: what the AI sees

AI never hears music. It sees a row of numbers, the same way ChatGPT sees words as numbers.

The numbers are MIDI note numbers: 60 is middle C, and each step up is one semitone. This phrase is from raga Kharaharapriya, with Sa on C.

Guess the next note

Adi tala, 8 beats. You in white, AI in pink. "," hold, "·" rest.

ReadsThinksGuessesPicks

What comes next?

If a new note, which one?

Each press, the AI looks at everything so far and picks its top guess for the next half beat: a new note, a hold or a rest. That's what ChatGPT does with words: one guess at a time.

The two switches are a harness: rules people put around the AI, each shown on screen when it acts. The model itself learned from mostly Western melodies. How the harness works

AI rules come from text AIs like ChatGPT, not from music theory: a note used in the last 8 notes has its chance cut (a "repeat penalty"), a 6-note phrase can't be played twice, and a note lasts at most 2 beats, a rest at most 1. They stop loops, but real music repeats on purpose (think of a korvai).

Raga rules come from Carnatic theory, at its most basic level: only the raga's notes (a guess outside them snaps to the nearest one, as in the Studio's "Continue with Magenta AI"), only the notes of the arohanam going up and of the avarohanam coming down, and a phrase that has run 4 beats comes to rest when it lands on Sa or Pa (resting notes), held for a beat and then a breath. Ragas also have signature phrases, their own resting notes and gamakas, which these rules don't know. Try Bilahari or Bhairavi, whose notes differ up and down.

The raga is the inspiration, like a prompt: the keys play only its notes and the melody starts from its scale, but the AI can still pick any of the 12 notes. Both charts are the model's own probabilities, straight from its output; the note chart combines octaves. Names in red are outside the raga you picked. One slot is half a beat.

Keep going

A whole song is just this, repeated: guess, add, guess again.

Temperature

CarefulWild

Low temperature plays it safe and repeats itself. High temperature takes risks. This is the same "temperature" setting ChatGPT has.

Here the AI rolls a die weighted by its guesses, instead of always taking the top one, and temperature changes the weights. The rules start off here, so you hear temperature alone (the length limit stays on).

It only knows what it learned

This model learned from Western melodies, not ragas, so left alone it wanders off the raga. To make it play a raga, you have to guide it.

Small vs big

This modelGPT-3 Parameters3,247,142175 billion Size13 MBabout 350 GB Runs onyour phonedata-centre GPUs Guesses the nextnoteword piece

Same idea, very different size. GPT-3, the model ChatGPT grew out of, has about 54,000 times as many numbers as this one.

Areas are to scale: the magenta dot is this model. "Parameters" are the numbers a model learns during training. OpenAI hasn't published the size of the models behind today's ChatGPT. This model is Magenta's basic_rnn: two layers of 512 LSTM units, the same checkpoint the Studio's "Continue with Magenta AI" uses.

Try it with your own raga

Write an opening with the keys, then let the AI carry on for two cycles. You in white, AI in pink.

Your turn. Change the raga, the rules, the temperature or the context window, and hear what the AI does with your opening.

Temperature at the far left takes the top guess every time, like step 2: the same opening always gets the same answer. Move it right and the AI rolls a die instead. The context window is how much of the melody the AI reads before each guess, like the amount of text ChatGPT can look back on: with 1 cycle it forgets your opening quickly; with everything it remembers it all but slows down as the melody grows. Want more? Play with ragas in the Studio, or see what's coming on the roadmap.