A Contrastive Self-Supervised Learning Scheme for Beat Tracking Amenable to Few-Shot Learning

Antonin Gagneré, Slim Essid, Geoffroy Peeters

Abstract

Beat tracking is a fundamental task in Music Information Retrieval (MIR), yet its performance is often limited by the scarcity of expert-annotated data. We propose a contrastive self-supervised learning (SSL) framework that leverages rhythmic priors to learn beat-related representations from vast unlabeled audio collections. By utilizing Predominant Local Pulse (PLP) and a power-of-two sampling strategy, our model learns to identify rhythmic relationships without explicit labels. Our approach demonstrates state-of-the-art performance in few-shot learning scenarios, outperforming existing unsupervised methods and rivaling fully supervised systems on standard benchmarks.

Introduction

Identifying the "pulse" or beat of a musical piece is a task humans perform intuitively but remains computationally challenging. Deep learning models for beat tracking typically require large amounts of labeled data, which is expensive and time-consuming to produce. While fields like computer vision benefit from millions of labeled images, the MIR community has access to only a few thousand annotated tracks. To address this data bottleneck, we explore self-supervised learning to harness the abundance of unlabeled music available online.

Methodology

Our framework is inspired by Contrastive Predictive Coding (CPC) and employs a Log-Mel-Spectrogram-Transformer as an encoder. The core innovation lies in the contrastive sampling strategy, which uses rhythmic priors to define positive and negative pairs without ground-truth labels.

Predominant Local Pulse (PLP)

We use the PLP technique to generate a rhythmic "proxy" from the audio signal. This provides a grid of candidate beat positions (tatums), serving as a structural scaffold for the learning process.

Contrastive Sampling Strategy

The sampling process identifies three types of pairs relative to a random anchor peak in the PLP:

  1. Anchor: A selected peak in the PLP signal.
  2. Positives: Peaks located at distances of $2^n$ units (e.g., 2, 4, 8) from the anchor. This leverages the binary metric structure prevalent in Western music.
  3. Negatives: "Easy" negatives are random time steps that are not PLP peaks, while "Hard" negatives are PLP peaks that do not fall on power-of-two intervals.
The contrastive sampling strategy uses rhythmic priors to select anchor, positive, and negative samples from the PLP signal.

The model is trained using the NT-Xent loss, which encourages the encoder to produce similar embeddings for anchor-positive pairs while maximizing the distance between anchor-negative pairs in the latent space.

Experimental Setup

The model undergoes a two-stage training process:

  • Unlabeled Pre-training: We utilize approximately 8,000 hours of unlabeled audio (~165,000 tracks) from the Free Music Archive (FMA), MTG-Jamendo, and MagnaTag-aTune (MTT).
  • Few-Shot Fine-tuning: The pre-trained model is fine-tuned on standard MIR benchmarks, including SMC, Ballroom, Hainsworth, and GTZAN, using a varying number of labeled tracks to evaluate few-shot performance.

Results

Our SSL-pre-trained model consistently outperforms the previous state-of-the-art unsupervised method, Zero-Note Samba (ZeroNS). Notably, the model achieves significant improvements in both F1 scores and continuity-based metrics (CMLt/CMLc).

Few-Shot Performance

The model's ability to generalize from minimal data is a key strength. As shown in Figure 3, the performance improves rapidly with only a few labeled examples, reaching high accuracy with as few as 10 to 32 tracks.

Performance metrics across four datasets as a function of training set size, comparing the proposed SSL method (blue) with baselines (green).

Comparison with Supervised SOTA

In cross-validation experiments on the GTZAN dataset, our model achieved an F1 score of 0.876. This result is remarkably close to fully supervised state-of-the-art models, which range between 0.885 and 0.887, despite our model using significantly less labeled data.

Discussion and Limitations

The success of this approach highlights the power of incorporating domain-specific priors—such as the binary rhythmic structure—into SSL frameworks. However, the current "power-of-two" assumption is a limitation for music with non-binary meters, such as waltzes (3/4) or compound meters (6/8). Future work will explore adaptive sampling mechanisms and additional audio features to better handle diverse metrical structures.

Conclusion

We have presented a contrastive SSL scheme for beat tracking that effectively learns rhythmic representations from unlabeled data. By bridging the gap between unsupervised and supervised learning, this framework enables high-performance beat tracking in data-scarce environments, paving the way for more scalable MIR systems.

Summary updated

Abstract

In this paper, we propose a novel Self-Supervised-Learning scheme to train rhythm analysis systems and instantiate it for few-shot beat tracking. Taking inspiration from the Contrastive Predictive Coding paradigm, we propose to train a Log-Mel-Spectrogram-Transformer-encoder to contrast observations at times separated by hypothesized beat intervals from those that are not. We do this without the knowledge of ground-truth tempo or beat positions, as we rely on the local maxima of a Predominant Local Pulse function, considered as a proxy for Tatum positions, to define candidate anchors, candidate positives (located at a distance of a power of two from the anchor) and negatives (remaining time positions). We show that a model pre-trained using this approach on the unlabeled FMA, MTT and MTG-Jamendo datasets can successfully be fine-tuned in the few-shot regime, i.e. with just a few annotated examples to get a competitive beat-tracking performance.
BibTeX
@inproceedings{gagnere2024contrastive,
  author = {Antonin Gagneré and Slim Essid and Geoffroy Peeters},
  title = {{A Contrastive Self-Supervised Learning Scheme for Beat Tracking Amenable to Few-Shot Learning}},
  booktitle = {ISMIR},
  year = {2024},
  url = {https://openreview.net/forum?id=sZZywV3WWg},
}
Figure