Downloads · 30 days
132
3% of all-time downloads
manoskary/musicbert-large
musicbert-large is a fill-mask model from manoskary. Use it when you need the model to fill a missing word. It is set up for transformers. The card lists the license as mit.
MusicBERT large is a 24-layer BERT-style masked language model trained on REMI+BPE symbolic music sequences extracted from the GigaMIDI corpus. It is tailored for symbolic music understanding, fill-mask style infillin…
Downloads · 30 days
132
3% of all-time downloads
All-time downloads
5.1K
Public
Parameters
346M
2.8 GB on disk
Likes
6
Public
Click a slice to open those files.
.safetensors1.4 GB · 100%
From the Hugging Face model README
MusicBERT large is a 24-layer BERT-style masked language model trained on REMI+BPE symbolic music sequences extracted from the GigaMIDI corpus. It is tailored for symbolic music understanding, fill-mask style infilling, and as a backbone for downstream generative tasks.
import torch
from transformers import BertForMaskedLM
from miditok import MusicTokenizer
# Load model and tokenizer
model = BertForMaskedLM.from_pretrained("manoskary/musicbert-large")
tokenizer = MusicTokenizer.from_pretrained("manoskary/miditok-REMI")
# Convert MIDI to BPE tokens (MIDI → REMI → BPE pipeline)
midi_path = "path/to/your/file.mid"
tok_seq = tokenizer(midi_path)
bpe_ids = tok_seq.ids
# Mask some tokens for prediction
import random
mask_token_id = 3 # MASK_None token
input_ids = bpe_ids.copy()
mask_positions = random.sample(range(1, len(input_ids)-1), k=5)
for pos in mask_positions:
input_ids[pos] = mask_token_id
# Run inference
input_tensor = torch.tensor([input_ids])
with torch.no_grad():
outputs = model(input_tensor)
predictions = outputs.logits[0, mask_positions, :].argmax(dim=-1)
print("Predicted token IDs:", predictions.tolist())
If you use this checkpoint, please cite the original MusicBERT introduction and the GigaMIDI dataset.