Downloads · 30 days
956
28% of all-time downloads
auriankelen/matpac_music
matpac_music is a audio classification model from auriankelen. Use it for the audio classification task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as apache-2.0.
MATPAC (Masked latent Prediction And Classification) is a self-supervised audio and music encoder. This repo hosts the MATPAC++ encoder pre-trained on music (matpacplusmusic6s2048enconly.pt), a transformers-native, tr…
Downloads · 30 days
956
28% of all-time downloads
All-time downloads
3.4K
Public
Parameters
85.4M
342 MB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors342 MB · 100%
From the Hugging Face model README
MATPAC (Masked latent Prediction And Classification) is a self-supervised audio
and music encoder. This repo hosts the MATPAC++ encoder pre-trained on music
(matpac_plus_music_6s_2048_enconly.pt), a transformers-native,
trust_remote_code port of the official inference code
(aurianworld/matpac, folder
inference_matpac), following the same pattern as
m-a-p/MERT-v0.
| Repo | Trained on | Output | Notes |
|---|---|---|---|
| matpac_general_audio | General audio (AudioSet) | 3840-d embeddings | Default general-purpose audio encoder |
| matpac_music (this repo) | Music | 3840-d embeddings | Music-specialized encoder |
| matpac_audioset_finetune_encoder | AudioSet (fine-tuned) | 3840-d embeddings | Fine-tuned encoder, no classification head |
| matpac_audioset_finetune_classifier | AudioSet (fine-tuned) | 527-way logits | Ready-to-use AudioSet tagger |
To use the downstream-task linear probes, download the weights from the original repo (Weights_probes_matpac.zip), and attach them to this encoder with the conversion script. See
Downstream task probes below for details.
from transformers import AutoModel, Wav2Vec2FeatureExtractor
import torch
import torchaudio
model = AutoModel.from_pretrained("auriankelen/matpac_music", trust_remote_code=True)
processor = Wav2Vec2FeatureExtractor.from_pretrained("auriankelen/matpac_music", trust_remote_code=True)
waveform, sr = torchaudio.load("my_song.wav")
waveform = waveform.mean(dim=0) # mono
resample_rate = processor.sampling_rate
if resample_rate != sr:
waveform = torchaudio.transforms.Resample(sr, resample_rate)(waveform)
inputs = processor(waveform, sampling_rate=resample_rate, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
# outputs.last_hidden_state: (batch, 3840) -- mean-pooled over time by default
# outputs.hidden_states: tuple of 12 tensors, one per encoder layer, each (batch, 3840)
all_layer_hidden_states = torch.stack(outputs.hidden_states)
print(all_layer_hidden_states.shape) # [12, batch, 3840]
# Keep the time axis instead of mean-pooling it
outputs = model(**inputs, pull_time_dimension=False)
# outputs.last_hidden_state: (batch, time, 3840)
# Vectorized inference: faster on large batches, adds some padding so it is
# slightly less precise than the default ("precise", used for the paper's results)
outputs = model(**inputs, inference_type="fast")
Get the probe
weights straight from here
Probes_weights
and merge them into a loadable HF folder with
convert_matpac_checkpoint.py:
python convert_matpac_checkpoint.py \
--checkpoint_path matpac_plus_6s_2048_enconly.pt \
--probe_checkpoint_path matpac++_general_audio/fsd50k.pth \
--class_mappings_dir matpac/inference_matpac/matpac/class_mappings \
--output_dir ./matpac-general-audio-fsd50k
outputs.logits then holds the task's logits and model.config.id2label the
corresponding labels, exactly as for the AudioSet head above.
This model needs a couple of packages beyond transformers to run its
trust_remote_code files: torchaudio, einops, and timm==0.4.12 (the exact
timm version the checkpoints were exported with — the internal naming of the ViT
block submodules must match for the weights to load correctly).
@inproceedings{quelennec2025matpac,
title={Masked Latent Prediction and Classification for Self-Supervised Audio Representation Learning},
author={Quelennec, Aurian and Chouteau, Pierre and Peeters, Geoffroy and Essid, Slim},
booktitle={ICASSP 2025 - 2025 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
year={2025},
url={https://ieeexplore.ieee.org/document/10887666},
doi={10.1109/ICASSP49660.2025.10887666}
}
@article{quelennec2025matpacenhancedmaskedlatent,
title={MATPAC++: Enhanced Masked Latent Prediction for Self-Supervised Audio Representation Learning},
author={Aurian Quelennec and Pierre Chouteau and Geoffroy Peeters and Slim Essid},
journal={arXiv preprint arXiv:2508.12709},
year={2025},
url={https://arxiv.org/abs/2508.12709}
}