MusicGen: Simple and Controllable Music Generation
A single-stage autoregressive transformer that generates high-fidelity music from text prompts using an efficient interleaved acoustic tokenization scheme.
Paper: Simple and Controllable Music Generation
Authors: Jade Copet, Felix Kreuk, Itai Gat, Tal Remez, David Kant, Gabriel Synnaeve, Yossi Adi, Alexandre Défossez · 2023
Read the paperThe Problem
Generating high-fidelity music is extremely difficult due to the massive sampling rate required (e.g., 32kHz or 48kHz). A few seconds of music contains hundreds of thousands of raw audio samples. Previous approaches, like AudioLM or Jukebox, solved this by using complex, multi-stage cascaded architectures: a model to generate coarse acoustic tokens, another model to generate fine tokens, and another to upscale them to raw audio. These multi-stage pipelines were slow, difficult to train, and hard to control with text prompts.
The Idea
MusicGen proved that music generation doesn't need a cascaded hierarchy of models. By cleverly interleaving the discrete audio tokens generated by an EnCodec tokenizer, a single-stage autoregressive Transformer could learn to generate high-fidelity music directly from text or melodic prompts.
How It Works
1. EnCodec Quantization MusicGen relies heavily on EnCodec, an audio tokenizer. EnCodec compresses a continuous audio waveform into discrete tokens using Residual Vector Quantization (RVQ). Instead of producing one token per timestep, RVQ produces multiple parallel streams (or "codebooks") of tokens per timestep. The first codebook captures the coarse structure of the sound, and subsequent codebooks capture finer details.
2. The Interleaved Pattern The primary challenge of a single-stage model is how to feed parallel codebooks into a standard Transformer, which expects a flat 1D sequence. The authors tested several patterns and found that an interleaved (delay) pattern worked best. If we have 4 codebooks, at time step , the model doesn't predict all 4 tokens for time at once. Instead, it predicts:
- Codebook 1 for time
- Codebook 2 for time
- Codebook 3 for time
- Codebook 4 for time
This staggering allows the Transformer to generate the audio sequentially in a single pass without needing a separate model for the fine details.
3. Conditioning The model is conditioned on text (using a pre-trained T5 text encoder) and can also be conditioned on a melodic prompt (by providing a chromagram of a reference melody). The text and melody embeddings are simply prepended to the sequence of audio tokens.
Why It Mattered
MusicGen dramatically simplified the architecture required for state-of-the-art music generation. It made open-source music generation accessible and fast, allowing users to generate high-quality 32kHz music locally on consumer hardware. It proved that clever data formatting (the interleaved pattern) can eliminate the need for complex multi-model pipelines.
What Came After
MusicGen became a foundational baseline for audio generation. Its single-stage, interleaved-RVQ approach heavily influenced subsequent models in speech generation, sound effect generation, and real-time audio synthesis.