# Unit-coverage retrain — v0.9.5 (#451, the v0-parity `unit` gap). One variable vs v0.9.3-de-regiontail:
# the corpus adds a 50K `synth-unit` source (US secondary-unit designators) and `synth-unit: 2.5` to
# source_weights. Everything else held — same v0.9.3 recipe (anchor on, self-cond on, region-tail
# German, v0.7.2 base, seed 42). This is the "continue from v0.9.3 + the unit source" the DeepSeek recipe
# consult (2026-06-08, 2 turns) signed off.
#
# why. The v0-parity assessment found `unit` at ~0% F1 — a corpus-coverage gap (NAD stores units at
# weight 1.0, but the tag is too rare + had no synth variety). #454 added the unit-designator synth
# augmentation (USPS Pub-28 C2 codex); this run raises prevalence with the unit-heavy recipe output. The
# hypothesis is "negative space": giving the model the `unit` category should also reduce `street`
# over-prediction (street currently swallows "Apt 456"), i.e. covering unit should raise street
# precision. See docs/articles/concepts/negative-space-coverage.md.
#
# single variable: identical to v0.9.3-de-regiontail except corpus v0.4.4-unit (= the v0.4.3 base parquet files
# referenced verbatim + the `synth-unit` overlay parquet file) and `synth-unit: 2.5` in source_weights. The
# B-unit/I-unit class weights were already 1.5. no schema/model/anchor change.
#
# source provenance (eval-honesty): the train rows are real non-Vermont US OpenAddresses skeletons with
# USPS Pub-28 C2 designators injected (OA stores bare unit ids only); the held-out unit eval is real
# vermont OA rows (the corpus defaultHoldout, never trained), measured separately via per-locale-f1 on
# /tmp/unit-val.jsonl. Geographic split = no leakage. note: designators are injected in both, so the VT
# eval measures designator recognition on held-out addresses. the real-in-the-wild designator signal is
# the libpostal/postal arenas (scripts/eval/external-arenas.ts). Read both lenses at the check.
#
# PRE-registered check (DeepSeek-signed. stop at 20k):
#   - `unit` F1 >= 20% (token-level) on the held-out VT unit eval — minimally measurable (was ~0%, but
#     on 5 golden rows = noise. this is the first real read).
#   - `street` precision >= +1pp vs v0.9.3 — confirms negative space (unit absorbed street false-positives).
#   - no-regression (all within ~1pp vs v0.9.3): US house_number >=73 / postcode >=80 / locality >=77 /
#     street >=86. FR comparable per-class floors. DE native postcode >=83 / street >=82. cross_pollution <1%.
#   If unit moves but street precision is flat/down: negative space refuted for our model — keep the
#     unit lift, note the result. If a US/FR/DE regression check trips: lower synth-unit weight (2.5 -> 1.5) + rerun.
# Measure: per-locale-f1.ts (US/FR + the VT unit eval) + external-arenas.ts (real-designator arenas) +
#   de-order-eval.ts (the DE native/intl × anchor 2x2 regression check).
#
# corpus: v0.4.4-unit — v0.4.3-de-regiontail base (686 parquet files) + 1 `synth-unit` parquet file (50K). Reproduce:
#   built by the unit recipe (packages/corpus/lib/recipes/unit.ts) with --output /tmp/unit-train.jsonl --count 50000 --seed 42
#   built by the unit recipe (packages/corpus/lib/recipes/unit.ts) with --output /tmp/unit-val.jsonl  --golden --count 2000 --seed 99
#   mailwoman dev jsonl-to-parquet --input /tmp/unit-train.jsonl --out /tmp/part-unit-train.parquet
#   # assemble overlay manifest (v0.4.3 base + the unit parquet file), then:
#   # Not `modal volume put`: a mounted container cannot see what it writes, so a run staged that
#   # way trains on whatever was already there and reports success. Route it through R2 instead.
#   mailwoman corpus upload --corpus-version v0.4.4-unit
#   node packages/mailwoman/tools/training/launch/launch.run.ts sync --corpus v0.4.4-unit
#
# Launch:
#   node packages/mailwoman/tools/training/launch/launch.run.ts start \
#     --config v0.9.5-unit.yaml --fresh

data:
  corpus_dir: /data/corpus/versioned/v0.4.4-unit/corpus-v0.4.4-unit
  tokenizer_dir: /data/models/tokenizer/v0.6.0-a0
  max_length: 128
  country_weights:
    US: 1.0
    FR: 1.0
    DE: 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-po-box: 1.5
    synth-intersection: 0.2
    synth-german: 6.0
    # New (#451): the unit-coverage source. 2.5 ≈ ~7% of the epoch (DeepSeek-signed 2–3; ≤3 to avoid
    # starving other tags). Lower to 1.5 if a US/FR/DE regression check trips on street recall.
    synth-unit: 2.5
  train_rows_per_epoch: 1000000
  val_rows: 4096
  coarse_filter: true
  augment_directional_prob: 0.3
  augment_region_prob: 0.3
  anchor_lookup_path: /data/anchor/pilot-anchor-lookup.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
  class_weights:
    O: 0.5
    B-country: 2.0
    I-country: 2.0
    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-v095-unit-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: 20000
  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
  trackio_project: mailwoman
  trackio_run_name: v0.9.5-unit-s42

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