Datasets:

Modalities:
Text
Formats:
json
Languages:
Thai
ArXiv:
License:
File size: 9,859 Bytes
b35eaa3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
08fb0d9
b35eaa3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c43195
b35eaa3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c43195
 
b35eaa3
 
 
 
 
 
 
 
 
08fb0d9
 
 
 
 
 
 
b35eaa3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
---
language:
- th
license:
- cc-by-sa-4.0
- cc-by-sa-3.0
- cc0-1.0
- apache-2.0
pretty_name: OpenThai2.0 WordSeg Benchmark
task_categories:
- token-classification
tags:
- thai
- word-segmentation
- tokenization
- benchmark
size_categories:
- 10K<n<100K
configs:
- config_name: tud
  default: true
  data_files:
  - split: test
    path: data/tud.jsonl
- config_name: pud
  data_files:
  - split: test
    path: data/pud.jsonl
- config_name: ws160
  data_files:
  - split: test
    path: data/ws160.jsonl
- config_name: vistec
  data_files:
  - split: test
    path: data/vistec.jsonl
---

# OpenThai2.0-WordSeg-Benchmark

A standard test for Thai word segmentation, version 1.0: seven test sets, one scoring rule, and the results of
twelve systems. It accompanies [the LATTE-WordSeg-Lite paper](https://arxiv.org/abs/2611.21300).

## Quick start

```bash
pip install -U huggingface_hub
hf download iapp/OpenThai2.0-WordSeg-Benchmark --repo-type dataset --local-dir wordseg-bench
cd wordseg-bench && pip install -r requirements.txt
```

```python
from benchmark import evaluate

evaluate(my_segmenter, name="my-segmenter")   # my_segmenter(text) -> list of words
```

This runs your segmenter on the 40,073 lines of the seven test sets. It prints word F1 and boundary F1 on each set
and their averages, next to the published systems, and saves `results-my-segmenter.json`. From the command line:
`python benchmark.py --module my_package:segment`, or `python benchmark.py --predictions my_outputs/` with one
file per set, `SET.jsonl`, holding `{"id": ..., "tokens": [...]}` for each line of `data/SET.jsonl`.

**Why the first run downloads files.** Four test sets are in this repository. The other three (BEST, ORCHID and
khammoon's test) have licences that do not allow sharing them. The first run downloads them from their owners
(about 50 MB), checks them and builds them here, once.

## Test sets

| Set | Source | Licence | Included |
|---|---|---|---|
| `tud` | [UD Thai-TUD](https://github.com/UniversalDependencies/UD_Thai-TUD), test split | CC BY-SA 4.0 | yes |
| `pud` | [UD Thai-PUD](https://github.com/UniversalDependencies/UD_Thai-PUD) | CC BY-SA 3.0 | yes |
| `ws160` | [Wisesight-160](https://github.com/PyThaiNLP/wisesight-sentiment) | CC0 1.0 | yes |
| `vistec` | [VISTEC-TP-TH-2021](https://github.com/mrpeerat/OSKut), test split | CC BY-SA 3.0 | yes |
| `bestdd` | [BEST 2009](https://huggingface.co/datasets/nectec/best2009), our split | CC BY-NC-SA 3.0 | no |
| `orchidndd` | [ORCHID](https://github.com/wannaphong/corpus_mirror/releases/tag/orchid-v1.0), our split | CC BY-NC-SA 3.0 | no |
| `khm` | [khammoon data](https://huggingface.co/datasets/typhoon-ai/khammoon-data), test split | CC BY-NC 4.0 | no |

How the sets were made from their sources is listed in [NOTICE](https://huggingface.co/datasets/iapp/OpenThai2.0-WordSeg-Benchmark/blob/main/NOTICE) and explained in the paper.

## Results

Average F1 (%) over the seven test sets:

<!-- results:start -->
| System | Word F1 | Boundary F1 |
|---|---|---|
| **LATTE-WordSeg-Lite** | **85.6** | **93.3** |
| SEFR CUT, `best` | 84.5 | 92.6 |
| DeepCut | 84.5 | 92.6 |
| AttaCut-SC | 84.0 | 92.4 |
| SEFR CUT, `ws1000` | 84.0 | 92.5 |
| AttaCut-C | 83.2 | 91.9 |
| khammoon | 81.8 | 91.3 |
| OSKut, `scads` | 79.4 | 89.9 |
| TLTK | 75.5 | 87.9 |
| OSKut, `ws` | 75.3 | 88.1 |
| PyThaiNLP nlpO3 | 70.9 | 85.6 |
| PyThaiNLP newmm | 70.9 | 85.7 |
<!-- results:end -->

LATTE-WordSeg-Lite with its default unit, `short` (`long`: 83.1 and 92.0, `minimal`: 82.1 and 91.5). khammoon
segments morphemes, not words: six of the seven sets count words, so compare it with `minimal`. Boundary F1 scores
each cut between two characters, so it is higher than word F1 and closer between systems. Both scores on each set are
in `results/expected.json`, and every system's output is in `predictions/`. The model is at
[iapp/OpenThai2.0-LATTE-WordSeg-Lite](https://huggingface.co/iapp/OpenThai2.0-LATTE-WordSeg-Lite) and in the
Python package [iapp-ai](https://pypi.org/project/iapp-ai/).

## How scores are computed

- **Word F1:** a word is correct when a gold word has the same start and end. **Boundary F1:** a cut between two
  characters is correct when gold cuts there too. A space always separates words and is never scored: a token
  that holds a space counts as the words between its spaces.
- Every system gets the same lines and the same rule, so its numbers can be compared with the table above.

## Data format

Each line of `data/SET.jsonl` is one test line, with the start and end of every gold word:

```json
{"id": 0, "text": "ยุ้ยจะบอกว่ามันนานแล้ว แต่เรารักกัน", "gold": [[0, 4], [4, 6], [6, 9], [9, 12], [12, 15], [15, 18], [18, 22], [23, 26], [26, 29], [29, 32], [32, 35]]}
```

The four included sets also load with `datasets`: `load_dataset("iapp/OpenThai2.0-WordSeg-Benchmark", "tud")`.

## Reproduce the paper

```bash
python fetch_sources.py     # every original file at its pinned revision, SHA-256 checked
python build_testsets.py    # every test file, checked against checksums.json
python score.py table       # every score of the paper, checked against results/expected.json
```

## Licences

- **Test files:** the licence of their source (table above). Files built from a CC BY-SA corpus are shared under
  the same licence. [NOTICE](https://huggingface.co/datasets/iapp/OpenThai2.0-WordSeg-Benchmark/blob/main/NOTICE) gives the attribution of each source.
- **Code** (`*.py`): Apache-2.0 ([LICENSE](https://huggingface.co/datasets/iapp/OpenThai2.0-WordSeg-Benchmark/blob/main/LICENSE)).
- **Predictions:** the word offsets contain no text; the token files of the four included sets contain their
  text, under its licence.

## Citation

If you use the benchmark, please cite the paper and the source of each test set you use.

```bibtex
@misc{chayintr2026lattewordseglite,
  title         = {{LATTE-WordSeg-Lite}: Multi-Granularity {Thai} Word Segmentation on a {CPU}, with a Reproducible Benchmark},
  author        = {Chay-intr, Thodsaporn and Viriyayudhakorn, Kobkrit and Theeramunkong, Thanaruk},
  year          = {2026},
  eprint        = {2611.21300},
  archivePrefix = {arXiv},
  primaryClass  = {cs.CL},
  url           = {https://arxiv.org/abs/2611.21300}
}
```

<details>
<summary>BibTeX of the sources</summary>

```bibtex
@article{sriwirote2025tud,
  title   = {The {Thai} {Universal} {Dependency} Treebank},
  author  = {Sriwirote, Panyut and Leong, Wei Qi and Polpanumas, Charin and Thanyawong, Santhawat and Tjhi, William Chandra and Aroonmanakun, Wirote and Rutherford, Attapol T.},
  journal = {Transactions of the Association for Computational Linguistics},
  volume  = {13},
  pages   = {376--391},
  year    = {2025},
  doi     = {10.1162/tacl_a_00745}
}

@inproceedings{zeman2017conll,
  title     = {{CoNLL} 2017 Shared Task: Multilingual Parsing from Raw Text to {Universal Dependencies}},
  author    = {Zeman, Daniel and others},
  booktitle = {Proceedings of the {CoNLL} 2017 Shared Task: Multilingual Parsing from Raw Text to {Universal Dependencies}},
  pages     = {1--19},
  year      = {2017}
}

@misc{suriyawongkul2024wisesight,
  title     = {{PyThaiNLP/Wisesight} Sentiment Corpus with Word Tokenization Label},
  author    = {Suriyawongkul, Arthit and Chuangsuwanich, Ekapol and Chormai, Pattarawat and Chantarapratin, Nitchakarn and Prasertsom, Ponrawee and Sawatphol, Jitkapat and Yamada, Nozomi and Rutherford, Attapol and Polpanumas, Charin and Udomcharoenchaikit, Can},
  publisher = {Zenodo},
  note      = {Version 1.1},
  doi       = {10.5281/zenodo.3457446},
  year      = {2024}
}

@inproceedings{limkonchotiwat2021oskut,
  title     = {Handling Cross- and Out-of-Domain Samples in {Thai} Word Segmentation},
  author    = {Limkonchotiwat, Peerat and Phatthiyaphaibun, Wannaphong and Sarwar, Raheem and Chuangsuwanich, Ekapol and Nutanong, Sarana},
  booktitle = {Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021},
  pages     = {1003--1016},
  year      = {2021}
}

@inproceedings{kosawat2009best,
  title     = {{BEST} 2009: {Thai} Word Segmentation Software Contest},
  author    = {Kosawat, Krit and Boriboon, Monthika and Chootrakool, Patcharika and Chotimongkol, Ananlada and Klaithin, Supon and Kongyoung, Sarawoot and Kriengket, Kanyanut and Phaholphinyo, Sitthaa and Purodakananda, Sumonmas and Thanakulwarapas, Tipraporn and Wutiwiwatchai, Chai},
  booktitle = {Eighth International Symposium on Natural Language Processing},
  pages     = {83--88},
  year      = {2009}
}

@article{sornlertlamvanich1999orchid,
  title   = {Building a {Thai} Part-of-Speech Tagged Corpus ({ORCHID})},
  author  = {Sornlertlamvanich, Virach and Takahashi, Naoto and Isahara, Hitoshi},
  journal = {Journal of the Acoustical Society of Japan (E)},
  volume  = {20},
  number  = {3},
  pages   = {189--198},
  year    = {1999},
  doi     = {10.1250/ast.20.189}
}

@article{khammoon2026,
  title   = {khammoon: From a Linguistic Guideline to a {Thai} Morpheme Segmenter},
  author  = {Sirichotedumrong, Warit and Na-Thalang, Adisai and Wittayasakpan, Chanakan and Phatcharoen, Kritsadha and Pipatanakul, Kunat},
  journal = {arXiv preprint arXiv:2611.13012},
  year    = {2026}
}

@inproceedings{limkonchotiwat2025wangchan,
  title     = {{WangchanThaiInstruct}: An Instruction-Following Dataset for Culture-Aware, Multitask, and Multi-domain Evaluation in {Thai}},
  author    = {Limkonchotiwat, Peerat and Tuchinda, Pume and Lowphansirikul, Lalita and Nonesung, Surapon and Tasawong, Panuthep and Aji, Alham Fikri and Udomcharoenchaikit, Can and Nutanong, Sarana},
  booktitle = {Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing},
  pages     = {3535--3558},
  year      = {2025}
}
```

</details>