$ cat lyrics-albert/README.md
M.S. AI coursework · University of Michigan-Dearborn · Jan 2025 – Mar 2025 · Dearborn, MI

Lyrics artist classification with ALBERT

A hobby and learning project: a clean, reproducible baseline that predicts a song's artist from its lyrics. It is not meant to compete with the best published results. About 1,290 songs across 13 artists, roughly 100 per artist, scraped with the Genius API.

Role
Solo project: data collection, training and evaluation
Data
~1,290 songs · ~100 per artist · 13 artists · Genius API
Stack
albert-base-v2 · Hugging Face Transformers · Python · Genius API · Ollama · Gemma 4B
Problem

Song lyrics are longer than the model's input window

ALBERT-v2 has a 512-token input limit. Most songs exceed it, so lyrics have to be split into chunks. The naive approach creates a bias: long songs contribute many more training examples than short ones, so the model over-learns long songs. The setup below corrects for that.

Data

Cleaned section headers ([Chorus], [Verse]), uploader tags and whitespace from raw API responses.

Stored one song per JSON row: text and label fields.

Stratified 80/10/10 train/validation/test split (roughly 9 songs per artist per split).

Setup
01Collected ~1,290 songs across 13 artists using the Genius API.
02Backbone albert-base-v2 (SentencePiece tokenizer). Split lyrics into overlapping chunks: max_length=256, stride=192.
03Chunks capped at 4 per song so long songs can't flood training.
04Training fix: each chunk is weighted by 1 / (number of chunks in its song), so every song contributes equally regardless of length.
05Evaluation fix: logits are averaged across all chunks of a song, giving one prediction per song instead of per chunk.
06Model selected on validation macro-F1.
07Also tried gentle class-weighted cross-entropy (weights normalized to mean 1). It lifted the weaker classes slightly without destabilizing training. No separate numbers are reported for it.
08Explored, not evaluated: used Gemma 4B through Ollama to generate artist-conditioned lyrics from a prompt, then classified them with the ALBERT model. Results depend heavily on prompt quality and are not reported.
Results
SplitAccuracyPrecision (W)Recall (W)F1 (W)Macro-F1CE loss
Validation0.5470.5750.5470.5470.547—
Test0.6350.6370.6350.6330.5901.087

With 13 classes, a random guess has a loss of about log(13) ≈ 2.57; the test loss of 1.09 means the model gives the true artist about 34% probability on average.

Strongest artists on validation: Hozier, Eminem, Drake. Weakest: The Weeknd, Post Malone, SZA.

Limitations
  • Small dataset: 1,290 songs across 13 artists; results are a proof-of-concept baseline rather than production-ready.
  • Songs longer than 256 tokens are split into chunks; content beyond 4 chunks per song is not seen by the model. Sliding-window support is already in place for future experiments.
  • Contemporary pop and R&B artists share vocabulary; some overlap between them is expected, and the confusion matrix shows where this occurs.
  • Softmax scores from logit averaging are useful for ranking artists but are not calibrated probability estimates.
Skills demonstrated
albert-base-v2fine-tuningsliding-window tokenizationchunk weightinglogit averagingHugging Face TransformersGenius APIOllamaGemma 4Bevaluation design