Add README.md
Browse files
README.md
CHANGED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# WangchanBERTa base model: `wangchanberta-base-att-spm-uncased`
|
2 |
+
|
3 |
+
<br>
|
4 |
+
|
5 |
+
Pretrained RoBERTa BASE model on assorted Thai texts (78.5 GB).
|
6 |
+
The script and documentation can be found at [this reposiryory](https://github.com/vistec-AI/thai2transformers).
|
7 |
+
<br>
|
8 |
+
|
9 |
+
## Model description
|
10 |
+
|
11 |
+
<br>
|
12 |
+
|
13 |
+
The architecture of the pretrained model is based on RoBERTa [[Liu et al., 2019]](https://arxiv.org/abs/1907.11692).
|
14 |
+
|
15 |
+
<br>
|
16 |
+
|
17 |
+
|
18 |
+
## Intended uses & limitations
|
19 |
+
|
20 |
+
<br>
|
21 |
+
|
22 |
+
You can use the pretrained model for masked language modeling (i.e. predicting a mask token in the input text). In addition, we also provide finetuned models for multiclass/multilabel text classification and token classification task.
|
23 |
+
|
24 |
+
<br>
|
25 |
+
|
26 |
+
**Multiclass text classification**
|
27 |
+
|
28 |
+
|
29 |
+
- `wisesight_sentiment`
|
30 |
+
|
31 |
+
4-class text classification task (`positive`, `neutral`, `negative`, and `question`) based on social media posts and tweets.
|
32 |
+
|
33 |
+
- `wongnai_reivews`
|
34 |
+
|
35 |
+
Users' review rating classification task (scale is ranging from 1 to 5)
|
36 |
+
|
37 |
+
- `generated_reviews_enth` : (`review_star` as label)
|
38 |
+
|
39 |
+
Generated users' review rating classification task (scale is ranging from 1 to 5).
|
40 |
+
|
41 |
+
**Multilabel text classification**
|
42 |
+
|
43 |
+
- `prachathai67k`
|
44 |
+
|
45 |
+
Thai topic classification with 12 labels based on news article corpus from prachathai.com. The detail is described in this [page](https://huggingface.co/datasets/prachathai67k).
|
46 |
+
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
**Token classification**
|
51 |
+
|
52 |
+
- `thainer`
|
53 |
+
|
54 |
+
Named-entity recognition tagging with 13 named-entities as descibed in this [page](https://huggingface.co/datasets/thainer).
|
55 |
+
|
56 |
+
- `lst20` : NER NER and POS tagging
|
57 |
+
|
58 |
+
Named-entity recognition tagging with 10 named-entities and Part-of-Speech tagging with 16 tags as descibed in this [page](https://huggingface.co/datasets/lst20).
|
59 |
+
|
60 |
+
<br>
|
61 |
+
|
62 |
+
## How to use
|
63 |
+
|
64 |
+
<br>
|
65 |
+
|
66 |
+
The getting started notebook of WangchanBERTa model can be found at this [Colab notebook](https://colab.research.google.com/drive/15GdAgMcTxhWfDia0OB76F1l0fKZ059Ez?usp=sharing#scrollTo=eVlb6CEDmYi3)
|
67 |
+
|
68 |
+
<br>
|
69 |
+
|
70 |
+
## Training data
|
71 |
+
|
72 |
+
`wangchanberta-base-att-spm-uncased` model was pretrained on assorted Thai text dataset. The total size of uncompressed text is 78.5GB.
|
73 |
+
|
74 |
+
### Preprocessing
|
75 |
+
|
76 |
+
Texts are preprocessed with the following rules:
|
77 |
+
|
78 |
+
- Replace HTML forms of characters with the actual characters such asnbsp;with a space and \<br /> with a line break [[Howard and Ruder, 2018]](https://arxiv.org/abs/1801.06146).
|
79 |
+
- Remove empty brackets ((), {}, and []) than sometimes come up as a result of text extraction such as from Wikipedia.
|
80 |
+
- Replace line breaks with spaces.
|
81 |
+
- Replace more than one spaces with a single space
|
82 |
+
- Remove more than 3 repetitive characters such as ดีมากกก to ดีมาก [Howard and Ruder, 2018]](https://arxiv.org/abs/1801.06146).
|
83 |
+
- Word-level tokenization using [[Phatthiyaphaibun et al., 2020]](https://zenodo.org/record/4319685#.YA4xEGQzaDU) ’s `newmm` dictionary-based maximal matching tokenizer.
|
84 |
+
- Replace repetitive words; this is done post-tokenization unlike [[Howard and Ruder, 2018]](https://arxiv.org/abs/1801.06146). since there is no delimitation by space in Thai as in English.
|
85 |
+
- Replace spaces with <\_>. The SentencePiece tokenizer combines the spaces with other tokens. Since spaces serve as punctuation in Thai such as sentence boundaries similar to periods in English, combining it with other tokens will omit an important feature for tasks such as word tokenization and sentence breaking. Therefore, we opt to explicitly mark spaces with <\_>.
|
86 |
+
|
87 |
+
<br>
|
88 |
+
|
89 |
+
|
90 |
+
Regarding the vocabulary, we use SentencePiece [[Kudo, 2018]](https://arxiv.org/abs/1808.06226) to train SentencePiece unigram model.
|
91 |
+
The tokenizer has a vocabulary size of 25,000 subwords, trained on 15M sentences sampled from the training set.
|
92 |
+
|
93 |
+
|
94 |
+
The length of each sequence is limited up to 416 subword tokens.
|
95 |
+
|
96 |
+
Regarding the masking procedure, for each sequence, we sampled 15% of the tokens and replace them with<mask>token.Out of the 15%, 80% is replaced with a<mask>token, 10% is left unchanged and 10% is replaced with a random token.
|
97 |
+
|
98 |
+
<br>
|
99 |
+
|
100 |
+
**Train/Val/Test splits**
|
101 |
+
|
102 |
+
After preprocessing and deduplication, we have a training set of 381,034,638 unique,mostly Thai sentences with sequence length of 5 to 300 words (78.5GB). The training set has a total of 16,957,775,412 words as tokenized by dictionary-based maximal matching [[Phatthiyaphaibun et al., 2020]](https://zenodo.org/record/4319685#.YA4xEGQzaDU), 8,680,485,067 subwords astokenized by SentencePiece tokenizer, and 53,035,823,287 characters.
|
103 |
+
<br>
|
104 |
+
|
105 |
+
**Pretraining**
|
106 |
+
|
107 |
+
The model was trained on 8 V100 GPUs for 500,000 steps with the batch size of 4,096 (32 sequences per device with 16 accumulation steps) and a sequence length of 416 tokens. The optimizer we used is Adam with the learning rate of $3e-4$, $\beta_1 = 0.9$, $\beta_2= 0.999$ and $\epsilon = 1e-6$. The learning rate is warmed up for the first 24,000 steps and linearly decayed to zero. The model checkpoint with minimum validation loss will be selected as the best model checkpoint.
|
108 |
+
|
109 |
+
As of Sun 24 Jan 2021, we release the model from the checkpoint @360,000 steps due to the model pretraining has not yet been completed
|
110 |
+
|
111 |
+
<br>
|
112 |
+
|
113 |
+
**BibTeX entry and citation info**
|
114 |
+
|
115 |
+
[Coming Soon]
|
116 |
+
|