lst-nectec/lst20
Updated • 246 • 6
Run lst-nectec/HoogBERTa-NER-lst20 on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Use HF Jobs to fine-tune https://huggingface.co/lst-nectec/HoogBERTa-NER-lst20. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Use HF Jobs to run batch inference with https://huggingface.co/lst-nectec/HoogBERTa-NER-lst20 on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
How to use lst-nectec/HoogBERTa-NER-lst20 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("token-classification", model="lst-nectec/HoogBERTa-NER-lst20") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForTokenClassification
tokenizer = AutoTokenizer.from_pretrained("lst-nectec/HoogBERTa-NER-lst20")
model = AutoModelForTokenClassification.from_pretrained("lst-nectec/HoogBERTa-NER-lst20", device_map="auto")This repository includes the Thai pretrained language representation (HoogBERTa_base) fine-tuned for Named-Entity Recognition (NER) Task.
Since we use subword-nmt BPE encoding, input needs to be pre-tokenize using BEST standard before inputting into HoogBERTa
pip install attacut
To initialize the model from hub, use the following commands
from transformers import RobertaTokenizerFast, RobertaForTokenClassification
from attacut import tokenize
import torch
tokenizer = RobertaTokenizerFast.from_pretrained("lst-nectec/HoogBERTa-NER-lst20")
model = RobertaForTokenClassification.from_pretrained("lst-nectec/HoogBERTa-NER-lst20")
To do NER Tagging, use the following commands
from transformers import pipeline
nlp = pipeline('token-classification', model=model, tokenizer=tokenizer, aggregation_strategy="none")
sentence = "วันที่ 12 มีนาคมนี้ ฉันจะไปเที่ยววัดพระแก้ว ที่กรุงเทพ"
all_sent = []
sentences = sentence.split(" ")
for sent in sentences:
all_sent.append(" ".join(tokenize(sent)).replace("_","[!und:]"))
sentence = " _ ".join(all_sent)
print(nlp(sentence))
For batch processing,
from transformers import pipeline
nlp = pipeline('token-classification', model=model, tokenizer=tokenizer, aggregation_strategy="none")
sentenceL = ["วันที่ 12 มีนาคมนี้","ฉันจะไปเที่ยววัดพระแก้ว ที่กรุงเทพ"]
inputList = []
for sentX in sentenceL:
sentences = sentX.split(" ")
all_sent = []
for sent in sentences:
all_sent.append(" ".join(tokenize(sent)).replace("_","[!und:]"))
sentence = " _ ".join(all_sent)
inputList.append(sentence)
print(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 LST20Please cite as:
@inproceedings{porkaew2021hoogberta,
title = {HoogBERTa: Multi-task Sequence Labeling using Thai Pretrained Language Representation},
author = {Peerachet Porkaew, Prachya Boonkwan and Thepchai Supnithi},
booktitle = {The Joint International Symposium on Artificial Intelligence and Natural Language Processing (iSAI-NLP 2021)},
year = {2021},
address={Online}
}