Can LLMs understand LilyPond?

A benchmark for symbolic music generation and understanding

1 Centro di Sonologia Computazionale, University of Padova  ·  2 Music Technology Group, Universitat Pompeu Fabra

Accepted at Ital-IA 2026 — 6th National Conference on Artificial Intelligence (CINI), Rome

📄 Paper (arXiv) 💻 Code 🗂️ Dataset 🧠 LilyBERT

Abstract

Symbolic music evaluation for large language models remains fragmented across representations, datasets, and metrics. We introduce LilyBench, a LilyPond-based benchmark that jointly evaluates symbolic music generation and music understanding on the same family of open-weight LLMs. The benchmark includes a 200-prompt generation suite and ten understanding tasks adapted from ABC-Eval, covering syntax, metadata prediction, structural sequencing, and music recognition. Generation quality is measured with compile rate, MusPy descriptor distributions via Jensen–Shannon similarity, and a LilyBERT-based Fréchet Music Distance (FMD). Experiments on four open-weight models show that executable LilyPond generation is achievable zero-shot, while structural understanding tasks remain hard despite strong composer and genre recognition. The descriptor- and embedding-based metrics systematically disagree, suggesting that symbolic music evaluation benefits from metric triangulation rather than single-score ranking.

Two benchmarks, one family of models

🎹 Generation

A fixed bank of 200 metadata-conditioned prompts (composer, period, form, ensemble, part). Outputs are scored by compile rate, JS similarity over three MusPy descriptors, and a LilyBERT-FMD against in-domain (BMdataset) and out-of-domain (Mutopia) references.

🔎 Understanding

Ten ABC-Eval-adapted tasks over raw LilyPond text, grouped by reasoning depth: counting, metadata QA, bar sequencing, next-bar prediction, captioning, composer / genre / emotion recognition, and error detection. Greedy decoding, no chain-of-thought.

CategoryTasknSourceFormatMetric
Basicbar_count100Mutopiaintegerexact-match acc.
metadata_qa60Mutopia4-way MCaccuracy
Segmentbar_sequencing119Mutopia4-digit perm.Kendall-τ (pen.)
next_bar_prediction119Mutopia4-way MCaccuracy
metadata_prediction60Mutopia4-way MCaccuracy
Sequencemusic_captioning60Mutopia4-way MCaccuracy
composer_recognition96Mutopia4-way MCaccuracy
genre_recognition132Mutopia4-way MCaccuracy
emotion_recognition120EMOPIA4-way MCaccuracy
error_detection220Mutopia†bar listmacro-F1

† Mutopia scores with five categories of synthetic corruption. The four backbones evaluated are Phi-4, Qwen2.5-Coder-14B, DeepSeek-Coder-V2-Lite and Codestral-22B.

Generation, heard

Each backbone receives the same metadata-conditioned prompt and must emit LilyPond. Below are the raw zero-shot outputs — engraved and sonified straight from the models, nothing cherry-picked bar-by-bar. Quality varies sharply: some models write idiomatic Baroque lines, others drift into ascending scale-runs (a real failure mode the compile/FMD metrics capture).

Generation results

Understanding, probed

Real benchmark questions with each model's greedy answer. Recognition is strong (composer, genre, title); one-shot structural reasoning — counting bars, locating a corrupted bar, placing emotion on the valence axis — collapses.

Understanding results

Citation

@inproceedings{spanio2026lilybench,
  title     = {Can LLMs understand LilyPond? A benchmark for symbolic
               music generation and understanding},
  author    = {Spanio, Matteo and Torabi, Mohammad and
               Poltronieri, Andrea and Rod{\`a}, Antonio},
  booktitle = {Proceedings of the 6th National Conference on Artificial
               Intelligence (Ital-IA 2026)},
  year      = {2026},
  address   = {Rome, Italy},
  publisher = {CEUR-WS},
  eprint    = {2606.08722},
  archivePrefix = {arXiv},
}