docs: update readme
Browse files
README.md
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
datasets:
|
4 |
+
- scb_mt_enth_2020
|
5 |
+
- oscar
|
6 |
+
- best2009
|
7 |
+
- wikipedia
|
8 |
+
language:
|
9 |
+
- th
|
10 |
+
library_name: fairseq
|
11 |
+
---
|
12 |
+
# HoogBERTa
|
13 |
+
|
14 |
+
This repository includes the Thai pretrained language representation (HoogBERTa_base) and the fine-tuned model for multitask sequence labeling.
|
15 |
+
|
16 |
+
|
17 |
+
|
18 |
+
# Documentation
|
19 |
+
|
20 |
+
To initialize the model from hub, use the following commands
|
21 |
+
```
|
22 |
+
from transformers import AutoTokenizer, AutoModel
|
23 |
+
|
24 |
+
tokenizer = AutoTokenizer.from_pretrained("new5558/HoogBERTa")
|
25 |
+
model = AutoModel.from_pretrained("new5558/HoogBERTa")
|
26 |
+
```
|
27 |
+
|
28 |
+
To annotate POS, NE and cluase boundary, use the following commands
|
29 |
+
```
|
30 |
+
|
31 |
+
```
|
32 |
+
|
33 |
+
To extract token features, based on the RoBERTa architecture, use the following commands
|
34 |
+
|
35 |
+
```python
|
36 |
+
with torch.no_grad():
|
37 |
+
model.eval()
|
38 |
+
sentence = "วันที่ 12 มีนาคมนี้ ฉันจะไปเที่ยววัดพระแก้ว ที่กรุงเทพ"
|
39 |
+
all_sent = []
|
40 |
+
sentences = sentence.split(" ")
|
41 |
+
for sent in sentences:
|
42 |
+
all_sent.append(" ".join(tokenize(sent)).replace("_","[!und:]"))
|
43 |
+
|
44 |
+
sentence = " _ ".join(all_sent)
|
45 |
+
token_ids = tokenizer(sentence, return_tensors = 'pt')['input_ids']
|
46 |
+
features = model(token_ids)
|
47 |
+
```
|
48 |
+
|
49 |
+
For batch processing,
|
50 |
+
|
51 |
+
```python
|
52 |
+
with torch.no_grad():
|
53 |
+
model.eval()
|
54 |
+
sentenceL = ["วันที่ 12 มีนาคมนี้","ฉันจะไปเที่ยววัดพระแก้ว ที่กรุงเทพ"]
|
55 |
+
inputList = []
|
56 |
+
for sentX in sentenceL:
|
57 |
+
sentences = sentX.split(" ")
|
58 |
+
all_sent = []
|
59 |
+
for sent in sentences:
|
60 |
+
all_sent.append(" ".join(tokenize(sent)).replace("_","[!und:]"))
|
61 |
+
|
62 |
+
sentence = " _ ".join(all_sent)
|
63 |
+
inputList.append(sentence)
|
64 |
+
token_ids = tokenizer(inputList, padding = True, return_tensors = 'pt').input_ids
|
65 |
+
features = model(token_ids)
|
66 |
+
```
|
67 |
+
|
68 |
+
To use HoogBERTa as an embedding layer, use
|
69 |
+
|
70 |
+
```python
|
71 |
+
with torch.no_grad():
|
72 |
+
features = model(token_ids) # where token_ids is a tensor with type "long".
|
73 |
+
```
|
74 |
+
|
75 |
+
# Citation
|
76 |
+
|
77 |
+
Please cite as:
|
78 |
+
|
79 |
+
``` bibtex
|
80 |
+
@inproceedings{porkaew2021hoogberta,
|
81 |
+
title = {HoogBERTa: Multi-task Sequence Labeling using Thai Pretrained Language Representation},
|
82 |
+
author = {Peerachet Porkaew, Prachya Boonkwan and Thepchai Supnithi},
|
83 |
+
booktitle = {The Joint International Symposium on Artificial Intelligence and Natural Language Processing (iSAI-NLP 2021)},
|
84 |
+
year = {2021},
|
85 |
+
address={Online}
|
86 |
+
}
|
87 |
+
```
|
88 |
+
|
89 |
+
Download full-text [PDF](https://drive.google.com/file/d/1hwdyIssR5U_knhPE2HJigrc0rlkqWeLF/view?usp=sharing)
|