SelanjutnyaPanduan berikutnya
Penyelarasan yang Dipaksa
AI Audio
PANDUAN Audio AI
MusicGen is Meta's open-weight text-to-music model, published in June 2023, that writes music as a sequence of compressed audio tokens using a single transformer language model.
Dengarkan panduan iniDiceritakan oleh AI · ~8 min
It can follow a text description such as a genre and mood, or a hummed or played melody, and outputs 32 kHz audio. Its code is MIT-licensed, while its weights are licensed for non-commercial use.
MusicGen is a model that generates music from a text description, optionally guided by a melody. It was introduced by Jade Copet and colleagues at Meta AI in the paper "Simple and Controllable Music Generation", first posted to arXiv in June 2023. It works the way a text language model does, predicting the next token from the previous ones, except that its tokens represent short slices of compressed audio rather than words. A separate neural audio codec turns those tokens back into sound. The word simple in the title refers to the design: one transformer generates everything in a single stage, instead of the chain of models that earlier systems such as Google's MusicLM used to go from coarse to fine detail.
The first ingredient is EnCodec, a neural audio codec from the same Meta team, described in an October 2022 paper. A codec compresses audio into a compact form and reconstructs it. The MusicGen version takes 32 kHz mono audio, downsamples it by a stride of 640 samples to 50 frames per second, and represents each frame with residual vector quantization (RVQ): four codebooks of 2,048 entries each, where the first codebook captures the coarse content and each later codebook encodes what the previous ones missed. Thirty seconds of music therefore becomes 1,500 frames, each with four tokens.
The second ingredient is how those four parallel token streams are fed to one transformer. Predicting all 6,000 tokens of a 30-second clip one by one, called flattening, is accurate but slow. Predicting all four codebooks of a frame at once, called parallel, is fast but ignores dependencies between them. MusicGen's default "delay" pattern offsets each codebook by one step, so at each step the model predicts codebook 1 for the current frame, codebook 2 for the previous frame, and so on. The paper says this turns 30 seconds of audio into 1,500 autoregressive steps. In its ablation, flattening still scored best, delay came close, and parallel was worst.
Conditioning steers the generation. Text prompts are encoded by a frozen T5 text encoder, and the paper also tested FLAN-T5 and CLAP. For melody, the model reads a chromagram, a representation of how much energy falls in each of the 12 pitch classes over time. The authors found that the raw chromagram led the model to copy the original track, so they kept only the dominant pitch class at each step and used Demucs, a source-separation model, to remove drums and bass first, because those dominated the chromagram. Generation uses classifier-free guidance: during training the condition is dropped 20% of the time, and at inference the model blends conditioned and unconditioned predictions with a guidance scale of 3.0 to follow the prompt more closely.
Training used about 20,000 hours of licensed music: an internal set of 10,000 high-quality tracks plus 25,000 and 365,000 instrument-only tracks from the ShutterStock and Pond5 collections, all at 32 kHz with text descriptions and metadata. The team trained models of 300 million, 1.5 billion and 3.3 billion parameters for one million steps on 30-second crops, using 32, 64 and 96 GPUs respectively. Meta announced the model publicly on 2 August 2023 as part of AudioCraft, alongside AudioGen for sound effects and an improved EnCodec decoder. The Hugging Face model card says the version 1 models were trained between April and May 2023.
On the MusicCaps benchmark of expert-written music descriptions, MusicGen compared well. Frechet Audio Distance (FAD), which measures how far generated audio statistics are from real audio, was 3.1 for the 300M model, against 4.0 reported for MusicLM, 7.5 for Mousai and 14.8 for Riffusion; Noise2Music reported the best FAD at 2.1. In human ratings on a 1 to 100 scale, the 3.3B model scored 84.81 for overall quality and the 1.5B model 83.70 for relevance to the text, against 80.51 and 82.35 for the public MusicLM demo. The authors note that larger models did not always improve automatic metrics even when listeners preferred them. With melody conditioning, the similarity between the reference and generated chromagrams rose from 0.10 to 0.66. A stereo variant, fine-tuned from the mono model with eight codebooks, was rated higher than mono.
Compared with alternatives, MusicGen's main trade is simplicity for some control. Hierarchical systems like MusicLM cascade several models, which the MusicGen authors avoided. Diffusion-based systems such as Riffusion and Mousai generate spectrograms or latents through iterative denoising rather than token by token. Within token-based models, MusicGen's interleaving patterns are its distinguishing choice. Its open release is also a difference: Meta published weights and code, while MusicLM's implementation was not public at the time of the paper.
The limitations are stated by Meta itself. The model card says MusicGen cannot generate realistic vocals, because vocals were removed from training data; works best with English descriptions; performs unevenly across musical styles and cultures; sometimes collapses to silence at the end of a song; and may need prompt engineering. The paper's authors note that their method offers no fine-grained control over how closely the output follows the conditioning beyond classifier-free guidance, and that the dataset contains a larger proportion of Western-style music. They also raise the concern that generative models could compete unfairly with artists. The weights are licensed CC-BY-NC 4.0, which rules out commercial use, even though the code is MIT-licensed. In practice, running MusicGen requires Python, PyTorch and ffmpeg per the AudioCraft README, and a GPU is advisable for the larger checkpoints; the model card's examples generate clips of a few seconds at a time.
04Contoh yang berhasil
Install Hugging Face Transformers version 4.31.0 or later and scipy, and confirm the use is non-commercial under the CC-BY-NC 4.0 weight license.
Load facebook/musicgen-small through the text-to-audio pipeline to keep memory use low for a first test.
Generate a clip from the prompt 'lo-fi hip hop beat with soft piano and vinyl crackle' and save the returned 32 kHz array as a WAV file.
Generate a second clip from the same prompt and listen to both; sampling with top-k makes each run different.
Change one element of the prompt, such as swapping piano for saxophone, and check whether the instrumentation changes accordingly.
Compare with the melody checkpoint by supplying a short reference melody and listening for whether the tune carries over.
Apa yang ditunjukkannya
Two or more short instrumental clips at 32 kHz that reflect the prompt's genre and instruments. Check them by listening for prompt adherence, for any collapse to silence near the end, and by noting that no realistic vocals appear, both of which match the limitations in Meta's model card.
Meta released MusicGen with AudioGen and EnCodec as the AudioCraft framework on 2 August 2023, publishing model weights and training code so researchers could train models on their own data.
Melody conditioning: the MusicGen melody checkpoint extracts a chromagram from a reference track after removing drums and bass, then generates new music that follows that tune while matching a text prompt.
Researchers load the small, medium, large or melody checkpoints through Hugging Face Transformers (version 4.31.0 or later) with the text-to-audio pipeline to produce mono 32 kHz clips.
In the paper's listening tests on MusicCaps, the 3.3B-parameter MusicGen scored 84.81 out of 100 for overall quality, above the 80.51 measured for the public MusicLM demo.
The AudioCraft repository later added related research models such as MAGNeT, a non-autoregressive text-to-music model, and AudioSeal for audio watermarking, built on the same codebase.
The MusicGen paper names its own open problems: finer control over how strictly output follows its conditioning, and better data augmentation and guidance for audio conditioning such as melodies. Meta's August 2023 announcement acknowledged that the training data skews toward Western-style music and English-only descriptions, which limits the model's range. Since 2023, the AudioCraft repository has grown to include MAGNeT, a non-autoregressive text-to-music and text-to-sound model, MusicGen Style, JASCO for conditioning on chords, melodies and drum tracks, and AudioSeal for watermarking generated audio, which shows the research direction toward faster generation, richer musical controls and provenance tools. Questions about training-data licensing, attribution and the economic effect on working musicians remain unresolved across the field, and the MusicGen authors flagged unfair competition for artists as an open issue. Evaluations using shared benchmarks such as MusicCaps, together with human listening tests, remain the main way to compare newer music models with MusicGen.
Buletin gratis
Tiga cerita AI terverifikasi setiap pagi hari kerja, ditulis dalam bahasa Inggris sederhana. Gratis selamanya, tanpa iklan.
Satu email setiap hari kerja. Berhenti berlangganan dalam satu klik. Kami tidak pernah menjual atau membagikan alamat Anda.
Uji diri Anda sendiri
Umpan balik instan untuk setiap jawaban, dan sertifikat yang dapat dibagikan dengan ID yang dapat diverifikasi setelah Anda lulus kursus.
Mendukung pendidikan AI gratis. AI Understanding adalah organisasi nirlaba 501(c)(3) — tanpa iklan, tanpa paywall, selamanya. Berikan sumbangan
MusicGen is Meta's open-weight text-to-music model, published in June 2023, that writes music as a sequence of compressed audio tokens using a single transformer language model. It can follow a text description such as a genre and mood, or a hummed or played melody, and outputs 32 kHz audio. Its code is MIT-licensed, while its weights are licensed for non-commercial use.
The melody-conditioned variant can use a text description and a reference melody; this input is not available in every text-only checkpoint.
MusicGen memodelkan token terpisah yang dihasilkan oleh codec EnCodec Meta, yang juga menerjemahkan token yang diprediksi kembali menjadi audio.
The architecture uses delayed interleaving in a single-stage autoregressive model; “single-stage” does not mean the whole song is generated in one forward pass.
Kromagram menangkap kelas nada mana yang muncul dari waktu ke waktu, sehingga MusicGen dapat mencocokkan harmoni dan kontur lagu tanpa mereproduksi timbre aslinya.
MusicGen dirilis pada tahun 2023 sebagai bagian dari proyek AudioCraft Meta AI, dengan kode terbuka dan bobot model.
Teruslah belajar
Panduan lainnya dipilih untuk topik ini
SelanjutnyaPanduan berikutnya
Penyelarasan yang Dipaksa
AI Audio