File size: 2,447 Bytes
46cc63a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Final Squeeze — Performance Push (full Toxic-BERT unfreeze, TTA, micro-LR anchor)

pipeline:
  random_state: 42
  test_size: 0.2
  val_size: 0.15
  max_train_test_gap: 0.048  # Gap defense budget (4.8 pp)
  target_f1_weighted: 0.80

data:
  raw_path: data/raw/youtoxic_english_1000.csv
  processed_preprocessed: data/processed/v2/comments_preprocessed.csv
  processed_stats: data/processed/v2/comments_with_stats.csv
  target_binary: IsToxic
  text_column: Text
  id_column: CommentId
  features_config: configs/features.yaml

augmentation:
  enabled: true
  strategy: back_translation
  source_lang: en
  pivot_lang: de
  min_words: 3
  max_words: 60
  rate_limit_every: 50
  rate_limit_sleep_sec: 1.0
  dedup:
    enabled: true
    cosine_threshold: 0.95
    embedding_model: sentence-transformers/all-MiniLM-L6-v2

transformer:
  model_id: unitary/toxic-bert
  max_length: 128
  freeze_mode: full  # all encoder layers + head (6 blocks in Toxic-BERT stack)
  learning_rate: 5.0e-6
  weight_decay: 0.01
  max_epochs: 20
  batch_size: 8
  warmup_ratio: 0.1
  head_dropout: 0.3
  label_smoothing: 0.1
  early_stopping:
    patience: 4
    metric: f1_weighted
    gap_stop_enabled: true
    max_train_val_gap: 0.048
    gap_check_min_epoch: 2
  metric_for_best: f1_weighted
  threshold_tuning:
    enabled: true
    metric: f1_weighted
    min_threshold: 0.30
    max_threshold: 0.70
    step: 0.01
  test_time_augmentation:
    enabled: true
    source_lang: en
    pivot_lang: de
    max_words: 60
    rate_limit_every: 50
    rate_limit_sleep_sec: 1.0

logistic_regression:
  C: 0.01
  max_iter: 2000
  class_weight: balanced
  solver: lbfgs
  gap_search:
    enabled: true
    max_gap: 0.048
    use_original_train_for_gap: true
    param_grid:
      - {C: 0.01, max_features: 300, min_df: 3}
      - {C: 0.008, max_features: 300, min_df: 5}
      - {C: 0.005, max_features: 300, min_df: 8}
      - {C: 0.01, max_features: 300, min_df: 5}
  tfidf:
    max_features: 300
    ngram_range: [1, 2]
    sublinear_tf: true
    min_df: 3

ensemble:
  bert_weight: 0.95
  lr_weight: 0.05
  fixed_weights: true
  threshold_tuning:
    enabled: true
    metric: f1_weighted
    min_threshold: 0.30
    max_threshold: 0.70
    step: 0.01

output:
  transformer_dir: models/performance_push_toxic_bert
  lr_path: models/performance_push_lr.joblib
  ensemble_meta_path: models/performance_push_ensemble_meta.json
  reports_dir: reports/performance_push