Views
No views yet
pip install attacut1from transformers import RobertaTokenizerFast, RobertaForTokenClassification
2from attacut import tokenize
3import torch
4
5tokenizer = RobertaTokenizerFast.from_pretrained("lst-nectec/HoogBERTa-SENTENCE-lst20")
6model = RobertaForTokenClassification.from_pretrained("lst-nectec/HoogBERTa-SENTENCE-lst20")1from transformers import pipeline
2
3nlp = pipeline('token-classification', model=model, tokenizer=tokenizer, aggregation_strategy="none")
4
5sentence = "วันที่ 12 มีนาคมนี้ ฉันจะไปเที่ยววัดพระแก้ว ที่กรุงเทพ"
6all_sent = []
7sentences = sentence.split(" ")
8for sent in sentences:
9 all_sent.append(" ".join(tokenize(sent)).replace("_","[!und:]"))
10
11sentence = " _ ".join(all_sent)
12
13print(nlp(sentence))1from transformers import pipeline
2
3nlp = pipeline('token-classification', model=model, tokenizer=tokenizer, aggregation_strategy="none")
4
5sentenceL = ["วันที่ 12 มีนาคมนี้","ฉันจะไปเที่ยววัดพระแก้ว ที่กรุงเทพ"]
6inputList = []
7for sentX in sentenceL:
8 sentences = sentX.split(" ")
9 all_sent = []
10 for sent in sentences:
11 all_sent.append(" ".join(tokenize(sent)).replace("_","[!und:]"))
12
13 sentence = " _ ".join(all_sent)
14 inputList.append(sentence)
15
16print(nlp(inputList))HoogBERTaEncoderFeature Extraction and Mask Language ModelingHoogBERTaMuliTaskTagger:Named-entity recognition (NER) based on LST20Part-of-speech tagging (POS) based on LST20Clause Boundary Classification based on LST201@inproceedings{porkaew2021hoogberta,
2 title = {HoogBERTa: Multi-task Sequence Labeling using Thai Pretrained Language Representation},
3 author = {Peerachet Porkaew, Prachya Boonkwan and Thepchai Supnithi},
4 booktitle = {The Joint International Symposium on Artificial Intelligence and Natural Language Processing (iSAI-NLP 2021)},
5 year = {2021},
6 address={Online}
7}