MIDI-GPT
MIDI-GPT is a GPT-2 transformer for symbolic music generation trained on the GigaMIDI dataset. It supports bar-level infill, autoregressive multi-track generation, and attribute-conditioned generation.
Paper: MIDI-GPT: A Controllable Language Model for Symbolic Music Performance Generation (AAAI 2025) GitHub: Metacreation/MIDI-GPT PyPI: midigpt
Models
| Model | Checkpoint | num_bars_map |
Context (tokens) | Infill | Attributes |
|---|---|---|---|---|---|
yellow_medium |
checkpoint | 4, 8 | 2048 | yes | note density, polyphony (min/max), note duration (min/max) |
yellow_small |
checkpoint | 4, 8 | 2048 | yes | note density, polyphony (min/max), note duration (min/max) |
prism_medium |
checkpoint | 4, 8, 12, 16 | 4096 | yes | key signature, pitch range, silence, note duration, note density (bar), polyphony (bar), pitch class set, genre |
expressive_medium |
checkpoint | 4, 8, 12, 16 | 4096 | yes | key signature, pitch range, silence, note duration, note density (bar), polyphony (bar), pitch class set, nomml, genre |
InferenceEngine.from_pretrained(name) downloads the current checkpoint for that model name.
model_dim in InferenceConfig is the context window in bars, not a vocabulary dimension — pass a
value from the model's num_bars_map. expressive additionally encodes sub-grid timing via delta
tokens and supports switchable velocity/microtiming controls. See
docs/models.md in the GitHub
repository for the full breakdown.
Installation
pip install "midigpt[inference]"
Usage
from midigpt import Score
from midigpt.inference.engine import InferenceEngine
from midigpt.inference.config import GenerationRequest, InferenceConfig, TrackPrompt
# Download and cache the model automatically
engine = InferenceEngine.from_pretrained("yellow_medium") # or "yellow_small", "prism_medium", "expressive_medium"
# Load a MIDI file
score = Score.from_midi("my_song.mid")
# Infill bars 4–7 on track 0 given surrounding context
request = GenerationRequest(
tracks=[
TrackPrompt(id=0, bars=list(range(4, 8))),
],
config=InferenceConfig(model_dim=8),
)
session = engine.session(score, request)
result = session.run()
result.to_midi("output.mid")
The model is downloaded once and cached by huggingface_hub in ~/.cache/huggingface/hub/.
Training
Models are trained on GigaMIDI v2.0.0 using the midigpt training pipeline
with PyTorch Lightning. Training configs and the preprocessing pipeline are
available in the GitHub repository.
Citation
@misc{pasquier2025midigptcontrollablegenerativemodel,
title={MIDI-GPT: A Controllable Generative Model for Computer-Assisted Multitrack Music Composition},
author={Philippe Pasquier and Jeff Ens and Nathan Fradet and Paul Triana and Davide Rizzotti and Jean-Baptiste Rolland and Maryam Safi},
year={2025},
eprint={2501.17011},
archivePrefix={arXiv},
primaryClass={cs.SD},
url={https://arxiv.org/abs/2501.17011},
}
License
Creative Commons Attribution-NonCommercial 4.0 International (CC-BY-NC-4.0). Copyright (c) 2026 Metacreation Lab.