# v2.4.1-fr-nsplice-ft (#444) — the principled FR-diacritic FIX: an init_from fine-tune that gives the
# merged FR diacritic pieces gradient steps, the retrain the #1047 falsification specified.
#
# Why (the #1047 mechanism finding): the training-free vocab-splice that fixed CZ/PL/SK/SI (#884) and
# Nordic (#912 change-4) is falsified for FR streets. The en-US line was trained from scratch on v0.7.1
# with abundant FR `é→O`, so `é` has a strong, well-trained O-signal. FVT mean-init of a merged FR
# piece — E(▁René) = mean(E[▁Ren], E[é]) — inherits that O pull, so the whole merged token tags O and
# the word drops (`Place René Cassin` → `place cassin`), NET-worse than the baseline dropping only the é
# (mangle 23.5%→26.4%). Mean-init-only can't teach the merged pieces. that needs gradient steps. This
# config supplies them: init_from the mean-init candidate, fine-tune on the v0.8.0-fr-nsplice vocab.
#
# the recipe = v2.3.0-nl-postcode-full (the shipped v5.4.0 lineage) verbatim, with exactly these deltas:
#   1. tokenizer_dir  → v0.8.0-fr-nsplice (v0.7.1's 63913 + 2406 FR diacritic pieces. md5 04995524…,
#      #900 overlap check passed, US byte-identical by construction).
#   2. init_from      → /data/models/fr-nsplice-expanded — the v230-nl-postcode (v5.4.0) step-005000
#      checkpoint's token_embeddings FVT mean-init-expanded 63913→66319 (mean_init_fr_nsplice, the
#      pytorch-checkpoint twin of the onnx-mean-init that produced the staged v240 candidate. same FVT
#      math, so the init is numerically the v240 mean-init candidate as a trainable checkpoint).
#   3. schedule → the vocab-splice fine-tune schedule established across v1.9.7/v1.9.8/v1.9.9/v2.1.0
#      (init_from a mean-init-expanded ckpt, fresh optimizer): constant lr 5.0e-5, warmup 200, 12000
#      steps, eval/save every 2000. Not v230's same-vocab lr 1e-5 (that fine-tune had no new rows to
#      move); the new FR rows must overcome the inherited O-signal, and 5e-5 is the splice-adaptation LR.
#   4. output_dir/run name → v241 (fresh dir. init_from reads v230's checkpoints, never overwrites).
# Everything else — the v0.10.1-nl-postcode corpus (699 parquet files), all source/country weights, the model
# config (crf_loss_weight 0.0. conventions loss-mask absent=off), anchor/gaz knobs, class_weights, seed
# 42, batch 128, bf16 — is v230-verbatim, so the spliced vocab + its gradient steps are the only variable.
#
# check when it lands (operator reviews. do not auto-promote): mangle rate < 23.5% baseline (the #444
# metric, scripts/eval/fr-accent-mangle-rate.ts). Honoré + René repros flip to HIT. gauntlet held-out FR
# + US z-tests via --candidate + --candidate-tokenizer v0.8.0-fr-nsplice (a model-only swap leaves the
# new rows dormant); non-FR byte-stability. NaN protocol: if the first checkpoints are NaN/inf, stop.
data:
  # v230's corpus verbatim (v0.10.1-nl-postcode = the v0.10.0 boundary-family base + synth-nl-postcode,
  # 699 parquet files). Stored as raw text + char-offset spans → RE-tokenized through the spliced tokenizer at
  # load, so the FR diacritic pieces fire and receive gradient. No corpus rebuild needed.
  corpus_dir: /data/corpus/versioned/v0.10.1-nl-postcode/corpus-v0.10.1-nl-postcode
  tokenizer_dir: /data/models/tokenizer/v0.8.0-fr-nsplice
  max_length: 128
  country_weights: # Verbatim from v1.9.3a3 (22 countries) — no new locales (surgical).
    US: 1.0
    FR: 1.0
    DE: 1.0
    ES: 1.0
    IT: 1.0
    NL: 1.0
    PT: 1.0
    BE: 1.0
    PL: 1.0
    AT: 1.0
    CH: 1.0
    CZ: 1.0
    DK: 1.0
    "NO": 1.0
    SE: 1.0
    FI: 1.0
    IE: 1.0
    GB: 1.0
    SK: 1.0
    SI: 1.0
    HR: 1.0
    HU: 1.0
    AU: 1.0
  source_weights: # Verbatim from v1.9.3a3 + the one new fr-bare-street source.
    wof-admin: 2.0
    wof-postalcode: 2.0
    ban: 3.0
    tiger: 4.0
    usgov-nppes: 2.0
    usgov-hrsa-fqhc: 2.0
    usgov-imls-pls: 2.0
    usgov-nad: 1.0
    state-ia-contractors: 2.0
    state-tx-notaries: 1.5
    state-ny-notaries: 2.0
    deepseek-kryptonite: 3.0
    synth-intersection: 1.0
    synth-german: 6.0
    synth-fr-order: 3.0
    synth-fr-admin-split: 6.0
    synth-unit: 1.5
    synth-po-box-cedex: 1.5
    synth-affix: 2.0
    synth-country: 2.0
    overture: 3.0
    gnaf: 6.0
    synth-anchor-absorption: 6.0
    # #251 new: the bare-no-postcode FR street source. 6.0 = targeted-fix precedent.
    synth-fr-bare-street: 12.0
    synth-si-bare-village: 12.0 # the family, balanced polarity
    synth-no-street-led: 12.0
    synth-cz-pcfirst-preposition: 12.0
    synth-nl-postcode: 6.0 # #924 the NL digits-first postcode fix
  train_rows_per_epoch: 1000000
  val_rows: 4096
  coarse_filter: true
  augment_directional_prob: 0.3
  augment_region_prob: 0.3
  augment_glue_prob: 0.25
  anchor_lookup_path: /data/anchor/pilot-anchor-lookup.json
  gazetteer_lexicon_path: /data/gazetteer/anchor-lexicon-v1.json
  gazetteer_choreography: true
  affix_relabel_lexicon_path: /data/gazetteer/affix-relabel-lexicon-v1.json
  anchor_paint_mode: shaped
  anchor_value_mode: posterior_latlon

model: # Verbatim from v1.9.3a3.
  hidden_size: 384
  num_hidden_layers: 6
  num_attention_heads: 6
  intermediate_size: 1536
  max_position_embeddings: 128
  type_vocab_size: 1
  hidden_dropout_prob: 0.1
  attention_probs_dropout_prob: 0.1
  use_crf: true
  crf_loss_weight: 0.0
  crf_normalization: per_sequence
  label_smoothing: 0.1
  use_locale_conditioning: true
  locale_loss_weight: 0.3
  use_postcode_anchor: true
  use_gazetteer_anchor: true
  gazetteer_feature_dim: 5
  class_weights:
    O: 0.5
    B-country: 3.5
    I-country: 3.5
    B-region: 1.5
    I-region: 1.5
    B-locality: 2.0
    I-locality: 2.0
    B-dependent_locality: 0.3
    I-dependent_locality: 0.3
    B-postcode: 1.5
    I-postcode: 1.5
    B-subregion: 0.3
    I-subregion: 0.3
    B-cedex: 1.0
    I-cedex: 1.0
    B-venue: 1.5
    I-venue: 1.5
    B-street: 2.0
    I-street: 2.0
    B-house_number: 1.5
    I-house_number: 1.5
    B-street_prefix: 1.5
    I-street_prefix: 1.5
    B-street_suffix: 1.5
    I-street_suffix: 1.5
    B-unit: 1.5
    I-unit: 1.5
    B-po_box: 1.5
    I-po_box: 1.5
    B-intersection_a: 1.0
    I-intersection_a: 1.0
    B-intersection_b: 1.0
    I-intersection_b: 1.0
  use_phrase_priors: true
  phrase_feature_dim: 10

train: # #444 vocab-splice INIT_FROM FINE-TUNE (the v1.9.7/v2.1.0 idiom: fresh optimizer over the
  # mean-init-expanded checkpoint. The default resume on a fresh output_dir resolves to no checkpoint → honors
  # init_from, loading model weights only). Not a from-scratch run and not a resume.
  output_dir: /data/output-v241-fr-nsplice-ft-s42/checkpoints
  seed: 42
  # The v230 (v5.4.0) step-005000 embeddings FVT mean-init-expanded to the v0.8.0-fr-nsplice vocab
  # (66319 rows). mean_init_fr_nsplice writes this on the volume; = the staged v240 candidate as a
  # trainable pytorch checkpoint. The new FR rows now receive gradient instead of inheriting é's O-signal.
  init_from: /data/models/fr-nsplice-expanded
  batch_size: 128
  eval_batch_size: 128
  grad_accum_steps: 1
  # 5.0e-5 = the vocab-splice fine-tune LR (v1.9.7/v1.9.8/v1.9.9/v2.1.0), 5× v230's same-vocab 1e-5 —
  # the mean-init FR rows must move off the inherited O-signal. drift on the trained encoder/US is
  # guarded by the US byte-identity + non-inferiority check. Constant schedule, warmup 200.
  learning_rate: 5.0e-5
  weight_decay: 0.01
  warmup_steps: 200
  grad_clip_norm: 1.0
  # 12000 steps, eval/save every 2000 (6 conditional checkpoints) — the fuller splice-fine-tune length
  # (v1.9.8/v2.1.0); FR overcomes a stronger O-prior than the CZ/PL/Nordic splices. ~1/8 the from-scratch
  # 100k schedule → a short fine-tune. Operator checks the best checkpoint when it lands (no auto-promote).
  max_steps: 12000
  eval_every_steps: 2000
  save_every_steps: 2000
  log_every_steps: 50
  precision: bf16
  num_workers: 0
  csv_log_path: "{output_dir}/../train_log.csv"
  lr_schedule: constant
  gazetteer_curriculum: false
  trackio_project: mailwoman
  trackio_run_name: v2.4.1-fr-nsplice-ft-s42

eval:
  golden_dir: /data/eval/golden/v0.1.2
  val_jsonl: ""
