OliverPerrin commited on
Commit
9710200
·
1 Parent(s): 8a54fec

Fix regression: restore balanced training settings, add technical manual filter

Browse files

Training configs:
- Restored LR: 3e-5 (medium), 2e-5 (full)
- Restored weight decay: 0.01
- Restored label smoothing: 0.1
- Restored dropout: 0.1
- Restored task weights: emotion=1.5, topic=0.5
- Restored epochs: 5 (medium), 8 (full)
- Restored early stopping patience: 3

Discovery dataset:
- Added technical manual filter (pottery recipes, camera specs, etc.)
- These non-narrative texts produce garbage summaries

configs/model/base.yaml CHANGED
@@ -7,7 +7,7 @@ num_encoder_layers: 12 # T5-base has 12 layers
7
  num_decoder_layers: 12 # T5-base has 12 layers
8
  num_attention_heads: 12
9
  ffn_dim: 2048 # T5 uses d_ff = 2048 for base model
10
- dropout: 0.15 # Increased from 0.1 for better regularization
11
  activation: gated-gelu # T5/FLAN-T5 uses gated-gelu (GELU activation with gating, not SwiGLU)
12
  use_pretrained: true
13
  pretrained_model_name: google/flan-t5-base
 
7
  num_decoder_layers: 12 # T5-base has 12 layers
8
  num_attention_heads: 12
9
  ffn_dim: 2048 # T5 uses d_ff = 2048 for base model
10
+ dropout: 0.1 # Standard dropout
11
  activation: gated-gelu # T5/FLAN-T5 uses gated-gelu (GELU activation with gating, not SwiGLU)
12
  use_pretrained: true
13
  pretrained_model_name: google/flan-t5-base
configs/training/full.yaml CHANGED
@@ -14,28 +14,28 @@ dataloader:
14
 
15
  optimizer:
16
  name: adamw
17
- lr: 1.5e-5 # Lower LR for best convergence
18
- weight_decay: 0.02 # Increased regularization
19
  eps: 1.0e-6
20
- betas: [0.9, 0.98] # Lower beta2 for faster adaptation
21
 
22
  scheduler:
23
  name: cosine
24
- warmup_steps: 800 # Longer warmup for larger dataset
25
 
26
  trainer:
27
- max_epochs: 6 # Reduced - converges by epoch 4-5
28
  gradient_clip_norm: 1.0
29
  gradient_accumulation_steps: 8 # Larger effective batch: 80 (10*8)
30
  validation_max_length: 128
31
- label_smoothing: 0.15 # Increased for better generalization
32
  task_weights:
33
  summarization: 1.0
34
- emotion: 2.0 # Boost emotion more (tends to underfit)
35
- topic: 0.3 # Reduced more - topic saturates quickly
36
  max_train_samples: 50000
37
  max_val_samples: 3000
38
- early_stopping_patience: 2 # Stop earlier on plateau
39
  log_grad_norm_frequency: 100
40
 
41
  compile_encoder: true
 
14
 
15
  optimizer:
16
  name: adamw
17
+ lr: 2.0e-5 # Lower LR for best convergence
18
+ weight_decay: 0.01 # Standard regularization
19
  eps: 1.0e-6
20
+ betas: [0.9, 0.999] # Standard betas
21
 
22
  scheduler:
23
  name: cosine
24
+ warmup_steps: 500 # Standard warmup
25
 
26
  trainer:
27
+ max_epochs: 8 # Full training
28
  gradient_clip_norm: 1.0
29
  gradient_accumulation_steps: 8 # Larger effective batch: 80 (10*8)
30
  validation_max_length: 128
31
+ label_smoothing: 0.1 # Standard smoothing
32
  task_weights:
33
  summarization: 1.0
34
+ emotion: 1.5 # Balanced boost
35
+ topic: 0.5 # Balanced weight
36
  max_train_samples: 50000
37
  max_val_samples: 3000
38
+ early_stopping_patience: 3 # Standard patience
39
  log_grad_norm_frequency: 100
40
 
41
  compile_encoder: true
configs/training/medium.yaml CHANGED
@@ -14,28 +14,28 @@ dataloader:
14
 
15
  optimizer:
16
  name: adamw
17
- lr: 2.0e-5 # Lower LR to prevent overfitting
18
- weight_decay: 0.02 # Increased regularization
19
  eps: 1.0e-6
20
- betas: [0.9, 0.98] # Lower beta2 for faster adaptation
21
 
22
  scheduler:
23
  name: cosine
24
- warmup_steps: 400 # Longer warmup
25
 
26
  trainer:
27
- max_epochs: 4 # Reduced - converges by epoch 3-4
28
  gradient_clip_norm: 1.0
29
  gradient_accumulation_steps: 6 # Effective batch: 60 (10*6)
30
  validation_max_length: 128
31
- label_smoothing: 0.15 # Increased for better generalization
32
  task_weights:
33
  summarization: 1.0
34
- emotion: 2.0 # Boost emotion more - tends to underfit
35
- topic: 0.3 # Reduced more - topic saturates quickly
36
  max_train_samples: 25000
37
  max_val_samples: 2500
38
- early_stopping_patience: 2 # Stop earlier on plateau
39
  log_grad_norm_frequency: 100
40
 
41
  compile_encoder: true
 
14
 
15
  optimizer:
16
  name: adamw
17
+ lr: 3.0e-5 # Balanced LR
18
+ weight_decay: 0.01 # Standard regularization
19
  eps: 1.0e-6
20
+ betas: [0.9, 0.999] # Standard betas
21
 
22
  scheduler:
23
  name: cosine
24
+ warmup_steps: 300 # Standard warmup
25
 
26
  trainer:
27
+ max_epochs: 5 # Allow more epochs
28
  gradient_clip_norm: 1.0
29
  gradient_accumulation_steps: 6 # Effective batch: 60 (10*6)
30
  validation_max_length: 128
31
+ label_smoothing: 0.1 # Standard smoothing
32
  task_weights:
33
  summarization: 1.0
34
+ emotion: 1.5 # Balanced boost
35
+ topic: 0.5 # Balanced weight
36
  max_train_samples: 25000
37
  max_val_samples: 2500
38
+ early_stopping_patience: 3 # More patience
39
  log_grad_norm_frequency: 100
40
 
41
  compile_encoder: true
scripts/build_discovery_dataset.py CHANGED
@@ -52,6 +52,23 @@ GARBAGE_PATTERNS = [
52
  r"\(\s*syn\s+", # Synonym references
53
  ]
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  # Non-English indicators (expanded)
56
  NON_ENGLISH_PATTERNS = [
57
  r"\b(le|la|les|un|une|des|du|de la|au|aux|et|est|sont|dans|pour|avec|sur|qui|que)\b", # French
@@ -75,6 +92,14 @@ INDEX_PATTERNS = [
75
  ]
76
 
77
 
 
 
 
 
 
 
 
 
78
  def is_english(text: str) -> bool:
79
  """Check if text appears to be English."""
80
  text_lower = text.lower()
@@ -133,6 +158,10 @@ def is_quality_text(text: str) -> bool:
133
  if re.search(pattern, text, re.IGNORECASE | re.MULTILINE):
134
  return False
135
 
 
 
 
 
136
  # Must have reasonable length
137
  if len(text) < 300: # Stricter: was 200
138
  return False
 
52
  r"\(\s*syn\s+", # Synonym references
53
  ]
54
 
55
+ # Patterns that indicate technical manuals/instructions (not narrative)
56
+ TECHNICAL_PATTERNS = [
57
+ r"\d+\.\s+It\s+(is|has|can)", # Numbered features "1. It is a..."
58
+ r"^\d+(st|nd|rd|th)\.", # "1st. 2nd. 3rd."
59
+ r"Mesh\.?\s*\d+", # Mesh sizes (pottery)
60
+ r"\d+\s*(oz|lb|kg|g|ml|mm|cm|inch)", # Measurements
61
+ r"Parts?\s*:?\s*\d+", # "Parts: 50"
62
+ r"Method of Using", # Instructions
63
+ r"How to\s+\w+", # How-to guides
64
+ r"Step\s+\d+", # Step-by-step
65
+ r"wire.*address", # Business instructions
66
+ r"orders?\s+should\s+be", # Order instructions
67
+ r"specifications?", # Technical specs
68
+ r"(Front|Back)\s+Focus", # Camera terms
69
+ r"Rack and Pinion", # Mechanical terms
70
+ ]
71
+
72
  # Non-English indicators (expanded)
73
  NON_ENGLISH_PATTERNS = [
74
  r"\b(le|la|les|un|une|des|du|de la|au|aux|et|est|sont|dans|pour|avec|sur|qui|que)\b", # French
 
92
  ]
93
 
94
 
95
+ def is_technical_manual(text: str) -> bool:
96
+ """Check if text appears to be a technical manual/instructions."""
97
+ for pattern in TECHNICAL_PATTERNS:
98
+ if re.search(pattern, text, re.IGNORECASE | re.MULTILINE):
99
+ return True
100
+ return False
101
+
102
+
103
  def is_english(text: str) -> bool:
104
  """Check if text appears to be English."""
105
  text_lower = text.lower()
 
158
  if re.search(pattern, text, re.IGNORECASE | re.MULTILINE):
159
  return False
160
 
161
+ # Reject technical manuals/instructions
162
+ if is_technical_manual(text):
163
+ return False
164
+
165
  # Must have reasonable length
166
  if len(text) < 300: # Stricter: was 200
167
  return False