Automatic Music Sample Identification with Multi-Track Contrastive Learning

Alain Riou, Joan Serrà, Yuki MitsufujiarXiv 2025 · DOI

Abstract

Automatic music sample identification—detecting when audio is reused and modified in a new track—is a significant challenge due to complex processing like pitch-shifting and mixing. We propose a self-supervised contrastive learning approach that generates artificial mixes on-the-fly using multi-track recordings. Our method achieves a new state-of-the-art on standard benchmarks, with a +15% boost in mean average precision (mAP). We demonstrate that the quality of training data, specifically the use of ground-truth isolated stems, is more impactful than simply increasing dataset scale.

Introduction

Sampling is a cornerstone of modern music production, yet identifying samples for attribution and copyright remains difficult. Producers often transform samples through pitch-shifting, time-stretching, and embedding them within dense arrangements. The lack of large-scale, annotated datasets for sampled music has historically limited the development of supervised models. While previous self-supervised methods used basic augmentations on single tracks, they failed to capture the reality of samples being mixed with entirely different audio sources.

Methods

Our approach frames sample identification as a self-supervised contrastive learning problem with a novel data-generation strategy designed to simulate real-world sampling.

Artificial Mixes and Augmentations

Instead of augmenting single tracks, we utilize a dataset of multi-track recordings. During training, we extract isolated stems (e.g., drums, vocals) from one song, apply random audio effects like EQ and compression, and mix them with stems from a completely different song in the same batch.

To handle transformations like pitch-shifting efficiently, we convert audio into Variable-Q Transform (VQT) spectrograms. Because VQT uses a log-frequency scale, vertical cropping of the spectrogram perfectly simulates pitch-shifting, avoiding the high computational cost of audio-domain processing.

Overview of the proposed pipeline including stem extraction, VQT transforms, and the contrastive loss matrix.

Contrastive Learning Framework

The batch generation process creates complex relationships where an artificial mix shares stems with multiple source tracks. To address this, we implemented a modified symmetric contrastive loss function capable of handling multiple positive pairs per item. We use a ResNet-IBN encoder to map these spectrograms into a 2048-dimensional embedding space.

Experimental Setup

The model was trained on a proprietary dataset of 21,000 multi-track recordings (approximately 1,350 hours) across various genres. Evaluation was conducted on:

  • Sample100: A standard benchmark primarily featuring hip-hop tracks.
  • SamplePairs: A new, genre-diverse dataset introduced to test scalability, containing 100 curated pairs and over 5,000 distractor tracks.

Key Insights and Results

Our model significantly outperformed previous benchmarks. On Sample100, it achieved an mAP of 0.603 and a Hit Rate @ 1 (HR@1) of 0.587, compared to previous bests of 0.442 and 0.155, respectively.

Data Quality vs. Quantity

A pivotal finding of this research is the importance of data quality. Training on just 20% of the dataset using high-quality ground-truth stems yielded better results than using the full 100% of the dataset with stems extracted via AI source separation (HT-Demucs). This suggests that the bottleneck for sample identification models is the precision of the training signals rather than the sheer volume of data.

Performance metrics (mAP and Normalized Rank) as a function of dataset size.

Robustness and Temporal Invariance

The use of VQT with increased bandwidth makes the model robust to variations in "hop size" during inference, a common failure point for standard Constant-Q Transforms (CQT). Furthermore, the model showed remarkable stability when distractor tracks were added, maintaining a high HR@1 even with thousands of "noise" songs.

Discussion and Future Work

A theoretical challenge identified is the violation of the triangle inequality in contrastive learning for sampling. If Song A is sampled by both Song B (drums) and Song C (vocals), B and C should both be close to A in the embedding space. However, B and C share no audio and should ideally remain distant. Standard contrastive loss tends to pull B and C together because they are both pulled toward A. Future research will focus on embedding paradigms that can better represent these non-transitive relationships in large-scale audio retrieval.

Summary updated

BibTeX
@misc{riou2025automatic,
  author = {Alain Riou and Joan Serrà and Yuki Mitsufuji},
  title = {{Automatic Music Sample Identification with Multi-Track Contrastive Learning}},
  year = {2025},
  eprint = {2510.11507},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.11507},
}
Figure