# === v1.9.1-multilocale-3order (#148 — the order-overfit FIX) ==================================
# v1.9.0 failed: it added the overture-multilocale source (150k real Overture rows each across 16 EU
# locales, ~2.4M total) but the recipe output was 100% canonical order ("street HN, PC town" — town always
# last). overture is the sole EU-format teacher (base = US sources + ban=FR + synth-german=DE +
# synth-fr-*=FR. WOF teaches place names rather than full-address format), so the model learned the positional
# shortcut "locality = last token-group" and emitted the street as locality on the eval's pc-first /
# city-first orders. Resolve rate regressed on every in-source locale (PT 52->35, PL 53->39, AT 50->45,
# CZ 43->31, IT 79->63. FR held 80->81 rather than in the source). Diagnosed via scripts/eval/locality-emit-diff.ts
# (dump-and-read). Not a grain mismatch. not a weight problem — source_weights is a multinomial over
# sources (5.7% of rows at weight 3.0 regardless of row count), so only the rendering fixes it.
#
# the FIX (one knob): the same 2.4M rows, re-rendered in 3 orders (canonical/pc-first/city-first,
# rotated i%3. scripts/rerender-overture-multiorder.mjs) so the locality appears in every position.
# Everything else is identical to v1.9.0 (overture weight stays 3.0. same rows/components/source_id) —
# a clean single-variable A/B. SK has no locality field -> stays canonical (no shortcut to break).
#
# critical (data_loader.py:244): country_weights.get(country) is None -> the row is excluded. All 22
# countries listed below at 1.0 (acceptance filter relative to max_weight rather than a 1/N split).
#
# goal / check: grade the assembled coordinate, never label-F1. Diagnostic-first: at step-2000/4000 run
# scripts/eval/nonus-coord-panel.ts — the in-source locales (PT/PL/AT/CZ/IT) resolve rate must recover
# toward / above the v1.8.0 baseline (PT 52, PL 53, AT 50, CZ 43, IT 79), and the US per-locale-F1
# guardrail must hold (not worse >1pp) + FR centroid flat. If in-source resolve is still below v1.8.0 at
# 2-4k, kill (the order fix didn't take). Not promoted without operator GO (model swap).
# corpus: corpus-v0.8.0 base (verbatim) + overture-multilocale 3-order overlay -> R2 -> sync_v091.
# Launch: node packages/mailwoman/tools/training/launch/launch.run.ts start --config v1.9.1-multilocale-3order.yaml --fresh
data:
  corpus_dir: /data/corpus/versioned/v0.9.1-multilocale/corpus-v0.9.1-multilocale
  tokenizer_dir: /data/models/tokenizer/v0.6.0-a0
  max_length: 128
  country_weights:
    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
  source_weights:
    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
    # #148 change: the multi-locale EU source. Weight 3.0 — solid EU exposure (each locale's ~150k rows
    # get comparable weighted mass to fr-admin-split's 60k*6.0) without dominating the US-heavy base;
    # the step-2000 diagnostic check adjudicates dilution (lower if US/FR regress, raise if mid-tier flat).
    overture: 3.0
  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

model:
  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:
  output_dir: /data/output-v191-multilocale-3order-s42/checkpoints
  seed: 42
  batch_size: 128
  eval_batch_size: 128
  grad_accum_steps: 1
  learning_rate: 1.5e-4
  weight_decay: 0.01
  warmup_steps: 1000
  grad_clip_norm: 1.0
  max_steps: 40000
  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: v1.9.1-multilocale-3order-s42

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