{"slug": "how-i-distilled-a-3m-parameter-model-into-a-557k-parameter-guitar-chord-model", "title": "How I Distilled a 3M Parameter Model into a 557K Parameter Guitar Chord Recognition Model", "summary": "A developer distilled the pretrained BTC (Bi-Directional Transformer for Musical Chord Recognition) model, which has roughly 3 million parameters, into a 557K-parameter BiGRU guitar chord recognition model, training and evaluating it on a 180-recording subset of the GuitarSet v1.1.0 dataset (360 recordings by six guitarists across five styles). The experiment used knowledge distillation with BTC as the teacher and split recordings by guitarist rather than by audio segment to avoid leakage, with accuracy figures applying only to compatible chord labels in the held-out test set.", "body_md": "As someone who enjoys playing the guitar, I wanted to explore a problem at the intersection of music and artificial intelligence.\n\n**Can I build a lightweight AI model that listens to my guitar recordings and identifies the chords I am playing?**\n\nWhile exploring Automatic Chord Recognition (ACR), I came across BTC, a pretrained Transformer-based model with approximately 3 million parameters.\n\nInstead of simply using the existing model, I decided to investigate another question:\n\nHow much smaller could I make this model without significantly compromising its accuracy?\n\nTo explore this, I experimented with knowledge distillation, multiple neural network architectures, audio feature extraction, and eventually a Bidirectional Gated Recurrent Unit (BiGRU).\n\nThese accuracy measurements apply to compatible chord labels in the held-out test dataset, rather than every possible guitar chord.\n\nGetting there, however, was not straightforward.\n\nThis article documents the experiment, including the initial failures, architectural decisions, training methodology, and final model publication.\n\nImagine playing the following chord progression on a guitar:\n\n```\nC Major → A Minor → F Major → G Major\n```\n\nAs humans, we can learn to identify these chords by listening to their musical characteristics.\n\nFor a computer, however, the recording is simply a sequence of numerical values representing sound pressure over time.\n\nThe computer does not inherently understand what C Major or A Minor means.\n\nAutomatic Chord Recognition is a problem within Music Information Retrieval (MIR) that involves identifying musical chords and their approximate positions in an audio recording.\n\nGiven an audio recording, we want the model to produce something like:\n\n*Illustrative example.*\n\nThis becomes challenging because multiple musical notes are played simultaneously, frequencies overlap, strings continue vibrating after being struck, and chords transition into one another.\n\nAdditionally, the same chord can sound different depending on the guitar, playing style, chord voicing, microphone, and recording environment.\n\nThe model must therefore learn musical patterns rather than simply memorize individual recordings.\n\nInstead of training a chord recognition system entirely from scratch, I started with an existing pretrained model.\n\nThe model I selected was BTC — Bi-Directional Transformer for Musical Chord Recognition.\n\nBTC uses a Transformer-based architecture to capture relationships across audio sequences and predict musical chords.\n\nThe pretrained model used in this experiment contains:\n\nPretrained model:\n\n[https://huggingface.co/puar-playground/btc-chord](https://huggingface.co/puar-playground/btc-chord)\n\nThe idea was to use BTC as a teacher.\n\nA 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.\n\nThis is where knowledge distillation comes into the picture.\n\nA machine learning model requires examples from which it can learn.\n\nFor this experiment, I used GuitarSet v1.1.0, a publicly available annotated guitar recording dataset.\n\nGuitarSet contains 360 recordings performed by six guitarists across five musical styles:\n\nAlong with audio recordings, GuitarSet provides musical annotations, including chord information.\n\nAn annotation describes which chord is associated with a particular interval in a recording.\n\nFor example:\n\n```\nStart: 0.00 secondsEnd:   7.44 secondsChord: D#:sus2(7)/1\n```\n\nThese annotations act as reference labels during training and evaluation.\n\nFor the final experimental pipeline, I used a subset of 180 recordings.\n\nRather than randomly splitting individual audio segments, I separated the recordings based on the guitarist who performed them.\n\nThis decision was important.\n\nIf recordings from the same guitarist appeared in both training and testing, the model could potentially learn characteristics associated with that individual’s playing style.\n\nThat would make it harder to determine whether the model had actually learned generalizable chord characteristics.\n\nBy reserving an unseen guitarist for testing, I could evaluate how well the model performed beyond the performers it encountered during training.\n\nHowever, evaluation on one unseen guitarist is still not sufficient to establish universal generalization.\n\nDataset:\n\nA neural network cannot directly interpret sound in the same way humans do.\n\nAn audio recording can be represented as a waveform containing thousands of numerical samples per second.\n\nAlthough neural networks can learn directly from waveforms, I used a frequency-based representation for this experiment.\n\nThe technique I used was the **Constant-Q Transform (CQT)**.\n\nA musical note corresponds to a fundamental frequency along with additional frequency components known as harmonics.\n\nNotice how the frequency doubles with each octave.\n\nMusical pitch relationships are logarithmic rather than linearly spaced.\n\nCQT uses logarithmically spaced frequency bins, making it particularly useful for representing musical pitches and their relationships.\n\nFor this experiment, the final model used a 144-bin log-CQT representation.\n\n```\nGuitar recording       ↓Audio loading and resampling       ↓Constant-Q Transform       ↓Log-frequency representation       ↓Feature normalization       ↓Temporal sequence preparation       ↓Neural network\n```\n\nThe final audio sample rate was 22,050 Hz, and each input sequence contained 108 time frames with 144 frequency features per frame.\n\nThe model therefore received an input tensor with the following shape for a single sequence:\n\n```\n[1, 108, 144]\n```\n\nWhere:\n\nInstead 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.\n\nMy initial approach was to build a relatively small convolutional neural network (CNN).\n\nThe first student architecture contained approximately 124,000 parameters.\n\nRather than immediately predicting 170 different chord classes, I simplified the problem by separating a chord into two components:\n\n**Root:** The fundamental musical note associated with the chord.\n\n```\nC, C#, D, D#, E, F,F#, G, G#, A, A#, B\n```\n\n**Quality:** The type of chord.\n\n```\nMajorMinorDominant seventhMajor seventhMinor seventhPower chord\nA Minor = Root: A + Quality: Minor\n```\n\nThe model produced separate predictions for the root and quality.\n\nThe motivation behind this approach was to simplify the classification problem and potentially allow the model to learn shared patterns across different chords.\n\nHowever, identifying the correct root and quality independently does not guarantee that the final combined prediction will be correct.\n\nThis became apparent in my subsequent experiments.\n\nTraditional supervised learning trains a model using inputs and their corresponding reference labels.\n\n```\nInput: Guitar audio featuresReference label: C Major\n```\n\nThe model learns to predict C Major when presented with similar features.\n\nKnowledge distillation introduces an additional source of information.\n\nInstead of learning only from the reference label, the student can also learn from the probability distribution produced by a pretrained teacher.\n\nConsider a simplified example:\n\nA traditional hard label only tells the model that C Major is correct.\n\nThe teacher’s probability distribution provides additional information about alternative predictions and their relative likelihood.\n\nThese probability distributions are commonly referred to as soft targets.\n\n```\nGuitar audio                      ↓                 CQT features                      ↓          ┌───────────┴───────────┐          ↓                       ↓     BTC Teacher             Student Model          ↓                       ↓   Soft probabilities     Student predictions          │                       │          └───────────┬───────────┘                      ↓              Distillation loss                      +              Supervised loss                      ↓              Update student\n```\n\nDuring training, the student learns from two sources:\n\nThe teacher remains fixed while the student’s parameters are updated.\n\nThe 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.\n\nOnce training is complete, the student can perform inference independently.\n\nThe 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.\n\nIn one experiment, I recorded myself playing a D Major chord.\n\nThe model repeatedly predicted E7.\n\nThis was not simply a slightly incorrect chord quality. Both the predicted root and quality were incorrect.\n\nThe experiment highlighted an important distinction:\n\n**A reasonable validation accuracy does not necessarily translate into reliable behaviour on a real-world recording.**\n\nI subsequently experimented with another student that predicted chord classes directly instead of independently classifying roots and qualities.\n\nThis improved validation performance on supported classes, but the predictions on my own recordings were still inconsistent.\n\nAt this point, I began reconsidering the model architecture.\n\nMusic is inherently sequential.\n\nA chord exists over a period of time, strings continue vibrating, notes appear at different moments during strumming, and transitions provide additional musical context.\n\nI wanted the student model to explicitly learn these temporal relationships.\n\nThis led to the third iteration of the experiment.\n\nA Gated Recurrent Unit, or GRU, is a type of recurrent neural network designed to process sequential data.\n\nUnlike a conventional feedforward neural network, a GRU maintains a hidden state that carries information from previous time steps.\n\nImagine a sequence of audio frames:\n\n```\nFrame 1 → Frame 2 → Frame 3 → Frame 4 → Frame 5\n```\n\nA standard forward GRU processes these frames sequentially.\n\nIts prediction at a particular frame can depend on information observed in preceding frames.\n\nA Bidirectional GRU extends this idea by processing the sequence in both directions.\n\n```\nForward:   F1 → F2 → F3 → F4 → F5\nBackward:  F1 ← F2 ← F3 ← F4 ← F5\n```\n\nThe resulting representations are combined, allowing the network to use information from both earlier and later frames within the available sequence.\n\nWhen playing a chord, all strings may not begin vibrating at precisely the same moment.\n\nFor example, during a downward strum, the lower strings may be struck before the higher strings.\n\nA single early audio frame might contain incomplete information about the chord.\n\nBy considering surrounding frames, a bidirectional architecture can potentially build a more informative representation.\n\nThis made a BiGRU a suitable architecture to investigate for recorded guitar audio.\n\nThe third version of the model used a two-layer Bidirectional GRU.\n\n```\nInput sequence[108 frames × 144 features]           ↓Bidirectional GRU — Layer 1           ↓Bidirectional GRU — Layer 2           ↓Classification layer           ↓170 chord classes per frame\n```\n\nThe final architecture contained 557,642 parameters.\n\nAlthough this was larger than my original CNN student, it remained substantially smaller than the BTC teacher.\n\nThis also changed how I approached model compression.\n\nThe objective was not simply to create the smallest possible model. It was to find a balance between model capacity and predictive performance.\n\nThe final training pipeline required three components:\n\nThe processed training dataset contained 424 sequences.\n\nEach sequence contained 108 audio frames.\n\nFor every relevant frame, the student could learn from the corresponding reference chord and the teacher’s predictions across the 170-class vocabulary.\n\nThe final student was trained using a combination of supervised cross-entropy and Kullback–Leibler divergence.\n\n**Total Loss = Cross-Entropy + 0.5 × KL Divergence**\n\nThese two components serve different purposes.\n\n**Cross-entropy loss**\n\nMeasures how well the student’s predictions match the reference chord labels.\n\n**KL divergence**\n\nMeasures the difference between the student’s predicted probability distribution and the distribution produced by the teacher.\n\nA simplified PyTorch representation of the training objective is:\n\n```\nstudent_log_probs = torch.log_softmax(    student_logits, dim=-1)\nsupervised_loss = F.cross_entropy(    student_logits[valid_mask],    ground_truth[valid_mask])\ndistillation_loss = F.kl_div(    student_log_probs[valid_mask],    teacher_probs[valid_mask],    reduction=\"batchmean\")\nloss = supervised_loss + 0.5 * distillation_loss\n```\n\nThis illustrative implementation assumes that the inputs are already frame-aligned and that valid_mask identifies eligible training labels.\n\nThe training objective encourages the student to learn from both reference annotations and the teacher’s predictive distribution.\n\nI trained the final model for 10 epochs.\n\nThe best validation accuracy was:\n\n**69.41% at epoch 8.**\n\nThe accuracy at epoch 10 was 65.99%.\n\nRather than automatically treating the last training epoch as the best model, I selected the checkpoint based on validation performance.\n\nThe selected checkpoint was then evaluated on the held-out test guitarist.\n\nTo make the comparison meaningful, both models were evaluated on the same held-out recordings and compatible reference frames.\n\nThe test dataset consisted of 30 recordings from guitarist 05, who was excluded from training and validation.\n\nThe student achieved approximately 96.9% of the teacher’s measured accuracy while using approximately 18.36% of its parameter count.\n\nThe difference in accuracy was around 2 percentage points.\n\nNot every chord annotation in GuitarSet could be directly mapped to the supported chord vocabulary used during evaluation.\n\nThe final evaluation included:\n\nThis means the reported accuracy is calculated on the compatible portion of the reference labels.\n\nIt should not be interpreted as accuracy across every possible chord in GuitarSet.\n\nAn aggregate accuracy score does not reveal how consistently a model performs across different musical styles\n\nThe results revealed substantial differences.\n\nThe student performed comparably to the teacher on Singer-Songwriter recordings and exceeded its measured accuracy on Rock and Funk recordings.\n\nHowever, it struggled significantly with Jazz and Bossa Nova.\n\nJazz 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.\n\nThis is why reporting per-style performance is important.\n\nThe relatively small overall accuracy gap masks a considerably larger performance gap in certain musical styles.\n\nThe original motivation behind this experiment was to build a model that could recognize chords from my own guitar playing.\n\nAfter training the final model, I tested it using personal microphone recordings.\n\nOne recording was approximately 18.6 seconds long.\n\nThe model produced timestamped predictions such as:\n\n```\n0.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\n```\n\nCompared with the earlier iterations, the final model produced a more coherent sequence of chord predictions in my qualitative tests.\n\nHowever, some predictions still varied between adjacent time intervals.\n\nThese recordings were useful for observing practical model behaviour, but they were not independently annotated and evaluated as a formal accuracy benchmark.\n\nConsequently, I treat these results as qualitative observations rather than evidence of measured real-world accuracy.\n\nThe model is publicly available on Hugging Face:\n\n[https://huggingface.co/minhack/guitar-chord-v3-distilled](https://huggingface.co/minhack/guitar-chord-v3-distilled)\n\nClone the repository:\n\n```\ngit clone https://huggingface.co/minhack/guitar-chord-v3-distilled\ncd guitar-chord-v3-distilled\n```\n\nInstall the dependencies:\n\n```\npip install -r requirements.txt\n```\n\nRun inference on a guitar recording:\n\n```\npython predict.py recording.wav\n```\n\nThe inference script produces timestamped chord predictions and a simplified chord progression.\n\nThe pretrained BTC teacher is not required at inference time.\n\nAlthough the experiment demonstrated that a substantially smaller model could retain much of the teacher’s aggregate accuracy, several limitations remain.\n\nThe model was trained using recordings from four guitarists and evaluated on one unseen test guitarist.\n\nA broader dataset would be necessary to establish generalization across different performers, guitars, tunings, and recording environments.\n\nThe student performed poorly on Jazz recordings.\n\nImproving its ability to distinguish complex chord structures remains an important area for future experimentation.\n\nThe model predicts from a fixed vocabulary of 170 classes.\n\nThe reported evaluation covered only compatible reference labels, and no-chord predictions have not been separately validated.\n\nThe BiGRU uses information from both earlier and later frames.\n\nThis 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.\n\nReducing the parameter count from approximately 3 million to 557,000 does not automatically establish a 5.45× inference speedup.\n\nThe original teacher and the student use different neural network architectures.\n\nActual inference performance depends on factors such as hardware, sequence length, feature extraction costs, memory access patterns, and runtime optimization.\n\nA separate latency, throughput, and memory benchmark would be required to quantify these benefits.\n\nWhat 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.\n\nI 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.\n\nThe final model achieved:\n\nThese results were measured on compatible reference chords from a held-out guitarist, and significant performance limitations remain in certain musical styles.\n\nOne of the most important lessons from this experiment was that model compression is not simply about reducing the number of parameters.\n\nIt is also about understanding which architectural properties matter for the problem being solved.\n\nIn this case, explicitly modelling the temporal characteristics of guitar audio provided a promising direction.\n\nThe next question I would like to investigate is:\n\n**Can this distilled model deliver measurable inference benefits on resource-constrained devices while maintaining acceptable chord recognition accuracy?**\n\nThat would take the experiment beyond parameter compression towards practical inference optimization.\n\n[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.", "url": "https://wpnews.pro/news/how-i-distilled-a-3m-parameter-model-into-a-557k-parameter-guitar-chord-model", "canonical_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_at": "2026-12-06 10:45:19+00:00", "updated_at": "2026-12-06 11:14:10.291529+00:00", "lang": "en", "topics": ["machine-learning", "artificial-intelligence", "neural-networks"], "entities": ["BTC", "GuitarSet v1.1.0", "BiGRU", "Hugging Face"], "also_reported_by": [], "takeaway": "Knowledge distillation from the ~3M-parameter BTC teacher into a 557K-parameter BiGRU produced a guitar chord recognition model, and splitting GuitarSet by guitarist rather than by audio segment prevents same-performer leakage between train and test.", "recommendation": {"advice": "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.", "playbook": "training-data", "playbook_url": "https://wpnews.pro/playbooks/training-data"}, "alternates": {"html": "https://wpnews.pro/news/how-i-distilled-a-3m-parameter-model-into-a-557k-parameter-guitar-chord-model", "markdown": "https://wpnews.pro/news/how-i-distilled-a-3m-parameter-model-into-a-557k-parameter-guitar-chord-model.md", "text": "https://wpnews.pro/news/how-i-distilled-a-3m-parameter-model-into-a-557k-parameter-guitar-chord-model.txt", "jsonld": "https://wpnews.pro/news/how-i-distilled-a-3m-parameter-model-into-a-557k-parameter-guitar-chord-model.jsonld"}}