MusicLoRA

Fine-tuning an LLM to write song lyrics with a lyricist's range.

Role
Creator
Areas
AI, Research

Ask a general-purpose LLM for song lyrics and you tend to get the same handful of rhymes and images, common words overused and the expressive vocabulary of real songwriting underused. MusicLoRA is our effort to fix that with a targeted fine-tune instead of more prompting.

Building the training pairs

The interesting part is the data pipeline, which turns finished lyrics into prompt and response pairs:

  1. Section splitting. Lyrics are split into their labeled sections, such as verses and choruses.
  2. Phrase segmentation. An LLM breaks each section into meaningful phrases of at least two lines and returns them as strict JSON. Robust extraction pulls the JSON out of the reply, and if it's invalid the prompt is reissued at a new random temperature, up to three attempts in all, before that section is skipped.
  3. Prompt reconstruction. For each phrase, the model writes five candidate prompts that could have led to it. A second pass, optionally using a different model for a different perspective, picks the best one.
Loop diagram: prompt the model at a random temperature between 0.5 and 0.9, extract JSON from the reply with a regular expression, parse it, and on failure try again, giving up after three attempts.
We retry at a fresh random temperature instead of resending the same request, which shakes loose a parseable answer.

The result is a set of pairs that capture the creative intent behind each phrase, which is what a model needs to learn to write like a lyricist instead of reciting lyrics.

Flow diagram of six steps: lyrics read from a CSV, split into labeled sections, segmented by an LLM into phrases of two or more lines, five candidate prompts generated per phrase, the best one picked by the same or an alternate model, and the phrase and prompt saved as a training pair.
We reverse-engineer a plausible prompt for every phrase, so the fine-tune learns intent rather than recitation.

Training

Those pairs fine-tune a pretrained LLM with LoRA, which adjusts only small low-rank weight matrices, keeping training cheap while preserving the base model's knowledge. Model paths are configurable, so base models can be swapped and a separate model can handle candidate selection.