MidiGen: Guitar Pro fine-tune

MidiGen is a 52.3 million parameter PyTorch transformer that continues a short prompt as multitrack symbolic music. It generates notes for a MIDI file, which can be edited in a sequencer or played through a synthesizer.

Training code, dataset builders and deployment scripts are on GitHub at 8mind/midigen.

Generate a MIDI file

Use Python 3.10 or newer; requirements.txt requires PyTorch 2.9 or newer. Download or clone this repository, including model.safetensors, and run:

python -m pip install -r requirements.txt
python generate.py --output harp.mid

The example starts with one middle-C orchestral harp note and generates up to 500 additional notes. It uses temperature 1.0 and top-p 0.95. The model can end generation earlier. The script automatically uses CUDA when available and otherwise runs on the CPU.

generate.py also accepts --notes (maximum number of generated notes, default 500), --seed (sampling seed, default 1337, so repeated runs give the same file) and --weights (path to a different .safetensors file).

Example output

This 52-second clip was generated by generate.py with its default settings and rendered to audio with FluidSynth and the Arachno SoundFont. The instrument sounds come from the SoundFont, not from the model.

If the player does not appear, download the MP3 file.

Model

This is a custom PyTorch model. model.py defines the architecture and the event format. Each event represents onset delta, track, instrument, pitch, and duration. Melodic instruments use MIDI program numbers and percussion uses separate instrument and pitch tokens.

The network is a decoder-only transformer with 16 layers, model width 512, 8 attention heads, SwiGLU feed-forward layers (width 1408) and RMSNorm. Position is encoded with rotary embeddings and xPos decay. The context is 2,048 events, with 512-event sliding-window attention. A cascaded output head predicts each event one field at a time: onset delta, then track, instrument, pitch and duration, with each prediction conditioned on the fields before it. Weights are stored in float32.

Training and evaluation

The model was first pretrained for one epoch on GigaMIDI. Its training split contains 2,094,399 songs and 2,463,160,429 note events, and its held-out split contains 4,184 songs and 5,001,532 note events. No dropout was used. The checkpoint with the lowest validation loss was saved at step 37,616.

The checkpoint was then fine-tuned on a guitar corpus, because the author likes guitar rhythms and motifs and wanted the model to lean towards them. The corpus is a private collection of Guitar Pro files, mostly guitar, bass and drum tracks, and is not redistributed. Its training split contains 47,590 songs and 175,342,558 note events, and its held-out split contains 1,391 songs and 5,002,480 note events. Fine-tuning ran for three epochs with 0.1 dropout on embeddings, residual connections and feed-forward layers. Attention-weight dropout stayed at zero so that training could use PyTorch FlexAttention. The checkpoint with the lowest validation loss was saved at step 8,028 and is the released model.

On the Guitar Pro held-out split, the released model's next-event validation loss is 0.7555, down from about 0.834 for the pretrained checkpoint. The loss is the sum of the mean cross-entropy losses of the five event fields. It measures how well the model predicts held-out music, not how good its output sounds.

The training pipeline, including the GigaMIDI and Guitar Pro dataset builders and the pretraining and fine-tuning wrappers, is in the GitHub repository.

Data and release terms

The Creative Commons Attribution-NonCommercial 4.0 International licence covers the code and model.safetensors to the extent Praveen Xavier holds rights in them.

GigaMIDI retains its Creative Commons Attribution-NonCommercial 4.0 International licence and dataset access terms. The Guitar Pro files used for fine-tuning retain the terms of their rights holders. The MidiGen licence does not extend to training data or to rights held by third parties.

Citation

If you use this model, please cite it as:

@misc{midigen2026guitarpro,
  title        = {MidiGen: Guitar Pro fine-tune},
  author       = {Xavier, Praveen},
  year         = {2026},
  howpublished = {\url{https://huggingface.co/dennis-xavier/MidiGen}}
}

Please also cite GigaMIDI:

@article{lee2025gigamidi,
  title   = {The GigaMIDI Dataset with Features for Expressive Music Performance Detection},
  author  = {Lee, Keon Ju Maverick and Ens, Jeff and Adkins, Sara and Sarmento, Pedro and Barthet, Mathieu and Pasquier, Philippe},
  journal = {Transactions of the International Society for Music Information Retrieval (TISMIR)},
  volume  = {8},
  number  = {1},
  pages   = {1--19},
  year    = {2025}
}

Contact

For questions or feedback, use the model's Hugging Face Discussions tab.

Downloads last month

-

Downloads are not tracked for this model. How to track
Safetensors
Model size
52.3M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Dataset used to train dennis-xavier/MidiGen