File size: 7,250 Bytes
d187a7f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | ---
pretty_name: code2music
language:
- en
license: other
license_name: agpl-3.0-or-later-with-third-party-licenses
license_link: LICENSE
task_categories:
- text-generation
size_categories:
- 1K<n<10K
tags:
- music
- strudel
- javascript
- synthetic
- supervised-fine-tuning
- reinforcement-learning
- grpo
configs:
- config_name: sft
default: true
data_files:
- split: train
path: sft/train.jsonl
- split: val
path: sft/val.jsonl
- split: benchmark
path: sft/benchmark.jsonl
- config_name: rl
data_files:
- split: train
path: rl/train.jsonl
- split: val
path: rl/val.jsonl
- split: benchmark
path: rl/benchmark.jsonl
---
# code2music
**code2music pairs music descriptions with executable Strudel programs and provides separate prompts for reinforcement learning.** It was built for TuneLM, a language model that writes musical code. Strudel runs the generated JavaScript to produce audio, which lets users inspect, edit, and play individual musical parts.
[Try TuneLM](https://www.tensorwrites.com/tunelm) · [Source code](https://github.com/shanmukh05/TuneLM) · [TuneLM checkpoint](https://huggingface.co/tensorfiend/TuneLM-LFM3-1.7B-code2music-2011)
## Dataset structure
| Configuration | `train` | `val` | `benchmark` |
| --- | ---: | ---: | ---: |
| `sft` | 2,526 | 250 | 150 |
| `rl` | 1,764 | 148 | 134 |
The SFT training and validation splits contain a listener request, teacher-written composition notes, and verified Strudel code. The SFT benchmark contains prompts for generation and evaluation. Every RL split contains prompts and machine-checkable request contracts. The benchmark and RL records have no reference completion.
```python
from datasets import load_dataset
sft = load_dataset("tensorfiend/code2music", "sft")
rl = load_dataset("tensorfiend/code2music", "rl")
example = sft["train"][0]
print(example["prompt"])
print(example["summary"])
print(example["code"])
request = rl["benchmark"][0]
print(request["prompt"])
print(request["contract"])
```
Each configuration has exactly three JSONL files, directly under `sft/` or `rl/`. The `val` and `benchmark` split names are preserved in the Hub configuration.
## How the data was created
The initial SFT set contains 2,016 training examples and 200 validation examples. Independently authored listener requests were answered by Gemini teachers. The saved training answers include Gemini 4 Argon, Gemini 4 Carbon, and Gemini 3.8 Flash. The initial benchmark contains 100 separate prompts.
An additional SFT set uses human-written captions from the Song Describer Dataset. The imported source has 1,106 captions for 706 recordings. Gemini 4 Argon, Carbon, and Hydrogen generated new Strudel answers. This release includes 510 accepted training examples and 50 validation examples from that stream. Its 50 benchmark prompts also come from Song Describer and have no reference completion. The release merges these records with the initial SFT set while keeping their original IDs and split assignments. See the [Song Describer release](https://zenodo.org/records/10072001) and [paper](https://arxiv.org/abs/2311.10057).
Teachers received optional reference material from a library of verified Strudel stems, along with API and sound references. The memory used 384-dimensional MiniLM embeddings and indexed training stems only. The student prompt used by TuneLM contains the listener's request and any explicitly supplied starting code. The saved `context` field is teacher reference material. See the [TuneLM pipeline](https://github.com/shanmukh05/TuneLM/blob/main/docs/usage.md).
The verifier parses and executes each candidate program, checks sound IDs, and records musical events. Failed candidates can be retried with diagnostic feedback. Passing these checks establishes execution compatibility within TuneLM's supported Strudel runtime. Musical quality still requires listening.
RL requests were authored separately from SFT requests. Their contracts record checkable preferences such as named instruments, forbidden sounds, tempo, key, part count, density, and arrangement changes. Quotes in each contract link its requirements to the listener's words. See the [GRPO reward design](https://github.com/shanmukh05/TuneLM/blob/main/docs/rl-reward-design.md).
## Record fields
| Field | Contents |
| --- | --- |
| `id`, `prompt_id`, `split` | Stable record identity, originating request identity, and split |
| `prompt` | Listener's music description |
| `summary`, `code` | Composition notes and executable program, present in SFT train and validation |
| `plan` | Composition metadata, evaluation cycles, and supplied code for co-creation |
| `contract` | Checkable listener requirements in RL records |
| `teacher`, `teacher_id` | Recorded answer provider and model profile in supervised records |
| `context`, `retrieved_ids`, `source_families` | Teacher reference packet and its source lineage |
| `verification`, `verifier_version` | Execution telemetry and runtime version for supervised answers |
A model completion follows this format.
````text
<think>
Composition notes describing tempo, instruments, rhythm, and arrangement.
</think>
```strudel
setcpm(120/4);
stack(s("bd*4").gain(0.4), note("c2 g2").s("sawtooth").gain(0.3))
```
````
## License and attribution
TuneLM's original contributions to this release use **AGPL-3.0-or-later**, consistent with the project's code license. Song Describer captions retain **CC BY-SA 4.0**. Embedded reference material retains the license identified by its source, including MIT, GPL-3.0-only, AGPL-3.0-only, and AGPL-3.0-or-later. The repository declares a mixed license because these terms apply to different components.
Strudel's software uses AGPL-3.0. Its contributed examples and tracks have separate licensing terms. This release preserves the notices and provenance for the selected references. See [LICENSE](LICENSE), [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md), [attribution/](attribution/), and [Strudel's licensing guidance](https://strudel.cc/technical-manual/project-start/).
## Limitations
The dataset focuses on instrumental music expressed through a supported subset of Strudel JavaScript. Teachers can produce generic arrangements, imperfect instrument choices, or inaccurate composition notes. Symbolic tempo, key, and event checks capture only part of a listener's intent. Generated code should be validated before execution. The release contains music descriptions and code, with runtime sound assets supplied separately by the playback environment.
Exact record IDs, request IDs, and normalized prompt text were checked for duplicates across the six release files. This check does not establish that different wordings describe different musical ideas. The released Song Describer subset has four shared artists between training and validation, and five between training and benchmark. Its saved source provenance describes an earlier artist grouping that differs from the exported split assignments. Record-level prompt disjointness does not establish artist-level separation. The reference library is rhythm-heavy, which can influence teacher outputs.
|