thai2transformers
Pretraining transformer-based Thai language models
thai2transformers provides customized scripts to pretrain transformer-based masked language model on Thai texts with various types of tokens as follows:
- spm: a subword-level token from SentencePiece library.
- newmm : a dictionary-based Thai word tokenizer based on maximal matching from PyThaiNLP.
- syllable: a dictionary-based Thai syllable tokenizer based on maximal matching from PyThaiNLP. The list of syllables used is from pythainlp/corpus/syllables_th.txt.
- sefr: a ML-based Thai word tokenizer based on Stacked Ensemble Filter and Refine (SEFR) [Limkonchotiwat et al., 2020] based on probabilities from CNN-based deepcut and SEFR tokenizer is loaded with
engine="best".
Thai texts for language model pretraining
We curate a list of sources that can be used to pretrain language model. The statistics for each data source are listed in this spreadsheet.
Also, you can download current version of cleaned datasets from here.
Model pretraining and finetuning instructions:
a) Instruction for RoBERTa BASE model pretraining on Thai Wikipedia dump:
In this example, we demonstrate how pretrain RoBERTa base model on Thai Wikipedia dump from scratch
-
Install required libraries: 1_installation.md
-
Prepare
thwikidataset from Thai Wikipedia dump: 2_thwiki_data-preparation.md -
Tokenizer training and vocabulary building :
a) For SentencePiece BPE (
spm), word-level token (newmm), syllable-level token (syllable): 3_train_tokenizer.mdb) For word-level token from Limkonchotiwat et al., 2020 (
sefr-cut) : 3b_sefr-cut_pretokenize.md -
Pretrain a masked langauge model: 4_run_mlm.md
b) Instruction for RoBERTa model finetuning on existing Thai text classification, and NER/POS tagging datasets.
In this example, we demonstrate how to finetune WanchanBERTa, a RoBERTa base model pretrained on Thai Wikipedia dump and Thai assorted texts.
-
Finetune model for sequence classification task from exisitng datasets including
wisesight_sentiment,wongnai_reviews,generated_reviews_enth(review star prediction), andprachathai67k: 5a_finetune_sequence_classificaition.md -
Finetune model for token classification task (NER and POS tagging) from exisitng datasets including
thainerandlst20: 5b_finetune_token_classificaition.md
BibTeX entry and citation info
@misc{lowphansirikul2021wangchanberta,
title={WangchanBERTa: Pretraining transformer-based Thai Language Models},
author={Lalita Lowphansirikul and Charin Polpanumas and Nawat Jantrakulchai and Sarana Nutanong},
year={2021},
eprint={2101.09635},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
Metadata
Release files for thai2transformers 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| thai2transformers-0.1.2.tar.gz | 27.0 kB | Without provenance | Details for thai2transformers-0.1.2.tar.gz |
Release files / thai2transformers-0.1.2.tar.gz
| Download URL | thai2transformers-0.1.2.tar.gz |
|---|---|
| Size | 27.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2d36991e76526022304df6e8c1d2b75a0c2e367fc928bafd13b2ac38f04bd5c
|
|
BLAKE2b-256 checksum How to use checksums |
33ff8ef8d4e6948ddd51a931567f659ae825c1740fb13457133eabe2276bbd3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/45.1.0.post20200127 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.6
|
Security for thai2transformers 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.