MIDI-LLM: Adapting Large Language Models for Text-to-MIDI Music Generation

Shih-Lun Wu, Yoon Kim, Cheng-Zhi Anna Huang

TL;DR

MIDI-LLM adapts a pretrained text language model (Llama 3.2 1B) into a controllable, multitrack text-to-MIDI generator by expanding its vocabulary with musical event tokens. Because it preserves standard Transformer architecture without custom modules, it runs directly on high-performance LLM serving frameworks like vLLM—generating music significantly faster and with higher fidelity than existing symbolic music baselines.

What Problem Does This Paper Address?

While recent audio-generation models (e.g., MusicGen) create convincing audio from text prompts, raw audio is opaque and notoriously difficult for creators to edit, re-arrange, or adapt into typical production workflows. In contrast, symbolic formats like MIDI offer full transparency and editability, but current text-to-MIDI systems lag behind: they often rely on custom architectures that struggle with prompt adherence and cannot easily benefit from the cutting-edge inference optimizations developed for mainstream Large Language Models (LLMs).

Methods

Instead of designing a bespoke text-to-music architecture, the authors adapt an existing open-weights LLM (Llama 3.2 1B):

  • Vocabulary Expansion: Rather than serializing musical events into verbose ASCII text strings, the model expands the base vocabulary (128K tokens) by adding 55K discrete musical tokens from the Anticipatory Music Transformer (AMT) framework. Each note is represented as three distinct events: arrival time, duration, and instrument-pitch.
  • Two-Stage Training:
  • Continued Pretraining: The model is exposed to ~3B tokens of music-adjacent text and standalone multitrack MIDI sequences to bridge natural language semantics with MIDI syntax.
  • Supervised Finetuning (SFT): The model is conditioned on paired text prompts (specifying genre, mood, instrumentation, chords, etc.) concatenated with target MIDI sequences. Data augmentation includes infilling tasks captioned using Qwen2.5-Omni.
  • Drop-in Acceleration via vLLM: Because the underlying Llama architecture remains strictly standard (only the embedding matrix dimensions changed), the model directly leverages serving optimizations like PagedAttention, CUDA graphs, and FP8 dynamic weight quantization out-of-the-box.

Datasets

  • Training (Stage 1 – Continued Pretraining):
  • MusicPile (subset): ~1.69B tokens of music-related articles, synthetic music knowledge (GPT-4), and ABC-notated music.
  • GigaMIDI: ~1.38B tokens of standalone multitrack MIDI files.
  • Training (Stage 2 – Finetuning):
  • MidiCaps + Lakh MIDI (LMD): 1.71B tokens of paired text captions and multitrack MIDI, scaled to 5.1B tokens with synthetic infilling augmentations.
  • Evaluation:
  • An 896-sample held-out intersection of the MidiCaps benchmark evaluated against the baseline Text2midi.

Key Insights and Ideas

  • Ecosystem Leverage Beats Custom Architectures: Pretrained LLMs already possess broad semantic and stylistic knowledge. Adapting an LLM by simply widening the token embedding matrix allows the model to immediately inherit mature inference runtimes (vLLM), delivering massive speedups with minimal engineering overhead.
  • Surprising Negative Finding on Music Text: Replacing domain-specific text (MusicPile) with a general web text corpus (FineWeb-Edu) during continued pretraining yielded no noticeable difference in downstream text-to-MIDI quality, questioning whether domain-specialized text is strictly necessary for continued pretraining.
  • Infilling Blind Spots: Even when trained on text-conditioned infilling tasks, during inference the model tended to rely almost exclusively on local MIDI context rather than the accompanying text prompt.

Key Results

Evaluated on the MidiCaps test set (synthesizing MIDI outputs to audio via FluidSynth):

  • Higher Musical Quality & Text Alignment: MIDI-LLM outperformed the previous state-of-the-art Text2midi baseline on both Fréchet Audio Distance (FAD 0.173 vs. 0.818, lower is better) and prompt relevance (CLAP score 22.1 vs. 18.7, higher is better).
  • Generation Speed: Despite having over 5× more parameters (1.47B vs. 0.27B), MIDI-LLM generated music up to 6× to 10× faster in wall-clock time:
  • At batch size = 1, generation time dropped from 47.0s (Text2midi) to 10.0s (BF16) and 8.1s (FP8).
  • Real-time factor (RTF) reached 14.17 with FP8 quantization at batch size 4 (generating ~14 seconds of music per 1 second of compute).

Limitations and Future Work

  • Note Dynamics: Unlike REMI-based tokenizers, the AMT tokenization scheme used here does not model note velocities (loudness/dynamics).
  • Weak Text Conditioning in Infilling: Text prompts currently have negligible impact during music infilling tasks compared to the surrounding musical context.
  • Future Directions: The authors plan to implement iterative, text-guided MIDI editing, integrate human preference alignment (RLHF/DPO) using data collected from their live web demo, and collaborate directly with musicians to design practical co-creative interfaces.

Summary updated

BibTeX
@inproceedings{wu2025midi,
  author = {Shih-Lun Wu and Yoon Kim and Cheng-Zhi Anna Huang},
  title = {{MIDI-LLM: Adapting Large Language Models for Text-to-MIDI Music Generation}},
  booktitle = {AI4Music @ NeurIPS},
  year = {2025},
  url = {https://openreview.net/forum?id=GVW9YixIAI},
}
Figure