|
Download conparse/README.md from iapp/OpenThai2.0-NLP-Core-Benchmark: direct link, hf CLI and curl.
- Browser
- Download file 9.16 kB
-
https://huggingface.co/datasets/iapp/OpenThai2.0-NLP-Core-Benchmark/resolve/main/conparse/README.md
- Command line
-
hf download hf://datasets/iapp/OpenThai2.0-NLP-Core-Benchmark/conparse/README.md
-
curl -L -o README.md https://huggingface.co/datasets/iapp/OpenThai2.0-NLP-Core-Benchmark/resolve/main/conparse/README.md
9.16 kB
| # Thai constituency parsing benchmark (Penn-style trees) | |
| 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 constituency parsing: 362 silver Penn-style trees over the UD Thai-TUD test sentences, one scorer, and | |
| the stored outputs of every system in the table below. It is the Penn-tree 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 "conparse/*" --local-dir nlp-core-bench | |
| cd nlp-core-bench/conparse && pip install -r requirements.txt | |
| ``` | |
| ```python | |
| from benchmark import evaluate | |
| evaluate(parse, raw=parse_text, name="my-parser") | |
| # parse(words) -> a bracketed tree over these words, "(S (NP (NCMN ...)) (VP ...))" | |
| # parse_text(text) -> a bracketed tree over the parser's own words | |
| ``` | |
| Give `parse`, `parse_text` or both. The words `(` and `)` are written `-LRB-` and `-RRB-` in a tree, and `None` means | |
| no tree. This parses the 362 sentences, prints bracket F1 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 (the layout of `predictions/`). Every file is in | |
| this repository: nothing is downloaded. | |
| ## Test set | |
| | Set | Source | Trees | Brackets | Licence | | |
| |---|---|---:|---:|---| | |
| | `tud` | the [UD Thai-TUD](https://github.com/UniversalDependencies/UD_Thai-TUD) test trees, UD 2.17 (= 2.19), converted to Penn-style trees (tud-ptb v3) | 362 | 7,529 | CC BY-SA 4.0 | | |
| **The trees are silver and have many errors.** They are converted by rules from the gold dependency trees of TUD, | |
| not drawn by hand. | |
| A review of 50 development trees of the same conversion found a structural error (a phrase with a wrong boundary, | |
| attachment or type) in 22 of them. The converter caused such an error in 6 of these trees and the annotation of | |
| TUD in 21, so 5 trees have both. The review was made by a language model that read the conversion guideline. Only | |
| part of the test trees has been checked by hand. | |
| The converter is tud-ptb v3, our rule-based conversion of UD trees to Penn-style trees, in its third round of | |
| 2026-11-23. The phrase labels are those of the Penn Treebank, with a classifier phrase, CLSP, for Thai. The word tags | |
| are those of ORCHID (NCMN, VTRA, JSBR and so on), since the tags of the Penn Treebank are made for English; they are | |
| not scored. One of the 363 test sentences, 1293, has no tree, because the word check of the converter failed, | |
| and it is not scored. How the set was made is in | |
| [NOTICE](https://huggingface.co/datasets/iapp/OpenThai2.0-NLP-Core-Benchmark/blob/main/conparse/NOTICE). | |
| ## Results | |
| Labelled bracket F1 (%): | |
| <!-- table:start --> | |
| | System | Gold words | Raw text | | |
| |---|---:|---:| | |
| | **OpenThai2.0-NLP-Core-Lite** | **80.2** | **79.4** | | |
| | Stanza 1.15 default_accurate, dependency trees converted, raw text with its sentence splitter off | 79.6 | 78.6 | | |
| | Stanza 1.15 default_accurate, dependency trees converted (raw text: its own sentence splits) | 79.6 | 76.7 | | |
| | Stanza 1.15 default, dependency trees converted, raw text with its sentence splitter off | 73.1 | 70.9 | | |
| | Stanza 1.15 default, dependency trees converted (raw text: its own sentence splits) | 73.1 | 68.6 | | |
| Bold: the best value of each column. | |
| <!-- table:end --> | |
| OpenThai2.0-NLP-Core-Lite is our model. Earlier versions were scored on this test set on 2026-11-23 and 2026-11-25, | |
| and this row on 2026-11-29. Each time followed a plan written in advance. Every choice was made on dev sets, the | |
| converter included. Before 2026-11-18 we looked at dependency scores of earlier models on the TUD test trees that | |
| these trees come from. Its training text was filtered against this test set. | |
| We found no public Thai constituency parser to compare: Stanza 1.15 has no Thai constituency model, benepar has no | |
| Thai model, and PyThaiNLP 5.4.0 has only a shallow chunker. The other rows are therefore dependency parsers. The Stanza rows | |
| have no constituency output, and their dependency trees go through the converter that made the test trees, which | |
| favours them. | |
| On raw text, Stanza ran twice. Its default call splits some test sentences again, and the pieces are joined into | |
| one tree with the further roots attached to the first as `parataxis`, which the converter turns into sister clauses. | |
| Our model reads each line as one sentence, so the rows with the sentence splitter off run Stanza in the same way | |
| (`tokenize_no_ssplit=True`), and these rows are the comparison. Precision and recall are in | |
| `results/expected.json`, and every system's output is in `predictions/`. | |
| ## How scores are computed | |
| - **Brackets:** labels without function tags (`NP-SBJ` counts as `NP`), a unary chain one bracket per label, no | |
| preterminals (the word tag directly above a word), no empty elements (`-NONE-`). Precision, recall and F1 are | |
| summed over the trees. | |
| - **Punctuation stays.** Every word is kept. Here 124 of the 7,661 words are PUNCT in TUD. EVALB with `COLLINS.prm` | |
| deletes the punctuation tags of the Penn Treebank, and these trees tag punctuation PUNC, so EVALB keeps every word | |
| too. At the gold words it gives the same precision, recall and F1 as this scorer (checked 2026-12-01). | |
| - **The sentence bracket counts,** as in EVALB: 439 of the 7,529 test brackets cover the whole sentence. An unlabelled | |
| outer wrapper around a tree is not a bracket. | |
| - **At the gold words:** the parser gets the treebank's words and must keep them as the leaves of its tree. | |
| - **From raw text:** the parser gets the text and finds its own words. A bracket counts only if its words cover | |
| exactly the characters of a test bracket with the same label, whitespace removed. | |
| - **Sentences** are given: the parser gets one gold sentence at a time. Trees are paired by `sent_id`. When a system | |
| gives no tree for a sentence, it gets no brackets there, and every test bracket of that sentence counts as missed. | |
| - **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. A published system needs both settings. `python score.py check` | |
| recomputes every published number from the stored outputs. | |
| ## Data format | |
| Each line of `data/penn/tud.jsonl` is one tree, with the brackets that are counted (word `i` to word `j`, `j` | |
| excluded): | |
| ```json | |
| {"sent_id": "61", "text": "ความพยายามอย่างถูกศีลธรรม", "words": ["ความพยายาม", "อย่าง", "ถูก", "ศีลธรรม"], "tree": "(NP (NP (NCMN ความพยายาม)) (SBAR (JSBR อย่าง) (S (NP-SBJ (-NONE- *)) (VP (VTRA ถูก) (NP (NCMN ศีลธรรม))))))", "brackets": [[0, 1, "NP"], [0, 4, "NP"], [1, 4, "SBAR"], [2, 4, "S"], [2, 4, "VP"], [3, 4, "NP"]]} | |
| ``` | |
| `data/syntax/tud.conllu` is the gold UD treebank of the same sentences. An output file, | |
| `predictions/SYSTEM/penn/tud.gold.jsonl` or `tud.raw.jsonl`, holds `{"sent_id", "words", "brackets"}` for each tree. | |
| ## Reproduce | |
| ```bash | |
| python build_testsets.py --all # tud.conllu from UD_Thai-TUD at the revision in sources.json; every tree's words checked against it | |
| python score.py check # every published number recomputed from predictions/ and checked | |
| ``` | |
| ## Licences | |
| - **Test files:** CC BY-SA 4.0, as UD_Thai-TUD, which they are built from. | |
| [NOTICE](https://huggingface.co/datasets/iapp/OpenThai2.0-NLP-Core-Benchmark/blob/main/conparse/NOTICE) gives the attribution and what was changed. | |
| - **Predictions:** the outputs contain the words of the TUD test sentences, under the same licence. | |
| - **Code** (`*.py`, `scoring/`): Apache-2.0 ([LICENSE](https://huggingface.co/datasets/iapp/OpenThai2.0-NLP-Core-Benchmark/blob/main/conparse/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 the test set. | |
| <details> | |
| <summary>BibTeX of the source</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} | |
| } | |
| ``` | |
| </details> | |