File size: 4,256 Bytes
46beb25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
extends: configs/base.yaml
phase: phase4
# Phase 4 keeps the 345M model frozen from phase 3 and only expands unique data.
# Rationale (2026-07-18): phase-3 was data-bound, not capacity-bound
# (1.103B unique train tokens = ~3.2 tokens/param vs Chinchilla-optimal ~7B for
# 345M; small train/val gap; val loss still falling at LR floor). The next lever
# is more unique tokens, not more parameters. Target case B below aims at ~3.0B
# train tokens (~2.7x). The frozen NDL selection pool (241,430 candidates) tops
# out near ~3.8B tokens under the current filters; beyond that needs new sources.
data:
  ndl_metadata_dir: data/raw/ndl/metadata
  ndl_metadata_glob: data/raw/ndl/metadata/books_*.zip
  ndl_metadata_urls:
    - https://dl.ndl.go.jp/static/files/dataset/dataset_202602_t_internet_01.zip
    - https://dl.ndl.go.jp/static/files/dataset/dataset_202602_t_internet_02.zip
    - https://dl.ndl.go.jp/static/files/dataset/dataset_202602_t_internet_03.zip
    - https://dl.ndl.go.jp/static/files/dataset/dataset_202602_t_internet_04.zip
    - https://dl.ndl.go.jp/static/files/dataset/dataset_202602_t_internet_05.zip
  # Same frozen 241,430-candidate pool and selection order as phase 3. Expanding
  # the download target just consumes deeper into this manifest; the head 50,000
  # zips are already on disk and skipped by checksum (never re-fetched).
  ndl_selection_manifest: data/processed/ndl/selection.jsonl
  ndl_download_manifest: data/processed/phase4/ndl_downloads.jsonl
  ndl_raw_dir: data/raw/ndl/books
  ndl_clean_dir: data/clean/ndl
  ndl_clean_manifest: data/processed/phase4/ndl_clean.jsonl
  # Reuse phase-3's 27,725 already-cleaned documents so ndl-clean only processes
  # the newly downloaded candidates.
  ndl_clean_reuse_manifest: data/processed/phase3/ndl_clean.jsonl
  ndl_clean_report: phase4_ndl_cleaning.json
  ndl_quality_sample_report: phase4_ndl_quality_sample.jsonl
  # Exclude phase-3 documents from the fresh 200-page human review sample.
  ndl_quality_exclude_manifest: data/processed/phase3/ndl_clean.jsonl
  # Case B (recommended). Head 50,000 already downloaded; this pulls ~136,000
  # more (~14k tokens/candidate in the deep pool) toward ~3.0B train tokens.
  # Case A (fast start): 114000 -> ~2.0B. Case C (exhaust pool): 241430 -> ~3.8B.
  # The actual target is passed on the CLI: ndl-download --max-documents 186000.
  ndl_target_documents: 186000
  ndl_download_delay_seconds: 0.2
  ndl_download_retries: 3
  ndl_max_download_seconds: 600
  split_manifest: data/processed/phase4/splits.jsonl
  ndl_max_abnormal_ngram_rate: 0.38
  ndl_max_latin_rate: 0.005
tokenizer:
  # Keep vocab 16384 (phase-3 choice) for cross-phase BPB comparability. Retrain
  # the BPE on a fresh seeded 200M-character subset of the larger train split.
  vocab_size: 16384
  directory: artifacts/phase4/tokenizer
  max_train_chars: 200000000
tokenized:
  directory: data/processed/phase4/tokenized
model:
  # Unchanged from phase 3: ~345M parameters (26L / 16H / 1024 embd / 1024 ctx).
  n_layer: 26
  n_head: 16
  n_embd: 1024
  block_size: 1024
  dropout: 0.0
training:
  device: cuda
  dtype: bfloat16
  # Same static shapes that completed phase 3 at 44.3/47.8GB on the L40S.
  batch_size: 32
  gradient_accumulation_steps: 8
  # Finalized after flight benchmark (2026-07-20): measured train tokens =
  # 2,742,489,368; flight measured 5.812 s/step on the L40S. tokens_per_step =
  # 32*8*1024 = 262,144. 27,000 iters => 7.08B processed => ~2.58 epochs, and
  # projects 27000*5.812s = ~43.6h / ~$43.2 with margin under the $45 cost cap
  # (28,000 would land ~$44.8, too close). Set lr_decay_iters == max_iters.
  max_iters: 27000
  learning_rate: 0.0003
  min_lr: 0.00003
  warmup_iters: 300
  lr_decay_iters: 27000
  eval_interval: 500
  eval_iters: 50
  checkpoint_interval: 500
  grad_clip: 1.0
  out_dir: artifacts/phase4
budget:
  # Finalized after tokenize (2026-07-20): measured train 2.742B > floor. The
  # binding constraint is the $45 cost cap (= 45.45h at $0.99/h); 28,000 iters
  # (~44.7h / ~$44.3) fits it. Hour cap set to 46 for headroom. Do not start
  # training if the GPU flight benchmark projects beyond these.
  minimum_train_tokens: 2700000000
  maximum_hours: 46
  maximum_usd: 45
  gpu_hourly_usd: 0.99