music music generation piano classical

Model card

<!-- Provide a quick summary of what the model is/does. -->

This is a generative model from the paper "Byte Pair Encoding for Symbolic Music" (EMNLP 2023). The model has been trained with Byte Pair Encoding (BPE) on the Maestro dataset to generate classical piano music with the REMI tokenizer.

Model Details

Model Description

<!-- Provide a longer summary of what this model is. -->

It has a vocabulary of 20k tokens learned with Byte Pair Encoding (BPE) using MidiTok.

Model Sources

<!-- Provide the basic links for the model. -->

Uses

The model is designed for autoregressive music generation. It generates the continuation of a music prompt.

How to Get Started with the Model

Use the code below to get started with the model. You will need the miditok (>=v2.1.7), transformers and torch packages to make it run, that can be installed with pip.

import torch
from transformers import AutoModelForCausalLM
from miditok import REMI
from miditoolkit import MidiFile

torch.set_default_device("cuda")
model = AutoModelForCausalLM.from_pretrained("Natooz/Maestro-REMI-bpe20k", trust_remote_code=True, torch_dtype="auto")
tokenizer = REMI.from_pretrained("Natooz/Maestro-REMI-bpe20k")
input_midi = MidiFile("path/to/file.mid")
input_tokens = tokenizer(input_midi)

generated_token_ids = model.generate(input_tokens.ids, max_length=200)
generated_midi = tokenizer(generated_token_ids)
generated_midi.dump("path/to/continued.mid")

Training Details

Training Data

<!-- This should link to a Data Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->

The model has been trained on the Maestro dataset. The dataset contains about 200 hours of classical piano music. The tokenizer is trained with Byte Pair Encoding (BPE) to build a vocabulary of 20k tokens.

Training Procedure

<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->

Training hyperparameters

The following hyperparameters were used during training:

Environmental impact

We cannot estimate reliably the amount of CO2eq emitted, as we lack data on the exact power source used during training. However, we can highlight that the cluster used is mostly powered by nuclear energy, which is a low carbon energy source ensuring a reduced direct environmental impact.

Citation

<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->

BibTeX:

@inproceedings{bpe-symbolic-music,
    title = "Byte Pair Encoding for Symbolic Music",
    author = "Fradet, Nathan  and
      Gutowski, Nicolas  and
      Chhel, Fabien  and
      Briot, Jean-Pierre",
    booktitle = "Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing",
    month = dec,
    year = "2023",
    address = "Singapore",
    publisher = "Association for Computational Linguistics",
    url = "https://arxiv.org/abs/2301.11975",
}