AjayRangoji's picture
Upload LOG.md
f9ad84b verified
|
Raw History Blame Contribute Delete
18.2 kB
# LOG
## 2026-10-18 - Phase 0: setup, decisions locked
### Decisions (approved by guide, locked before any run)
| # | Decision |
|---|---|
| 1 | Start from **pretrained-only** checkpoint. VERIFIED AVAILABLE: `buddhist-nlp/byt5-sanskrit`. Paper must state pretraining saw raw unsegmented DCS/Sangraha text (not gold-split leakage). |
| 2 | Paper's model size (**ByT5-base**) for everything reported. ByT5-small only for code debugging, never for the pilot. |
| 3 | Transliteration: **IAST, NFC-normalised, lowercase**, matching ByT5-Sanskrit's training format. Print IAST for human checks. |
| 4 | Overlap test set DCS n Itihasa, ref-match then fuzzy >=0.95, dev ~500 / test ~1000-2000, ids frozen. Report ACTUAL matched count. Near-duplicate removal at 0.95 against both train data and pseudo-label pool. |
| 5 | Build dictionary scorer (A) -> run pilot -> then aligner scorer (B). |
| 6 | Lemmatiser retrained on DCS train split with dev/test removed. NOT the multitask model (gold-annotation leakage). |
| 7 | **GO/NO-GO RULE, FIXED 2026-10-18 BEFORE ANY RESULTS WERE SEEN** (see below). |
| 8 | 3 seeds x 3 gold sizes. Paired bootstrap over test sentences for the main comparison. Report seed std as well. |
| 9 | All stretch goals deferred until Experiments 1-3 are complete. |
| 10 | Venue: ISCLS. Hand-checks done on a sample by the operator; do not block computation on them. |
### GO/NO-GO RULE (fixed 2026-10-18, before running anything)
> **GO** if combined gold@1 beats splitter-alone gold@1 by **>= 3.0 points absolute** on the
> **dev** set at the **10% gold** size, **AND** the paired bootstrap 95% confidence interval
> on that difference excludes zero.
>
> Otherwise NO-GO: follow the guide's fallback (try the 1% model; if translation-only is near
> random, inspect 30 failures before continuing).
This rule was written down before any pilot number existed.
### Findings (Phase 0 investigation)
- `dharmamitra/byt5-sanskrit-analyzers` is the official repo for Nehrdich, Hellwig & Keutzer
(EMNLP Findings 2024), "One Model is All You Need: ByT5-Sanskrit". arXiv:2409.13920.
- **Pretrained base checkpoint IS released**: `buddhist-nlp/byt5-sanskrit`. Decision 1 stands,
no fallback to (b) needed.
- Its `config.json` is **ByT5-base** geometry: d_model=1536, d_ff=3968, 18 encoder layers,
6 decoder layers, 12 heads, vocab 384. So "the paper's size" = ByT5-base (~582M params).
- Finetuned multitask model (for reference / NOT to be used for our lemmas):
`chronbmm/sanskrit5-multitask`.
- **Input format, read off `applications/segmentation-lemma-tagging/`**:
- Transliteration is **IAST** (toy-data: `agnim ide purohitam yajnasya devam rtvijam`),
lowercase, no dandas, no verse numbers, one sentence per line.
- Task prefix for segmentation is the literal string `"S "` prepended to the input.
Other prefixes: `SM `, `L `, `LM `, `SLM `.
- `max_length = 512` for both input and generation.
- Pretraining data: AI4Bharat Sangraha. Finetuning data: DCS.
- **Training/preprocessing code is NOT released** ("we will add the training and data sections
in the future"). Our baseline recipe must therefore be reconstructed from the paper, and the
reproduction target (within ~1 point of published segmentation score) is the check that we
reconstructed it correctly.
### Cluster
- 10.0.139.113: 8x H100 80GB, 192 cores, free.
- 10.0.144.104: 8/8 GPUs IN USE (shyam.pawar, shyama-intern) - DO NOT TOUCH.
- 10.0.145.120 / 10.0.155.166 / 10.0.157.253: 8x H100 each, free.
- /fsx is 99% full, 487 GB free. Watch this.
## 2026-10-18 - Phase 1a: environment + data acquisition
### Environment
- conda env at `./.conda-env` (Python 3.10.22). Install with
`PYTHONNOUSERSITE=1 ./.conda-env/bin/pip install -r requirements.txt`.
- **Always set `PYTHONNOUSERSITE=1`** and invoke `python -I`: the login node has a populated
`~/.local/lib/python3.10/site-packages` that otherwise shadows the env.
- Pinned `indic-transliteration==2.3.82` (2.3.63 was never released on PyPI).
- torch 2.4.1 + transformers 4.44.2 installed and importable.
### Data downloaded to data/raw/ (2026-10-18)
| Source | Files | Size / count |
|---|---|---|
| `rahular/itihasa` | train/dev/test .sn.csv + .en.csv | 75,161 train pairs (+dev/test) |
| `chronbmm/sanskrit-sandhi-split-sighum` | train/validation/test.parquet | 99,889 / 4,200 / 4,200 |
| `chronbmm/sanskrit-sandhi-split-hackathon` | train/validation/test.parquet | 89,323 / 10,235 / 9,965 |
The two `chronbmm/*` datasets are the ByT5-Sanskrit authors' own segmentation benchmark splits
(columns: `sentence` = sandhied input, `unsandhied` = gold split). This gives us the "standard
segmentation benchmark" for comparability without reconstructing it ourselves.
### !! DEFECT FOUND in sighum dataset
`sanskrit-sandhi-split-sighum` **validation and test splits are byte-identical**
(both n=4,200, md5 `910044e1469b`). Tuning anything on that validation set would be tuning on
test. Consequences:
- Use **hackathon** as the primary standard benchmark (its validation n=10,235 and test n=9,965
are genuinely distinct, md5 `d0e92fe3b23d` vs `7112eeaad721`).
- If a SIGHUM number is needed for comparability, report test only and tune nothing on it, or
obtain the original SIGHUM release separately.
### Format confirmation
Benchmark data is already **IAST, lowercase, no dandas, no verse numbers** - matches the format
ByT5-Sanskrit expects. Decision 3 confirmed against real data.
**Itihasa Sanskrit is in DEVANAGARI**, not IAST (e.g. `ॐ तपः स्वाध्यायनिरतं ...`), so the
normalisation step must transliterate Devanagari -> IAST (NFC) before anything else. The
English side is plain text.
### Still to acquire
- DCS corpus proper (for lemma/morph annotations and the epic verses used in overlap matching).
Candidate: `tokushige-koyasan/dcs-corpus` (CoNLL-U, ~210 MB).
- Monier-Williams / Apte digital dictionary for Scorer A.
- Pretrained checkpoint `buddhist-nlp/byt5-sanskrit`.
## 2026-10-18 - Phase 1b/2: corpora built, overlap set built, splits FROZEN
### Corpora (data/processed/)
| File | Verses |
|---|---|
| `dcs_epics.jsonl` (Ramayana + Mahabharata, gold splits) | 91,931 |
| `dcs_all.jsonl` (all 270 DCS texts, gold splits) | 392,204 |
| `itihasa.jsonl` (Sanskrit + English) | 93,026 |
DCS source: `tokushige-koyasan/dcs-corpus`, a mirror of `OliverHellwig/sanskrit`
`dcs/data/conllu/files` @ `04e0778d`, 270 texts / 754,726 sentences, CC BY 4.0.
CoNLL-U carries `Unsandhied=` per token (gold split), `lemma` (for D07 lemmatiser training)
and `Case=Cpd` (lets us report compound-internal vs between-word splits separately, as the
evaluation section requires).
### Overlap set (DCS n Itihasa) - **actual matched count, as D04 requires**
- exact (collapsed key): **15,247**
- fuzzy >= 0.95: **22,979**
- **TOTAL: 38,226** verses = 41.1% of Itihasa, 41.6% of DCS epics
- ambiguous dropped: 773
- fuzzy similarity: min 0.9500, p10 0.9551, median 0.9753
- of the exact matches, **15,031** are character-identical ignoring whitespace (-> D17 pool)
- composition: Mahabharata 30,303 / Ramayana 7,923; mean 14.2 gold words per verse
This is far above the 1,500-2,500 the guide hoped for. The feared failure mode (editions too
different to match) did not occur: Itihasa and the DCS epics are evidently close editions.
### Manual verification (D11, done by operator)
Inspected 8 random matches and the 6 lowest-similarity fuzzy matches.
- All 14 are genuinely the same verse; the English in each case translates that verse.
- The lowest accepted matches differ only by edition variants
(`dharmarthinam`/`dharmartho`, `mukhyesu`/`yuktesu`, `sambhuna`/`sambhuna`) or OCR noise.
- Conclusion: the 0.95 threshold admits no false positives in this sample. Recorded rather
than assumed.
### FROZEN SPLITS (data/splits/) - never regenerate
```
overlap_dev.ids 82 chapters 501 verses
overlap_test.ids 324 chapters 2001 verses
```
Sampled by chapter with seed 13; chapter sets asserted disjoint. `make_splits.py` refuses to
overwrite these files (D20). Provenance in `data/splits/PROVENANCE.md`.
### Code added
`src/data/normalize.py`, `src/data/dcs.py`, `src/data/build_corpora.py`,
`src/data/overlap.py`, `src/data/make_splits.py`; configs `data.yaml`, `overlap.yaml`,
`splits.yaml`.
## 2026-10-18 - Phase 2b: leakage-free pools + audit
### Pools built (`build_pools.py`, seed 13, threshold 0.95)
| Pool | Kept | Dropped (held-out id) | Dropped (near-duplicate) |
|---|---|---|---|
| `dcs_train_pool.jsonl` | 389,691 | 2,502 | 11 |
| `itihasa_pool.jsonl` | 90,510 | 2,502 | 14 |
Near-duplicate counts are low because dev/test were sampled by whole chapter (D19), so most
repeats of a held-out verse were already removed with its chapter.
### Leakage audit (`assert_no_leakage.py`) - RUN BEFORE EVERY TRAINING RUN
```
dcs_train_pool n= 389691 held_id=0 identical_text=0 near_dup>=0.95=0
itihasa_pool n= 90510 held_id=0 identical_text=0 near_dup>=0.95=0
CLEAN (exit 0)
```
The auditor is deliberately written independently of `build_pools.py`: a shared bug would
otherwise be invisible to both.
### Negative test of the auditor (important)
A passing audit means nothing unless the audit can fail. Injected into a copy of the pool:
1. a dev verse re-inserted under a different id, and
2. a dev verse with a single character mutated.
Result: `identical_text=1 near_dup>=0.95=1`, **exit 1**. The audit detects both. Verified
rather than assumed.
## 2026-10-18 - Phase 3: evaluator + unit tests
`src/evaluate.py` is the single evaluation module for every experiment.
Metrics: token P/R/F1, sentence exact match, split-location P/R/F1, and the
compound-internal / between-word distinction (available via DCS `Case=Cpd`).
### Two deliberate design choices
1. **Multiset, not set, token matching.** Gold `ca ca na na` against prediction
`ca na` scores recall 2/4, not 1.0. Epic verses repeat particles (`ca`, `na`,
`kaḥ`) constantly, so set matching would silently inflate every number. There
is a regression test pinning this.
2. **Split-location via Levenshtein alignment, not a greedy character scan.**
The first implementation walked the sandhied string with `str.find` and
mis-aligned whenever a character recurred later - which in Sanskrit is
constant. It failed 2 of 10 unit tests, including "perfect prediction must
score 100". Replaced with an opcode-based position map. **This is exactly the
failure the guide warns about: code that runs and silently miscounts.** It was
caught only because the hand-worked tests were written first.
### Unit tests (`tests/test_evaluate.py`) - 10/10 pass
Includes the two the guide requires (perfect prediction = 100, empty prediction
= 0 without crashing), plus empty gold, multiset semantics, a set-matching
regression guard, order sensitivity, hand-computed partial credit, and a
"form error" case where boundaries are right but the sandhi form is wrong
(token F1 penalised, split-location not).
### Real-data validation on the frozen test set (2,001 verses)
| Prediction | token F1 | exact match | split-loc F1 | align failures |
|---|---|---|---|---|
| gold vs gold (must be 100) | 100.00 | 100.00 | 100.00 | 0 |
| no-split baseline (raw text) | 44.32 | 0.05 | 86.14 | 0 |
| empty | 0.00 | 0.00 | 0.00 | 2001 |
Zero alignment failures on 2,001 real verses.
**Worth noting for the paper:** the no-split baseline already reaches 86.14
split-location F1, because DCS sandhied text is printed with spaces at most word
boundaries; only compound-internal and sandhi-fused boundaries are missing. So
split-location is the *easy* metric on this data and will compress differences
between systems. **Token F1 and sentence exact match are the discriminative
metrics** and should lead the results tables.
## 2026-10-19 - Phase 4a: training data rebuilt from a clean source
### !! CONTAMINATION FOUND IN THE RELEASED BENCHMARK TRAIN SPLITS
Checked at **half-verse** granularity (the granularity the benchmarks use):
| Split | identical to held-out | near-dup | contaminated |
|---|---|---|---|
| hackathon **train** | 5,535 | 352 | **6.59%** of 89,323 |
| hackathon test | 86 | 106 | 1.93% |
| sighum **train** | 3,662 | 3 | **3.67%** of 99,889 |
| sighum validation | 40 | 1 | 0.98% |
| sighum test | 40 | 1 | 0.98% |
Training the baseline on the released hackathon train split - the obvious move - would have put
a half-verse of one of our frozen test verses in ~1 of every 15 training examples.
### How the first check nearly passed it
The first contamination check compared **full-verse** keys against the **half-verse** benchmark
and returned **0.00% for all six splits**. A false clean: keys of different granularity can never
match. Caught only because six clean splits of DCS-derived data was implausible; measuring
string lengths showed benchmark sentences average 35 chars vs our 81. -> **D24**.
### Response (D21-D23)
Never train on a released benchmark train split. All training data derived from our own audited
`dcs_train_pool.jsonl`, emitted at both granularities:
| File | Pairs |
|---|---|
| `seg_train_half.jsonl` | 744,649 (dropped 10,077 held-out/near-dup) |
| `seg_train_full.jsonl` | 389,690 (dropped 1) |
| `seg_train_all.jsonl` | **1,134,339** |
Independent re-audit at both granularities against 7,562 held-out keys:
`identical=0 near_dup=0` -> **CLEAN**.
### Gold-size subsets (`data/processed/gold/`, seed 13, by chapter, NESTED)
| Subset | Chapters | Records | full / half |
|---|---|---|---|
| `gold_1pct` | 138 | 11,466 (1.01%) | 3,995 / 7,471 |
| `gold_10pct` | 1,495 | 113,636 (10.02%) | 38,829 / 74,807 |
| `gold_100pct` | 15,790 | 1,134,339 (100%) | 389,690 / 744,649 |
Nesting is asserted in code (1% subset of 10% subset of 100%), so a difference between gold
sizes is a difference in quantity only, not in which chapters are present.
### Checkpoint verified (D01, D02)
`buddhist-nlp/byt5-sanskrit`: **581.7M params**, d_model 1536, d_ff 3968, 18 enc / 6 dec,
12 heads - ByT5-**base**, confirming D02. Tokenizer `ByT5Tokenizer`, vocab 256 (byte-level).
IAST round-trip through the tokenizer is exact, confirming D03 end to end.
### Cluster note
/fsx recovered to 1.2 TB free. Nodes 139.113 / 145.120 / 157.253 now all 8/8 busy with other
users' jobs; **155.166 is the only free node** and is the one to use.
## 2026-10-20 - Phase 4b: training pipeline live, end-to-end verified
### First GPU run (ByT5-small debug, node 10.0.157.253 GPU 0)
Purpose: prove the pipeline before spending base-size compute (D02). Never a reported number.
**Run 1 FAILED - and this is why the debug run exists.**
Training completed fine (loss 0.32 -> 0.21, 200 steps, 10.7 it/s), then crashed at
*checkpoint save*:
```
ValueError: You are trying to save a non contiguous tensor:
`encoder.block.0.layer.0.SelfAttention.q.weight`
```
ByT5 checkpoints load with non-contiguous attention weights; safetensors refuses them. The
failure strikes AFTER training finishes, so on a full base-size run it would have thrown away
hours of H100 time at the final step - and would have hit all ~36 runs.
Fix: `make_contiguous()` packs every parameter after load and again before the final save.
**Run 2 PASSED.** train_loss 0.460, 24.6 s, 65 samples/s, checkpoint written
(`outputs/debug_small_seed13/final`, 1.2 GB). Leakage gate passed before training in both runs.
### Candidate generation verified (`src/splitter/topk.py`)
Ran k=5 beam search on 20 dev verses with the debug model:
- 5 candidates per verse after whitespace dedup
- top-1 token F1 **69.0**, exact match 0.0, oracle recall@5 **0/20**
Those numbers are *expected to be poor*: a 200-step ByT5-small on 4k examples. What they prove
is that the chain runs end to end - data -> prefix "S " -> training -> checkpoint -> beam search
-> evaluator.
### !! RISK TO WATCH at the baseline stage
The 5 candidates for a verse are **very similar to each other**, differing in one or two
boundaries. The guide requires that "candidates should differ in meaningful ways", and the whole
project depends on the gold split being *present among the candidates* - if beam search returns
near-duplicates, oracle recall@k stays near top-1 accuracy and reranking cannot help, whatever
the translation scorer does. Beam search on a confident seq2seq model is known to do this.
**Action: measure oracle recall@5/10/20 on the real baselines before building the scorers.** If
recall@10 is not well above top-1, raise k, add diverse beam search, or move to word-level
candidates as the guide suggests.
### Code added
`src/splitter/train.py` (with leakage gate + contiguity fix), `src/splitter/topk.py`,
`scripts/launch.sh` (claims only GPUs under 100 MiB used, refuses to launch otherwise),
configs `train_debug_small.yaml`, `topk_debug.yaml`.
## 2026-10-20 - Phase 4c: baselines live
### Three baselines launched in parallel on H100s
| Run | Node | GPU | Steps | Data (pairs) | Eff batch |
|---|---|---|---|---|---|
| base_1pct seed 13 | 10.0.155.166 | 0 | 4,000 | 11,466 | 16 |
| base_10pct seed 13 | 10.0.157.253 | 0 | 20,000 | 113,636 | 16 |
| base_100pct seed 13 | 10.0.157.253 | 1 | 60,000 | 1,134,339 | 16 |
Measured throughput: **4.14 it/s** on one H100 at batch 8 for ByT5-base.
Projected: 1pct ~16 min, 10pct ~80 min, 100pct ~4h. All three leakage gates passed.
### LAUNCHER RACE CONDITION FIXED
The first launcher queried `nvidia-smi` for `memory.used < 100 MiB`. When two runs launched
within 5 seconds, both saw GPU 0 as idle (the first job had not yet allocated memory) and both
claimed it. Caught by inspecting GPU utilisation afterward: pid 3679706 and 3679990 both on the
same UUID.
Fix in `scripts/launch.sh`: a GPU counts busy if it has ANY compute process OR >=100 MiB
memory. Supports explicit `GPU=<index>` to override. The second launch now gets a different
UUID. If I had not checked GPU utilisation, both runs would have thrashed on one GPU for 4
hours and the 100% baseline would have been garbage.
### Loss curve - 1pct, first 1,600 steps
0.38 (step 100) -> 0.10 -> 0.05 -> 0.052 -> 0.046 -> 0.038 -> 0.024 (step 1600).
Steady decrease, grad norms well-behaved (0.15-0.80), lr decaying as scheduled.