Aligning Language Models for Lyric-to-Melody Generation with Rule-Based Musical Constraints

Hao Meng, Siyuan Zheng, Shuran Zhou, Qiangqiang Wang, Yang Song
4/20/2026
cs.SDcs.CLeess.AS

No confident code implementation found for this paper. 1 possible match can be shown below.

Abstract

Large Language Models (LLMs) show promise in lyric-to-melody generation, but models trained with Supervised Fine-Tuning (SFT) often produce musically implausible melodies with issues like poor rhythm and unsuitable vocal ranges, a phenomenon we term "constraint violation". To address this, we propose a novel alignment framework that instills musical knowledge without human annotation. We define rule-based musical constraints to automatically generate a preference dataset from an SFT model's outputs. The model is then aligned through a sequential process, first using Direct Preference Optimization (DPO) on paired preference data, followed by Kahneman-Tversky Optimization (KTO) on unpaired negative samples. Experimental results demonstrate that our aligned model substantially reduces rule violations and outperforms strong baselines in both objective and subjective evaluations, generating melodies with substantially improved musicality and coherence. An interactive demo with audio comparisons is available at https://arain233.github.io/AligningMelody-demo.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 1 weaker match is hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{meng2026aligning,
  title  = {Aligning Language Models for Lyric-to-Melody Generation with Rule-Based Musical Constraints},
  author = {Hao Meng and Siyuan Zheng and Shuran Zhou and Qiangqiang Wang and Yang Song},
  year   = {2026},
  eprint = {2604.18489},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2604.18489v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2604.18489.svg)](https://codeofpaper.com/paper/2604.18489)

Discussion