A Bi-directional Transformer for Musical Chord Recognition

Jonggwon Park, Kyoyun Choi, Sungwook Jeon, Dokyun Kim, Jonghun Park

Abstract

Chord recognition is an important task since chords are highly abstract and descriptive features of music. For effective chord recognition, it is essential to utilize relevant context in audio sequence. While various machine learning models such as convolutional neural networks (CNNs) and recurrent neural networks (RNNs) have been employed for the task, most of them have limitations in capturing long-term dependency or require training of an additional model. In this work, we utilize a self-attention mechanism for chord recognition to focus on certain regions of chords. Training of the proposed bi-directional Transformer for chord recognition (BTC) consists of a single phase while showing competitive performance. Through an attention map analysis, we have visualized how attention was performed. It turns out that the model was able to divide segments of chords by utilizing adaptive receptive field of the attention mechanism. Furthermore, it was observed that the model was able to effectively capture long-term dependencies, making use of essential information regardless of distance.

Introduction

Automatic Chord Recognition (ACR) is the process of generating a time-synchronized sequence of chord labels (e.g., C Major, A minor) from raw audio. It is a foundational task in Music Information Retrieval (MIR) with applications in lead-sheet generation and music structure analysis.

The primary challenge in ACR lies in capturing musical context. A single moment of audio may contain "noisy" non-chord tones, and chords can vary significantly in duration. Traditional models like CNNs are limited by fixed receptive fields, while RNNs often struggle with very long-term dependencies and slow training speeds. Furthermore, many top-performing systems require a complex two-stage process: a deep learning feature extractor followed by a separate sequence decoder like a Conditional Random Field (CRF). The BTC model addresses these issues by using a self-attention mechanism to learn musical grammar end-to-end.

Methodology

The proposed Bi-directional Transformer for Chord recognition (BTC) utilizes a single-phase training approach. Key technical components include:

  • Bi-directional Self-Attention: Unlike standard Transformers that may only look at previous tokens, BTC uses bi-directional masking. This allows the model to incorporate both "past" and "future" audio context to determine the chord at any given timestamp.
  • Position-wise Convolutional Blocks: Standard feed-forward networks are replaced with 1D convolutional layers. This helps the model "smooth" the chord sequence by exploring adjacent information in the time domain.
  • CQT Input: The model processes Constant-Q Transform (CQT) features, a standard audio representation that aligns frequencies with musical octaves.
The BTC architecture (a) and the internal bi-directional self-attention layer (b).

Experimental Setup

The model was evaluated using standard MIR datasets: Isophonics (221 songs), Robbie Williams (65 songs), and UsPop2002 (185 songs). The researchers manually aligned labels to audio files to ensure high data quality and used pitch augmentation (shifting audio by -5 to +6 semitones) to increase training diversity.

Analysis and Insights

A core contribution of the BTC model is its ability to utilize adaptive receptive fields through the self-attention mechanism. Visualization of attention maps reveals how the model processes information:

  • Implicit Segmentation: The model effectively learns to "segment" the music. Attention maps show rectangular regions of high probability, indicating the model has identified the boundaries where one chord starts and another ends.
  • Long-term Dependencies: In the final layers, the model focuses only on the most essential frames for a specific chord, regardless of their temporal distance, effectively capturing global musical structure.
Attention map analysis showing how the model focuses on specific chord segments and captures long-term dependencies.

Results

The authors compared BTC against several baselines using Weighted Chord Symbol Recall (WCSR):

  • Performance: BTC achieved a WCSR of 83.8% on the "maj-min" label type, nearly identical to the state-of-the-art CNN+CRF (84.0%).
  • Large Vocabulary: On a complex 170-chord vocabulary, BTC outperformed the CNN+CRF in specific categories like "Sevenths" (71.8% vs 71.3%).
  • Efficiency: BTC requires only a single training phase, whereas the CNN+CRF requires training the CNN first and then a separate CRF decoder.

Conclusion

BTC demonstrates that a self-attention mechanism is powerful enough to learn the "grammar" of chord progressions without complex multi-stage decoding. While the model still faces challenges with harmonic overlap (e.g., confusing A Major with F# minor), it represents a significant step forward in applying Transformer architectures to audio sequence tasks. Future work will explore integrating more complex musical structures and larger datasets.

Summary updated

BibTeX
@inproceedings{park2019bi,
  author = {Jonggwon Park and Kyoyun Choi and Sungwook Jeon and Dokyun Kim and Jonghun Park},
  title = {{A Bi-directional Transformer for Musical Chord Recognition}},
  booktitle = {ISMIR},
  year = {2019},
  url = {https://openreview.net/forum?id=RpboAIuiUy},
}
Figure