Skip to page content
SAVRN
Search Plan a project

Open-weight model · Token classification

phayathaibert-thai-pos-tagger-onnx

by WIRIYA wiriyabot/phayathaibert-thai-pos-tagger-onnx

phayathaibert-thai-pos-tagger-onnx is an open-weight model for token classification from WIRIYA, released under MIT License. It has 512-token context. Its published files total 549.8 MB.

This is an ONNX version of nlp-chula/phayathaibert-thai-pos-tagger, a PhayaThaiBERT model fine-tuned for Universal POS tagging on UD Thai-TUD. It runs with onnxruntime and tokenizers, without PyTorch or Transformers. This repository only converts the model.

Parameters—
Context512
Weights532.4 MB
Licensemit
AccessOpen weights
Monthly Downloads—

Model Card

By WIRIYA, published under mit, revision 59e3502bd06e.

This is an ONNX version of nlp-chula/phayathaibert-thai-pos-tagger, a PhayaThaiBERT model fine-tuned for Universal POS tagging on UD Thai-TUD. It runs with onnxruntime and tokenizers, without PyTorch or Transformers. This repository only converts the model. All credit for training goes to the original authors at nlp-chula and to the PhayaThaiBERT authors. Made for the PyThaiNLP POS tagging engine Input is a list of pre-segmented Thai words. Each word is tagged with the prediction for its first subword, the same alignment the model was trained with. Keep each model call at 415 subwords or fewer, counting and. Split longer input into sentences, or into chunks of whole words, and tag each one…

Read WIRIYA's full model card

This is an ONNX version of nlp-chula/phayathaibert-thai-pos-tagger, a PhayaThaiBERT model fine-tuned for Universal POS tagging on UD Thai-TUD. It runs with onnxruntime and tokenizers, without PyTorch or Transformers.

This repository only converts the model. All credit for training goes to the original authors at nlp-chula and to the PhayaThaiBERT authors.

Made for the PyThaiNLP POS tagging engine (issue #1536).

Files

File Contents
model.onnx The model, opset 17, with dynamic batch and sequence axes. Embedding tables are int8; all other weights are float32.
tokenizer.json Tokenizer, unchanged from the original model.
config.json Original config, including the 15 id2label UPOS tags.
scripts/ Scripts for export, inference and the comparison against PyTorch.

Usage

Input is a list of pre-segmented Thai words. Each word is tagged with the prediction for its first subword, the same alignment the model was trained with.

pip install onnxruntime tokenizers numpy huggingface_hub
import json

import numpy as np
import onnxruntime as ort
from huggingface_hub import snapshot_download
from tokenizers import Tokenizer

model_dir = snapshot_download("wiriyabot/phayathaibert-thai-pos-tagger-onnx")
session = ort.InferenceSession(f"{model_dir}/model.onnx", providers=["CPUExecutionProvider"])
tokenizer = Tokenizer.from_file(f"{model_dir}/tokenizer.json")
id2label = {int(k): v for k, v in json.load(open(f"{model_dir}/config.json"))["id2label"].items()}

words = ["ฉัน", "กิน", "ข้าว", "ที่", "ร้านอาหาร"]
enc = tokenizer.encode(words, is_pretokenized=True)
logits = session.run(None, {
    "input_ids": np.array([enc.ids], dtype=np.int64),
    "attention_mask": np.array([enc.attention_mask], dtype=np.int64),
})[0][0]

tags, prev = [], None
for i, word_id in enumerate(enc.word_ids):
    if word_id is not None and word_id != prev:
        tags.append(id2label[int(logits[i].argmax())])
    prev = word_id
print(list(zip(words, tags)))
# [('ฉัน', 'PRON'), ('กิน', 'VERB'), ('ข้าว', 'NOUN'), ('ที่', 'ADP'), ('ร้านอาหาร', 'NOUN')]

Input length

Keep each model call at 415 subwords or fewer, counting <s> and </s>. Split longer input into sentences, or into chunks of whole words, and tag each one separately.

  • The model runs on up to 510 tokens (longer input fails), but only the first 415 are reliable. From position 415 on, accuracy drops from about 89% to about 34%. The original PyTorch model does the same, so the drop is not caused by the ONNX export. It suggests that the model was pretrained on sequences of about 416 tokens.
  • tokenizer.json truncates at 510 tokens without a warning. This setting comes from the original model. Words after the cut get no subword, so the loop above returns fewer tags than words. Call tokenizer.no_truncation() and check the length yourself.

Measured on the UD Thai-TUD test set, tagged as one long text in chunks of whole words:

Maximum chunk length UPOS accuracy
510 subwords 80.26%
415 subwords 90.08%
One sentence at a time (longest sentence: 164 subwords) 91.21%

The PyThaiNLP engine pos_tag(words, engine="phayathaibert") (issue #1536) chunks long input this way.

Evaluation

All results below are on the UD Thai-TUD test set: 363 sentences, 7,683 words, gold segmentation. Each run was on CPU (Intel Core i5-1340P) with onnxruntime 1.30, using scripts/compare_with_pytorch.py.

Version Size UPOS accuracy Same tag as PyTorch
PyTorch original 1,108 MB 91.16% —
ONNX float32 1,108 MB 91.16% 100%
ONNX, int8 embeddings (this repo) 532 MB 91.21% 99.64%
ONNX, int8 everywhere (not used) 278 MB 87.91% 92.05%
  • Speed. ONNX averaged roughly 35–45 ms per sentence on this CPU; PyTorch averaged about 120 ms.
  • Batching. Outputs are identical whether a sentence is run alone or inside a padded batch.
  • Tokenizer. The tokenizers encoding matches the Transformers tokenizer on every test sentence.
  • Which weights are int8. Only the embedding tables (Gather: word, position and token type embeddings) are quantized. They hold 69% of the weights and tolerate int8 well. Quantizing the attention and feed-forward MatMul layers too costs 3.3 accuracy points. It also makes the results depend on the batch, so those layers stay float32.
  • Comparison with the model card. The original model card reports 90.64%. The higher figure here was measured with the same alignment, by a different evaluation script.

Reproduce

pip install torch transformers onnx onnxruntime
hf download nlp-chula/phayathaibert-thai-pos-tagger --local-dir source
python scripts/export_onnx.py source out          # export + embedding quantization
python scripts/pos_tag_onnx.py out th_tud-ud-test.conllu

Citation

Please cite PhayaThaiBERT:

@article{Sriwirote_2025,
  title={PhayaThaiBERT: Enhancing a Pretrained Thai Language Model with Unassimilated Loanwords},
  volume={24},
  ISSN={2375-4702},
  url={http://dx.doi.org/10.1145/3765962},
  DOI={10.1145/3765962},
  number={11},
  journal={ACM Transactions on Asian and Low-Resource Language Information Processing},
  publisher={Association for Computing Machinery (ACM)},
  author={Sriwirote, Panyut and Rutherford, Attapol T. and Thapiang, Jalinee and Timtong, Vasan},
  year={2025},
  month=Oct,
  pages={1–17}
}

License

MIT, the same as the original model. Training data: the UD Thai-TUD treebank (CC BY-SA 4.0).

Configuration

Architecture
CamembertForTokenClassification
Context length (tokens)
512
Layers
12
Hidden size
768
Feed-forward size
3,072
Attention heads
12
Vocabulary size
249,262
Stored precision
float32
Model type
camembert

Identity and Version

Repository
wiriyabot/phayathaibert-thai-pos-tagger-onnx
Publisher
WIRIYA
Task
Token classification
Modality
Text
Library
onnx
Parameters
Not stated by the source
Languages
th
Revision
59e3502bd06e2222d32f11b51b4fb9569235a020
First published
2026-10-06
Last updated
2026-10-07

Files and Weights

9 files, 549.8 MB in total. The weights are 1 file totalling 532.4 MB in onnx.

Weights1 file · 532.4 MB
Configuration5 files · 11.0 KB
Tokenizer1 file · 17.3 MB
Documentation1 file · 6.4 KB
Repository1 file · 1.6 KB
Every file
FileTypeSizeSHA-256
model.onnxWeights532.4 MB 854a2f77cac2
config.jsonConfiguration1.2 KB —
scripts/compare_with_pytorch.pyConfiguration4.1 KB —
scripts/export_onnx.pyConfiguration1.9 KB —
scripts/pos_tag_onnx.pyConfiguration2.7 KB —
special_tokens_map.jsonConfiguration1.0 KB —
README.mdDocumentation6.4 KB —
.gitattributesRepository1.6 KB —
tokenizer.jsonTokenizer17.3 MB 6bd9e947fbe9

License and Download

License
mit
Access
Open weights, no gate
Download size
532.4 MB
Download from WIRIYA

Released by WIRIYA through its official repository on Hugging Face. Read the license.

Built From

  • Derived from nlp-chula/phayathaibert-thai-pos-tagger
  • Quantized from nlp-chula/phayathaibert-thai-pos-tagger
  • Trained on (disclosed) universal_dependencies

Memory Requirements

PrecisionWeights in memory
As published532.4 MB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About phayathaibert-thai-pos-tagger-onnx

Can I use phayathaibert-thai-pos-tagger-onnx commercially?

Yes. phayathaibert-thai-pos-tagger-onnx is released under MIT License. The MIT License is a short permissive license. It permits commercial use, modification and redistribution, provided the copyright notice and permission notice are included.

What is phayathaibert-thai-pos-tagger-onnx's context length?

512 tokens, from the maximum position embeddings in its published configuration.

Similar Models

Model · Token classification

stanford-deidentifier-base

Stanford AIMI

Stanford de-identifier was trained on a variety of radiology and biomedical documents with the goal of automatising the de-identification process while reaching satisfactory accuracy for use in production. Manuscript in-proceedings. These model weights are the recommended ones among all available deidentifier weights. This work was supported in part by the Medical Imaging and Data Resource Center (MIDRC), which is funded by the National Institute of Biomedical Imaging and Bioengineering (NIBIB) of the National Institutes of Health under contract 75N92020D00021 and through The Advanced Research Projects Agency for Health (ARPA-H)

Open weights mit 512 tokens transformers

Model · Token classification

bert-portuguese-ner

Luís Filipe Cunha

This model is a fine-tuned version of neuralmind/bert-base-portuguese-cased It achieves the following results on the evaluation set: This model was fine-tunned on token classification task (NER) on Portuguese archival documents. The annotated labels are: Date, Profession, Person, Place, Organization All the training and evaluation data is available at: http://ner.epl.di.uminho.pt/ The following hyperparameters were used during training: - learningrate: 2e-05 - trainbatchsize: 16 - evalbatchsize: 16 - lrschedulertype: linear - numepochs: 4 - Transformers 4.10.0.dev0 - Pytorch 1.9.0+cu111 - Datasets 1.10.2 - Tokenizers 0.10.3

Open weights mit 512 tokens transformers

Model · Token classification

privacy-filter-nemotron-GGUF

LocalAI-io

GGUF conversion of OpenMed/privacy-filter-nemotron, a fine-grained PII token-classification model — a fine-tune of openai/privacy-filter on the nvidia/Nemotron-PII dataset. It labels every token with a BIOES tag over 55 PII categories (221 classes) in a single forward pass, then decodes coherent spans with a constrained Viterbi procedure — so it can be served locally with no Python as the encoder/NER tier of a PII redactor. Where the base openai/privacy-filter covers 8 coarse categories, this fine-tune trades multilingual breadth for category depth: 55 fine-grained English categories (first/last name, government IDs, financial, healthcare, vehicle, digital, …). For the full model…

Open weights apache-2.0 gguf

Model · Token classification

punctuate-all

KREDOR

This is based on Oliver Guhr's work. The difference is that it is a finetuned xlm-roberta-base instead of an xlm-roberta-large and on twelve languages instead of four. The languages are: English, German, French, Spanish, Bulgarian, Italian, Polish, Dutch, Czech, Portugese, Slovak, Slovenian. precision recall f1-score support accuracy 0.98 84425503 macro avg 0.83 0.74 0.77 84425503 weighted avg 0.98 0.98 0.98 84425503

Open weights mit 514 tokens transformers

Model · Token classification

privacy-filter-multilingual-GGUF

LocalAI-io

GGUF conversion of OpenMed/privacy-filter-multilingual, a multilingual PII token-classification model (a fine-tune of openai/privacy-filter). It labels every token with a BIOES tag over 54 PII categories (217 classes) across 16 languages, so it can be served locally with no Python as the encoder/NER tier of a PII redactor. For the full model description, label space, evaluation, limitations, and citations, see the source model card — this card only covers the GGUF packaging and how to run it. This GGUF uses a custom architecture, openai-privacy-filter, that is not (yet) part of 1. privacy-filter.cpp (recommended) — a small standalone GGML engine for exactly this model family, on stock…

Open weights apache-2.0 gguf

Model · Token classification

unbiased-toxic-roberta-onnx

Protect AI

This model is a conversion of unitary/unbiased-toxic-roberta to ONNX format using the Optimum library. Trained models & code to predict toxic comments on 3 Jigsaw challenges: Toxic comment classification, Unintended Bias in Toxic comments, Multilingual toxic comment classification. Built by Laura Hanu at Unitary. The huggingface models currently give different results to the detoxify library (see issue here). All challenges have a toxicity label. The toxicity labels represent the aggregate ratings of up to 10 annotators according the following schema: - Very Toxic (a very hateful, aggressive, or disrespectful comment that is very likely to make you leave a discussion or give up on sharing…

Open weights apache-2.0 514 tokens transformers