File size: 10,451 Bytes
107d71b | 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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | ---
pretty_name: Elixir preference optimization — DPO and KTO sets
license: apache-2.0
language:
- en
tags:
- elixir
- code
- code-generation
- preference-optimization
- dpo
- kto
- rlhf
- otp
task_categories:
- text-generation
size_categories:
- n<1K
configs:
- config_name: dpo-failv0
data_files: data/dpo/dpo_failv0.jsonl
default: true
- config_name: kto-v0
data_files: data/kto/kto_v0.jsonl
- config_name: onpolicy-micro-dpo-v1
data_files: data/onpolicy/qwen25c3b_micro_dpo_v1.jsonl
- config_name: onpolicy-round02-dpo
data_files: data/onpolicy/qwen25c3b_micro_round2_dpo.jsonl
- config_name: onpolicy-round04-dpo
data_files: data/onpolicy/qwen25c3b_micro_round4_dpo.jsonl
- config_name: onpolicy-round13-dpo
data_files: data/onpolicy/qwen25c3b_micro_round13_dpo.jsonl
- config_name: onpolicy-round03-kto
data_files: data/onpolicy/qwen25c3b_micro_round3_kto.jsonl
- config_name: onpolicy-round06-kto
data_files: data/onpolicy/qwen25c3b_micro_round6_kto.jsonl
- config_name: onpolicy-round11-kto
data_files: data/onpolicy/qwen25c3b_micro_round11_kto.jsonl
---
# Elixir preference optimization — DPO and KTO sets
**909 preference rows in 9 configs** for Elixir code models: 654 DPO pairs, 76 balanced
KTO examples, and 179 rows from the on-policy Qwen2.5-Coder-3B refinement rounds. Every
chosen completion was executed and passed the project's isolated Elixir scorer (compile +
ExUnit + static contract checks); every rejected completion was confirmed to fail the
intended gate. The frozen evaluation packs are held out: measured prompt-level and
module-level collisions are **zero** for every config.
> **Do not execute the rejected completions.** They are deliberately broken, and some
> contain intentional defects (swallowed errors, wrong endianness, unsafe state handling).
> Treat every `rejected` field as hostile input.
## What "preference" means here
These pairs are not style opinions. They encode **executable correctness and static
contracts** for Elixir:
- `preference_kind: correctness` — the chosen module compiles and passes its tests; the
rejected one fails to compile, fails a test, or drops a required contract.
- `preference_kind: functional-style` — both sides may behave correctly, but the rejected
side uses process state, side effects or a non-idiomatic construct where the task
explicitly asked for pure functional code. The rejection is a violated static gate, not
a matter of taste.
The failure modes were mined from real model output, then re-targeted onto original tasks
with new module names and specifications, so no benchmark task is copied into the data.
## Configs
| config | rows | format | what it is |
| --- | ---: | --- | --- |
| `dpo-failv0` | 654 | DPO pairs | Mined from evaluation failures of `gemma12b-elixir-cpt-q4` (40/128) and `qwen35-9b-elixir-cpt-sft-q5` (46/128). 534 correctness pairs + 120 functional-style pairs. |
| `kto-v0` | 76 | KTO | Balanced 38 accepted / 38 rejected. Each original task contributes exactly one accepted and one rejected completion; 40 functional-style + 36 correctness rows. |
| `onpolicy-micro-dpo-v1` | 36 | DPO pairs | First on-policy DPO round for the Qwen2.5-Coder-3B depth-expanded checkpoint. |
| `onpolicy-round02-dpo` | 25 | DPO pairs | Round 2: up to three fresh, scorer-gated prompts per construction weakness; format-only pairs excluded. |
| `onpolicy-round04-dpo` | 11 | DPO pairs | Round 4. |
| `onpolicy-round13-dpo` | 17 | DPO pairs | Round 13. |
| `onpolicy-round03-kto` | 34 | KTO | Round 3 KTO: OTP and bit-syntax focus. |
| `onpolicy-round06-kto` | 22 | KTO | Round 6 KTO: functional-style focus (12 functional rows). |
| `onpolicy-round11-kto` | 34 | KTO | Round 11 KTO: four rows per family. |
DPO family coverage (`dpo-failv0`): otp 134, functional 120, binaries 119, beam 66,
stdlib 49, errors 47, abstractions 41, core 41, collections 37. The weakness taxonomy is
distilled from the failing completions — the largest buckets are `format-hygiene` (114),
`enum-state` (99), `err-swallow` (42), `edge-empty` (42), `functional-style-process-state`
(40), `functional-style-agent-state` (40), `bin-size-guard` (33) and `bin-endian` (24);
the complete per-weakness counts are in `metadata/dataset_stats.json`.
KTO family coverage: functional 40, otp 12, binaries 10, protocol 4, stdlib 4, errors 2,
core 2, format 2.
The `onpolicy-*` configs are **checkpoint-specific** artifacts of one model's targeted
rounds; each round's build manifest (base checkpoint, selection rules, counts, validation)
is in `metadata/manifests/`. If you want a single general preference set, use
`dpo-failv0` (or `kto-v0` for the balanced KTO formulation).
## Row schemas
DPO (`dpo-failv0` and the on-policy DPO configs) — ShareGPT prompt plus two string
completions:
```json
{
"id": "dpo.binaries.s16be.bin-endian",
"family": "binaries",
"source": "elixir_dpo_failv0",
"weakness": "bin-endian",
"origin": "designed",
"preference_kind": "correctness",
"models": ["gemma12b-elixir-cpt-q4", "qwen35-9b-elixir-cpt-sft-q5"],
"conversations": [
{"from": "system", "value": "You are a friendly coding assistant ..."},
{"from": "human", "value": "Write a module `S16BE` with: ..."}
],
"chosen": "```elixir\ndefmodule S16BE do ... end\n```",
"rejected": "```elixir\ndefmodule S16BE do ... end\n```"
}
```
KTO (`kto-v0` and the on-policy KTO configs) — TRL conversational schema with a boolean
label:
```json
{
"id": "kto.functional.map-pipeline.chosen",
"family": "functional",
"label": true,
"preference_kind": "functional-style",
"weakness": "functional-pipeline",
"prompt": [
{"role": "system", "content": "You are a friendly coding assistant ..."},
{"role": "user", "content": "Write a module `KtoFnMapPipeline` with: ..."}
],
"completion": [{"role": "assistant", "content": "```elixir ... ```"}]
}
```
In DPO files, `models` records which checkpoints' failures motivated the pair and
`origin` distinguishes `designed`, `handmade` and `functional-style` rows. The on-policy
files carry the same fields plus the round-specific annotations.
## Loading
```python
from datasets import load_dataset
dpo = load_dataset("jmarceno/elixir-preference", "dpo-failv0", split="train")
kto = load_dataset("jmarceno/elixir-preference", "kto-v0", split="train")
print(dpo[0]["chosen"][:200])
print(kto[0]["label"], kto[0]["prompt"])
```
Raw JSONL:
```python
from huggingface_hub import hf_hub_download
path = hf_hub_download(
"jmarceno/elixir-preference", "data/dpo/dpo_failv0.jsonl", repo_type="dataset"
)
```
Shaping the DPO file for TRL `DPOTrainer`:
```python
from datasets import load_dataset
ROLE = {"system": "system", "human": "user", "gpt": "assistant"}
def to_dpo(row):
return {
"prompt": [
{"role": ROLE[turn["from"]], "content": turn["value"]}
for turn in row["conversations"]
],
"chosen": [{"role": "assistant", "content": row["chosen"]}],
"rejected": [{"role": "assistant", "content": row["rejected"]}],
}
ds = load_dataset("jmarceno/elixir-preference", "dpo-failv0", split="train")
ds = ds.map(to_dpo, remove_columns=ds.column_names)
```
The KTO configs already match the TRL `KTOTrainer` columns (`prompt`, `completion`,
`label`) and need no conversion.
## Quality gates
- Every `chosen` completion was executed through the real scorer: compile, generated ExUnit
tests, and static contract checks. A row only ships when the chosen side has zero test
failures and a clean static result; compile warnings are counted and reported.
- Every `rejected` completion fails the declared gate for a reason recorded in `weakness`.
For functional-style pairs, the rejected side is behaviourally correct and fails only the
declared style gate — that is the teaching signal.
- Ids are unique per file, and prompts are unique per file.
- Zero exact prompt collisions and zero module-name collisions against both frozen
evaluation packs.
- `metadata/sha256sums.txt` lets you confirm the bytes you downloaded are the bytes that
passed those gates.
## Intended use and limitations
- **Intended:** DPO or KTO preference tuning of Elixir code models that already produce
working code, especially for OTP timeouts, error handling, edge cases, bit syntax and
functional style.
- **Not intended:** as a standalone fine-tuning dataset (use an SFT set first), for
instruction-following evaluation, for multi-turn agent data, or for any non-Elixir
language.
- 909 rows is small by design. These sets target specific failure families observed in this
project's models; they are not a general Elixir preference corpus and will not teach
unrelated skills.
- Rejected completions are broken on purpose; never execute them in an unsandboxed process.
- Do not treat the size of a configuration as its importance: the on-policy rounds exist to
document a training loop, not to be pooled blindly into a new run.
## Provenance and licensing
Rows were authored for this project and mined from this project's own model evaluations on
original tasks. No benchmark task and no upstream repository code is redistributed here.
The CPT corpora (which do contain upstream Elixir/Erlang sources) are published separately.
Released under **Apache-2.0**. "Elixir" and "Erlang" are trademarks of their respective
owners; this dataset is not affiliated with or endorsed by the Elixir or Erlang teams.
## Repository layout
```
data/dpo/dpo_failv0.jsonl dpo-failv0
data/kto/kto_v0.jsonl kto-v0
data/onpolicy/qwen25c3b_micro_*_dpo.jsonl onpolicy-*-dpo configs
data/onpolicy/qwen25c3b_micro_*_kto.jsonl onpolicy-*-kto configs
metadata/dataset_stats.json per-file rows, hashes, families, pack overlap
metadata/sha256sums.txt data-file checksums
metadata/provenance.json source commit, exclusions, build note
metadata/manifests/*.json per-round build manifests
```
## Citation
```bibtex
@dataset{jmarceno_elixir_preference_2026,
author = {jmarceno},
title = {Elixir preference optimization — DPO and KTO sets},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/datasets/jmarceno/elixir-preference},
note = {Apache-2.0}
}
```
|