# v8-leg2-charword is the character-word arm of a paired encoder comparison with v8-leg2-sp.
#
# The two recipes share the data block, the 384-unit 4-layer geometry and the 8k-step schedule. They
# differ only in the embedding front end. Both train from scratch without channels or a CRF. The
# comparison reads val token F1 and per-tag F1 at step 8k and has no pass bar.
#
# The SP arm drops rows longer than 128 pieces, and this arm caps rows at 64 word units. The Latin
# char vocab came from a 1M-row sample, so rare characters map to UNK.
#
# Launch: node packages/mailwoman/tools/training/launch/launch.run.ts start --config v8-leg2-charword.yaml --fresh

data:
  corpus_dir: /data/corpus/versioned/v0.13.0-latam/corpus-v0.13.0-latam
  tokenizer_dir: /data/models/tokenizer/v0.9.0-multisplice
  max_length: 128
  country_weights: # These weights are copied from v2.4.1.
    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 # CA rows come from Overture.
    MX: 1.0 # MX rows come from Overture. BR is left out because its house numbers are unreliable.
  # These are the v3.1.0 weights plus overture-latam and synth-no-fragment. synth-no-street-led is zero
  # because its on-disk rows overlap the eval board.
  source_weights:
    # CA, MX and BR rows from Overture use their own source, so the EU `overture` weight is unchanged.
    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
    # Address fragments of the kind typed into autocomplete.
    synth-fragment: 6.0
    # French streets without a house number, plus bare-locality counterexamples. Targeted sources use 12.0.
    synth-fr-fragment: 12.0
    # Norwegian bare streets and street-number pairs without a postcode, plus counterexamples.
    synth-no-fragment: 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
  # This probability adds a copy of a row with its commas removed, so the model learns to split street
  # and locality without relying on commas.
  augment_punct_drop_prob: 0.3
  affix_relabel_lexicon_path: /data/gazetteer/affix-relabel-lexicon-v1.json
  # Each unit is one whole word, encoded by `encode_row_units` without neighbor context.
  char_mode: word
  char_vocab_path: /data/corpus/versioned/v8-leg2/char-vocab-latin-v1.json
  char_ctx: 0
  max_unit_width: 16
  max_units: 64

model:
  hidden_size: 384
  num_hidden_layers: 4
  num_attention_heads: 6
  intermediate_size: 1536
  use_crf: false
  label_smoothing: 0.1
  max_position_embeddings: 64
  use_char_embed: true
  char_embed_dim: 64

train:
  output_dir: /data/output-v8-leg2-charword-s42
  seed: 42
  batch_size: 256
  eval_batch_size: 512
  learning_rate: 5.0e-4
  warmup_steps: 1000
  max_steps: 8000
  eval_every_steps: 1000
  save_every_steps: 2000
  log_every_steps: 100
  precision: bf16
  lr_schedule: cosine
  grad_clip_norm: 1.0
