# How I Distilled a 3M Parameter Model into a 557K Parameter Guitar Chord Recognition Model

> Source: <https://pub.towardsai.net/how-i-distilled-a-3m-parameter-model-into-a-557k-parameter-guitar-chord-recognition-model-913d4dc9c193?source=rss----98111c9905da---4>
> Published: 2026-12-06 10:45:19+00:00

**Recommendation:** When training a distilled audio model on GuitarSet, split by guitarist rather than by audio segment so the same performer never appears in both train and test.
More in the playbook "Fine-tuning and data": <https://wpnews.pro/playbooks/training-data>

As someone who enjoys playing the guitar, I wanted to explore a problem at the intersection of music and artificial intelligence.

**Can I build a lightweight AI model that listens to my guitar recordings and identifies the chords I am playing?**

While exploring Automatic Chord Recognition (ACR), I came across BTC, a pretrained Transformer-based model with approximately 3 million parameters.

Instead of simply using the existing model, I decided to investigate another question:

How much smaller could I make this model without significantly compromising its accuracy?

To explore this, I experimented with knowledge distillation, multiple neural network architectures, audio feature extraction, and eventually a Bidirectional Gated Recurrent Unit (BiGRU).

These accuracy measurements apply to compatible chord labels in the held-out test dataset, rather than every possible guitar chord.

Getting there, however, was not straightforward.

This article documents the experiment, including the initial failures, architectural decisions, training methodology, and final model publication.

Imagine playing the following chord progression on a guitar:

```
C Major → A Minor → F Major → G Major
```

As humans, we can learn to identify these chords by listening to their musical characteristics.

For a computer, however, the recording is simply a sequence of numerical values representing sound pressure over time.

The computer does not inherently understand what C Major or A Minor means.

Automatic Chord Recognition is a problem within Music Information Retrieval (MIR) that involves identifying musical chords and their approximate positions in an audio recording.

Given an audio recording, we want the model to produce something like:

*Illustrative example.*

This becomes challenging because multiple musical notes are played simultaneously, frequencies overlap, strings continue vibrating after being struck, and chords transition into one another.

Additionally, the same chord can sound different depending on the guitar, playing style, chord voicing, microphone, and recording environment.

The model must therefore learn musical patterns rather than simply memorize individual recordings.

Instead of training a chord recognition system entirely from scratch, I started with an existing pretrained model.

The model I selected was BTC — Bi-Directional Transformer for Musical Chord Recognition.

BTC uses a Transformer-based architecture to capture relationships across audio sequences and predict musical chords.

The pretrained model used in this experiment contains:

Pretrained model:

[https://huggingface.co/puar-playground/btc-chord](https://huggingface.co/puar-playground/btc-chord)

The idea was to use BTC as a teacher.

A pretrained teacher already contains useful information learned during its original training. Instead of requiring a smaller model to independently discover all these patterns, I could train it using information provided by the teacher.

This is where knowledge distillation comes into the picture.

A machine learning model requires examples from which it can learn.

For this experiment, I used GuitarSet v1.1.0, a publicly available annotated guitar recording dataset.

GuitarSet contains 360 recordings performed by six guitarists across five musical styles:

Along with audio recordings, GuitarSet provides musical annotations, including chord information.

An annotation describes which chord is associated with a particular interval in a recording.

For example:

```
Start: 0.00 secondsEnd:   7.44 secondsChord: D#:sus2(7)/1
```

These annotations act as reference labels during training and evaluation.

For the final experimental pipeline, I used a subset of 180 recordings.

Rather than randomly splitting individual audio segments, I separated the recordings based on the guitarist who performed them.

This decision was important.

If recordings from the same guitarist appeared in both training and testing, the model could potentially learn characteristics associated with that individual’s playing style.

That would make it harder to determine whether the model had actually learned generalizable chord characteristics.

By reserving an unseen guitarist for testing, I could evaluate how well the model performed beyond the performers it encountered during training.

However, evaluation on one unseen guitarist is still not sufficient to establish universal generalization.

Dataset:

A neural network cannot directly interpret sound in the same way humans do.

An audio recording can be represented as a waveform containing thousands of numerical samples per second.

Although neural networks can learn directly from waveforms, I used a frequency-based representation for this experiment.

The technique I used was the **Constant-Q Transform (CQT)**.

A musical note corresponds to a fundamental frequency along with additional frequency components known as harmonics.

Notice how the frequency doubles with each octave.

Musical pitch relationships are logarithmic rather than linearly spaced.

CQT uses logarithmically spaced frequency bins, making it particularly useful for representing musical pitches and their relationships.

For this experiment, the final model used a 144-bin log-CQT representation.

```
Guitar recording       ↓Audio loading and resampling       ↓Constant-Q Transform       ↓Log-frequency representation       ↓Feature normalization       ↓Temporal sequence preparation       ↓Neural network
```

The final audio sample rate was 22,050 Hz, and each input sequence contained 108 time frames with 144 frequency features per frame.

The model therefore received an input tensor with the following shape for a single sequence:

```
[1, 108, 144]
```

Where:

Instead of asking the model to interpret thousands of raw audio samples, I provided it with a structured representation of how frequency content evolves over time.

My initial approach was to build a relatively small convolutional neural network (CNN).

The first student architecture contained approximately 124,000 parameters.

Rather than immediately predicting 170 different chord classes, I simplified the problem by separating a chord into two components:

**Root:** The fundamental musical note associated with the chord.

```
C, C#, D, D#, E, F,F#, G, G#, A, A#, B
```

**Quality:** The type of chord.

```
MajorMinorDominant seventhMajor seventhMinor seventhPower chord
A Minor = Root: A + Quality: Minor
```

The model produced separate predictions for the root and quality.

The motivation behind this approach was to simplify the classification problem and potentially allow the model to learn shared patterns across different chords.

However, identifying the correct root and quality independently does not guarantee that the final combined prediction will be correct.

This became apparent in my subsequent experiments.

Traditional supervised learning trains a model using inputs and their corresponding reference labels.

```
Input: Guitar audio featuresReference label: C Major
```

The model learns to predict C Major when presented with similar features.

Knowledge distillation introduces an additional source of information.

Instead of learning only from the reference label, the student can also learn from the probability distribution produced by a pretrained teacher.

Consider a simplified example:

A traditional hard label only tells the model that C Major is correct.

The teacher’s probability distribution provides additional information about alternative predictions and their relative likelihood.

These probability distributions are commonly referred to as soft targets.

```
Guitar audio                      ↓                 CQT features                      ↓          ┌───────────┴───────────┐          ↓                       ↓     BTC Teacher             Student Model          ↓                       ↓   Soft probabilities     Student predictions          │                       │          └───────────┬───────────┘                      ↓              Distillation loss                      +              Supervised loss                      ↓              Update student
```

During training, the student learns from two sources:

The teacher remains fixed while the student’s parameters are updated.

The objective is not to copy the teacher’s internal architecture. It is to train a smaller architecture that reproduces useful aspects of the teacher’s predictive behaviour.

Once training is complete, the student can perform inference independently.

The initial results were promising enough to continue experimenting, but the models were not behaving as expected when I tested them with my own guitar recordings.

In one experiment, I recorded myself playing a D Major chord.

The model repeatedly predicted E7.

This was not simply a slightly incorrect chord quality. Both the predicted root and quality were incorrect.

The experiment highlighted an important distinction:

**A reasonable validation accuracy does not necessarily translate into reliable behaviour on a real-world recording.**

I subsequently experimented with another student that predicted chord classes directly instead of independently classifying roots and qualities.

This improved validation performance on supported classes, but the predictions on my own recordings were still inconsistent.

At this point, I began reconsidering the model architecture.

Music is inherently sequential.

A chord exists over a period of time, strings continue vibrating, notes appear at different moments during strumming, and transitions provide additional musical context.

I wanted the student model to explicitly learn these temporal relationships.

This led to the third iteration of the experiment.

A Gated Recurrent Unit, or GRU, is a type of recurrent neural network designed to process sequential data.

Unlike a conventional feedforward neural network, a GRU maintains a hidden state that carries information from previous time steps.

Imagine a sequence of audio frames:

```
Frame 1 → Frame 2 → Frame 3 → Frame 4 → Frame 5
```

A standard forward GRU processes these frames sequentially.

Its prediction at a particular frame can depend on information observed in preceding frames.

A Bidirectional GRU extends this idea by processing the sequence in both directions.

```
Forward:   F1 → F2 → F3 → F4 → F5
Backward:  F1 ← F2 ← F3 ← F4 ← F5
```

The resulting representations are combined, allowing the network to use information from both earlier and later frames within the available sequence.

When playing a chord, all strings may not begin vibrating at precisely the same moment.

For example, during a downward strum, the lower strings may be struck before the higher strings.

A single early audio frame might contain incomplete information about the chord.

By considering surrounding frames, a bidirectional architecture can potentially build a more informative representation.

This made a BiGRU a suitable architecture to investigate for recorded guitar audio.

The third version of the model used a two-layer Bidirectional GRU.

```
Input sequence[108 frames × 144 features]           ↓Bidirectional GRU — Layer 1           ↓Bidirectional GRU — Layer 2           ↓Classification layer           ↓170 chord classes per frame
```

The final architecture contained 557,642 parameters.

Although this was larger than my original CNN student, it remained substantially smaller than the BTC teacher.

This also changed how I approached model compression.

The objective was not simply to create the smallest possible model. It was to find a balance between model capacity and predictive performance.

The final training pipeline required three components:

The processed training dataset contained 424 sequences.

Each sequence contained 108 audio frames.

For every relevant frame, the student could learn from the corresponding reference chord and the teacher’s predictions across the 170-class vocabulary.

The final student was trained using a combination of supervised cross-entropy and Kullback–Leibler divergence.

**Total Loss = Cross-Entropy + 0.5 × KL Divergence**

These two components serve different purposes.

**Cross-entropy loss**

Measures how well the student’s predictions match the reference chord labels.

**KL divergence**

Measures the difference between the student’s predicted probability distribution and the distribution produced by the teacher.

A simplified PyTorch representation of the training objective is:

```
student_log_probs = torch.log_softmax(    student_logits, dim=-1)
supervised_loss = F.cross_entropy(    student_logits[valid_mask],    ground_truth[valid_mask])
distillation_loss = F.kl_div(    student_log_probs[valid_mask],    teacher_probs[valid_mask],    reduction="batchmean")
loss = supervised_loss + 0.5 * distillation_loss
```

This illustrative implementation assumes that the inputs are already frame-aligned and that valid_mask identifies eligible training labels.

The training objective encourages the student to learn from both reference annotations and the teacher’s predictive distribution.

I trained the final model for 10 epochs.

The best validation accuracy was:

**69.41% at epoch 8.**

The accuracy at epoch 10 was 65.99%.

Rather than automatically treating the last training epoch as the best model, I selected the checkpoint based on validation performance.

The selected checkpoint was then evaluated on the held-out test guitarist.

To make the comparison meaningful, both models were evaluated on the same held-out recordings and compatible reference frames.

The test dataset consisted of 30 recordings from guitarist 05, who was excluded from training and validation.

The student achieved approximately 96.9% of the teacher’s measured accuracy while using approximately 18.36% of its parameter count.

The difference in accuracy was around 2 percentage points.

Not every chord annotation in GuitarSet could be directly mapped to the supported chord vocabulary used during evaluation.

The final evaluation included:

This means the reported accuracy is calculated on the compatible portion of the reference labels.

It should not be interpreted as accuracy across every possible chord in GuitarSet.

An aggregate accuracy score does not reveal how consistently a model performs across different musical styles

The results revealed substantial differences.

The student performed comparably to the teacher on Singer-Songwriter recordings and exceeded its measured accuracy on Rock and Funk recordings.

However, it struggled significantly with Jazz and Bossa Nova.

Jazz frequently involves complex chord extensions, altered chords, and more varied harmonic progressions. These characteristics could contribute to the difficulty, although this experiment did not independently isolate their effect.

This is why reporting per-style performance is important.

The relatively small overall accuracy gap masks a considerably larger performance gap in certain musical styles.

The original motivation behind this experiment was to build a model that could recognize chords from my own guitar playing.

After training the final model, I tested it using personal microphone recordings.

One recording was approximately 18.6 seconds long.

The model produced timestamped predictions such as:

```
0.00s – 1.00s : F1.00s – 2.00s : E:min2.00s – 3.00s : E3.00s – 4.00s : C4.00s – 5.00s : C5.00s – 6.00s : A:min
```

Compared with the earlier iterations, the final model produced a more coherent sequence of chord predictions in my qualitative tests.

However, some predictions still varied between adjacent time intervals.

These recordings were useful for observing practical model behaviour, but they were not independently annotated and evaluated as a formal accuracy benchmark.

Consequently, I treat these results as qualitative observations rather than evidence of measured real-world accuracy.

The model is publicly available on Hugging Face:

[https://huggingface.co/minhack/guitar-chord-v3-distilled](https://huggingface.co/minhack/guitar-chord-v3-distilled)

Clone the repository:

```
git clone https://huggingface.co/minhack/guitar-chord-v3-distilled
cd guitar-chord-v3-distilled
```

Install the dependencies:

```
pip install -r requirements.txt
```

Run inference on a guitar recording:

```
python predict.py recording.wav
```

The inference script produces timestamped chord predictions and a simplified chord progression.

The pretrained BTC teacher is not required at inference time.

Although the experiment demonstrated that a substantially smaller model could retain much of the teacher’s aggregate accuracy, several limitations remain.

The model was trained using recordings from four guitarists and evaluated on one unseen test guitarist.

A broader dataset would be necessary to establish generalization across different performers, guitars, tunings, and recording environments.

The student performed poorly on Jazz recordings.

Improving its ability to distinguish complex chord structures remains an important area for future experimentation.

The model predicts from a fixed vocabulary of 170 classes.

The reported evaluation covered only compatible reference labels, and no-chord predictions have not been separately validated.

The BiGRU uses information from both earlier and later frames.

This is suitable for processing recorded audio, but a real-time streaming implementation would need to account for the additional context required by the backward recurrent network.

Reducing the parameter count from approximately 3 million to 557,000 does not automatically establish a 5.45× inference speedup.

The original teacher and the student use different neural network architectures.

Actual inference performance depends on factors such as hardware, sequence length, feature extraction costs, memory access patterns, and runtime optimization.

A separate latency, throughput, and memory benchmark would be required to quantify these benefits.

What started as an experiment inspired by my interest in playing the guitar became an exploration of audio machine learning, temporal neural networks, and knowledge distillation.

I started with a small convolutional neural network, experimented with different chord prediction strategies, encountered unreliable predictions on personal recordings, and eventually moved to a Bidirectional GRU architecture.

The final model achieved:

These results were measured on compatible reference chords from a held-out guitarist, and significant performance limitations remain in certain musical styles.

One of the most important lessons from this experiment was that model compression is not simply about reducing the number of parameters.

It is also about understanding which architectural properties matter for the problem being solved.

In this case, explicitly modelling the temporal characteristics of guitar audio provided a promising direction.

The next question I would like to investigate is:

**Can this distilled model deliver measurable inference benefits on resource-constrained devices while maintaining acceptable chord recognition accuracy?**

That would take the experiment beyond parameter compression towards practical inference optimization.

[How I Distilled a 3M Parameter Model into a 557K Parameter Guitar Chord Recognition Model](https://pub.towardsai.net/how-i-distilled-a-3m-parameter-model-into-a-557k-parameter-guitar-chord-recognition-model-913d4dc9c193) was originally published in [Towards AI](https://pub.towardsai.net) on Medium, where people are continuing the conversation by highlighting and responding to this story.
