ChristophSchuhmann commited on
Commit
fdfc24c
·
verified ·
1 Parent(s): 145e617

Dataset card, verification record and the four build scripts

Browse files
Files changed (6) hide show
  1. README.md +507 -0
  2. code/build_cfg.py +401 -0
  3. code/build_pairs2.py +287 -0
  4. code/mix_cfg.py +44 -0
  5. code/mix_pairs2.py +54 -0
  6. verify.json +204 -0
README.md ADDED
@@ -0,0 +1,507 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ pretty_name: LAION Voice Profiles — contrastive DPO pairs (CFG + phase 2)
4
+ annotations_creators: [machine-generated]
5
+ language_creators: [machine-generated]
6
+ language: [en, de]
7
+ task_categories: [text-to-speech]
8
+ tags: [tts, dpo, preference, rlhf, voice-cloning, speech-emotion, moss, audio-codec, classifier-free-guidance]
9
+ size_categories: [100K<n<1M]
10
+ configs:
11
+ - config_name: cfg
12
+ data_files: [{split: train, path: cfg/shard-*.parquet}]
13
+ - config_name: p2
14
+ data_files: [{split: train, path: p2/shard-*.parquet}]
15
+ ---
16
+
17
+ # LAION Voice Profiles — contrastive DPO pairs (CFG + phase 2)
18
+
19
+ **Authors: Christoph Schuhmann and LAION.**
20
+
21
+ **842,935 preference pairs in four families**, built from the same 500 synthetic voice profiles as
22
+ [`laion/laion-voice-profiles-sft`](https://huggingface.co/datasets/laion/laion-voice-profiles-sft)
23
+ and [`laion/laion-voice-profiles-dpo`](https://huggingface.co/datasets/laion/laion-voice-profiles-dpo).
24
+ These are the two pair families that the sister DPO set does **not** contain: they were built later,
25
+ for two measured defects of the models trained on it, and they are the complete remainder of the
26
+ project's preference material that is publishable under CC-BY-4.0.
27
+
28
+ | config | family | pairs | contrast | words in the prompt? |
29
+ |---|---|--:|---|---|
30
+ | `cfg` | `cfg_high` | 237,209 | same voice, matched length, the **top 1 %** of that voice's own range on one measured dimension against the **bottom 1 %**; the instruction asks for the dimension **high**, the high clip is chosen | no — replaced by `...` |
31
+ | `cfg` | `cfg_low` | 237,209 | the **same 237,209 pairs with the roles flipped**: the instruction asks for the dimension **low**, the low clip is chosen | no |
32
+ | `p2` | `p2_emox` | 309,128 | same voice, matched length, **intense on emotion A against intense on emotion B**; the instruction names A | no |
33
+ | `p2` | `p2_len` | 59,389 | the **same clip at its true length against itself cut to 50–75 % or run on to 125–150 %**, with the emotion named | yes — the full timed script |
34
+
35
+ Both sides of every pair ship as MOSS-Audio-Tokenizer-v2 codes (`codes` = chosen, `rej_codes` =
36
+ rejected), together with the reference clip the chosen take was generated against (`ref_codes`).
37
+ There is no audio in this repository; the waveforms of every source clip are in
38
+ [`laion/laion-voice-profiles-annotated`](https://huggingface.co/datasets/laion/laion-voice-profiles-annotated)
39
+ and the join is exact — see *The join*.
40
+
41
+ ---
42
+
43
+ ## Read this first
44
+
45
+ 1. **"CFG" is the project's name for the construction, not a guidance scale.** Nothing here was
46
+ generated with classifier-free guidance and there is no numeric guidance weight anywhere in the
47
+ data. The name comes from the *shape* of the pair: two clips of one voice that differ only in how
48
+ strongly one dimension is expressed, put under one prompt that states the level, and emitted in
49
+ both directions — the same conditional/unconditional contrast that guidance exploits at
50
+ inference, moved into the preference data. `cfg_high` / `cfg_low` mean "the instruction asked for
51
+ the dimension high / low", nothing else.
52
+ 2. **`uid` is a pair id, not a corpus utterance id.** `cfg<pair_id><h|l>` and
53
+ `p2<pair_id><e|c|x>`. The source clips are named in `cfg/pairs_index.parquet` and
54
+ `p2/pairs_index.parquet` (and, for `cfg`, also in the row's own `caption_tpl`), and *those* ids
55
+ are byte-identical to `uid` in `laion/laion-voice-profiles-annotated`.
56
+ 3. **Every row is `src = 0`, i.e. one of the 500 published synthetic voice profiles.** No real
57
+ recording, no podcast, no broadcast material contributes a clip, a transcript or a word
58
+ timeline to this set. Checked on every row and every source-clip reference, as an allowlist.
59
+ 4. **The words are deliberately absent from three of the four families.** A DPO pair shares one
60
+ prompt; when chosen and rejected are different recordings with different words, the words would
61
+ make the preference decidable from the transcript. `cfg_free_text = true` tells the prompt
62
+ renderer to print `...` for every speech chunk while keeping every pause, duration, burst and
63
+ direction tag. The `text` column is still shipped — it is the chosen clip's text, for lookup —
64
+ but it must not go into the prompt of those rows.
65
+ 5. **These rows are the training-corpus format, not the sister set's 86-column format.** They
66
+ are the exact files the two DPO runs below read, shipped unchanged (31 columns, `zstd`, 128
67
+ shards by `uid` hash). The per-clip annotation stack (40 emotion heads, 57 VoiceNet dimensions,
68
+ captions, speaker embedding) is not repeated here; it is one join away.
69
+
70
+ ---
71
+
72
+ ## Files
73
+
74
+ | path | count | size | what |
75
+ |---|--:|--:|---|
76
+ | `cfg/shard-000.parquet` … `shard-127.parquet` | 128 | 3,668,193,909 B | `cfg_high` + `cfg_low`, 474,418 rows, 31 columns |
77
+ | `p2/shard-000.parquet` … `shard-127.parquet` | 128 | 2,822,830,198 B | `p2_emox` + `p2_len`, 368,517 rows, same 31 columns |
78
+ | `cfg/pairs_index.parquet` | 1 | 8,533,671 B | 237,209 base pairs: `pair_id`, `hi_uid`, `lo_uid`, measured values, percentiles, frames |
79
+ | `p2/pairs_index.parquet` | 1 | 9,697,805 B | 368,517 rows: `pair_id`, `ch_uid`, `rj_uid`, percentiles, frames, `mode`, `cut_frames` |
80
+ | `code/build_cfg.py`, `code/build_pairs2.py` | 2 | — | the two builders, verbatim, with their design notes in the docstrings |
81
+ | `code/mix_cfg.py`, `code/mix_pairs2.py` | 2 | — | how the families were concatenated onto the earlier corpora for training |
82
+ | `verify.json` | 1 | — | the verification run reproduced at the end of this card |
83
+
84
+ Rows are bucketed by `blake2b(uid) % 128`, so every shard is a uniform random sample of its
85
+ config and the two families of a config are interleaved. Shard `b` of `cfg/` and shard `b` of
86
+ `p2/` are unrelated.
87
+
88
+ ```python
89
+ from datasets import load_dataset
90
+ cfg = load_dataset("laion/laion-voice-profiles-dpo-cfg", "cfg", split="train")
91
+ p2 = load_dataset("laion/laion-voice-profiles-dpo-cfg", "p2", split="train")
92
+ ```
93
+
94
+ ---
95
+
96
+ ## What the pairs are, and why
97
+
98
+ Everything the project's models had been trained on *described* an emotion; nothing ever made two
99
+ clips compete on **how strongly** one dimension is expressed. Asked for the 0.90–0.98 percentile of
100
+ a named emotion, the round-3 model landed at 0.34. The two builds here are the two attempts to put
101
+ intensity itself into the preference signal. Quoted numbers below are from the project protocol
102
+ (§16, §I.13 of the technical report) and were re-derived from the shipped files where possible.
103
+
104
+ ### `cfg` — direction contrast on one measured dimension, both ways
105
+
106
+ For one voice and one dimension, the clip pool is that voice's own training clips (1,199,355
107
+ clips over 500 voices in the pool: `src = 0`, not held out, with codes), ranked by the value the
108
+ annotation model **measured** on the finished audio — never by what the generating prompt asked
109
+ for and never by the clip's intended condition.
110
+
111
+ * **dimensions**: all **40** emotion heads and **15** VoiceNet ordinal ladders that describe *how*
112
+ something is spoken — `AROU BRGT CLRT DFLU FULL RANG RESP ROUG STNC TEMP TENS VALN VOLT VULN
113
+ WARM`. Identity, recording-quality and content heads (`AGEV GEND RCQL BKGN ESTH EXPL`) are
114
+ excluded: they are not things a performer can be asked to do.
115
+ * **the two clips**: top 1 % against bottom 1 % of *that voice's* distribution (floor of 24 clips
116
+ per tail when 1 % is smaller). For emotion heads a separation of at least 0.25 corpus IQR is
117
+ required; realised median corrected percentile of the high clip is **0.998**, of the low clip
118
+ **0.000**, and the smallest high-minus-low gap in the set is 0.73. For VoiceNet ladders the two
119
+ clips sit in different ladder buckets (high side mostly buckets 4–6, low side 0–1).
120
+ * **same voice** (`voice_key`), so speaker identity cannot decide the preference; **frames within
121
+ 10 %** (`|f_hi − f_lo| ≤ 0.10 · min`, true on 237,209 / 237,209), so length cannot decide it;
122
+ **no words**, so the transcript cannot decide it. Language is **not** matched — 54.6 % of pairs
123
+ are same-language; the row's `lang` is the chosen clip's.
124
+ * **nine base pairs per (voice, dimension) cell**, 237,209 base pairs in all (173,116 on emotion
125
+ heads, 64,093 on VoiceNet ladders), 408–495 per voice.
126
+ * **both roles.** Every base pair is emitted twice. `cfg_high` (`uid` ends in `h`): instruction
127
+ asks for the dimension high, `codes` is the high clip, `rej_codes` the low one. `cfg_low` (`l`):
128
+ instruction asks for it low, roles swap. Each clip is therefore chosen in one row and rejected in
129
+ another; a policy that simply prefers louder or denser audio scores 50 % on this set, and the only
130
+ way to win is to condition on the instruction. The two families are balanced to the row.
131
+
132
+ **How the level is stated.** For an emotion head the row carries the corpus's own caption form,
133
+ `A voice <band phrase> expressing <emotion>, <prose>; reads as <emotion>`, and `emo_strength` is set
134
+ so the prompt renderer picks the matching band:
135
+
136
+ | role | `emo_strength` | band | band phrases | prose tail |
137
+ |---|---|---|---|---|
138
+ | high | 0.95 or 0.99, alternating by `uid` hash | `intense` / `extreme` | *intensely, powerfully, viscerally* / *to the extreme, utterly, overwhelmingly* | the corpus's expressed-side prose for that emotion |
139
+ | low | the low clip's own percentile, capped at 0.60 (0.00 on 162,160 of 173,116 rows) | `faint` | *mildly, slightly, faintly, a little* | one of three generic "barely there" tails |
140
+
141
+ The high role alternates between `intense` and `extreme` on purpose: both words are true of a clip
142
+ at percentile 0.998, and a two-point contrast cannot calibrate *between* them. For a VoiceNet
143
+ ladder there is no emotion to name; `caption_general` is `A voice; <clause> is <ladder tag>` and
144
+ `cfg_neutral` carries the direction the renderer puts into the script — `"<tag>, and hold it there;
145
+ otherwise exactly as this voice normally speaks"` — with `emo_strength = null` (128,186 rows).
146
+
147
+ ### `p2` — the two phase-2 families
148
+
149
+ Built after the `cfg` run, for two defects it measured. The base pool and the matching rules are
150
+ the same as above; the selection constants are `HI_PCT = 0.90`, `LO_PCT = 0.50`, `FRAME_TOL =
151
+ 0.10`, 8 emotion-contrastive and 6 length pairs per cell, seed 4711.
152
+
153
+ **`p2_emox` — intense against intense, for selectivity.** Per-emotion adapters trained on
154
+ intense-versus-mild contrasts raised their own emotion by +0.047 when asked for it — and by +0.033
155
+ when not. "A ratio of 1.4 : 1 is not control, it is tinting" (the builder's docstring). Every
156
+ earlier contrast pits an intense clip against a mild one, so a model can win by being generically
157
+ expressive. Here the chosen clip sits at percentile ≥ 0.90 on the head being asked for *and* has
158
+ that head as its own top emotion; the partner is ≤ 0.50 on that head and ≥ 0.90 on *its* own top
159
+ head. Both sides really are intense, on different emotions, same voice, frames within 10 % (true
160
+ on 309,128 / 309,128), words removed. Each base pair is emitted twice, the mirror naming the
161
+ partner's own top emotion with the roles swapped (154,564 base pairs, 19,884 (voice, emotion)
162
+ cells, all 40 heads). Realised: chosen-side percentile median 0.986 (min 0.900), rejected-side
163
+ median 0.215, median gap 0.76.
164
+
165
+ One honest detail about the mirror: the ≤ 0.50 bound was enforced on the *original* direction
166
+ only. In the mirror row the rejected clip is the original's chosen clip, whose percentile on the
167
+ partner's emotion was never constrained. Across all 309,128 rows the rejected side is ≤ 0.50 on the
168
+ named head on 247,324 (80.0 %), above 0.50 on 61,804, and ≥ 0.90 on 14,281 (4.6 %) — those last
169
+ are pairs where one clip is intense on both emotions — and on 3,372 rows (1.1 %) the rejected side
170
+ is actually *higher* on the named head than the chosen one (worst gap −0.095). `p2/pairs_index.parquet` carries `ch_pct`
171
+ and `rj_pct` per row, so you can filter on the gap you want.
172
+
173
+ **`p2_len` — the right length, conditioned on the emotion.** The sister set's `truncation` and
174
+ `continuation` families know nothing about emotion and teach "the right length is better" in the
175
+ abstract. Here the speaker, the text and the emotion stay fixed and only the length moves: chosen
176
+ is a clip whose top emotion is at percentile ≥ 0.90, rejected is the **same clip** cut to 50–75 %
177
+ of its frames (`mode = cut`, 29,564 rows; realised keep fraction 0.49–0.75, median 0.62) or run on
178
+ to 125–150 % by appending the opening frames of another clip of the same voice (`mode = ext`,
179
+ 29,825 rows; realised 1.23–1.50, median 1.37; the donor is `rj_uid`, same language on 54 %).
180
+ Because the words are shared, the prompt carries the full timed script — the timing tags are
181
+ exactly what the rejected side violates. Clips shorter than 40 frames (3.2 s) were not used.
182
+
183
+ ### What they trained, and what happened
184
+
185
+ | adapter | corpus | pairs seen | reward | WER | emotion pct | quality | burst | burst hit rate |
186
+ |---|---|--:|--:|--:|--:|--:|--:|--:|
187
+ | SFT-3 base, no adapter | — | — | 0.4584 | 0.0987 | 0.3494 | 0.9127 | 0.3564 | 0.666 |
188
+ | previous best DPO (sister families only) | 1,853,486 pairs | step 3216 | 0.4687 | 0.1094 | 0.3401 | 0.9211 | 0.3929 | 0.709 |
189
+ | [`laion/moss-va-sft3-dpo-lora`](https://huggingface.co/laion/moss-va-sft3-dpo-lora) | sister families + **`cfg`** (2,327,904; 20.4 % `cfg`) | step 4912 | 0.4708 | **0.0950** | 0.3373 | **0.9235** | **0.4271** | **0.772** |
190
+ | [`laion/moss-va-sft3-dpo-lora-p2`](https://huggingface.co/laion/moss-va-sft3-dpo-lora-p2) | the above + **`p2`** (2,696,421; 13.7 % `p2`) | step 5022 | **0.4757** | 0.0977 | **0.3541** | 0.9208 | 0.4180 | 0.762 |
191
+
192
+ Both runs: LoRA rank 64 on
193
+ [`laion/moss-tts-local-transformer-4.55b-voice-acting-v2-sft3`](https://huggingface.co/laion/moss-tts-local-transformer-4.55b-voice-acting-v2-sft3),
194
+ β 30, lr 1e-6, 256 pairs per step, 8 nodes, stopped by a 6-hour wall clock at roughly half an
195
+ epoch; 80-prompt standard evaluation, 320 clips per row.
196
+
197
+ Read plainly: the `cfg` families made the best *general* checkpoint the project had measured —
198
+ word error rate better than the supervised base, the highest quality and burst realisation — and
199
+ did **not** move the thing they were built for; emotion percentile fell. Preference accuracy on the
200
+ `cfg` rows went 0.56 → 0.98, so the model learned to *recognise* the level without gaining the
201
+ ability to *reach* it — the high side of a pair is only as intense as the corpus gets. The `p2`
202
+ families then produced the first preference-tuned model above the supervised baseline on emotion
203
+ percentile (0.3541 against 0.3494, requested band 0.90–0.98), with emotion-contrastive preference
204
+ accuracy 0.951 post-warmup, while `p2_len` saturated at accuracy 1.000 in the second half of the
205
+ run — that family is solved and could be dropped from a future mix. The remaining half epoch of
206
+ each run was never trained.
207
+
208
+ ---
209
+
210
+ ## The prompt
211
+
212
+ The rows carry the *ingredients* of the prompt, not the rendered string, because the renderer is
213
+ stochastic (direction placement, timed/untimed script, burst dropout, reference-versus-name slot,
214
+ all drawn per step). The training code rendered every row into the base model's `<user_inst>`
215
+ template with `prompt_lib2.render_prompt` (format hash `073aeb09dc923376`); the renderer itself
216
+ is part of the training stack and is not shipped here. What it does with the columns of this set:
217
+
218
+ * `caption_general` → the `GENERAL:` line (the level statement for emotion rows);
219
+ * `text` + `words_json` + `burst_*` + `dur_s` → the timed `SCRIPT:` — segment durations, pauses,
220
+ detected bursts with their lengths, and the delivery direction drawn from `emo_strength`'s band
221
+ (or `cfg_neutral` for VoiceNet rows);
222
+ * `cfg_free_text = true` → every speech chunk of that script becomes `...`;
223
+ * `frames` → the `- Tokens:` budget; `lang` → `- Language:`; `ref_codes` → the `<|audio|>`
224
+ reference slot, or `Speaker: <speaker_name>` in name mode.
225
+
226
+ Two rows of this set, rendered by that code (reference-audio mode):
227
+
228
+ `cfg_high`, emotion head *Intoxication*, uid `cfgd0ac06bc0eea0a5f4dcch`:
229
+
230
+ ```
231
+ <user_inst>
232
+ - Reference(s):
233
+ <|audio|>
234
+ - Instruction:
235
+ GENERAL: A voice utterly expressing intoxication, a woozy, slurring voice, intoxicated and untethered, in an altered haze, impossible to hide; reads as intoxication altered states of consciousness
236
+ SCRIPT:
237
+ (not holding it together at all, breath shallow and fast, the fear plain in the voice, unguarded; completely intoxicated) [4.3 seconds duration] ... [0.5 seconds pause] (keep it overwhelmingly intoxicated) [2.7 seconds duration] ...
238
+ - Tokens:
239
+ 94
240
+ - Quality:
241
+ None
242
+ - Sound Event:
243
+ None
244
+ - Ambient Sound:
245
+ None
246
+ - Language:
247
+ English
248
+ - Text:
249
+ (not holding it together at all, breath shallow and fast, the fear plain in the voice, unguarded; completely intoxicated) [4.3 seconds duration] ... [0.5 seconds pause] (keep it overwhelmingly intoxicated) [2.7 seconds duration] ...
250
+ </user_inst>
251
+ ```
252
+
253
+ `cfg_low`, VoiceNet ladder *WARM* (timbre), uid `cfga19aa3876e64686f91c1l` — no `GENERAL:` line,
254
+ the level sits in the script as `cfg_neutral`:
255
+
256
+ ```
257
+ - Instruction:
258
+ SCRIPT:
259
+ [5.5 seconds pause] (slightly cool, and hold it there; otherwise exactly as this voice normally speaks) [1.4 seconds duration] ... [0.8 seconds pause] [3.2 seconds duration] ... [0.3 seconds pause]
260
+ - Tokens:
261
+ 140
262
+ ```
263
+
264
+ A `p2_len` row renders the same way with the words present in the script. The `[n seconds
265
+ duration]` and `[n seconds pause]` tags come from `words_json`; the `(burst, n seconds)` tags from
266
+ `burst_starts` / `burst_ends` / `burst_labels`; the parenthesised directions are drawn from the
267
+ band and are not stored in the row.
268
+
269
+ ---
270
+
271
+ ## Columns — the 31 columns of `cfg/shard-*` and `p2/shard-*`
272
+
273
+ | column | type | meaning |
274
+ |---|---|---|
275
+ | `uid` | `string` | pair-row id. `cfg` + 20-hex `pair_id` + `h`/`l` (role), or `p2` + 9-digit `pair_id` + `e`/`c`/`x` (`emox` / `cut` / `ext`). Unique across the whole set. |
276
+ | `family` | `string` | `cfg_high`, `cfg_low`, `p2_emox`, `p2_len` |
277
+ | `src` | `int8` | source group of the training corpus; **0 on every row** = synthetic voice profile |
278
+ | `voice_key` | `string` | voice-profile id, one of the 500 (`anime_000`, `emolia_c0123`, `mediathek_…`, `refvoice_…`, `k<n>_age<n>_bg<n>`); both clips of the pair share it |
279
+ | `lang` | `string` | `en` / `de` — of the **chosen** clip; the rejected clip of a `cfg` / `p2_emox` pair may be in the other language |
280
+ | `text` | `string` | the chosen clip's generation text, verbatim (may contain the generator's own parenthesised burst directions). **Not** in the prompt when `cfg_free_text` is true. |
281
+ | `text_bursts` | `string` | `text` with the *detected* vocal bursts inserted inline as `(label)`; equals `text` when nothing was detected (73 % of `cfg` rows, 75 % of `p2`) |
282
+ | `caption_general` | `string` | the level statement. Emotion rows: `A voice <band> expressing <emotion>, <prose>; reads as <emotion>`. VoiceNet rows: `A voice; <clause> is <tag>`. |
283
+ | `caption_script` | `string` | always empty in this set |
284
+ | `caption_tpl_text` | `string` | always empty in this set |
285
+ | `caption_tpl` | `string` | provenance key. `cfg`: `cfg\|<emo\|vn>\|<dimension>\|<hi_uid>\|<lo_uid>`. `p2`: `p2\|<emox\|len>\|<emox\|cut\|ext>\|<dimension>` |
286
+ | `speaker_name` | `string` | the voice's assigned given name (the same mapping as `names.csv` in the sister set) |
287
+ | `spoken_dur_s` | `float32` | end of the last aligned word of the chosen clip, seconds |
288
+ | `dur_s` | `float32` | duration of the chosen clip, seconds (generator's pre-encode measurement; `frames == round(dur_s · 12.5)`) |
289
+ | `words_json` | `string` | JSON list `[{"w","s","e"}, …]` — MMS_FA forced alignment of the chosen clip's text, seconds |
290
+ | `burst_starts` / `burst_ends` | `list<float32>` | detected vocal-burst spans in the chosen clip, seconds |
291
+ | `burst_labels` | `list<string>` | their class labels (`Contented Sigh`, `Breathy Giggle`, …) |
292
+ | `in_extreme` | `bool` | legacy flag of the older corpus; **always false** here (`emo_strength` carries the band instead) |
293
+ | `frames` | `int32` | MOSS frames of the chosen clip |
294
+ | `codes` | `binary` | **chosen** MOSS codes, little-endian `uint16`, `frames × 12` values |
295
+ | `rej_frames` | `int32` | MOSS frames of the rejected side |
296
+ | `rej_codes` | `binary` | **rejected** MOSS codes, same layout. `cfg` / `p2_emox`: the other clip; `cut`: a frame-aligned prefix of `codes`; `ext`: `codes` followed by `cut_frames` frames of the donor |
297
+ | `ref_frames` | `int32` | MOSS frames of the reference clip |
298
+ | `ref_codes` | `binary` | the reference clip the chosen take was paired with in the training corpus — another take of the same voice; its uid is not carried in these rows |
299
+ | `has_ref` | `bool` | always true here |
300
+ | `is_val` | `bool` | `blake2b(uid) % 1000 == 0` — the training runs' held-out rows (490 in `cfg`, 373 in `p2`); shipped, not excluded |
301
+ | `cfg_free_text` | `bool` | render the script without words. True on every `cfg` row and every `p2_emox` row, false on `p2_len` |
302
+ | `cfg_neutral` | `string` | VoiceNet rows only: the direction stating the ladder tag (`"very tense, and hold it there; otherwise exactly as this voice normally speaks"`); empty elsewhere |
303
+ | `emo_strength` | `float32`, nullable | the emotion band the prompt states, as a percentile: 0.95 / 0.99 for the high or named side, ≤ 0.06 for `cfg_low` emotion rows, **null** on VoiceNet rows |
304
+
305
+ ### `cfg/pairs_index.parquet` — 237,209 rows, one per base pair
306
+
307
+ | column | type | meaning |
308
+ |---|---|---|
309
+ | `pair_id` | `string` | 20 hex characters; the row uids are `cfg{pair_id}h` and `cfg{pair_id}l` |
310
+ | `voice_key` | `string` | the voice |
311
+ | `dim` | `string` | emotion head name or VoiceNet code |
312
+ | `kind` | `string` | `emo` (173,116) or `vn` (64,093) |
313
+ | `hi_uid` / `lo_uid` | `string` | the high and the low clip — **uids of `laion/laion-voice-profiles-annotated`** |
314
+ | `hi_val` / `lo_val` | `float32` | the measured value of `dim` on each clip (emotion intensity, or VoiceNet regression) |
315
+ | `hi_frames` / `lo_frames` | `int32` | their MOSS frames |
316
+ | `hi_pct` / `lo_pct` | `float32` | `emo`: tie-aware corpus ECDF percentile of the value; `vn`: the ladder bucket (0–6) as a float |
317
+
318
+ ### `p2/pairs_index.parquet` — 368,517 rows, one per shipped row
319
+
320
+ | column | type | meaning |
321
+ |---|---|---|
322
+ | `pair_id` | `string` | 9 digits; the row uid is `p2{pair_id}{mode[0]}` |
323
+ | `family` | `string` | `emox` or `len` (the row's `family` is `p2_` + this) |
324
+ | `voice_key`, `dim` | `string` | the voice; the emotion head the instruction names |
325
+ | `ch_uid` | `string` | the chosen clip — uid in `laion/laion-voice-profiles-annotated` |
326
+ | `rj_uid` | `string` | `emox`: the rejected clip; `cut`: equal to `ch_uid`; `ext`: the donor whose opening frames are appended |
327
+ | `ch_pct` / `rj_pct` | `float32` | percentile of `dim` on the chosen / rejected clip (`len`: both the chosen clip's own top-head percentile) |
328
+ | `ch_frames` / `rj_frames` | `int32` | `emox`: frames of the two clips; `cut`: `rj_frames` is the kept prefix length; `ext`: `rj_frames` is the number of donor frames appended |
329
+ | `mode` | `string` | `emox` / `cut` / `ext` |
330
+ | `cut_frames` | `int32` | `cut`: frames kept; `ext`: frames appended; `emox`: 0 |
331
+
332
+ ---
333
+
334
+ ## The join
335
+
336
+ `hi_uid`, `lo_uid`, `ch_uid`, `rj_uid` **are** the `uid` column of
337
+ [`laion/laion-voice-profiles-annotated`](https://huggingface.co/datasets/laion/laion-voice-profiles-annotated)
338
+ (`index/origin=original/`, and the tar member stem under `data/origin=original/`), of the form
339
+ `<voice>__<block>__<cell>__<lang>.cNNN` — e.g. `anime_000__E__Affection__D__de.c037`. Verified
340
+ byte-for-byte on the released index (see below). From there you have the MP3, the 205-column
341
+ annotation, the speaker embedding, and — via the same uid — the rows of
342
+ `laion/laion-voice-profiles-sft` and `-dpo`.
343
+
344
+ ```python
345
+ import numpy as np, pyarrow.parquet as pq, pyarrow.dataset as ds
346
+
347
+ def codes(b, frames, n_vq=12):
348
+ return np.frombuffer(b, dtype="<u2").reshape(frames, n_vq)
349
+
350
+ row = pq.read_table("cfg/shard-000.parquet").slice(0, 1).to_pylist()[0]
351
+ chosen, rejected = codes(row["codes"], row["frames"]), codes(row["rej_codes"], row["rej_frames"])
352
+
353
+ # which clips are these? (cfg: also readable from caption_tpl.split("|")[3:5])
354
+ idx = pq.read_table("cfg/pairs_index.parquet").to_pandas().set_index("pair_id")
355
+ p = idx.loc[row["uid"][3:-1]]
356
+ chosen_uid, rejected_uid = (p.hi_uid, p.lo_uid) if row["uid"].endswith("h") else (p.lo_uid, p.hi_uid)
357
+
358
+ # the same for p2
359
+ row = pq.read_table("p2/shard-000.parquet").slice(0, 1).to_pylist()[0]
360
+ p = pq.read_table("p2/pairs_index.parquet").to_pandas().set_index("pair_id").loc[row["uid"][2:-1]]
361
+ chosen_uid, rejected_uid, mode = p.ch_uid, p.rj_uid, p.mode # rj_uid == ch_uid when mode == "cut"
362
+
363
+ # audio + full annotation, from the annotated corpus (local snapshot)
364
+ ann = ds.dataset("laion-voice-profiles-annotated/index", partitioning="hive", format="parquet")
365
+ a = ann.to_table(filter=ds.field("uid") == chosen_uid).to_pylist()[0]
366
+ # tar: data/origin=original/{a['shard']}.tar, members {chosen_uid}.mp3 / .json / .moss.npy / .vclap.npy
367
+ ```
368
+
369
+ `uid` in the annotated corpus **contains dots** — do not split on the first one. Its
370
+ `audio_key` is not unique across runs; join on `uid`.
371
+
372
+ ---
373
+
374
+ ## MOSS codes
375
+
376
+ `codes`, `rej_codes`, `ref_codes` are raw little-endian `uint16`, `(frames, 12)` after reshape:
377
+ **12 codebooks × 1024 entries at 12.5 fps, one frame = 12 tokens = 80 ms.** There is no 32-token
378
+ block and no interleaving; the 32 associated with this stack is the codec's `num_quantizers`, of
379
+ which the TTS model consumes the first 12. Every `cut` boundary is a whole frame. The `p2` builder drops
380
+ rejected sides longer than 620 frames (49.6 s); the training corpus caps chosen takes the same way.
381
+
382
+ **These codes are from the corrected tokenisation.** The voice-profile corpus once carried codes
383
+ computed on a half-speed decode (a stereo-to-mono bug that doubled every duration and frame count
384
+ in the first annotation tree). The frame counts here were compared, clip by clip, with
385
+ `moss_frames` of the released annotated index for 1,322 clip references of voice `anime_000`
386
+ (its first three index parts): ratio **1.00 on every one**, and `dur_s` likewise. Nothing in this set comes from the broken tree.
387
+
388
+ ---
389
+
390
+ ## The material this is built from
391
+
392
+ 500 synthetic **voice profiles**, each one reference speaker driven through a fixed matrix of 842
393
+ named acting conditions in English and German, keeping every candidate take. Generator
394
+ [`laion/moss-tts-local-transformer-4.55b-voice-acting-v2`](https://huggingface.co/laion/moss-tts-local-transformer-4.55b-voice-acting-v2),
395
+ codec [`OpenMOSS-Team/MOSS-Audio-Tokenizer-v2`](https://huggingface.co/OpenMOSS-Team/MOSS-Audio-Tokenizer-v2),
396
+ run `vprof_base`. The full corpus with audio and the complete annotation stack is
397
+ `laion/laion-voice-profiles-annotated`; the per-voice LoRAs and reference clips are
398
+ [`laion/moss-voice-profile-loras-500`](https://huggingface.co/laion/moss-voice-profile-loras-500).
399
+ The clip pool for both builds is the voice-profile part of the project's second training corpus
400
+ (`src = 0`, 1,199,355 clips) — the same top-3-per-cell takes that make up
401
+ `laion/laion-voice-profiles-sft` (1,200,531 rows), minus the corpus's 1-in-1000 held-out rows, joined
402
+ with the corrected re-annotation. The source clips span every block of the matrix — for
403
+ the `cfg` high side, 115,656 come from emotion cells, 88,904 from VoiceNet cells, 22,562 from edge
404
+ cases, 6,532 from character voices, 2,957 from isolated bursts, 380 sports and 218 explicit cells —
405
+ because the ranking is by the measured value, not by the cell.
406
+
407
+ The measured values that rank the clips are the 40 Empathic-Insight emotion intensities and the 57
408
+ VoiceNet regressions of the corrected re-annotation (`laion/voiceclap-commercial` →
409
+ `laion/voicenet-dimension-predictors-commercial`), with the percentiles taken from the project's
410
+ tie-aware ECDF over 132.8 M rows pooled across its corpora. The same caveat as on the sister cards
411
+ applies: these are model outputs, not human ratings, and the VoiceNet heads were trained on
412
+ Gemini perceptual estimates (mean r 0.79).
413
+
414
+ ---
415
+
416
+ ## Limitations, honestly
417
+
418
+ * **No human has listened to any pair in a controlled study.** "High" and "low" are model
419
+ measurements on model output.
420
+ * **The high side is only as intense as the corpus gets.** These pairs teach the *direction* of a
421
+ dimension within a voice's own range; they cannot teach a level the generator never produced.
422
+ That is exactly the result the `cfg` run showed.
423
+ * **Language is not matched within a `cfg` / `p2_emox` pair** (54.6 % / 59.1 % same-language).
424
+ The prompt states the chosen clip's language and the words are absent, so the mismatch is not
425
+ visible in the prompt — but the rejected side may be a German clip against an English prompt.
426
+ * **The `p2_emox` mirror rows are looser than the original direction** (20.0 % of rows with the
427
+ rejected side above 0.50 on the named head; 4.6 % at or above 0.90). Filter on `rj_pct` if you
428
+ want the strict version.
429
+ * **`p2_len` negatives are constructed, not observed**, and the `ext` splice has no crossfade.
430
+ Its preference accuracy saturated at 1.000 during training; it carries little signal for a model
431
+ that already handles timing tags.
432
+ * **The rendered prompts are not shipped**, only their ingredients; reproducing them exactly needs
433
+ the project's renderer. The example strings above are what the trainer saw.
434
+ * **Speaker identity is weak against the nominal reference, everywhere**, as inherited from the
435
+ generation run (per-voice mean `spk_sim` 0.18–0.69 in the sister set). Same voice within a pair
436
+ is guaranteed by `voice_key`, not by a similarity threshold.
437
+
438
+ ---
439
+
440
+ ## What is, and is not, in the sister sets
441
+
442
+ | repository | families | relation to this set |
443
+ |---|---|---|
444
+ | [`laion/laion-voice-profiles-dpo`](https://huggingface.co/datasets/laion/laion-voice-profiles-dpo) | `emotion`, `truncation`, `continuation` — 3,451,531 pairs | the `vp_*` families of the training corpora; **none of the four families here** |
445
+ | [`laion/tts-realspeech-dpo-en-de`](https://huggingface.co/datasets/laion/tts-realspeech-dpo-en-de) | `too_short`, `too_long` on real speech — 3,959,192 pairs | the `rs_*` families; real recordings, disjoint by construction (`src ≠ 0`) |
446
+ | **this set** | `cfg_high`, `cfg_low`, `p2_emox`, `p2_len` — 842,935 pairs | the remainder |
447
+
448
+ The training corpora were nested unions: `dpo_corpus2` (1,853,486, sister families) ⊂
449
+ `dpo_corpus_cfg` (+ `cfg`, 2,327,904) ⊂ `dpo_corpus_p2` (+ `p2`, 2,696,421). `code/mix_cfg.py` and
450
+ `code/mix_pairs2.py` are the two concatenations. Overlap was checked, not assumed:
451
+ every `uid`,
452
+ `chosen_uid`, `rejected_uid`, `ref_uid` and `donor_uid` of all 1,922 parquet files of both sister sets
453
+ (7,410,723 rows) was read, and **none of the 237,209 `cfg` base pairs and none of the 154,564
454
+ `p2_emox` base pairs is a `(chosen, rejected)` tuple of the sister `emotion` family (1,064,594
455
+ tuples), in either order.** What *is* shared is the pool: all 332,576 / 342,284 source clips appear
456
+ in the sister set as a chosen take, because both are built from the same top-3 selection, and every
457
+ `p2_len` chosen clip also has a `truncation` and a `continuation` negative there — cut at a sentence
458
+ boundary in the 30–85 % window rather than at 50–75 % of the frames, so the pairs differ. No row of
459
+ this set is a copy of a row there.
460
+
461
+ ---
462
+
463
+ ## Verification run on the shipped files
464
+
465
+ | check | result |
466
+ |---|---|
467
+ | rows shipped | `cfg` **474,418** (`cfg_high` 237,209 · `cfg_low` 237,209) · `p2` **368,517** (`p2_emox` 309,128 · `p2_len` 59,389) — counted with `pyarrow` over all 256 shards |
468
+ | languages (of the chosen clip) | `cfg` en 227,068 / de 247,350 · `p2` en 179,649 / de 188,868 |
469
+ | `uid` unique across each config | 474,418 / 474,418 · 368,517 / 368,517 |
470
+ | `src == 0` | 474,418 / 474,418 · 368,517 / 368,517 |
471
+ | `voice_key` is one of the 500 published profiles | 474,418 / 474,418 · 368,517 / 368,517 (500 voices in each config) |
472
+ | every source-clip reference is `<voice>__<block>__<cell>__<lang>.cNNN` with `voice` in the 500 | 1,423,254 / 1,423,254 (`cfg`, index + `caption_tpl`) · 737,034 / 737,034 (`p2`); **0** matches to any real-speech or broadcast uid pattern |
473
+ | every row has an entry in its `pairs_index.parquet` | 474,418 / 474,418 · 368,517 / 368,517 |
474
+ | sample join, 200 rows per family: role, `voice_key`, `frames`, `rej_frames` agree with the index | 200 / 200 on `cfg_high`, `cfg_low`, `p2_emox`; 82 / 82 on `p2_len` |
475
+ | code buffer length `== frames × 12 × 2` for `codes`, `rej_codes`, `ref_codes` | 682 / 682 sampled rows |
476
+ | all codes in 0..1023 | 682 / 682 |
477
+ | `abs(frames − round(dur_s × 12.5)) ≤ 1` | 682 / 682 |
478
+ | `cut`: `rej_codes` is a frame-aligned prefix of `codes` | 41 / 41 sampled |
479
+ | `ext`: `rej_codes` begins with all of `codes` | 41 / 41 sampled |
480
+ | frame tolerance `|f_hi − f_lo| ≤ 0.10 · min` | 237,209 / 237,209 `cfg` base pairs · 309,128 / 309,128 `p2_emox` rows |
481
+ | frames and `dur_s` against the released annotated index (`moss_frames`, `dur_s`) | 1,322 / 1,322 clip references at ratio 1.00 — the corrected tokenisation |
482
+ | `has_ref` | true on every row |
483
+ | `in_extreme`, `caption_script`, `caption_tpl_text` | always false / empty / empty, all rows |
484
+ | overlap with `laion/laion-voice-profiles-dpo` and `laion/tts-realspeech-dpo-en-de` | 7,410,723 sister rows read; **0** identical pairs; 0 / 800 sampled row uids present there |
485
+ | files on the Hub vs. local, `HfApi.repo_info(files_metadata=True)` | **258 / 258** files, size and LFS sha256 identical, **6,509,255,583 bytes** |
486
+
487
+ Each check re-derives a property from a quantity other than the one the writer used — frames
488
+ against `dur_s`, code length against the declared frame count, the row's frames against the pair
489
+ index, the pair index against the released annotated index — rather than re-running the builders.
490
+
491
+ ---
492
+
493
+ ## Licence and attribution
494
+
495
+ **CC-BY-4.0.** Credit **Christoph Schuhmann** and **LAION**, and the upstream sources listed in
496
+ `laion/laion-voice-profiles-annotated`. Every clip referenced here is model output from one of the
497
+ 500 synthetic profiles; no take is a recording of a person, and no clip, transcript or timeline from
498
+ the project's real-speech or broadcast corpora is included.
499
+
500
+ ```bibtex
501
+ @misc{schuhmann2026voiceprofilesdpocfg,
502
+ title = {LAION Voice Profiles -- contrastive DPO pairs (CFG + phase 2)},
503
+ author = {Schuhmann, Christoph and LAION},
504
+ year = {2026},
505
+ url = {https://huggingface.co/datasets/laion/laion-voice-profiles-dpo-cfg}
506
+ }
507
+ ```
code/build_cfg.py ADDED
@@ -0,0 +1,401 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Classifier-free-guidance CONTRAST PAIRS for the DPO corpus.
3
+
4
+ THE MEASURED PROBLEM. The round-3 evaluation asks for percentile 0.90-0.98 of a named emotion and
5
+ the model lands at 0.34 on the zero-point-corrected scale. Everything the model has been trained
6
+ on told it ABOUT an emotion; nothing ever made two clips compete on HOW STRONGLY one dimension is
7
+ expressed. Intensity was described, never contrasted.
8
+
9
+ THE PAIR. For one voice and one measured dimension, take a clip in the top 1 % of THAT VOICE's
10
+ own distribution and a clip in its bottom 1 %, and put them against each other under ONE prompt:
11
+
12
+ * SAME VOICE (`voice_key`). Across voices the preference would be decidable from speaker
13
+ identity, and the model would learn to pick a speaker rather than a level.
14
+ * FRAME BUDGET within 10 %. A DPO pair shares one prompt and therefore one `Tokens:` value.
15
+ If the two clips differ in length the preference is decidable from length -- which is the one
16
+ thing the round-1 corpus already over-taught -- and nothing about intensity would be learned.
17
+ * NO WORDS. `cfg_free_text` renders every speech chunk as `...` and keeps every tag: the
18
+ pauses, the per-segment durations, the burst labels and lengths, the delivery direction and
19
+ the token budget. Two clips of the same voice say different words; leaving the words in
20
+ would make the preference decidable from the transcript.
21
+ * BOTH ROLES. Every pair is emitted TWICE, flipped: with the instruction asking for the
22
+ dimension HIGH the high clip is chosen, and with the instruction asking for it LOW the low
23
+ clip is chosen. This is the whole point. Each clip therefore appears as chosen in one row
24
+ and as rejected in another, so a policy that simply prefers louder/denser audio scores 50 %
25
+ and the only way to win is to condition on the instruction.
26
+
27
+ THE MEASURED VALUE IS THE HINDSIGHT ONE. Clips are ranked by the value the annotation model
28
+ MEASURED on the finished audio (`emo40` / `vn57` in corpus v2), never by what the generating
29
+ prompt asked for and never by the uid's intended emotion bucket. For the voice-profile corpus
30
+ those two disagree often enough to matter: a clip generated "for Anger" is not necessarily in the
31
+ top of the Anger head.
32
+
33
+ DIMENSIONS. All 40 emotion heads, plus the 15 VoiceNet ordinal ladders from the project's own
34
+ caption vocabulary (`tokcorpus/code/caption2.py` L7) that describe HOW something is spoken. The
35
+ identity, recording-quality and content heads (AGEV, GEND, RCQL, BKGN, ESTH, EXPL) are excluded:
36
+ they are not things a performer can be asked to do. The ladder-to-column mapping and its polarity
37
+ were verified empirically on 147,190 corpus rows -- mean `vn57` value rises monotonically with the
38
+ caption's own ladder bucket on every one of the 15.
39
+
40
+ HOW THE LEVEL IS STATED IN THE PROMPT.
41
+ * emotion dims: through the two channels the corpus already uses, so the surface stays in
42
+ distribution. `caption_general` gets the corpus's own opening sentence for that emotion at
43
+ the requested band plus a `reads as <emotion>` clause, which is what `directions.
44
+ emotions_from_row` reads; `emo_strength` is set so `prompt_lib2._band` returns the requested
45
+ band, which is what picks the intensity adverb of the inline direction. The two rows of a
46
+ pair differ in the band word and in nothing else.
47
+ * VoiceNet dims: those have no emotion to name, so the row carries `cfg_neutral`, which
48
+ overrides `directions.NEUTRAL` for the emotion-free branch and states the ladder tag the
49
+ clip actually measured at ("very tense, and hold it there").
50
+ """
51
+ import argparse, glob, hashlib, json, os, random, re, sys, time
52
+ from collections import defaultdict
53
+ import numpy as np
54
+ import pyarrow as pa
55
+ import pyarrow.parquet as pq
56
+
57
+ NB = "/e/data1/datasets/playground/mmlaion/schuhmann1/dramabox"
58
+ sys.path[:0] = [f"{NB}/train2/code", f"{NB}/train2/code/grpo"]
59
+ import directions as DIR
60
+ from select_emo1 import VN_ORDER, emo_names
61
+ import reward as RW
62
+
63
+ SRC = f"{NB}/train2/corpus"
64
+ WORK = "/e/scratch/reformo/schuhmann1_moss/cfg_work"
65
+ PAIRS = f"{WORK}/cfg_pairs.parquet"
66
+ ROWS = "/e/scratch/reformo/schuhmann1_moss/cfg_rows"
67
+ NBUCKET = 128
68
+
69
+ TAIL_MIN = 24 # "top N / bottom N" floor when 1 % of the voice is smaller than this
70
+ TAIL_FRAC = 0.01
71
+ PAIRS_PER_CELL = 9 # base pairs; each is emitted twice (flipped), so 18 rows per cell
72
+ FRAME_TOL = 0.10 # |f_hi - f_lo| <= FRAME_TOL * min(f_hi, f_lo)
73
+ GAP_IQR = 0.25 # emotion dims: required separation, as a fraction of the corpus IQR
74
+
75
+ # The 15 VoiceNet ordinal ladders that describe HOW something is spoken, with the caption clause
76
+ # they belong to. Verbatim from tokcorpus/code/caption2.py L7 (post-2026-08-22 polarity fix).
77
+ VN_LADDER = {
78
+ "AROU": ("delivery", ["lethargic","very low-energy","subdued","normally alert","energised","highly aroused","frantic"]),
79
+ "VALN": ("affect", ["deeply negative","negative","mildly negative","neutral","mildly positive","positive","elated"]),
80
+ "TEMP": ("delivery", ["very slow","slow","measured","normal-paced","brisk","fast","very fast"]),
81
+ "WARM": ("timbre", ["cold","cool","slightly cool","neutral-toned","slightly warm","warm","very warm"]),
82
+ "BRGT": ("timbre", ["very dark","dark","slightly dark","neutral-bright","slightly bright","bright","very bright"]),
83
+ "TENS": ("delivery", ["fully relaxed","relaxed","slightly relaxed","neutral tension","slightly tense","tense","very tense"]),
84
+ "VOLT": ("delivery", ["completely steady","steady","fairly steady","moderately variable","variable","volatile","highly volatile"]),
85
+ "ROUG": ("timbre", ["very smooth","smooth","fairly smooth","slightly rough","rough","very rough","gravelly"]),
86
+ "CLRT": ("speech", ["very slurred","slurred","somewhat unclear","average clarity","clear","very clear","crisply articulate"]),
87
+ "DFLU": ("speech", ["no disfluency","almost no disfluency","little disfluency","some disfluency","frequent disfluency","heavy disfluency","severely disfluent"]),
88
+ "RESP": ("speech", ["no audible breath","minimal breath","light breath","normal breath","audible breath","heavy breath","breathless"]),
89
+ "RANG": ("speech", ["monotone pitch","narrow pitch range","fairly narrow pitch","moderate pitch range","wide pitch range","very wide pitch range","extreme pitch range"]),
90
+ "FULL": ("timbre", ["very thin","thin","slightly thin","balanced body","full","very full","booming"]),
91
+ "VULN": ("affect", ["guarded","fairly guarded","slightly guarded","neutral openness","slightly vulnerable","vulnerable","very vulnerable"]),
92
+ "STNC": ("affect", ["very submissive","submissive","slightly submissive","neutral stance","slightly dominant","dominant","very dominant"]),
93
+ }
94
+ VN_DIMS = list(VN_LADDER)
95
+
96
+ SCHEMA = pa.schema([
97
+ ("uid", pa.string()), ("family", pa.string()), ("src", pa.int8()),
98
+ ("voice_key", pa.string()), ("lang", pa.string()),
99
+ ("text", pa.string()), ("text_bursts", pa.string()),
100
+ ("caption_general", pa.string()), ("caption_script", pa.string()),
101
+ ("caption_tpl_text", pa.string()), ("caption_tpl", pa.string()),
102
+ ("speaker_name", pa.string()), ("spoken_dur_s", pa.float32()), ("dur_s", pa.float32()),
103
+ ("words_json", pa.string()),
104
+ ("burst_starts", pa.list_(pa.float32())), ("burst_ends", pa.list_(pa.float32())),
105
+ ("burst_labels", pa.list_(pa.string())), ("in_extreme", pa.bool_()),
106
+ ("frames", pa.int32()), ("codes", pa.binary()),
107
+ ("rej_frames", pa.int32()), ("rej_codes", pa.binary()),
108
+ ("ref_frames", pa.int32()), ("ref_codes", pa.binary()), ("has_ref", pa.bool_()),
109
+ ("is_val", pa.bool_()),
110
+ # ---- new in the CFG build; both are no-ops when absent/False/null
111
+ ("cfg_free_text", pa.bool_()), ("cfg_neutral", pa.string()),
112
+ ("emo_strength", pa.float32()),
113
+ ])
114
+
115
+ PAIR_SCHEMA = pa.schema([
116
+ ("pair_id", pa.string()), ("voice_key", pa.string()), ("dim", pa.string()),
117
+ ("kind", pa.string()), # "emo" | "vn"
118
+ ("hi_uid", pa.string()), ("lo_uid", pa.string()),
119
+ ("hi_val", pa.float32()), ("lo_val", pa.float32()),
120
+ ("hi_frames", pa.int32()), ("lo_frames", pa.int32()),
121
+ ("hi_pct", pa.float32()), ("lo_pct", pa.float32()), # corrected ecdf pct (emo) or bucket (vn)
122
+ ])
123
+
124
+
125
+ def _uid_hash(u):
126
+ return int.from_bytes(hashlib.blake2b(u.encode(), digest_size=8).digest(), "big")
127
+
128
+
129
+ # ------------------------------------------------------------------ stage 1: choose the pairs
130
+ LIGHT = ["uid", "src", "voice_key", "frames", "dur_s", "is_val", "emo40", "vn57"]
131
+
132
+
133
+ def stage_select():
134
+ E = emo_names()
135
+ ecdf = RW.Ecdf()
136
+ fs = sorted(glob.glob(f"{SRC}/shard-*.parquet"))
137
+ uids, vk, fr, dur, Em, Vm = [], [], [], [], [], []
138
+ t0 = time.time()
139
+ st = defaultdict(int)
140
+ for k, f in enumerate(fs):
141
+ d = pq.read_table(f, columns=LIGHT).to_pydict()
142
+ keep = [i for i in range(len(d["uid"]))
143
+ if d["src"][i] == 0 and not d["is_val"][i] and (d["frames"][i] or 0) > 0]
144
+ st["rows_total"] += len(d["uid"])
145
+ st["rows_vp_train"] += len(keep)
146
+ if not keep:
147
+ continue
148
+ uids += [d["uid"][i] for i in keep]
149
+ vk += [d["voice_key"][i] for i in keep]
150
+ fr += [int(d["frames"][i]) for i in keep]
151
+ dur += [float(d["dur_s"][i] or 0.0) for i in keep]
152
+ Em.append(np.stack([np.frombuffer(d["emo40"][i], np.float32) for i in keep]))
153
+ Vm.append(np.stack([np.frombuffer(d["vn57"][i], np.float32) for i in keep]))
154
+ if k % 32 == 0:
155
+ print(f"[sel] {k+1}/{len(fs)} rows={len(uids):,} {time.time()-t0:.0f}s", flush=True)
156
+ Em = np.concatenate(Em, 0)
157
+ Vm = np.concatenate(Vm, 0)
158
+ fr = np.asarray(fr, np.int32)
159
+ dur = np.asarray(dur, np.float32)
160
+ n = len(uids)
161
+ print(f"[sel] voice-profile training clips {n:,} emo40={Em.shape} vn57={Vm.shape}", flush=True)
162
+
163
+ # corpus IQR per emotion head -> the minimum separation a pair must show
164
+ emo_gap = {}
165
+ for j, h in enumerate(E):
166
+ q1, q3 = np.percentile(Em[:, j], [25, 75])
167
+ emo_gap[h] = float(GAP_IQR * max(q3 - q1, 1e-9))
168
+
169
+ by_voice = defaultdict(list)
170
+ for i, v in enumerate(vk):
171
+ by_voice[v].append(i)
172
+ print(f"[sel] voices {len(by_voice):,}", flush=True)
173
+
174
+ rows = []
175
+ rng = random.Random(90210)
176
+ for vi, (voice, idx) in enumerate(sorted(by_voice.items())):
177
+ idx = np.asarray(idx)
178
+ N = max(TAIL_MIN, int(round(TAIL_FRAC * len(idx))))
179
+ if len(idx) < 2 * N:
180
+ st["voice_too_small"] += 1
181
+ continue
182
+ st["voices_used"] += 1
183
+ for kind, dims in (("emo", E), ("vn", VN_DIMS)):
184
+ for dj, dim in enumerate(dims):
185
+ jj = -1 if kind == "emo" else VN_ORDER.index(dim)
186
+ col = (Em[idx, dj] if kind == "emo" else Vm[idx, jj])
187
+ order = np.argsort(col, kind="stable")
188
+ lo_i = idx[order[:N]]
189
+ hi_i = idx[order[-N:]][::-1] # strongest first
190
+ st["cells"] += 1
191
+ # value gate
192
+ if kind == "emo":
193
+ gap = emo_gap[dim]
194
+ ok_pair = lambda a, b: (Em[a, dj] - Em[b, dj]) >= gap
195
+ else:
196
+ L = VN_LADDER[dim][1]
197
+ nb = len(L) - 1
198
+ bk = lambda x: int(min(nb, max(0, round(float(x)))))
199
+ ok_pair = lambda a, b, _j=jj: bk(Vm[a, _j]) > bk(Vm[b, _j])
200
+ # greedy: strongest high first, matched to the weakest low whose frame budget is
201
+ # within tolerance and whose value gap clears the gate
202
+ used = set()
203
+ got = []
204
+ for a in hi_i:
205
+ if len(got) >= PAIRS_PER_CELL:
206
+ break
207
+ best, bestd = None, 1e18
208
+ for b in lo_i:
209
+ if b in used or not ok_pair(a, b):
210
+ continue
211
+ fa, fb = int(fr[a]), int(fr[b])
212
+ if abs(fa - fb) > FRAME_TOL * min(fa, fb):
213
+ continue
214
+ d2 = abs(fa - fb)
215
+ if d2 < bestd:
216
+ best, bestd = b, d2
217
+ if best is None:
218
+ st[f"{kind}_no_partner"] += 1
219
+ continue
220
+ used.add(best)
221
+ got.append((int(a), int(best)))
222
+ if not got:
223
+ st[f"{kind}_cell_empty"] += 1
224
+ continue
225
+ st[f"{kind}_cell_ok"] += 1
226
+ st[f"{kind}_pairs"] += len(got)
227
+ for (a, b) in got:
228
+ if kind == "emo":
229
+ hv, lv = float(Em[a, dj]), float(Em[b, dj])
230
+ hp = ecdf.emo_pct(dim, hv)
231
+ lp = ecdf.emo_pct(dim, lv)
232
+ else:
233
+ hv, lv = float(Vm[a, jj]), float(Vm[b, jj])
234
+ L = VN_LADDER[dim][1]
235
+ hp = float(min(len(L) - 1, max(0, round(hv))))
236
+ lp = float(min(len(L) - 1, max(0, round(lv))))
237
+ pid = hashlib.blake2b(f"{dim}|{uids[a]}|{uids[b]}".encode(),
238
+ digest_size=10).hexdigest()
239
+ rows.append((pid, voice, dim, kind, uids[a], uids[b], hv, lv,
240
+ int(fr[a]), int(fr[b]), hp, lp))
241
+ if vi % 50 == 0:
242
+ print(f"[sel] voice {vi+1}/{len(by_voice)} pairs={len(rows):,} "
243
+ f"{time.time()-t0:.0f}s", flush=True)
244
+
245
+ os.makedirs(WORK, exist_ok=True)
246
+ cols = list(zip(*rows))
247
+ pq.write_table(pa.Table.from_arrays([pa.array(c, type=f.type)
248
+ for c, f in zip(cols, PAIR_SCHEMA)],
249
+ schema=PAIR_SCHEMA), PAIRS, compression="zstd")
250
+ st["base_pairs"] = len(rows)
251
+ st["emitted_rows"] = 2 * len(rows)
252
+ json.dump(dict(st), open(f"{WORK}/select_stats.json", "w"), indent=1)
253
+ print(json.dumps(dict(st), indent=1), flush=True)
254
+ print(f"[sel] wrote {PAIRS} base_pairs={len(rows):,} rows={2*len(rows):,}", flush=True)
255
+
256
+
257
+ # ------------------------------------------------------------------ stage 2: materialise rows
258
+ FULL = ["uid", "voice_key", "lang", "text", "text_bursts", "speaker_name", "words_json",
259
+ "burst_starts", "burst_ends", "burst_labels", "spoken_dur_s", "dur_s",
260
+ "frames", "codes", "ref_frames", "ref_codes", "has_ref"]
261
+
262
+ BANDS = (("extreme", 0.98), ("intense", 0.90), ("moderate", 0.70), ("faint", 0.0))
263
+
264
+
265
+ def _band_of(es):
266
+ for name, lo in BANDS:
267
+ if es >= lo:
268
+ return name
269
+ return "faint"
270
+
271
+
272
+ # `directions.EMO_PROSE` is written for the EXPRESSED extreme of each emotion ("a furious voice,
273
+ # seething and exploding into a rant"). Pasted behind a faint band phrase it produces "A voice
274
+ # faintly expressing anger, a furious voice, seething and exploding into a rant" -- two
275
+ # instructions in one sentence, which is the exact failure `directions.py` exists to remove. The
276
+ # faint side therefore gets its own tail instead of the corpus prose. It is generic on purpose:
277
+ # there is no harvested suppressed-side prose per emotion, and inventing forty of them would put
278
+ # forty untested sentences into a fifth of the corpus.
279
+ FAINT_TAIL = ["only a trace of it, kept almost out of the voice, the rest an ordinary plain read",
280
+ "barely there, held down and mostly absent, otherwise a plain everyday delivery",
281
+ "just a hint of it and no more, the delivery otherwise unremarkable and level"]
282
+
283
+
284
+ def _emo_caption(emo, band, rng):
285
+ """The corpus's own opening sentence for `emo` at `band`, plus the `reads as` clause that
286
+ `directions.emotions_from_row` reads back. The high and the low row of a pair differ in the
287
+ band phrase and in the prose tail that matches it, and in nothing else."""
288
+ head = rng.choice(DIR.BAND_PHRASE.get(band, DIR.BAND_PHRASE["moderate"]))
289
+ noun = DIR.NOUN.get(emo, DIR.pretty(emo))
290
+ prose = rng.choice(FAINT_TAIL) if band == "faint" else DIR.EMO_PROSE.get(emo, "")
291
+ reads = emo.replace("_", " ").lower()
292
+ return f"A voice {head} expressing {noun}, {prose}; reads as {reads}"
293
+
294
+
295
+ def _vn_caption(dim, bucket):
296
+ clause, L = VN_LADDER[dim]
297
+ tag = L[int(bucket)]
298
+ return f"A voice; {clause} is {tag}", tag
299
+
300
+
301
+ def stage_rows():
302
+ P = pq.read_table(PAIRS).to_pydict()
303
+ npair = len(P["pair_id"])
304
+ need = set(P["hi_uid"]) | set(P["lo_uid"])
305
+ print(f"[rows] {npair:,} base pairs, {len(need):,} distinct clips needed", flush=True)
306
+
307
+ # what the chosen role needs (everything) and what the rejected role needs (codes only)
308
+ rec, rej = {}, {}
309
+ need_ch = set(P["hi_uid"]) | set(P["lo_uid"]) # both roles appear as chosen
310
+ fs = sorted(glob.glob(f"{SRC}/shard-*.parquet"))
311
+ t0 = time.time()
312
+ for k, f in enumerate(fs):
313
+ t = pq.read_table(f, columns=FULL)
314
+ u = t["uid"].to_pylist()
315
+ sel = [i for i, x in enumerate(u) if x in need_ch]
316
+ if sel:
317
+ d = t.take(pa.array(sel)).to_pylist()
318
+ for r in d:
319
+ rec[r["uid"]] = r
320
+ if k % 16 == 0:
321
+ print(f"[rows] shard {k+1}/{len(fs)} cached={len(rec):,} {time.time()-t0:.0f}s",
322
+ flush=True)
323
+ print(f"[rows] cached {len(rec):,}/{len(need):,} clips {time.time()-t0:.0f}s", flush=True)
324
+
325
+ st = defaultdict(int)
326
+ buckets = defaultdict(list)
327
+ rng = random.Random(31337)
328
+ for i in range(npair):
329
+ hi, lo = P["hi_uid"][i], P["lo_uid"][i]
330
+ a, b = rec.get(hi), rec.get(lo)
331
+ if a is None or b is None or not a["codes"] or not b["codes"]:
332
+ st["missing_clip"] += 1
333
+ continue
334
+ dim, kind, pid = P["dim"][i], P["kind"][i], P["pair_id"][i]
335
+ for role in ("high", "low"):
336
+ ch, rj = (a, b) if role == "high" else (b, a)
337
+ uid = f"cfg{pid}{'h' if role == 'high' else 'l'}"
338
+ uh = _uid_hash(uid)
339
+ rr = random.Random(uh & 0xFFFFFFFF)
340
+ if kind == "emo":
341
+ pct = float(P["hi_pct"][i] if role == "high" else P["lo_pct"][i])
342
+ # THE BAND WORD. A CFG pair teaches a DIRECTION on one dimension: the two clips
343
+ # are the top and the bottom of ONE VOICE's own range, and the high clip is at
344
+ # corrected corpus percentile 0.998 (median) as well, so both "intensely" and
345
+ # "overwhelmingly" are true of it. The round-3 failure is that BOTH words produce
346
+ # 0.34, so both are given the same contrastive target and the high role alternates
347
+ # between them by uid hash. Absolute calibration BETWEEN intense and extreme is
348
+ # not something a two-point contrast can teach and is not what is broken.
349
+ es = (0.99 if (uh & 1) else 0.95) if role == "high" else min(pct, 0.60)
350
+ band = _band_of(es)
351
+ cap = _emo_caption(dim, band, rr)
352
+ neutral = ""
353
+ st[f"band_{band}"] += 1
354
+ else:
355
+ bucket = int(P["hi_pct"][i] if role == "high" else P["lo_pct"][i])
356
+ cap, tag = _vn_caption(dim, bucket)
357
+ neutral = (f"{tag}, and hold it there; otherwise exactly as this voice "
358
+ f"normally speaks")
359
+ es = None
360
+ buckets[uh % NBUCKET].append({
361
+ "uid": uid, "family": f"cfg_{role}", "src": 0,
362
+ "voice_key": ch["voice_key"] or "", "lang": ch["lang"] or "en",
363
+ "text": ch["text"] or "", "text_bursts": ch["text_bursts"] or ch["text"] or "",
364
+ "caption_general": cap, "caption_script": "",
365
+ "caption_tpl_text": "", "caption_tpl": f"cfg|{kind}|{dim}|{hi}|{lo}",
366
+ "speaker_name": ch["speaker_name"] or "",
367
+ "spoken_dur_s": float(ch["spoken_dur_s"] or 0.0),
368
+ "dur_s": float(ch["dur_s"] or 0.0), "words_json": ch["words_json"] or "[]",
369
+ "burst_starts": [float(x) for x in (ch["burst_starts"] or [])],
370
+ "burst_ends": [float(x) for x in (ch["burst_ends"] or [])],
371
+ "burst_labels": [str(x) for x in (ch["burst_labels"] or [])],
372
+ "in_extreme": False,
373
+ "frames": int(ch["frames"]), "codes": ch["codes"],
374
+ "rej_frames": int(rj["frames"]), "rej_codes": rj["codes"],
375
+ "ref_frames": int(ch["ref_frames"] or 0) if ch["has_ref"] else 0,
376
+ "ref_codes": ch["ref_codes"] if ch["has_ref"] else b"",
377
+ "has_ref": bool(ch["has_ref"]),
378
+ "is_val": uh % 1000 == 0,
379
+ "cfg_free_text": True, "cfg_neutral": neutral,
380
+ "emo_strength": es,
381
+ })
382
+ st[f"rows_{kind}_{role}"] += 1
383
+ os.makedirs(ROWS, exist_ok=True)
384
+ tot = 0
385
+ for b in range(NBUCKET):
386
+ rs = buckets.get(b, [])
387
+ cols = {n: [r[n] for r in rs] for n in SCHEMA.names}
388
+ pq.write_table(pa.Table.from_pydict(cols, schema=SCHEMA),
389
+ f"{ROWS}/shard-{b:03d}.parquet", compression="zstd", row_group_size=150)
390
+ tot += len(rs)
391
+ st["rows_written"] = tot
392
+ json.dump(dict(st), open(f"{WORK}/rows_stats.json", "w"), indent=1)
393
+ print(json.dumps(dict(st), indent=1), flush=True)
394
+ print(f"[rows] wrote {tot:,} rows to {ROWS}", flush=True)
395
+
396
+
397
+ if __name__ == "__main__":
398
+ ap = argparse.ArgumentParser()
399
+ ap.add_argument("stage", choices=("select", "rows"))
400
+ a = ap.parse_args()
401
+ (stage_select if a.stage == "select" else stage_rows)()
code/build_pairs2.py ADDED
@@ -0,0 +1,287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Two new DPO pair families: emotion-contrastive (selectivity) and length-contrastive (duration).
3
+
4
+ WHY THESE TWO, AND WHY NOW.
5
+
6
+ The round-3 measurements say two different things are broken, and they need two different contrasts.
7
+
8
+ 1. SELECTIVITY. The per-emotion LoRAs raise their own emotion by +0.047 when it is asked for --
9
+ and by +0.033 when it is NOT (17 adapters, same three speakers, identical prompts). A ratio
10
+ of 1.4 : 1 is not control, it is tinting. Every contrast built so far pits an INTENSE clip
11
+ against a MILD one, so a model can win by being generically expressive. Family A pits
12
+ intense against intense: same speaker, same length, emotion A against emotion B, and the
13
+ instruction names A. Turning the intensity up is then worth nothing; only listening to the
14
+ instruction is.
15
+
16
+ 2. DURATION, CONDITIONED ON THE DIMENSION. The corpus already has truncation and continuation
17
+ families, but they know nothing about emotion, so they teach "the right length is better" in
18
+ the abstract. Family B keeps the speaker, the text and the emotion fixed and varies ONLY the
19
+ length: chosen is the clip at its true duration, rejected is the same clip cut short or run
20
+ long. The prompt states that emotion and that duration, so what is learned is "this emotion
21
+ AT this length" rather than a length prior.
22
+
23
+ THE TEXT FIELD DIFFERS BETWEEN THE TWO, DELIBERATELY.
24
+
25
+ * Family A: chosen and rejected are DIFFERENT recordings with different words, and there is only
26
+ one prompt for the pair, so the words must not be in it -- otherwise the preference is
27
+ decidable from the text alone. Free text (`...`), like the existing CFG rows.
28
+ * Family B: chosen and rejected are the SAME recording at two lengths, so the words are shared
29
+ and belong in the prompt. The full timed script is used, because the timing tags are exactly
30
+ what the rejected side violates.
31
+
32
+ Both families take the emotion from the MEASURED value, never from the prompt that generated the
33
+ clip: the chosen side's top emotion has to be the dimension being asked for.
34
+ """
35
+ import argparse, glob, json, os, random, sys, time
36
+ from collections import defaultdict
37
+
38
+ import numpy as np
39
+ import pyarrow as pa
40
+ import pyarrow.parquet as pq
41
+
42
+ NB = "/e/data1/datasets/playground/mmlaion/schuhmann1/dramabox"
43
+ SC = "/e/scratch/reformo/schuhmann1_moss"
44
+ sys.path[:0] = [f"{NB}/train2/code", f"{NB}/train2/code/grpo"]
45
+ import reward as RW
46
+ from build_cfg import (SCHEMA, LIGHT, FULL, SRC, NBUCKET, emo_names, _uid_hash, _emo_caption,
47
+ _band_of)
48
+
49
+ WORK = f"{SC}/pairs2_work"
50
+ PAIRS = f"{WORK}/pairs2.parquet"
51
+ ROWS = f"{SC}/pairs2_rows"
52
+
53
+ HI_PCT = 0.90 # the chosen side must actually be intense on the asked-for head
54
+ LO_PCT = 0.50 # ... and the rejected side must not be
55
+ FRAME_TOL = 0.10
56
+ EMOX_PER_CELL = 8 # base pairs per (voice, emotion); each is emitted once per direction
57
+ LEN_PER_CELL = 6
58
+ CUT_LO, CUT_HI = 0.50, 0.75 # truncation keeps this fraction of the frames
59
+ EXT_LO, EXT_HI = 1.25, 1.50 # extension runs this many times the frames
60
+
61
+ PAIR_SCHEMA = pa.schema([
62
+ ("pair_id", pa.string()), ("family", pa.string()), ("voice_key", pa.string()),
63
+ ("dim", pa.string()), ("ch_uid", pa.string()), ("rj_uid", pa.string()),
64
+ ("ch_pct", pa.float32()), ("rj_pct", pa.float32()),
65
+ ("ch_frames", pa.int32()), ("rj_frames", pa.int32()),
66
+ ("mode", pa.string()), # emox | cut | ext
67
+ ("cut_frames", pa.int32()),
68
+ ])
69
+
70
+
71
+ def log(m):
72
+ print(f"[{time.strftime('%H:%M:%S')}] {m}", flush=True)
73
+
74
+
75
+ def stage_select():
76
+ E = emo_names()
77
+ ecdf = RW.Ecdf()
78
+ fs = sorted(glob.glob(f"{SRC}/shard-*.parquet"))
79
+ uids, vk, fr = [], [], []
80
+ Em = []
81
+ st = defaultdict(int)
82
+ for k, f in enumerate(fs):
83
+ d = pq.read_table(f, columns=LIGHT).to_pydict()
84
+ keep = [i for i in range(len(d["uid"]))
85
+ if d["src"][i] == 0 and not d["is_val"][i] and (d["frames"][i] or 0) > 0]
86
+ st["rows_total"] += len(d["uid"]); st["rows_vp_train"] += len(keep)
87
+ if not keep:
88
+ continue
89
+ uids += [d["uid"][i] for i in keep]
90
+ vk += [d["voice_key"][i] for i in keep]
91
+ fr += [int(d["frames"][i]) for i in keep]
92
+ Em.append(np.stack([np.frombuffer(d["emo40"][i], np.float32) for i in keep]))
93
+ if k % 32 == 0:
94
+ log(f"[sel] {k+1}/{len(fs)} rows={len(uids):,}")
95
+ Em = np.concatenate(Em, 0)
96
+ fr = np.asarray(fr, np.int32)
97
+ n = len(uids)
98
+ log(f"[sel] {n:,} voice-profile training clips")
99
+
100
+ # corrected percentile per head, once
101
+ P = np.zeros_like(Em)
102
+ for j, h in enumerate(E):
103
+ P[:, j] = [ecdf.emo_pct(h, float(x)) for x in Em[:, j]]
104
+ top = P.argmax(1)
105
+ topv = P.max(1)
106
+ log("[sel] percentiles done")
107
+
108
+ by_voice = defaultdict(list)
109
+ for i, v in enumerate(vk):
110
+ by_voice[v].append(i)
111
+
112
+ rows = []
113
+ rng = random.Random(4711)
114
+ for voice, idx in sorted(by_voice.items()):
115
+ idx = np.asarray(idx)
116
+ # ---------- family A: emotion vs emotion, same voice, same length
117
+ for j, h in enumerate(E):
118
+ hi = idx[(P[idx, j] >= HI_PCT) & (top[idx] == j)]
119
+ if len(hi) == 0:
120
+ continue
121
+ # partners: intense on SOMETHING ELSE, weak on h
122
+ other = idx[(P[idx, j] <= LO_PCT) & (topv[idx] >= HI_PCT) & (top[idx] != j)]
123
+ if len(other) == 0:
124
+ st["emox_no_partner"] += 1
125
+ continue
126
+ made = 0
127
+ for a in rng.sample(list(hi), min(len(hi), EMOX_PER_CELL * 4)):
128
+ cand = other[np.abs(fr[other] - fr[a]) <= FRAME_TOL * np.minimum(fr[other], fr[a])]
129
+ if len(cand) == 0:
130
+ continue
131
+ b = int(rng.choice(list(cand)))
132
+ rows.append(("emox", voice, h, uids[a], uids[b], float(P[a, j]), float(P[b, j]),
133
+ int(fr[a]), int(fr[b]), "emox", 0))
134
+ # the mirror: name the partner's own top emotion, roles swap
135
+ hb = E[int(top[b])]
136
+ rows.append(("emox", voice, hb, uids[b], uids[a], float(P[b, top[b]]),
137
+ float(P[a, top[b]]), int(fr[b]), int(fr[a]), "emox", 0))
138
+ made += 1
139
+ if made >= EMOX_PER_CELL:
140
+ break
141
+ st["emox_cells"] += 1
142
+ st["emox_pairs"] += made
143
+ # ---------- family B: same clip, right length vs wrong length
144
+ strong = idx[topv[idx] >= HI_PCT]
145
+ if len(strong) == 0:
146
+ continue
147
+ for a in rng.sample(list(strong), min(len(strong), LEN_PER_CELL * 20)):
148
+ h = E[int(top[a])]
149
+ f0 = int(fr[a])
150
+ if f0 < 40:
151
+ continue
152
+ if rng.random() < 0.5:
153
+ cut = max(20, int(f0 * rng.uniform(CUT_LO, CUT_HI)))
154
+ rows.append(("len", voice, h, uids[a], uids[a], float(topv[a]), float(topv[a]),
155
+ f0, cut, "cut", cut))
156
+ else:
157
+ donor = idx[np.abs(fr[idx] - f0) <= 0.6 * f0]
158
+ donor = donor[donor != a]
159
+ if len(donor) == 0:
160
+ continue
161
+ d = int(rng.choice(list(donor)))
162
+ extra = max(8, int(f0 * rng.uniform(EXT_LO - 1.0, EXT_HI - 1.0)))
163
+ rows.append(("len", voice, h, uids[a], uids[d], float(topv[a]), float(topv[a]),
164
+ f0, extra, "ext", extra))
165
+ st["len_pairs"] += 1
166
+ if st["len_pairs"] % max(1, LEN_PER_CELL) == 0:
167
+ pass
168
+ st["len_cells"] += 1
169
+
170
+ log(f"[sel] {len(rows):,} base pairs")
171
+ os.makedirs(WORK, exist_ok=True)
172
+ cols = list(zip(*rows)) if rows else [[]] * 11
173
+ pq.write_table(pa.Table.from_pydict({
174
+ "pair_id": [f"{i:09d}" for i in range(len(rows))],
175
+ "family": list(cols[0]), "voice_key": list(cols[1]), "dim": list(cols[2]),
176
+ "ch_uid": list(cols[3]), "rj_uid": list(cols[4]),
177
+ "ch_pct": [float(x) for x in cols[5]], "rj_pct": [float(x) for x in cols[6]],
178
+ "ch_frames": [int(x) for x in cols[7]], "rj_frames": [int(x) for x in cols[8]],
179
+ "mode": list(cols[9]), "cut_frames": [int(x) for x in cols[10]],
180
+ }, schema=PAIR_SCHEMA), PAIRS, compression="zstd")
181
+ json.dump(dict(st), open(f"{WORK}/select_stats.json", "w"), indent=1)
182
+ log(json.dumps(dict(st), indent=1))
183
+
184
+
185
+ def _slice_blob(b, frames, keep, n_vq=12):
186
+ a = np.frombuffer(b, np.int16).reshape(int(frames), n_vq)
187
+ return a[:int(keep)].tobytes(), int(keep)
188
+
189
+
190
+ def _cat_blob(b1, f1, b2, f2, extra, n_vq=12):
191
+ a = np.frombuffer(b1, np.int16).reshape(int(f1), n_vq)
192
+ c = np.frombuffer(b2, np.int16).reshape(int(f2), n_vq)[:int(extra)]
193
+ return np.concatenate([a, c], 0).tobytes(), int(f1) + int(c.shape[0])
194
+
195
+
196
+ def stage_rows():
197
+ P = pq.read_table(PAIRS).to_pydict()
198
+ npair = len(P["pair_id"])
199
+ need = set(P["ch_uid"]) | set(P["rj_uid"])
200
+ log(f"[rows] {npair:,} pairs, {len(need):,} distinct clips")
201
+ rec = {}
202
+ fs = sorted(glob.glob(f"{SRC}/shard-*.parquet"))
203
+ for k, f in enumerate(fs):
204
+ t = pq.read_table(f, columns=FULL)
205
+ u = t["uid"].to_pylist()
206
+ sel = [i for i, x in enumerate(u) if x in need]
207
+ if sel:
208
+ for r in t.take(pa.array(sel)).to_pylist():
209
+ rec[r["uid"]] = r
210
+ if k % 16 == 0:
211
+ log(f"[rows] shard {k+1}/{len(fs)} cached={len(rec):,}")
212
+ log(f"[rows] cached {len(rec):,}/{len(need):,}")
213
+
214
+ st = defaultdict(int)
215
+ buckets = defaultdict(list)
216
+ for i in range(npair):
217
+ ch = rec.get(P["ch_uid"][i]); rj = rec.get(P["rj_uid"][i])
218
+ if ch is None or rj is None or not ch["codes"] or not rj["codes"]:
219
+ st["missing"] += 1
220
+ continue
221
+ fam, dim, mode = P["family"][i], P["dim"][i], P["mode"][i]
222
+ uid = f"p2{P['pair_id'][i]}{mode[0]}"
223
+ uh = _uid_hash(uid)
224
+ rr = random.Random(uh & 0xFFFFFFFF)
225
+ try:
226
+ if mode == "emox":
227
+ rb, rf = rj["codes"], int(rj["frames"])
228
+ free_text = True
229
+ elif mode == "cut":
230
+ rb, rf = _slice_blob(ch["codes"], ch["frames"], P["cut_frames"][i])
231
+ free_text = False
232
+ else:
233
+ rb, rf = _cat_blob(ch["codes"], ch["frames"], rj["codes"], rj["frames"],
234
+ P["cut_frames"][i])
235
+ free_text = False
236
+ except Exception:
237
+ st["blob_error"] += 1
238
+ continue
239
+ if rf <= 0 or rf > 620:
240
+ st["rej_len"] += 1
241
+ continue
242
+ # the band word alternates by uid hash: a two-point contrast cannot calibrate BETWEEN
243
+ # intense and extreme, and both are true of a clip at corrected percentile >= 0.90
244
+ es = 0.99 if (uh & 1) else 0.95
245
+ cap = _emo_caption(dim, _band_of(es), rr)
246
+ buckets[uh % NBUCKET].append({
247
+ "uid": uid, "family": f"p2_{fam}", "src": 0,
248
+ "voice_key": ch["voice_key"] or "", "lang": ch["lang"] or "en",
249
+ "text": ch["text"] or "", "text_bursts": ch["text_bursts"] or ch["text"] or "",
250
+ "caption_general": cap, "caption_script": "", "caption_tpl_text": "",
251
+ "caption_tpl": f"p2|{fam}|{mode}|{dim}",
252
+ "speaker_name": ch["speaker_name"] or "",
253
+ "spoken_dur_s": float(ch["spoken_dur_s"] or 0.0),
254
+ "dur_s": float(ch["dur_s"] or 0.0), "words_json": ch["words_json"] or "[]",
255
+ "burst_starts": [float(x) for x in (ch["burst_starts"] or [])],
256
+ "burst_ends": [float(x) for x in (ch["burst_ends"] or [])],
257
+ "burst_labels": [str(x) for x in (ch["burst_labels"] or [])],
258
+ "in_extreme": False,
259
+ "frames": int(ch["frames"]), "codes": ch["codes"],
260
+ "rej_frames": int(rf), "rej_codes": rb,
261
+ "ref_frames": int(ch["ref_frames"] or 0) if ch["has_ref"] else 0,
262
+ "ref_codes": ch["ref_codes"] if ch["has_ref"] else b"",
263
+ "has_ref": bool(ch["has_ref"]),
264
+ "is_val": uh % 1000 == 0,
265
+ "cfg_free_text": free_text, "cfg_neutral": "",
266
+ "emo_strength": es,
267
+ })
268
+ st[f"rows_{mode}"] += 1
269
+ os.makedirs(ROWS, exist_ok=True)
270
+ tot = 0
271
+ for b in range(NBUCKET):
272
+ rs = buckets.get(b, [])
273
+ cols = {nme: [r[nme] for r in rs] for nme in SCHEMA.names}
274
+ pq.write_table(pa.Table.from_pydict(cols, schema=SCHEMA),
275
+ f"{ROWS}/shard-{b:03d}.parquet", compression="zstd", row_group_size=150)
276
+ tot += len(rs)
277
+ st["rows_written"] = tot
278
+ json.dump(dict(st), open(f"{WORK}/rows_stats.json", "w"), indent=1)
279
+ log(json.dumps(dict(st), indent=1))
280
+ log(f"[rows] wrote {tot:,} rows to {ROWS}")
281
+
282
+
283
+ if __name__ == "__main__":
284
+ ap = argparse.ArgumentParser()
285
+ ap.add_argument("stage", choices=("select", "rows"))
286
+ a = ap.parse_args()
287
+ (stage_select if a.stage == "select" else stage_rows)()
code/mix_cfg.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Concatenate the CFG contrast pairs into the round-3 DPO corpus.
3
+
4
+ Shard b of the mix is shard b of `dpo_corpus2` (1,853,486 pairs, already globally shuffled at
5
+ build time) plus shard b of `cfg_rows` (the CFG pairs, bucketed by uid hash, so also globally
6
+ shuffled), permuted together. The three columns the CFG build adds are filled in for the legacy
7
+ rows with the values that make `prompt_lib2` render them byte-identically to before:
8
+ `cfg_free_text=False`, `cfg_neutral=""`, `emo_strength=null` (so `_band` keeps falling back to
9
+ `in_extreme`, exactly as it does when the column is absent).
10
+
11
+ `is_val` is carried through untouched from both sides -- both were assigned by the same
12
+ `uid_hash % 1000 == 0` rule -- so the holdout logic is the one every earlier run used.
13
+ """
14
+ import glob, json, os, sys, time
15
+ import numpy as np, pyarrow as pa, pyarrow.parquet as pq
16
+
17
+ sys.path[:0] = ["/e/data1/datasets/playground/mmlaion/schuhmann1/dramabox/train2/code"]
18
+ from build_cfg import SCHEMA, NBUCKET
19
+
20
+ OLD = "/e/scratch/reformo/schuhmann1_moss/dpo_corpus2"
21
+ CFG = "/e/scratch/reformo/schuhmann1_moss/cfg_rows"
22
+ OUT = "/e/scratch/reformo/schuhmann1_moss/dpo_corpus_cfg"
23
+
24
+
25
+ def run(task, ntask):
26
+ os.makedirs(OUT, exist_ok=True)
27
+ t0 = time.time()
28
+ for b in range(task, NBUCKET, ntask):
29
+ o = pq.read_table(f"{OLD}/shard-{b:03d}.parquet")
30
+ n = o.num_rows
31
+ o = o.append_column("cfg_free_text", pa.array(np.zeros(n, bool)))
32
+ o = o.append_column("cfg_neutral", pa.array([""] * n, pa.string()))
33
+ o = o.append_column("emo_strength", pa.array([None] * n, pa.float32()))
34
+ o = o.select(SCHEMA.names).cast(SCHEMA)
35
+ c = pq.read_table(f"{CFG}/shard-{b:03d}.parquet", schema=SCHEMA)
36
+ t = pa.concat_tables([o, c])
37
+ t = t.take(pa.array(np.random.RandomState(7000 + b).permutation(t.num_rows)))
38
+ pq.write_table(t, f"{OUT}/shard-{b:03d}.parquet", compression="zstd", row_group_size=150)
39
+ print(f"[mix.{task}] shard-{b:03d} old={n} cfg={c.num_rows} out={t.num_rows} "
40
+ f"{time.time()-t0:.0f}s", flush=True)
41
+
42
+
43
+ if __name__ == "__main__":
44
+ run(int(sys.argv[1]), int(sys.argv[2]))
code/mix_pairs2.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Mix the two new pair families into the CFG corpus.
3
+
4
+ The base is `dpo_corpus_cfg` (2,327,904 pairs) rather than `dpo_corpus2`, because the CFG corpus
5
+ produced the best checkpoint measured so far (reward 0.4708, WER 0.0950). Everything the CFG
6
+ corpus already teaches is kept; the new families are added on top, so a difference in the trained
7
+ model is attributable to them alone.
8
+ """
9
+ import glob, json, os, sys
10
+ import numpy as np
11
+ import pyarrow as pa
12
+ import pyarrow.parquet as pq
13
+
14
+ SC = "/e/scratch/reformo/schuhmann1_moss"
15
+ BASE = f"{SC}/dpo_corpus_cfg"
16
+ NEW = f"{SC}/pairs2_rows"
17
+ DST = f"{SC}/dpo_corpus_p2"
18
+ NBUCKET = 128
19
+
20
+
21
+ def main():
22
+ bs = sorted(glob.glob(f"{BASE}/shard-*.parquet"))
23
+ ns = sorted(glob.glob(f"{NEW}/shard-*.parquet"))
24
+ assert bs and ns, (len(bs), len(ns))
25
+ schema = pq.ParquetFile(bs[0]).schema_arrow
26
+ nsch = pq.ParquetFile(ns[0]).schema_arrow
27
+ missing = [f for f in schema.names if f not in nsch.names]
28
+ extra = [f for f in nsch.names if f not in schema.names]
29
+ print(f"base fields {len(schema.names)}, new fields {len(nsch.names)}; "
30
+ f"missing in new {missing}; extra in new {extra}", flush=True)
31
+ os.makedirs(DST, exist_ok=True)
32
+ nb = sum(pq.ParquetFile(f).metadata.num_rows for f in bs)
33
+ nn = sum(pq.ParquetFile(f).metadata.num_rows for f in ns)
34
+ print(f"base {nb:,} + new {nn:,} = {nb+nn:,} (new share {nn/(nb+nn):.1%})", flush=True)
35
+ for b in range(NBUCKET):
36
+ parts = []
37
+ for src in (f"{BASE}/shard-{b:03d}.parquet", f"{NEW}/shard-{b:03d}.parquet"):
38
+ if os.path.exists(src):
39
+ t = pq.read_table(src)
40
+ parts.append(t.select(schema.names) if t.schema != schema else t)
41
+ if not parts:
42
+ continue
43
+ t = pa.concat_tables(parts, promote_options="permissive")
44
+ t = t.take(pa.array(np.random.RandomState(7000 + b).permutation(t.num_rows)))
45
+ pq.write_table(t, f"{DST}/shard-{b:03d}.parquet", compression="zstd", row_group_size=150)
46
+ if b % 16 == 0:
47
+ print(f"[mix] shard {b} rows={t.num_rows}", flush=True)
48
+ tot = sum(pq.ParquetFile(f).metadata.num_rows
49
+ for f in glob.glob(f"{DST}/shard-*.parquet"))
50
+ print(f"[mix] wrote {tot:,} rows to {DST}", flush=True)
51
+
52
+
53
+ if __name__ == "__main__":
54
+ main()
verify.json ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "local": {
3
+ "rows": {
4
+ "cfg": 474418,
5
+ "p2": 368517,
6
+ "families": {
7
+ "cfg_low": 237209,
8
+ "cfg_high": 237209,
9
+ "p2_emox": 309128,
10
+ "p2_len": 59389
11
+ },
12
+ "lang": {
13
+ "cfg": {
14
+ "en": 227068,
15
+ "de": 247350
16
+ },
17
+ "p2": {
18
+ "en": 179649,
19
+ "de": 188868
20
+ }
21
+ }
22
+ },
23
+ "files": {
24
+ "cfg_shards": 128,
25
+ "p2_shards": 128,
26
+ "cfg_bytes": 3668193909,
27
+ "p2_bytes": 2822830198
28
+ },
29
+ "uid_unique": {
30
+ "cfg": 474418,
31
+ "p2": 368517
32
+ },
33
+ "src0_all_rows": {
34
+ "cfg": 474418,
35
+ "p2": 368517
36
+ },
37
+ "voice_in_500": {
38
+ "cfg": 474418,
39
+ "p2": 368517
40
+ },
41
+ "source_uid_allowlisted": {
42
+ "cfg_mentions": 1423254,
43
+ "p2_mentions": 737034,
44
+ "restricted_pattern_hits": 0
45
+ },
46
+ "rows_with_index_entry": {
47
+ "cfg": 474418,
48
+ "p2": 368517
49
+ },
50
+ "distinct_source_clips": {
51
+ "cfg": 332576,
52
+ "p2": 342284
53
+ },
54
+ "has_ref_all": {
55
+ "cfg": 474418,
56
+ "p2": 368517
57
+ },
58
+ "is_val": {
59
+ "cfg": 490,
60
+ "p2": 373
61
+ },
62
+ "constants": {
63
+ "cfg_rows|in_extreme_true": 0,
64
+ "cfg_rows|caption_script_nonempty": 0,
65
+ "cfg_rows|caption_tpl_text_nonempty": 0,
66
+ "cfg_rows|text_bursts_differs": 127992,
67
+ "cfg_rows|speaker_name_empty": 0,
68
+ "cfg_rows|rows": 474418,
69
+ "pairs2_rows|in_extreme_true": 0,
70
+ "pairs2_rows|caption_script_nonempty": 0,
71
+ "pairs2_rows|caption_tpl_text_nonempty": 0,
72
+ "pairs2_rows|text_bursts_differs": 92235,
73
+ "pairs2_rows|speaker_name_empty": 0,
74
+ "pairs2_rows|rows": 368517
75
+ },
76
+ "sample_join_200_per_family": {
77
+ "cfg_high": {
78
+ "tpl_hi_lo_match": 200,
79
+ "fam_role_match": 200,
80
+ "n": 200,
81
+ "voice_match": 200,
82
+ "frames_match_chosen": 200,
83
+ "frames_match_rejected": 200,
84
+ "codes_len_ok": 200,
85
+ "rej_len_ok": 200,
86
+ "codes_range_ok": 200,
87
+ "ref_len_ok": 200,
88
+ "has_ref": 200,
89
+ "frames_vs_dur": 200,
90
+ "ch_uid_shape_ok": 200,
91
+ "rj_uid_shape_ok": 200,
92
+ "ch_voice_prefix": 200,
93
+ "rj_voice_prefix": 200
94
+ },
95
+ "cfg_low": {
96
+ "tpl_hi_lo_match": 200,
97
+ "fam_role_match": 200,
98
+ "n": 200,
99
+ "voice_match": 200,
100
+ "frames_match_chosen": 200,
101
+ "frames_match_rejected": 200,
102
+ "codes_len_ok": 200,
103
+ "rej_len_ok": 200,
104
+ "codes_range_ok": 200,
105
+ "ref_len_ok": 200,
106
+ "has_ref": 200,
107
+ "frames_vs_dur": 200,
108
+ "ch_uid_shape_ok": 200,
109
+ "rj_uid_shape_ok": 200,
110
+ "ch_voice_prefix": 200,
111
+ "rj_voice_prefix": 200
112
+ },
113
+ "p2_emox": {
114
+ "mode_match": 200,
115
+ "fam_match": 200,
116
+ "tpl_dim_match": 200,
117
+ "n": 200,
118
+ "voice_match": 200,
119
+ "frames_match_chosen": 200,
120
+ "frames_match_rejected": 200,
121
+ "codes_len_ok": 200,
122
+ "rej_len_ok": 200,
123
+ "codes_range_ok": 200,
124
+ "ref_len_ok": 200,
125
+ "has_ref": 200,
126
+ "frames_vs_dur": 200,
127
+ "ch_uid_shape_ok": 200,
128
+ "rj_uid_shape_ok": 200,
129
+ "ch_voice_prefix": 200,
130
+ "rj_voice_prefix": 200
131
+ },
132
+ "p2_len": {
133
+ "mode_match": 82,
134
+ "fam_match": 82,
135
+ "tpl_dim_match": 82,
136
+ "n": 82,
137
+ "voice_match": 82,
138
+ "frames_match_chosen": 82,
139
+ "frames_match_rejected": 82,
140
+ "codes_len_ok": 82,
141
+ "rej_len_ok": 82,
142
+ "codes_range_ok": 82,
143
+ "ref_len_ok": 82,
144
+ "has_ref": 82,
145
+ "frames_vs_dur": 82,
146
+ "ch_uid_shape_ok": 82,
147
+ "rj_uid_shape_ok": 82,
148
+ "ch_voice_prefix": 82,
149
+ "rj_voice_prefix": 82,
150
+ "cut_is_prefix": 41,
151
+ "ext_has_chosen_prefix": 41
152
+ }
153
+ },
154
+ "frame_tolerance_10pct": {
155
+ "cfg_base_pairs": 237209,
156
+ "p2_emox_rows": 309128
157
+ },
158
+ "same_language_within_pair": {
159
+ "cfg": 0.5458098132870169,
160
+ "p2_emox": 0.5912049377604099
161
+ },
162
+ "p2_emox_rejected_pct": {
163
+ "le_0.5": 247324,
164
+ "gt_0.5": 61804,
165
+ "ge_0.9": 14281,
166
+ "gap_negative": 3372,
167
+ "gap_median": 0.7619638368487358
168
+ },
169
+ "frames_vs_annotated_index": {
170
+ "clip_refs_compared": 1322,
171
+ "ratio_1.00": 1322,
172
+ "voice": "anime_000 (index parts 0-2)"
173
+ },
174
+ "overlap_with_sisters": {
175
+ "sister_rows_read": 7410723,
176
+ "sister_files": 1922,
177
+ "row_uid_sample_hits": {
178
+ "sample_cfg_low": 0,
179
+ "sample_cfg_high": 0,
180
+ "sample_p2_emox": 0,
181
+ "sample_p2_len": 0
182
+ },
183
+ "identical_pairs_cfg": 0,
184
+ "identical_pairs_p2_emox": 0,
185
+ "source_clips_present_as_sister_chosen": {
186
+ "cfg": 332576,
187
+ "p2": 342284
188
+ }
189
+ }
190
+ },
191
+ "remote": {
192
+ "repo": "laion/laion-voice-profiles-dpo-cfg",
193
+ "private": false,
194
+ "sha": "145e617015eac33cd2c25b50472f6759052757f4",
195
+ "n_remote_files": 259,
196
+ "checked": 258,
197
+ "size_ok": 258,
198
+ "sha_ok": 258,
199
+ "missing": [],
200
+ "bytes_local": 6509255583,
201
+ "bytes_remote": 6509255583,
202
+ "ok": true
203
+ }
204
+ }