OpenThai 2.0 NLP Core Lite: seven Thai NLP tasks in one 31 MB model, on a CPU
OpenThai (formerly OpenThaiGPT) and iApp release OpenThai 2.0 NLP Core Lite, one model for the basic tasks of Thai language processing. From raw text it splits sentences and clauses, segments words, tags parts of speech, finds named entities, and builds dependency and constituency trees. Its accuracy is close to or above the best available tool for each task, it runs 14 to 69 times as fast on a CPU, and the whole model is 31 MB. It is free to download, and commercial use is allowed.
Model: huggingface.co/iapp/OpenThai2.0-NLP-Core-Lite · Benchmark: huggingface.co/datasets/iapp/OpenThai2.0-NLP-Core-Benchmark · Install: pip install "iapp-ai[nlp]"
Why one model
Thai text processing usually chains several tools: one segments words, the next tags them, a third parses them and a fourth finds names. An error at the start of the chain carries into every step after it, and each tool may cut words its own way, so their outputs have to be aligned by hand. In OpenThai 2.0 NLP Core Lite every task runs on one shared network and reads the same words, so the results of all seven tasks fit together.
Seven results from one call
| Task | What it gives | Typical use |
|---|---|---|
| Sentences | Sentence ends in running Thai text, also without spaces or punctuation | Subtitles, input for translation and summarisation |
| Clauses | Each sentence split into clauses | Text-to-speech phrasing, RAG chunks |
| Words | Three units: long keeps compounds whole, short (the default) gives words, minimal gives morphemes | Search, keywords |
| Parts of speech | 17 UD tags, or 37 tags based on ORCHID | Filtering words, grammar |
| Named entities | The 16 types of ThaiNER, such as people, organisations, places and dates | Personal-data (PDPA) screening, organisation lists |
| Dependency trees | Which word modifies which (UD) | Who did what, information extraction |
| Constituency trees | Nested phrases, Penn Treebank style | Noun phrases, sentence structure |
Results
Each score is out of 100 and is the main score of its task, measured on raw text. The comparison is with the best tool from other authors for each task, and every system gets the same input. Speed is measured on one CPU core with one line per call, for every system.
| Task | Score | OpenThai 2.0 NLP Core Lite | Best other tool | Its score | Times as fast |
|---|---|---|---|---|---|
| Sentences | boundary F1, 12 test sets | 78.6† | SaT-12l-sm, tuned | 77.5 | 14 |
| Clauses | boundary F1, 3 treebanks | 70.8 | HoogBERTa* | 30.0 | 25 |
| Words | word F1, 7 test sets | 85.7† | SEFR CUT | 84.5 | 20 |
| Parts of speech | UPOS F1, 3 treebanks | 74.7† | Stanza 1.15 | 73.1 | 69 |
| Dependency trees | LAS F1, 3 treebanks | 52.8† | Stanza 1.15 | 49.8 | 59 |
| Constituency trees | bracket F1, UD Thai-TUD | 79.4 | Stanza 1.15* | 78.6 | 58 |
| Named entities | entity F1, ThaiNER | 84.7 | phayathaibert-thainer | 85.7 | 19 |
- † marks a lead beyond the 95% interval of a paired bootstrap. A higher score without † is a tie.
- * No tool does this task directly, so the closest one is used: HoogBERTa cuts a different unit from a clause, and Stanza's constituency trees are converted from its dependency trees. The clause and constituency labels were made by rules from the gold treebank trees and partly checked by hand.
- Size: 26.5 million parameters. The best tools of the seven tasks hold 957 million between them, 36 times as many.
- On one CPU thread the model reads about 25,000 characters a second for sentences, 20,000 for parts of speech, 18,000 for named entities and 8,900 for dependency trees.
- The benchmark holds the test sets, the outputs of every system compared and the scoring script, so you can score the tool you use today on the same data. Where a source's licence does not allow its text to be shared, the benchmark gives ids and character offsets instead.
Where it is behind
- Named entities: phayathaibert-thainer leads by 1.0 point. It was trained on ThaiNER's training split and OpenThai 2.0 NLP Core Lite was not; on the 1,385 test texts that share no text with that split, the two are level: 84.8 for OpenThai 2.0 NLP Core Lite and 85.4 for phayathaibert-thainer, a gap inside the margin of error.
- Rare entity types are weak: FACILITY scores 46.4 and URL 51.7, against 94.0 for PERSON and 85.6 for ORGANIZATION.
- Parsing reads one sentence at a time, so a long paragraph with no sentence end parses slowly.
- Words: Thai corpora disagree on what a word is. Part-of-speech tags follow UD Thai-TUD, which tags many state words VERB where a dictionary has ADJ.
Install and use
With Python 3.10 or later:
pip install "iapp-ai[nlp]"
One call to analyze returns all seven results in one document:
from iapp_ai.nlp import core
doc = core.analyze("กรมอุตุนิยมวิทยาประกาศเตือนฝนตกหนักในจังหวัดเช ียงใหม่")
print(doc.entities)
# [Entity(text='กรมอุตุนิยมวิทยา', label='ORGANIZATION', start=0, end=16),
# Entity(text='จังหวัดเชียงใหม่', label='LOCATION', start=37, end=53)]
Each task can also be called on its own:
core.tokenize("เจ้าหน้าที่การศึกษาเปิดเผยว่า")
# ['เจ้า', 'หน้าที่', 'การ', 'ศึกษา', 'เปิด', 'เผย', 'ว่า']
core.tokenize("เจ้าหน้าที่การศึกษาเปิดเผยว่า", unit="long")
# ['เจ้าหน้าที่', 'การศึกษา', 'เปิดเผย', 'ว่า']
core.pos_tag("นักเรียนอ่านหนังสือในห้องสมุด")
# [('นักเรียน', 'NOUN'), ('อ่าน', 'VERB'), ('หนังสือ', 'NOUN'), ('ใน', 'ADP'), ('ห้องสมุด', 'NOUN')]
Only what a call needs is loaded: tokenize loads the word part of the model alone, and pos_tag never loads the parsers. Results can be saved as JSON with doc.to_dict() or as CoNLL-U with doc.to_conllu(). The model runs offline with ONNX Runtime and NumPy, and needs no GPU. Every function and option is listed on the model page.
Licence
- The model is licensed CC BY-SA 4.0. You may use it in commercial products with attribution, and if you modify the model and share it, you share it under the same licence. The code is Apache-2.0.
- Every training dataset carries a licence that its owner states allows commercial use. ThaiNER, BEST, ORCHID, LST20 and other non-commercial corpora were not used, and the training text was filtered against every test set.
- The datasets and the licence of each: NOTICE.
Links
- Model: iapp/OpenThai2.0-NLP-Core-Lite
- Benchmark, with the test sets, the outputs of every system and the scoring script: iapp/OpenThai2.0-NLP-Core-Benchmark
- Python package: iapp-ai on PyPI
Developed by iApp, launched with AIEAT. Thank you to Siam AI Corporation for the GPUs used to train this model.