|
Download depparse/README.md from iapp/OpenThai2.0-NLP-Core-Benchmark: direct link, hf CLI and curl.
- Browser
- Download file 11.7 kB
-
https://huggingface.co/datasets/iapp/OpenThai2.0-NLP-Core-Benchmark/resolve/main/depparse/README.md
- Command line
-
hf download hf://datasets/iapp/OpenThai2.0-NLP-Core-Benchmark/depparse/README.md
-
curl -L -o README.md https://huggingface.co/datasets/iapp/OpenThai2.0-NLP-Core-Benchmark/resolve/main/depparse/README.md
11.7 kB
| # Thai dependency parsing benchmark | |
| Part of [OpenThai2.0-NLP-Core-Benchmark](https://huggingface.co/datasets/iapp/OpenThai2.0-NLP-Core-Benchmark). Benchmark version 1.0. | |
| A fixed test for Thai Universal Dependencies parsing: four test sets, two settings (at the treebank's words, and from | |
| raw text, where the parser finds its own words), one scorer, and the stored outputs of every system in the table | |
| below. It is the dependency part of a benchmark frozen on 2026-11-23 (version 1.0). Its test files, scorer and scores | |
| are those of that version. | |
| ## Quick start | |
| ```bash | |
| pip install -U huggingface_hub | |
| hf download iapp/OpenThai2.0-NLP-Core-Benchmark --repo-type dataset --include "depparse/*" --local-dir nlp-core-bench | |
| cd nlp-core-bench/depparse && pip install -r requirements.txt | |
| ``` | |
| ```python | |
| from benchmark import evaluate | |
| evaluate(parse, raw=parse_text, name="my-parser") | |
| # parse(words) -> one (head, deprel) per word, heads 1-based, 0 = root | |
| # parse_text(text) -> [(word, head, deprel), ...] in text order | |
| ``` | |
| Give `parse`, `parse_text` or both. This parses the 1,965 sentences of the four sets, prints UAS and LAS on each set | |
| next to the published systems, and saves `outputs/my-parser/` and `results-my-parser.json`. From the command line: | |
| `python benchmark.py --module my_package:parse --raw-module my_package:parse_text --name my-parser`, or | |
| `python benchmark.py --predictions DIR` for outputs you already have (CoNLL-U, the layout of `predictions/`). | |
| **Why the first run downloads files.** `tudp` is TUD as released with its paper. That repository has no licence | |
| file, so `tudp` and the paper's stored predictions are not in this repository. The first run downloads them (1.5 MB) | |
| from GitHub at a pinned commit, checks them and builds them here, once. | |
| ## Test sets | |
| | Set | Source | Sentences | Words | Licence | Included | | |
| |---|---|---:|---:|---|---| | |
| | `tud` | [UD Thai-TUD](https://github.com/UniversalDependencies/UD_Thai-TUD) test, UD 2.17 (= 2.19) | 363 | 7,683 | CC BY-SA 4.0 | yes | | |
| | `pud` | [UD Thai-PUD](https://github.com/UniversalDependencies/UD_Thai-PUD) test, UD 2.17 | 1,000 | 22,330 | CC BY-SA 3.0 | yes | | |
| | `tdt` | [UD Thai-TDT](https://github.com/UniversalDependencies/UD_Thai-TDT) test, UD 2.19, nine online political news articles | 239 | 5,806 | CC BY-SA 4.0 | yes | | |
| | `tudp` | [TUD as released with its paper](https://github.com/nlp-chula/TUD), test, the older annotation | 363 | 7,683 | no licence file | no | | |
| `tud` and `tudp` have the same sentences and words; 3.0% of their heads differ. `tudp` is here to score the paper's | |
| stored predictions on the annotation they were made for. How each set was made is in | |
| [NOTICE](https://huggingface.co/datasets/iapp/OpenThai2.0-NLP-Core-Benchmark/blob/main/depparse/NOTICE). | |
| ## Results | |
| LAS at the gold words / LAS F1 from raw text (%): | |
| <!-- table:start --> | |
| | System | TUD | PUD | TDT | TUDP | | |
| |---|---:|---:|---:|---:| | |
| | **OpenThai2.0-NLP-Core-Lite** | **78.8** / **67.2** | **60.0** / **45.8** | **52.7** / **45.4** | 76.9 / **65.3** | | |
| | Stanza 1.15, default_accurate package | 76.3 / 65.5 | 57.6 / 42.3 | 52.2 / 41.5 | 74.5 / 63.9 | | |
| | Stanza 1.11, default_accurate package (wangchanberta) | 75.7 / 63.7 | 57.4 / 39.8 | 51.6 / 38.8 | 77.1‖ / 64.9‖ | | |
| | attaparse 1.0.0 (nlp-chula) | 73.7 / 61.3 | 56.0 / 38.8 | 50.7 / 38.2 | 75.2‖ / 62.4‖ | | |
| | Stanza 1.15, default package | 72.2 / 60.1 | 54.0 / 38.2 | 49.8 / 37.8 | 71.2 / 59.2 | | |
| | Stanza 1.11, default package | 70.7 / 59.7 | 53.4 / 37.2 | 48.5 / 36.0 | 72.1‖ / 61.0‖ | | |
| | PyThaiNLP esupar parser | – / 57.7 | – / 67.4§ | – / 42.8 | – / 58.7 | | |
| | PyThaiNLP ud_goeswith parser | – / 36.6 | – / 79.4‡ | – / 31.0 | – / 37.5 | | |
| | PyThaiNLP transformers_ud parser | – / 30.8 | – / 56.1§ | – / 25.2 | – / 31.6 | | |
| | PyThaiNLP spacy_thai parser | – / 25.4 | – / 24.0‡ | – / 16.7 | – / 26.2‖ | | |
| | the TUD paper's best parser without gold POS, its stored predictions | – | – | – | **78.1**‖ / – | | |
| | the TUD paper's parser given its tagger's POS, its stored predictions | – | – | – | 77.5‖ / – | | |
| ‡ trained on this test set, as its model card, corpus name or training script says; § likely trained on PUD: its card names no treebank, and its PUD score is far above its TDT score; ‖ trained on the training split of TUD as released with its paper, so the TUDP column holds the annotation it learnt. Bold: the best value of each column, cells marked ‡ or § left out. | |
| <!-- table:end --> | |
| OpenThai2.0-NLP-Core-Lite is our model. Before 2026-11-18 we looked at test scores of earlier models during | |
| development. Since then every choice has been made on dev sets. Earlier versions were scored on these test sets on | |
| 2026-11-23 and 2026-11-25, and this row on 2026-11-29. Each time followed a plan written in advance. | |
| Its training text was filtered against these test sets. | |
| The TUD paper's rows are its stored test predictions at the gold words of `tudp`. The first is its best parser | |
| without gold POS: Stanza with PhayaThaiBERT given no POS, LAS 78.09 in Table 4 of the paper (84.54 when given gold | |
| POS). The second is the same parser given the POS of its tagger. | |
| attaparse 1.0.0 (nlp-chula, MIT, on PyPI) packages that best parser. Its model file is a training checkpoint of step | |
| 7,700, and the development history stored in the file has its best LAS at step 6,800 (77.3, against 76.7 at step | |
| 7,700). At the gold words of `tudp` it scores 75.2, below the 78.1 of the paper's stored predictions. The later step | |
| accounts for 0.6 points on the development set; we have not found the rest of the gap. | |
| Stanza 1.11 learnt the same release of TUD: its release notes (1.11.0, October 2025) add "a Thai TUD dataset from | |
| https://github.com/nlp-chula/TUD (not yet included in UD)". TUD entered UD in release 2.17, in November 2025, and the | |
| Thai models of Stanza 1.15 are trained on UD 2.18. PyThaiNLP's parsers run these models: esupar | |
| KoichiYasuoka/roberta-base-thai-spm-upos, ud_goeswith KoichiYasuoka/deberta-base-thai-ud-goeswith, transformers_ud | |
| KoichiYasuoka/deberta-base-thai-ud-head, and spacy_thai the UDPipe 1 model of spaCy-Thai 0.7.8. UAS and the raw-text | |
| UAS F1 are in `results/expected.json`, and every system's output is in `predictions/`. | |
| ## How scores are computed | |
| - **At the gold words:** the parser gets the treebank's words. UAS and LAS over every gold word, punctuation | |
| included. With the same words, these scores equal their F1. | |
| - **From raw text:** the parser gets each sentence's text and finds its own words. A word matches when it covers the | |
| same characters as a gold word, whitespace removed; a head counts only if the system's head word is matched to the | |
| gold head word (the CoNLL 2018 shared task definitions). UAS F1 and LAS F1 of precision over the system's words and | |
| recall over the gold words. | |
| - **Labels:** LAS compares the universal part of DEPREL, as in CoNLL 2018 (`nmod:poss` counts as `nmod`). PUD gold has | |
| 2,351 subtyped relations and TDT 505; TUD has none. | |
| - **Sentences** are given: the parser gets one gold sentence at a time. Stanza and attaparse would split some of them | |
| again. Their rows therefore take the raw-text columns from runs with the sentence splitter off | |
| (`tokenize_no_ssplit=True`, `<name>-nossplit` in `predictions/`), as our model reads each line as one sentence. The | |
| runs of their default call stay in `predictions/<name>/`, where the pieces of a split sentence are joined into one | |
| tree, with the further roots attached to the first as `parataxis`. The CoNLL 2018 shared task gave whole documents | |
| and scored the sentence split too. Sentences are paired by their order in the file (and their text), not by | |
| `sent_id`. One TDT id is `# sent_id =Thai_Political_UngIng_PM_News11_19`, without a space after `=`, as in | |
| UD_Thai-TDT itself. | |
| - **Checked:** the evaluation script of the CoNLL 2018 shared task, `conll18_ud_eval.py`, gives the same scores | |
| on every stored output, to two decimals (2026-12-01). | |
| - **Rounding:** half to even (Python's `round`), once, from the unrounded score: two decimals in | |
| `results/expected.json`, one here. | |
| ## Add a system | |
| ```bash | |
| python benchmark.py --module my_package:parse --raw-module my_package:parse_text --name my-parser | |
| python add_system.py my-parser --from outputs/my-parser --display "My parser 1.0" | |
| ``` | |
| `add_system.py` checks the files, copies them to `predictions/`, scores them with the same scorer, and adds the row | |
| to `results/expected.json` and to the table above. `python score.py check` recomputes every published number from | |
| the stored outputs. | |
| ## Data format | |
| `data/syntax/SET.conllu` is the gold treebank in CoNLL-U, each sentence with its `# sent_id` and `# text`; | |
| `data/syntax/SET.txt` holds the text of each sentence, one per line. An output is CoNLL-U with the same sentences in | |
| the same order: `predictions/SYSTEM/syntax/SET.gold.conllu` on the gold words, `SET.raw.conllu` on the system's own | |
| words, with `# sent_id` and `# text` as in the gold file. | |
| ## Reproduce | |
| ```bash | |
| python build_testsets.py --all # every test file from its source at the revision in sources.json, checked against checksums.json | |
| python score.py check # every published number recomputed from predictions/ and checked | |
| ``` | |
| ## 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-NLP-Core-Benchmark/blob/main/depparse/NOTICE) gives the attribution of each | |
| source and what was changed. | |
| - **Predictions:** the outputs contain the words and text of `tud`, `pud` and `tdt`, under their licence. The `tudp` | |
| output of every tool is identical to its `tud` output (same words and text). | |
| - **Code** (`*.py`, `scoring/`): Apache-2.0 ([LICENSE](https://huggingface.co/datasets/iapp/OpenThai2.0-NLP-Core-Benchmark/blob/main/depparse/LICENSE)). | |
| - **Other files we made** (`manifest.json`, `checksums.json`, `release.json`, `sources.json`, `results/`): Apache-2.0, as the code. | |
| ## Citation | |
| Please cite the source of each test set you use. | |
| <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{ud219, | |
| title = {Universal Dependencies 2.19}, | |
| author = {Zeman, Daniel and others}, | |
| year = {2026}, | |
| howpublished = {LINDAT/CLARIAH-CZ, \url{http://hdl.handle.net/11234/1-6316}} | |
| } | |
| @article{demarneffe2021ud, | |
| title = {{Universal Dependencies}}, | |
| author = {de Marneffe, Marie-Catherine and Manning, Christopher D. and Nivre, Joakim and Zeman, Daniel}, | |
| journal = {Computational Linguistics}, | |
| volume = {47}, | |
| number = {2}, | |
| pages = {255--308}, | |
| year = {2021}, | |
| doi = {10.1162/coli_a_00402} | |
| } | |
| ``` | |
| UD_Thai-TDT (Rattananiyomkul and Zeman) names no paper in its README. Cite it with the Universal Dependencies release | |
| 2.19 (`ud219`), the release `tdt` comes from, and the paper on Universal Dependencies (`demarneffe2021ud`). | |
| </details> | |