Content-based Music Similarity with Triplet Networks

Joseph Cleveland, Derek Cheng, Michael Zhou, Thorsten Joachims, Douglas Turnbull

TL;DR

This paper demonstrates that shallow triplet neural networks can effectively learn music embeddings for content-based similarity tasks. By training on triplets of songs to distinguish between artists, the authors achieved a significant performance boost in artist retrieval compared to standard distance-based baselines, even when using relatively simple, pre-extracted audio features.

What Problem Does This Paper Address?

Most modern music recommendation engines, like those powering Spotify or Apple Music, rely heavily on collaborative filtering (CF)—analyzing the listening habits of millions of users to find patterns. While powerful, CF suffers from the "cold-start" problem: it cannot recommend new or obscure artists because there is no historical data to link them to other users.

To solve this, researchers turn to content-based (CB) approaches, which analyze the audio signal itself. The challenge lies in creating a mathematical "embedding space" where songs that sound similar are physically close to each other. This paper explores whether Triplet Networks—a popular architecture in facial recognition—can be adapted to map raw acoustic features into a more meaningful similarity space for music.

Methods

The authors employed a Triplet Network architecture. Unlike standard classifiers, these networks are trained on three inputs simultaneously:

  1. Anchor ($a$): A reference song.
  2. Positive ($p$): A different song by the same artist as the anchor.
  3. Negative ($n$): A song by a different artist.

The goal is to minimize a triplet loss function, which pushes the anchor and positive embeddings together while shoving the negative embedding away by at least a specific margin ($\alpha$).

The Architecture

While previous music similarity research often uses deep convolutional neural networks (CNNs) on raw spectrograms, this study opted for a shallow, fully connected network (two layers) to prioritize scalability. They used 518 standard audio features (like MFCCs, Chroma, and Tonnetz) as inputs.

Sampling Strategies

The researchers compared two ways of picking the "negative" song:

  • Random Triplets: The negative song is chosen from any other artist at random.
  • Genre Triplets: The negative song is chosen from a different artist but within the same genre as the anchor. This is intended to be a "harder" task, forcing the model to learn finer acoustic nuances.

Datasets

The study utilized the Free Music Archive (FMA) dataset.

  • Features: 518 spectral features extracted via the Librosa library.
  • Split: The data included 8,429 artists. The models were trained on songs from 70% of these artists and evaluated on the remaining 30%.
  • Evaluation: The task was artist retrieval: given a query song, how well can the model rank other songs by the same artist at the top of the list?

Key Insights and Ideas

  • Shallow is Sufficient: One of the most interesting findings is that a simple two-layer network can significantly improve upon raw feature distances. This suggests that for music recommendation, we don't always need massive, computationally expensive deep models if we have good pre-extracted features.
  • The Genre Paradox: Surprisingly, the model trained on "harder" genre-matched triplets performed worse than the one trained on random triplets. The authors speculate that because many artists are acoustically diverse, forcing the model to distinguish between similar-sounding genres might have introduced too much noise or "confusion" during training.
  • Baselines are Strong: Simple Euclidean distance on z-scored features performed remarkably well (AUC 0.825), indicating that standard audio features already capture a significant amount of similarity information even before machine learning is applied.

Key Results

The performance was measured using the Area Under the ROC Curve (AUC), where 1.0 is a perfect ranking and 0.5 is random.

Table 1. The average AUC over 2,529 rankings of 25,290 songs for four embedding models: raw vectors and z-scored vectors baselines, and Triplet networks trained with two types of triplets.

As shown in Table 1, the Triplet NN trained on random triplets achieved the highest AUC of 0.900, a notable improvement over the z-scored baseline of 0.825.

Limitations and Future Work

  • Artist vs. Acoustic Similarity: The authors acknowledge that "same artist" is an imperfect proxy for "sounds like." An artist might release a folk song and an electronic song; a model trained to put these together might struggle to define true acoustic similarity.
  • Subjectivity: Music similarity is inherently subjective. The authors suggest that future work should incorporate data from actual user listening studies to better align the model with human perception.
  • Hard Triplet Mining: Beyond genre matching, more sophisticated "hard negative mining" techniques (finding the specific songs that the model currently finds most confusing) could further refine the embedding space.

Summary updated

BibTeX
@misc{cleveland2020content,
  author = {Joseph Cleveland and Derek Cheng and Michael Zhou and Thorsten Joachims and Douglas Turnbull},
  title = {{Content-based Music Similarity with Triplet Networks}},
  year = {2020},
  eprint = {2008.04938},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2008.04938},
}
Figure