# === v4.2.0-base-anchor-v2-2k — the cheap recipe-validation probe for v4.2.0-base-anchor-v2.yaml. ===
#
# Diagnostic-before-fix: 2,000 steps to prove the recipe runs before committing 60,000. Not a check —
# no threshold here is pre-registered. It answers four mechanical questions the 60,000-step
# from-scratch run shouldn't be the first place to discover:
#
#   1. Does `load_anchor_lookup` survive the v2 artifact at scale? 1.32 GB resident / 1.37 GB peak
#      measured locally — the loader pays it once per worker at init. An OOM or a silent fallback
#      to the pilot lookup shows up in the first minute.
#   2. Does the startup census draw the GB/NL/ES/IT sources, and do GB anchor spans paint at
#      runtime? (The v383 gap: a truncated census log hid a source drawing zero rows. the #1467
#      root cause was a slot that never saw gradient. Zero painted GB rows here = the defect
#      repeating, silently.)
#   3. Does `synth-gb` at weight 6.0 under the corrected 1.0 dependent_locality class weight skew the
#      dep-loc emission? Read per-tag F1 — dep-loc firing on US/FR rows is the v4.1.x failure mode
#      this probe exists to catch before the spend.
#   4. Does `synth-sub-venue` at 12.0 move `unit` without bleeding into `venue`? Same per-tag read.
#
# Deliberate deviations from v4.2.0-base-anchor-v2.yaml (curves are not directly comparable):
#   * `warmup_steps: 200` instead of 1000 — half-warmup probes read as stalls.
#   * cosine fully anneals inside the probe. The 60,000-step from-scratch run is 3.3% through its cosine at step 2,000.
#   * `eval_every_steps: 250` — the point is the shape of the curve rather than the endpoint.
#   * `save_every_steps: 1000` — saves twice, insurance against a save-path crash surfacing at
#     step 5,000 of the real run.
# Everything else is byte-identical to v4.2.0-base-anchor-v2.yaml. If you change that file, change
# this one.
#
# Launch: node packages/mailwoman/tools/training/launch/launch.run.ts start --config v4.2.0-base-anchor-v2-2k.yaml --fresh
data:
  # v0.17.0-batch = v0.15.0-venue + two overlay parquet files (manifest chain assembled 2026-08-05):
  #   part-sub-venue.parquet  120,000 rows  source=synth-sub-venue  (#1486 — designator x per-region identifier)
  #   part-gb.parquet         800,000 rows  source=synth-gb         (v0.14.0-gb's recipe output, HM Land Registry PPD OGL v3.0)
  corpus_dir: /data/corpus/versioned/v0.17.0-batch/corpus-v0.17.0-batch
  tokenizer_dir: /data/models/tokenizer/v0.9.0-multisplice
  max_length: 128
  country_weights: # Verbatim from v4.0.1. Deliberately not re-weighted: one variable.
    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
    CA: 1.0 # Overture — live locality.
    MX: 1.0 # Overture — BR stays out (0% OA-lineage + SN-garbage numbers).
  source_weights: # Verbatim from v4.0.1. `source_weights` drops unlisted sources — see the pending decisions.
    synth-house-venue: 2.0
    overture-latam: 6.0
    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
    synth-fr-bare-street: 12.0
    synth-si-bare-village: 12.0
    synth-no-street-led: 0.0
    synth-cz-pcfirst-preposition: 12.0
    synth-nl-postcode: 6.0
    synth-fragment: 6.0
    synth-fr-fragment: 12.0
    synth-no-fragment: 12.0
    # ---- decisions resolved 2026-08-05 (both sources ride the v0.17.0-batch overlay above) ----
    # synth-gb at 6.0: operator ruled "do it all to make the most of the cost"; the measured risk
    # (32.8% B-dependent_locality mass skewing the tag, seen in the v4.1.x arc under the 0.3 class
    # weight this run corrects to 1.0) is exactly what the 2k probe reads before the 60k spend —
    # per-tag dep-loc emission + the US/FR stability boards are the kill switch. Weight 6.0 matches
    # the other single-country synth sources rather than the 12.0 saturation tier.
    synth-gb: 6.0
    # The `synth-sub-venue` source (#1486): 120k rows (84k pos / 36k neg), weight 12.0 per the recipe report —
    # `unit` is a starved tag and the recipe output's negatives (rejection-ledger confounds) encode the
    # identifier-required shape rule, so the saturation weight is deliberate.
    synth-sub-venue: 12.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
  augment_ordinal_prob: 0.3
  augment_punct_drop_prob: 0.3
  # `anchor_lookup_path` is the one stated delta. 2,286,339 keys / 2,214,803 letter-containing, vs the pilot's 67,708 / 0.
  # Rebuild with: mailwoman gazetteer build anchor-lookup --include DE,FR,US,GB,NL,ES,IT --output <path>
  anchor_lookup_path: /data/anchor/pilot-anchor-lookup-v2-2026-08-05.json
  gazetteer_lexicon_path: /data/gazetteer/anchor-lexicon-v1.json
  country_lexicon_path: /data/gazetteer/country-surface-lexicon-v1.json
  gazetteer_choreography: true
  affix_relabel_lexicon_path: /data/gazetteer/affix-relabel-lexicon-v1.json
  # Already `shaped` in v4.0.1 — restated because it is required here. The shaped painter is what
  # makes the widened lookup reachable: it detects postcode shapes over the raw text (so a GB unit
  # arrives as one span with its space) where the gold path only ever painted labeled postcode spans.
  anchor_paint_mode: shaped
  anchor_value_mode: posterior_latlon
  street_type_lexicon_path: /data/gazetteer/street-type-lexicon-v3.json
  locality_surface_lexicon_path: /data/gazetteer/locality-surface-lexicon-v7.json

model: # Verbatim from v4.0.1.
  hidden_size: 384
  use_span_boundary_head: true
  span_boundary_loss_weight: 0.5
  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
  use_country_anchor: true
  country_feature_dim: 2
  use_street_type_anchor: true
  street_type_feature_dim: 1
  use_locality_surface_anchor: true
  locality_surface_feature_dim: 2
  country_ambiguous_scale: 0.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
    # 1.0 rather than the 0.3 that ran from v0.5.1 through v0.8.0 under "penalize hallucination of rare
    # tags". The R5 diagnosis (`docs/superpowers/plans/2026-08-01-r5-us-deploc-preregistration.md`)
    # traced the shipped model's dead US dependent_locality to exactly that weight: US surfaces
    # contain more raw dep-loc mass than the GB ones that work, so the tag was never dead — it was
    # weighted down. Corrected in v4.0.1 and kept here. the shipped lineage still predates the
    # correction, so this run is the first base to retrain it in.
    B-dependent_locality: 1.0
    I-dependent_locality: 1.0
    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: # FROM SCRATCH (D1): no init_from, full-length cosine, one param group. Verbatim from v4.0.1.
  output_dir: /data/output-v420-base-anchor-v2-2k-s42/checkpoints
  seed: 42
  batch_size: 128
  eval_batch_size: 128
  grad_accum_steps: 1
  learning_rate: 5.0e-4
  weight_decay: 0.01
  warmup_steps: 200
  grad_clip_norm: 1.0
  max_steps: 2000
  eval_every_steps: 250
  save_every_steps: 1000
  log_every_steps: 50
  precision: bf16
  num_workers: 0
  csv_log_path: "{output_dir}/../train_log.csv"
  lr_schedule: cosine
  gazetteer_curriculum: true
  evidence_curriculum: true
  evidence_noise_prob: 0.15
  fisher_capture: false # probe — the Fisher artifact belongs to the 60,000-step from-scratch run only.
  fisher_capture_last_n_steps: 2000
  trackio_project: mailwoman
  trackio_run_name: v4.2.0-base-anchor-v2-2k-s42

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