🚀 HoogBERTa
このリポジトリには、固有表現抽出(NER)タスク用にファインチューニングされたタイ語の事前学習言語表現(HoogBERTa_base)が含まれています。
🚀 クイックスタート
前提条件
subword - nmt BPEエンコーディングを使用しているため、HoogBERTaに入力する前に、入力をBEST標準を使用して事前にトークン化する必要があります。
pip install attacut
モデルの初期化
ハブからモデルを初期化するには、以下のコマンドを使用します。
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")
NERタグ付けの実行
NERタグ付けを行うには、以下のコマンドを使用します。
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))
バッチ処理
バッチ処理を行うには、以下のコマンドを使用します。
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))
📚 ドキュメント
Huggingfaceモデル
HoogBERTaEncoder
- [HoogBERTa](https://huggingface.co/lst - nectec/HoogBERTa):
特徴抽出
および マスク言語モデリング
HoogBERTaMuliTaskTagger
:
- [HoogBERTa - NER - lst20](https://huggingface.co/lst - nectec/HoogBERTa - NER - lst20): LST20に基づく
固有表現抽出(NER)
- [HoogBERTa - POS - lst20](https://huggingface.co/lst - nectec/HoogBERTa - POS - lst20): LST20に基づく
品詞タグ付け(POS)
- [HoogBERTa - SENTENCE - lst20](https://huggingface.co/lst - nectec/HoogBERTa - SENTENCE - lst20): LST20に基づく
節境界分類
📄 引用
以下のように引用してください。
@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}
}
全文をPDFでダウンロードできます。
コードはGithubで確認できます。