MusicGen

On this page 7

MusicGen is an open text-to-music model released by Meta AI in June 2023 that generates instrumental audio from a written description and, optionally, a reference melody. In generative media, a branch of artificial intelligence, it is a reference example of the token-based approach: a single autoregressive transformer predicts compressed audio tokens, which a neural codec then turns back into a waveform.

The model ships as part of Meta’s AudioCraft library and was described in the paper on simple and controllable music generation. Its importance lies less in commercial use than in being one of the first high-quality music generators with public weights, which made it a common baseline for research and experimentation.

How MusicGen generates music from tokens

MusicGen produces music by predicting discrete audio tokens one time step at a time and then decoding them into sound. The tokens come from EnCodec, a neural audio codec that compresses 32 kHz mono audio into four parallel streams of codes, called codebooks, at a frame rate of 50 Hz.

Earlier systems such as MusicLM used several cascaded models to handle these streams. MusicGen instead uses a single-stage transformer with a codebook interleaving pattern. In the default delay pattern, each codebook is shifted by one step relative to the previous one, so the model can predict all four streams in one pass while still respecting their dependencies.

The table below traces the main stages of the generation pipeline.

StageComponentFunction
Text encodingFrozen T5 text encoderTurns the prompt into conditioning vectors
Melody conditioningChromagram extractorSupplies pitch contour from reference audio
Token predictionAutoregressive transformer decoderPredicts codebook tokens with cross-attention to the text
GuidanceClassifier-free guidanceStrengthens adherence to the prompt
DecodingEnCodec decoderReconstructs the waveform from tokens
Stages of the MusicGen pipeline

Sampling typically uses top-k sampling with k of 250 and a guidance coefficient around 3. Higher guidance follows the prompt more strictly but can make the output repetitive or harsh, a trade-off users tune by ear.

Model sizes and variants

MusicGen is distributed in several checkpoints that trade quality against speed and memory. All share the same architecture and differ in parameter count or conditioning.

CheckpointParametersConditioningTypical use
SmallAbout 300 millionTextFast tests on modest GPUs
MediumAbout 1.5 billionTextBalanced quality and speed
LargeAbout 3.3 billionTextHighest text-only quality
MelodyAbout 1.5 billionText and melodyFollowing a hummed or played tune
Stereo variantsSame as base sizesText or melodyTwo-channel output
Main MusicGen checkpoints

The models were trained on roughly 20,000 hours of licensed music, including an internal Meta collection and stock music libraries. Because the training data was licensed and largely instrumental, the model does not produce intelligible vocals, and prompts asking for a singer usually yield vocal-like textures at best.

The code is released under the MIT license, while the model weights use a non-commercial Creative Commons license. This distinction matters: researchers and hobbyists can use the weights freely, but commercial products cannot ship them without separate rights.

How MusicGen compares with other music generators

MusicGen sits among several approaches to AI music, and the differences come mostly from the generation method and the availability of weights. The comparison below covers neighbors in the same field.

SystemGeneration methodWeightsNotable trait
MusicGenAutoregressive tokensOpen, non-commercialMelody conditioning
Stable AudioLatent diffusionPartly openTiming control and longer clips
RiffusionDiffusion on spectrogram imagesOpenBuilt on an image model
LyriaProprietary model familyClosedVocals and real-time control
MusicLMCascaded token modelsClosedHierarchical semantic tokens
MusicGen and related systems

The autoregressive design gives MusicGen good local coherence of rhythm and harmony but makes generation sequential and relatively slow. Diffusion systems such as Stable Audio generate a whole segment in parallel and handle fixed-length timing more naturally, while closed commercial services add vocals and lyrics that MusicGen does not attempt.

Using MusicGen effectively

Good results with MusicGen depend on specific prompts, suitable clip lengths and the right checkpoint. The model was trained on 30-second excerpts, so that length is its natural working window.

GoalRecommended choiceReason
Quick idea sketchesSmall model, 10 to 15 secondsFast iteration on limited hardware
Best audio qualityLarge model, up to 30 secondsMore capacity for timbre and structure
Matching an existing tuneMelody model with reference audioChromagram keeps the pitch contour
Longer tracksWindowed continuationExtends beyond the training length
Practical choices when running MusicGen

Effective prompts name genre, instrumentation, tempo and mood, for example a lo-fi hip-hop beat at 80 BPM with soft piano and vinyl crackle. Vague prompts produce generic results. On a consumer GPU with 16 GB of memory, the medium model generates a 30-second clip in well under a minute, while the large model needs more memory and time.

Limitations and open questions

MusicGen has clear technical and legal limits that users should understand before relying on it.

  • Short structure: long-range form such as verse and chorus is weak, and continuations can drift.
  • No usable vocals: the model was not trained to sing words.
  • Audio fidelity: 32 kHz codec output lacks some high-frequency detail compared with studio masters.
  • Genre bias: training data skews toward Western styles, so other traditions are rendered less faithfully.
  • Licensing: the non-commercial weight license restricts product use.

As with other generative audio models, questions about style imitation and originality remain open. Licensed training data reduces some concerns, but output can still resemble familiar patterns, so human review before publication remains good practice.

In simple terms

MusicGen is a computer program that writes short pieces of music from a description. You type something like calm guitar music for a rainy evening. A few seconds later, you get an audio clip.

It works a bit like predictive text for sound. The program guesses the next tiny piece of audio, then the next one, until the clip is complete. You can also hum a tune, and it will build an arrangement around it. It cannot sing lyrics, and the clips are short.

A practical example

A small independent game studio needs placeholder music for a prototype with five levels. The sound designer runs the medium MusicGen model locally and writes prompts such as an ambient synth pad at 70 BPM with slow arpeggios for a calm forest level.

For each level, the designer generates ten 20-second clips, picks the best two and loops them in the game engine. For the boss level, the designer hums a short motif into a microphone and uses the melody checkpoint to turn it into an orchestral version. The team tests the mood of each level within a day. Because the weights carry a non-commercial license, the studio later replaces the clips with commissioned music before release, using the prototypes as a reference brief for the composer.