mengsay commited on
Commit
4e34812
·
verified ·
1 Parent(s): e62d863

Initial private draft of the Samdei Type release

Browse files
README.md ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: Samdei Type Pretraining Data
3
+ license: cc-by-sa-4.0
4
+ language:
5
+ - km
6
+ task_categories:
7
+ - text2text-generation
8
+ tags:
9
+ - transliteration
10
+ - romanization
11
+ - romanized-khmer
12
+ - khmer
13
+ - synthetic
14
+ size_categories:
15
+ - 10M<n<100M
16
+ multilinguality: monolingual
17
+ source_datasets:
18
+ - extended|HPLT/HPLT2.0_cleaned
19
+ - extended|HuggingFaceFW/fineweb-2
20
+ - extended|wikimedia/wikipedia
21
+ - extended # + ALT (Asian Language Treebank, NICT), downloaded from NICT, not from the Hub
22
+ annotations_creators:
23
+ - machine-generated
24
+ language_creators:
25
+ - found
26
+ - machine-generated
27
+ configs:
28
+ - config_name: generator_v2
29
+ default: true
30
+ data_files:
31
+ - split: train
32
+ path: generator_v2/train_v2_s3.parquet
33
+ - split: validation
34
+ path: generator_v2/train_v2_s3.dev.parquet
35
+ - config_name: generator_v1
36
+ data_files:
37
+ - split: train
38
+ path:
39
+ - generator_v1/train_web_s1.parquet
40
+ - generator_v1/train_web_s2.parquet
41
+ - split: validation
42
+ path: generator_v1/train_web_s1.dev.parquet
43
+ - config_name: llm_chat_sentences
44
+ data_files:
45
+ - split: train
46
+ path: llm/train_gemma_s1.parquet
47
+ - config_name: llm_romanized
48
+ data_files:
49
+ - split: train
50
+ path: llm/train_gemrom.parquet
51
+ ---
52
+
53
+ # Samdei Type Pretraining Data
54
+
55
+ These are the exact **pretraining (stage-1)** pairs of the Samdei Type romanized-Khmer → Khmer-script converters: 19.3M (romanized input, Khmer target) pairs. Every **Khmer target is real text**: 1.41M sentences from HPLT v2, FineWeb-2, Khmer Wikipedia and ALT, plus 2,483 chat sentences written by Gemma 4. The **romanized input** is made by a rule-based generator that spells each piece of a sentence as one of four typing personas would type it, and for a small part by Gemma 4.
56
+
57
+ They trained the checkpoints in [`samdei/samdei-type-pretrained`](https://huggingface.co/samdei/samdei-type-pretrained), from which Samdei Type Mini and Base were fine-tuned. The fine-tuning and adaptation data (stages 2–3) is in [`samdei/samdei-type-finetuning-data`](https://huggingface.co/datasets/samdei/samdei-type-finetuning-data).
58
+
59
+ Paper: `<paper-url>`. Code: `<code-repo-url>`. Test set: [`samdei/samdei-type-bench`](https://huggingface.co/datasets/samdei/samdei-type-bench).
60
+
61
+ ## Configs and files
62
+
63
+ The data is organized by what it is, not by model. `recipes.json` gives the exact mix of each model (files, repeats, steps, learning rate), read from the training arguments stored in the checkpoints.
64
+
65
+ | Config | Files (rows) | What it is | Used by |
66
+ |---|---|---|---|
67
+ | `generator_v2` (default) | `train_v2_s3` (6,501,912) | web sentences and the chat sentences, spelled by the second generator version (seed 3) | Mini |
68
+ | `generator_v1` | `train_web_s1` (6,289,947), `train_web_s2` (6,288,484) | web sentences, spelled by the first generator version (seeds 1 and 2) | Base; the channel model (`train_web_s1`) |
69
+ | `llm_chat_sentences` | `train_gemma_s1` (189,431) | the 2.4k LLM-written chat sentences, spelled by the first generator version, ×40 | Base; the channel model |
70
+ | `llm_romanized` | `train_gemrom` (5,715) | Gemma 4 romanizations of 2,000 real sentences (×3 copies with random casing) | Mini (listed ×3 in its mix); the channel model |
71
+
72
+ | Model | Stage-1 mix | Pairs |
73
+ |---|---|---|
74
+ | Base (18.2M) | `train_web_s1` + `train_web_s2` + `train_gemma_s1` | 12,767,862 |
75
+ | Mini (7.1M) | `train_v2_s3` + `train_gemrom` ×3 | 6,519,057 |
76
+ | channel model (Khmer → Latin, used in Base's reranker) | `train_web_s1` + `train_gemma_s1` + `train_gemrom` | 6,485,093 |
77
+
78
+ **Why two generator versions.** Base was pretrained first, with the first generator version. The second version adds:
79
+ - English chat words and place names inserted on both sides;
80
+ - standalone place-name pairs (`persona` = `place`);
81
+ - sentence-final punctuation dropped from both sides together.
82
+
83
+ It came out of the errors of the first models. Mini was pretrained with it, and both models' later stages use it. Both versions are here, so both models' pretraining can be reproduced exactly.
84
+
85
+ **Validation splits** are synthetic: held-out sentences spelled by the same generator, monitored during training. Checkpoints were selected on separate evaluation sets, which are not part of this dataset.
86
+
87
+ ```
88
+ generator_v1/ train_web_s1.parquet train_web_s2.parquet train_web_s1.dev.parquet
89
+ generator_v2/ train_v2_s3.parquet train_v2_s3.dev.parquet
90
+ llm/ train_gemma_s1.parquet train_gemrom.parquet
91
+ recipes.json
92
+ ```
93
+
94
+ ## Columns
95
+
96
+ | Column | Content |
97
+ |---|---|
98
+ | `latin` | romanized input, as the model saw it |
99
+ | `khmer` | Khmer-script target, normalized with `khnormal`; English words, digits and brand names are copied from the input |
100
+ | `persona` | `formal`, `careful`, `mixed` or `lazy` (the generator's typing personas, from standard spelling to heavy chat shortcuts and typos); `place` (gazetteer pair); `gemrom0`–`gemrom3` (Gemma 4 with one of four style prompts) |
101
+ | `source` | where the Khmer target comes from: `hplt`, `fineweb2`, `wikipedia`, `alt` (a piece of a web sentence); `gemma` (a piece of an LLM-written chat sentence); `gazetteer`; `gemrom_<x>` (a whole sentence from `<x>`, romanized by Gemma 4) |
102
+
103
+ ## How to load
104
+
105
+ ```python
106
+ from datasets import load_dataset
107
+ ds = load_dataset("samdei/samdei-type-pretraining-data", "generator_v2", split="train")
108
+ print(ds[0]) # {'latin': ..., 'khmer': ..., 'persona': ..., 'source': ...}
109
+ ```
110
+
111
+ To rebuild a mix exactly, read `recipes.json` and concatenate its files in order, with repeats. The training script reads the same four columns from TSV (`scripts/train.py --train <files...>` in the code repository).
112
+
113
+ ## How the pairs were made
114
+
115
+ 1. **Khmer targets.**
116
+ - 1.41M web sentences: HPLT v2 802k (3 of 13 shards of khm_Khmr), FineWeb-2 280k, Khmer Wikipedia 306k (20231101 dump) and the Khmer side of ALT 22k.
117
+ - Each sentence is normalized with `khnormal`, split and deduplicated.
118
+ - Lines with URLs or e-mail-like strings, and lines that are mostly Latin, are dropped.
119
+ - Sentences that overlap an evaluation set are removed before any pair is made.
120
+ - 2,483 chat sentences were written by Gemma 4 12B, run locally, across 50 chat domains and 4 registers.
121
+ 2. **The persona generator** (`rkhmer.romanize`, `scripts/make_synth.py`):
122
+ 1. It cuts each sentence into pieces of 1–12 words (mostly 5–6) with `khmercut`.
123
+ 2. It pronounces each word with Google's Khmer pronunciation lexicon (62k words, CC BY 4.0); rule-based G2P covers the rest.
124
+ 3. It spells the piece in a sampled persona: formal 8%, careful 32%, mixed 40%, lazy 20%. Personas differ in spelling choices (`nh / ny / gn`, final consonants, vowels) and in how often they use a hand-written chat lexicon (`knhom`, `kyom` or `nh` for ខ្ញុំ).
125
+ 4. It adds noise: glued or split words, dropped vowels, k/g and t/d swaps, mistyped keys.
126
+ 3. **LLM romanizations.** Gemma 4 12B romanized real sentences "the way Cambodians type on Messenger", with 4 style prompts. The Khmer side stays the original sentence.
127
+
128
+ **Test separation.**
129
+ - Every sentence of every evaluation set, including Samdei Type Bench, is removed from the corpus and banned in the generator.
130
+ - No Samdei Type Bench message equals a training target. The only shared strings are common single words.
131
+
132
+ **Reproducibility.** The seeds are in the file names (`_s1`, `_s2`, `_s3`). The generator has since gained stricter banned lists, so regenerating today can differ slightly. These files are the ones the released models were trained on.
133
+
134
+ ## Limitations
135
+
136
+ - **Synthetic inputs.** No row is real typing; romanizations follow our four personas and one LLM.
137
+ - **Pieces, not messages.** Inputs are short (median 26 characters, at most 132).
138
+ - **Web noise.** About 1.5% of HPLT lines are misordered text extracted from PDFs.
139
+ - **Personal data.** Web text may contain names, phone numbers or other personal data of the original authors. Lines with URLs or e-mail-like strings were dropped, but no other personal-data filter was run. Contact `<contact>` to have a row removed.
140
+ - **LLM text.** The Gemma-written chat sentences and romanizations can contain mistakes.
141
+
142
+ ## License and attribution
143
+
144
+ **CC BY-SA 4.0** ([license text](https://creativecommons.org/licenses/by-sa/4.0/)). The rows contain pieces of the source sentences, so the source licenses travel with them: Khmer Wikipedia's share-alike terms set the license of the whole set, and rows from the other sources also stay under their own terms below.
145
+
146
+ | Source | Side | License |
147
+ |---|---|---|
148
+ | HPLT v2 (`HPLT/HPLT2.0_cleaned`, khm_Khmr) | Khmer | CC0 packaging; Common Crawl terms of use apply to the text |
149
+ | FineWeb-2 (`HuggingFaceFW/fineweb-2`, khm_Khmr) | Khmer | ODC-By 1.0; Common Crawl terms of use apply to the text |
150
+ | Khmer Wikipedia (`wikimedia/wikipedia`, 20231101.km) | Khmer | CC BY-SA 4.0 (share-alike) |
151
+ | Asian Language Treebank (ALT), Khmer side | Khmer | CC BY 4.0 |
152
+ | LLM-written chat sentences (ours, Gemma 4) | Khmer | CC BY 4.0 (Gemma 4: Apache-2.0) |
153
+ | Gemma 4 romanizations (ours) | Latin | Apache-2.0 model output; Khmer side as its source |
154
+ | Google Khmer pronunciation lexicon | Latin (generator) | CC BY 4.0 |
155
+ | Chat lexicon, place names, English chat words (ours) | Latin (generator) | CC0 |
156
+
157
+ Rows whose `source` is `wikipedia` or `gemrom_wikipedia` carry Wikipedia's share-alike terms. They are about 19% of `train_web_s1`, `train_web_s2` and `train_v2_s3`.
158
+
159
+ **Changes to the source text.** The sentences were normalized with `khnormal`, filtered and deduplicated; the generator cut them into pieces of 1–12 words. Each Khmer target is paired with a romanization in the `latin` column (see "How the pairs were made").
160
+
161
+ ## Citation
162
+
163
+ ```bibtex
164
+ @misc{samdei-type-2026,
165
+ title = {Samdei Type: Separating What Is Written from How It Is Spelled for Romanized Khmer Transliteration},
166
+ author = {<authors>},
167
+ year = {2026},
168
+ url = {<paper-url>}
169
+ }
170
+ ```
171
+
172
+ Contact: `<contact>`
generator_v1/train_web_s1.dev.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1099f14ea06187a4ee4750f4ebc159339e03713d374a3ca12c9f2037d0980f90
3
+ size 552434
generator_v1/train_web_s1.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad1c21bccef71b41a595c7cc67c2dc4cf6c6fffa34577aebb7ad85acb9ce4770
3
+ size 240663472
generator_v1/train_web_s2.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad764d5392449db8bbb7ecf515779888183f1ff53c500de85f0301d197c884a6
3
+ size 240628626
generator_v2/train_v2_s3.dev.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b4542d22a9847a859badbc27551f4589999cb8fd0ad0e7b5f79e421daef207d
3
+ size 573860
generator_v2/train_v2_s3.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3bc76e3e432cb6cb594c55d62d6d7f8da93757baea9ffcddaffc9d60ad4bebf7
3
+ size 254725596
llm/train_gemma_s1.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:02110d37c9916390cbae80d585d01c88603de73861e35fe3a27dbf7d0cad7c55
3
+ size 2295066
llm/train_gemrom.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5fd098ef99c3cb734ba19a51ecebfa25d6e4d499dee124c6526d03813ef8131f
3
+ size 163495
recipes.json ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "about": "Exact training mixes of the Samdei Type checkpoints trained on this dataset, read from the arguments stored in each checkpoint (scripts/train.py). Files are listed in the order given to the training script; 'repeat' is how many times the file was listed. Paths are relative to this dataset unless they name another repo. 'monitor' is the synthetic held-out file watched during training; checkpoints were selected as given in 'selected_on'.",
3
+ "shared": {
4
+ "optimizer": "AdamW, betas 0.9/0.98, weight decay 0.01",
5
+ "schedule": "cosine decay to 5% of the peak",
6
+ "label_smoothing": 0.1,
7
+ "precision": "bf16 autocast",
8
+ "batching": "about 12k tokens per batch, 2-D length buckets padded to multiples of 16"
9
+ },
10
+ "runs": [
11
+ {
12
+ "model": "samdei-type-base",
13
+ "stage": 1,
14
+ "direction": "latin->khmer",
15
+ "init": null,
16
+ "released_as": "samdei/samdei-type-pretrained: base/",
17
+ "train": [
18
+ {
19
+ "file": "generator_v1/train_web_s1.parquet",
20
+ "repeat": 1
21
+ },
22
+ {
23
+ "file": "generator_v1/train_web_s2.parquet",
24
+ "repeat": 1
25
+ },
26
+ {
27
+ "file": "llm/train_gemma_s1.parquet",
28
+ "repeat": 1
29
+ }
30
+ ],
31
+ "monitor": "generator_v1/train_web_s1.dev.parquet",
32
+ "steps": 60000,
33
+ "selected_step": 60000,
34
+ "warmup": 3000,
35
+ "peak_lr": 0.0007,
36
+ "max_tokens_per_batch": 12000,
37
+ "seed": 1,
38
+ "selected_on": "lowest mean greedy CER on Dev-Sentences and Akkhara-Preview (selection only; never trained on)",
39
+ "model_config": {
40
+ "d_model": 384,
41
+ "nhead": 6,
42
+ "enc_layers": 6,
43
+ "dec_layers": 3,
44
+ "ff": 1536,
45
+ "dropout": 0.1,
46
+ "max_len": 256,
47
+ "src_vocab": 216,
48
+ "tgt_vocab": 228
49
+ }
50
+ },
51
+ {
52
+ "model": "samdei-type-mini",
53
+ "stage": 1,
54
+ "direction": "latin->khmer",
55
+ "init": null,
56
+ "released_as": "samdei/samdei-type-pretrained: mini/",
57
+ "train": [
58
+ {
59
+ "file": "generator_v2/train_v2_s3.parquet",
60
+ "repeat": 1
61
+ },
62
+ {
63
+ "file": "llm/train_gemrom.parquet",
64
+ "repeat": 3
65
+ }
66
+ ],
67
+ "monitor": "generator_v2/train_v2_s3.dev.parquet",
68
+ "steps": 40000,
69
+ "selected_step": 35000,
70
+ "warmup": 2000,
71
+ "peak_lr": 0.001,
72
+ "max_tokens_per_batch": 12000,
73
+ "seed": 1,
74
+ "selected_on": "lowest mean greedy CER on Dev-Sentences and Akkhara-Preview (selection only; never trained on)",
75
+ "model_config": {
76
+ "d_model": 256,
77
+ "nhead": 4,
78
+ "enc_layers": 6,
79
+ "dec_layers": 2,
80
+ "ff": 1024,
81
+ "dropout": 0.1,
82
+ "max_len": 256,
83
+ "src_vocab": 215,
84
+ "tgt_vocab": 228
85
+ }
86
+ },
87
+ {
88
+ "model": "samdei-type-base: channel model",
89
+ "stage": 1,
90
+ "direction": "khmer->latin",
91
+ "init": null,
92
+ "released_as": "samdei/samdei-type-base: channel/",
93
+ "train": [
94
+ {
95
+ "file": "generator_v1/train_web_s1.parquet",
96
+ "repeat": 1
97
+ },
98
+ {
99
+ "file": "llm/train_gemma_s1.parquet",
100
+ "repeat": 1
101
+ },
102
+ {
103
+ "file": "llm/train_gemrom.parquet",
104
+ "repeat": 1
105
+ }
106
+ ],
107
+ "monitor": "generator_v1/train_web_s1.dev.parquet",
108
+ "steps": 25000,
109
+ "selected_step": 20000,
110
+ "warmup": 2000,
111
+ "peak_lr": 0.001,
112
+ "max_tokens_per_batch": 12000,
113
+ "seed": 1,
114
+ "selected_on": "lowest greedy CER on the monitor file",
115
+ "model_config": {
116
+ "d_model": 256,
117
+ "nhead": 4,
118
+ "enc_layers": 6,
119
+ "dec_layers": 2,
120
+ "ff": 1024,
121
+ "dropout": 0.1,
122
+ "max_len": 256,
123
+ "src_vocab": 228,
124
+ "tgt_vocab": 216
125
+ }
126
+ }
127
+ ]
128
+ }