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

Source: [Aligning Language Models for Lyric-to-Melody Generation with Rule-Based Musical Constraints](<https://www.sota2.com/research/paper/69e7052e7d0172140ec7f366>)

Collection index: [llms.txt](<https://www.sota2.com/research/llms.txt>)

Data updated: 2026-04-22T05:23:53.567Z

Authors: Hao Meng, Siyuan Zheng, Shuran Zhou, Qiangqiang Wang, Yang Song

Published: 2026-04-20T16:40:45.000Z

## 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.

## Recorded benchmark results

A research result applies to its stated dataset, split, metric and evaluation configuration. Compare like-for-like settings, preserve the metric's unit and direction, and distinguish paper-reported results from independent reproduction. The best result recorded here is not a claim of exhaustive, current global coverage.

- [Lyric-to-Melody generation on GTSinger (test)](<https://www.sota2.com/research/sota/lyric-to-melody-generation-on-gtsinger-test.md>): Lyric-to-Melody generation; GTSinger (test); MOS: 3.42.

- [Lyric-to-Melody generation on GTSinger English (test)](<https://www.sota2.com/research/sota/lyric-to-melody-generation-on-gtsinger-english-test.md>): Lyric-to-Melody generation; GTSinger English (test); Pitch Deviation (PD): 32.37.

## Original sources and implementation

[Original paper](<https://arxiv.org/abs/2604.18489>)

[PDF](<https://arxiv.org/pdf/2604.18489.pdf>)
