# v0.4.0 second bisect: lr 3.0e-4 → 1.5e-4 — v0.3.0 baseline LR + all v0.4.0 changes.
#
# Both lr=5.0e-4 and lr=3.0e-4 diverged during warmup. The destabilization band lives
# around lr≈2.5e-4 in both runs:
#
#   lr=5.0e-4: best macro_f1=0.36 at step 500 (lr@0.25e-4); collapse step 750
#              (lr@3.75e-4) → val 3.39 / macro_f1 0.14
#   lr=3.0e-4: best macro_f1=0.37 at step 750 (lr@2.25e-4); collapse step 1000
#              (lr@3.0e-4 peak) → val 3.62 / macro_f1 0.14
#
# v0.3.0 successfully shipped at lr=1.5e-4 with crf_loss_weight=0.05 (the
# hand-weighted dual-loss workaround). The v0.4.0 per_token CRF normalization keeps
# the dual gradients comparably scaled at crf_loss_weight=1.0, so peak LR at 1.5e-4
# never crosses the destabilization band — warmup ends below it.
#
# Effective gradient magnitude vs v0.3.0:
#   v0.3.0:  CE_uniform × 1.0 + per_seq_NLL × 0.05  ≈ unit-scale aggregate at lr=1.5e-4
#   v0.4.0:  CE_weighted × ~1.3 (class-mean) + per_token_NLL × 1.0
#            ≈ ~1.3× unit-scale, still well below the lr=3e-4 unstable band
#
# Separate output_dir. keeps the lr=3e-4 step-750 best checkpoint preserved as a
# secondary fallback.

data:
  corpus_dir: /data/corpus/versioned/v0.3.0/corpus-v0.3.0
  tokenizer_dir: /data/models/tokenizer/v0.1.0
  max_length: 128
  country_weights:
    US: 1.0
    FR: 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
  train_rows_per_epoch: null
  val_rows: 4096
  coarse_filter: true

model:
  hidden_size: 256
  num_hidden_layers: 6
  num_attention_heads: 4
  intermediate_size: 1024
  max_position_embeddings: 128
  type_vocab_size: 1
  hidden_dropout_prob: 0.1
  attention_probs_dropout_prob: 0.1
  use_crf: true
  label_smoothing: 0.0
  crf_normalization: per_token
  crf_loss_weight: 1.0
  class_weights:
    O: 1.0
    B-country: 2.0
    I-country: 2.0
    B-region: 2.0
    I-region: 2.0
    B-locality: 1.5
    I-locality: 1.5
    B-dependent_locality: 1.5
    I-dependent_locality: 1.5
    B-postcode: 1.5
    I-postcode: 1.5
    B-subregion: 1.5
    I-subregion: 1.5
    B-cedex: 2.0
    I-cedex: 2.0
    B-venue: 0.5
    I-venue: 0.5
    B-street: 0.5
    I-street: 0.5
    B-house_number: 0.5
    I-house_number: 0.5

train:
  output_dir: /data/models/checkpoints/v0_4_0-lr1.5e4
  seed: 42
  batch_size: 32
  eval_batch_size: 40
  grad_accum_steps: 4
  # v0.3.0 baseline LR. Peak (1.5e-4) sits below the empirical destabilization band
  # observed in the lr=3e-4 and lr=5e-4 runs (both crashed crossing lr≈2.5e-4).
  learning_rate: 1.5e-4
  weight_decay: 0.01
  warmup_steps: 1000
  grad_clip_norm: 1.0
  max_steps: 50000
  eval_every_steps: 250
  save_every_steps: 100
  log_every_steps: 50
  precision: bf16
  num_workers: 2
  csv_log_path: "{output_dir}/train_log.csv"

eval:
  golden_dir: ""
  val_jsonl: ""
