Small transformer improves music key detection in local apps

Deployment-constrained key estimation with a DSP-guided transformer reranker

SoundMachine Learning

Summary

Figuring out the key of a song is important for music apps that organize your library. The authors improved a small, fast system that runs directly on your device to identify a song's key better than earlier simple methods. They combined a basic signal processing approach with a tiny transformer model to enhance accuracy while keeping the system lightweight and fast. This approach works well on diverse music tracks and comes close to larger, more complex methods.

What this means in practice

  • For mobile app developers: Include accurate, fast key detection in local music apps without increasing model size significantly.
  • For audio software engineers: Improve music analysis tools by integrating a compact transformer model guided by DSP for efficient key detection.

Authors

Pardis Noorzad

Abstract

Local music applications estimate key during library import and benefit from an analyzer that is small, fast, and runs in-process. We start from a compact chroma-template key analyzer that fits this budget but lags behind learned references. Learned systems reach higher accuracy, but their installed model and runtime dependencies can occupy tens to hundreds of megabytes. We present key lime, a 21.5k-parameter DSP-guided transformer reranker with a 115 KB model artifact and a 76.7 MB installed footprint, including the extracted ONNX Runtime. It adds 0.32 ms per track to deterministic DSP scoring. Trained from labels on 4,040 FMAK tracks, with 449 tracks for validation and 1,000 disjoint FMAKv2 tracks held out for evaluation, it improves MIREX from 61.08 to 73.55 +/- 0.46 and exact accuracy from 52.30 to 67.07 +/- 0.65 over three seeds (mean +/- population SD). It approaches a same-manifest local madmom KeyCNN reference at 74.16 MIREX. A 12-parameter circular input stage matches the accuracy range of a 468-parameter linear input projection.