# === v0.9.8-affix (#452-adjacent) — street-affix coverage, the next negative-space parity change ====
# One conceptual variable vs v0.9.7-unit-v3 (the shipped v4.1.0): the corpus adds a 50K format-diverse
# street-affix recipe output (OA streets split into street_prefix/street/street_suffix via the USPS Pub-28
# C1/C2 codex) and `synth-affix: 2.0` to source_weights. Corpus v0.4.6-affix = v0.4.5-unit-v2 base
# (so the `unit` F1 rise is retained) + the affix overlay recipe output. Everything else held — v0.9.3 recipe
# (anchor on, self-cond on, region-tail German), v0.7.2 base lineage, seed 42, 20k steps.
#
# why. The v0-parity assessment (#15) found street_prefix + street_suffix at ~0% F1 — collapsed into
# `street` (the model lumps "N Main St" into one street span). Same coverage mechanism as `unit`:
# the corpus contains the tags (tiger/NAD-structured), but prevalence is too low. This recipe output raises
# prevalence with format diversity (abbrev "N"/"St" vs expanded "North"/"Street", + full/bare/
# street-only/venue layouts), and injects a directional onto ~30% of prefix-less streets for
# street_prefix signal. hypothesis (negative space): teaching the model to split off prefix+suffix
# should also raise `street` precision. See docs/articles/concepts/negative-space-coverage.md.
#
# source provenance (eval-honesty): train rows = real non-Vermont US OA streets, split via the codex
# (directionals + USPS suffixes), prefixes partly injected. Held-out VT golden measures affix
# recognition on held-out addresses. the real-in-the-wild check is data/eval/external/
# street-affix-real.jsonl (30 curated real addresses, naturally-occurring affixes — the trustworthy
# lens, mirroring the unit-real-designators eval). Read the real-affix eval at the check rather than the VT #.
#
# PRE-registered check (stop at 20k):
#   - street_suffix F1 >= 70% and street_prefix F1 >= 60% on the real-affix eval (both were ~0%).
#   - `street` F1 >= v4.1.0 (no loss. ideally +. negative space) on golden US + the real-affix eval.
#   - retain unit: `unit` >= 88% on data/eval/external/unit-real-designators.jsonl (was 92.3%).
#   - no-regression (within ~1pp vs v4.1.0 / v0.9.7, fp32-to-fp32): US house_number / postcode /
#     locality / region. FR per-class floors. DE native-order locality (de-order-eval.ts).
#   decision: affixes clear + street holds + unit retained + no regression check → promote candidate.
#     If street/house_number slips or affixes over-fire: lower synth-affix 2.0 -> 1.5 + rerun
#     (the unit-v3 action). If affixes move but `street` drops: negative space refuted here — keep
#     the affix result, note it.
# Measure: per-locale-f1.ts (US/FR golden) + the street-affix-real + unit-real-designators evals
#   (fp32) + de-order-eval.ts (DE 2x2 regression check).
#
# corpus: v0.4.6-affix (no rebuild of base). Reproduce:
#   built by the street-affix recipe (packages/corpus/lib/recipes/street/affix.ts) with --output /tmp/affix-train.jsonl --count 50000 --seed 42
#   built by the street-affix recipe (packages/corpus/lib/recipes/street/affix.ts) with --output /tmp/affix-val.jsonl --golden --count 2000 --seed 99
#   mailwoman dev jsonl-to-parquet --input /tmp/affix-train.jsonl --out <new>/train/part-affix-train.parquet
#   # assemble the overlay manifest (v0.4.5-unit-v2 base + the affix parquet file), then stage both through
#   # R2 — not `modal volume put`, which a mounted container cannot see:
#   mailwoman corpus upload --corpus-version v0.4.6-affix
#   node packages/mailwoman/tools/training/launch/launch.run.ts sync --corpus v0.4.6-affix
#
# Launch:
#   node packages/mailwoman/tools/training/launch/launch.run.ts start \
#     --config v0.9.8-affix.yaml --fresh

data:
  corpus_dir: /data/corpus/versioned/v0.4.6-affix/corpus-v0.4.6-affix
  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
    # retained from v4.1.0 (v0.9.7-unit-v3), so `unit` stays at or above 88% on unit-real-designators.
    synth-unit: 1.5
    # new: the street-affix source. 2.0 ≈ ~6% of the epoch — two starved tags to lift, but capped to
    # avoid over-firing affixes / starving `street`. Lower to 1.5 if a street/house_number regression check trips.
    synth-affix: 2.0
  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-v098-affix-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.8-affix-s42

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