# === v8-cjk-full — the full JP source plus the CN organizational-unit source, one 49-label head (#2034). ===
#
# `v8-jp-full` (seed 42, 24k steps) cleared its pre-registered check: coordinate-acceptability 0.9928 on
# the held-out 20,000-row JP board (the v8-jp-full 24k record under docs/records/evals/, dated 2026-08-05). This run
# keeps everything that config decided — geometry, schedule, head LR, from-scratch, char path, register
# mix — and changes two things, both attributable:
#
#   1. The head. `label_set: stage3-cjk` = stage3-jp + `locality_unit` (47 → 49 BIO). Every stage3-jp
#      label keeps its id, so the JP per-tag read is comparable against the 24k record label for label.
#   2. The mixture. The corpus is the v8-cjk overlay: the eight JP train parts referenced where they
#      already sit on the volume, plus one CN part of 126 rows the `cn-organizational-units` recipe labeled
#      by the suffix grammar (train 126 / val 11 / board 14. docs on #2034). `source_weights` is the
#      mixture knob — the loader samples a source per pull from this multinomial and restarts an exhausted
#      source with a fresh shuffled pass — so CN's 2% share means the 126 rows are each presented roughly
#      (24000 × 256 × 0.02) / 126 ≈ 975 times over the run: a rule-shaped tag learned from a small register,
#      not a claim about Chinese addresses at large. `country_weights` isn't that knob: it is a per-row
#      acceptance filter (a row survives with probability weight / max weight), and the first launch set
#      CN to 0.02 there. That filter rejected 98% of the 126 rows and left the CN source with no row to
#      yield. The loader raised `generator raised StopIteration` before step 1 (app ap-sBZtCQpys7yNmVHN8TcsDb).
#      Both countries accept every row. the mixture lives in source_weights. Set the CN source to 0.0 and
#      this config is v8-jp-full with a wider head. That variant is the control if the JP read moves.
#
# --- why one head and not A CN model (the distribution decision, operator 2026-09-05) ---------------------
# The consumer-facing shape is one CJK weights package a consumer installs as a unit: #1177 Phase B makes
# the CJK char model the second script-routed weights package beside the Latin SentencePiece model, and JP + CN
# ride it together. A per-script CN model was refused on supply — 126 labeled rows cannot train a model
# that stands on its own. they can supplement one.
#
# Han unification is the cost this pays, measured before the spend (JP train/part-0000, 250,000 rows,
# against the 126 CN train rows): 103 of the 203 distinct CN characters are shared code points, 55% of
# the `locality_unit` label mass (171 / 311 labeled characters) sits on them, and every one of the 103
# has a different JP majority label (一 is `block` 68% in JP and `locality_unit` 89% in CN; 三 is
# `prefecture` 29% / `locality_unit` 92%; 分 is `prefecture` 57% via 大分県 / `locality_unit` 73%).
# What the model has to separate the scripts: 126 / 126 CN rows contain a simplified-only character inside
# the `locality_unit` span (队 场 连 团 组 are not JP code points), so the ±3 character window always sees
# a script marker beside the colliding numeral. The auxiliary locale head isn't switched on for this:
# `use_locale_conditioning` was off in v8-jp-full, CN isn't in `LOCALE_COUNTRIES`, and adding both here
# would be a third delta the 24k comparison couldn't attribute. If the JP read moves, the control above
# (CN source 0.0) separates the head widening from the mixture. the locale head is the fix to try after.
#
# --- from scratch, for the same two reasons v8-jp-full states: the classifier is (49, 384) here and
# (47, 384) at the JP checkpoint, and the char vocabulary is re-sealed (2,237 JP characters plus every CN
# train character, re-sorted by code point), so a padded copy would map the wrong row to the wrong
# character. Never `init_from` to grow a capability.
#
# --- what the RUN must show (pre-registered, read on the same instruments as the JP record) ----------
#   * JP half: the 24k record's per-tag span exact-match table, re-scored on jp-board.jsonl with
#     `score_jp_probe_board.py --label-set stage3-cjk`; coordinate-acceptability ≥ 0.70 is the check the
#     JP arc registered and stays the check here. A drop of more than 1pp on any JP tag against the 24k
#     record is the finding that the CN rows cost JP accuracy.
#   * CN half: per-tag F1 for `locality_unit` and `dependent_locality` on the 11 CN val rows every eval
#     step (train_log.csv), and span exact-match on the 14 rows of cn-board.jsonl at the end. n is small
#     and the bar is stated as a reading rather than a check: the rows are the register's whole labeled supply.
#     The zh-CN gauntlet rows stay improvement targets until a serving path exists. The val stream
#     draws from the same source multinomial as train, so the 11 CN val rows are pulled about 2% of
#     val pulls with restarts (≈ 400 pulls at val_rows 20011, each row ≈ 36 times); the F1 is over 11
#     distinct rows regardless of the number of times they're shown.
#
# --- Char mode is channel-free (D5): no anchor / gazetteer / country / evidence paths here, by interface.
#
# `precision`, `lr_schedule` and `grad_clip_norm` are spelled out because the trainer's default precision
# is fp32 and v8-jp-full ran bf16. an omitted field here would be a silent third delta.
#
# Launch order (`v8-cjk-full-2k.yaml` runs first and this file waits on its read):
#   node packages/mailwoman/tools/training/launch/launch.run.ts sync --corpus v8cjk
#   node packages/mailwoman/tools/training/launch/launch.run.ts start --config v8-cjk-full-2k.yaml --fresh
#   node packages/mailwoman/tools/training/launch/launch.run.ts start --config v8-cjk-full.yaml

data:
  corpus_dir: /data/corpus/versioned/v8-cjk-2026-09-05
  # Unused in char mode (SentencePiece is skipped entirely); kept pointing at the production
  # tokenizer so config auditing stays uniform. Same as v8-jp-full.
  tokenizer_dir: /data/models/tokenizer/v0.9.0-multisplice
  max_length: 96
  country_weights:
    JP: 1.0
    CN: 1.0
  # The mixture (see the header): per-pull source multinomial, exhausted sources restart.
  source_weights:
    overture-jp: 0.98
    coarse-placer-cn-units: 0.02
  coarse_filter: false
  # JP val 20,000 + CN val 11.
  val_rows: 20011
  # The 49-label CJK head. Supported only on the char path. the SP path raises (#1349's lesson).
  label_set: stage3-cjk
  char_mode: char
  char_vocab_path: /data/corpus/versioned/v8-cjk-2026-09-05/char-vocab-cjk.json
  char_ctx: 3
  max_unit_width: 7
  max_units: 96

model:
  # v8-jp-full's geometry, unchanged, so the two deltas above are the only deltas.
  hidden_size: 384
  num_hidden_layers: 4
  num_attention_heads: 6
  intermediate_size: 1536
  max_position_embeddings: 96
  use_crf: false
  label_smoothing: 0.1
  use_char_embed: true
  char_embed_dim: 64

train:
  output_dir: /data/output-v8-cjk-full-s42
  seed: 42
  batch_size: 256
  eval_batch_size: 512
  learning_rate: 5.0e-4
  classifier_learning_rate: 1.0e-3
  warmup_steps: 1000
  max_steps: 24000
  eval_every_steps: 2000
  save_every_steps: 4000
  log_every_steps: 100
  precision: bf16
  lr_schedule: cosine
  grad_clip_norm: 1.0
