🚀 PhoBERT: ベトナム語向け事前学習言語モデル
事前学習されたPhoBERTモデルは、ベトナム語向けの最先端の言語モデルです。(Pho は、ベトナムで人気のある食べ物「フォー」を指します。)
- 「base」と「large」の2種類のPhoBERTバージョンは、ベトナム語向けに事前学習された最初の公開大規模単言語言語モデルです。PhoBERTの事前学習アプローチは、RoBERTa に基づいており、BERT の事前学習手順を最適化して、より堅牢なパフォーマンスを実現しています。
- PhoBERTは、以前の単言語および多言語アプローチを上回り、品詞タグ付け、依存構造解析、固有表現認識、自然言語推論という4つの下流のベトナム語NLPタスクで新たな最先端のパフォーマンスを達成しています。
PhoBERTの一般的なアーキテクチャと実験結果は、私たちの論文 で確認できます。
@inproceedings{phobert,
title = {{PhoBERT: Pre-trained language models for Vietnamese}},
author = {Dat Quoc Nguyen and Anh Tuan Nguyen},
booktitle = {Findings of the Association for Computational Linguistics: EMNLP 2020},
year = {2020},
pages = {1037--1042}
}
PhoBERTを使用して公開された結果を生成する場合、または他のソフトウェアに組み込む場合は、必ず私たちの論文を引用してください。
🚀 クイックスタート
PhoBERTを使用するには、transformers
または fairseq
を使うことができます。以下に詳細を説明します。
✨ 主な機能
- ベトナム語向けの最先端の事前学習言語モデル。
- 品詞タグ付け、依存構造解析、固有表現認識、自然言語推論などの下流タスクで高いパフォーマンスを発揮。
📦 インストール
transformers
を使用する場合
transformers
をpipでインストールします: pip install transformers
、または ソースから transformers
をインストール します。
なお、PhoBERT用の低速トークナイザーを transformers
のメインブランチにマージしています。PhoBERT用の高速トークナイザーのマージプロセスは、このプルリクエスト で議論されています。高速トークナイザーを利用したい場合は、以下のように transformers
をインストールします。
git clone --single-branch --branch fast_tokenizers_BARTpho_PhoBERT_BERTweet https://github.com/datquocnguyen/transformers.git
cd transformers
pip3 install -e .
tokenizers
をpipでインストールします: pip3 install tokenizers
py_vncorenlp
を使用する場合
pip install py_vncorenlp
💻 使用例
transformers
を使用する場合
基本的な使用法
import torch
from transformers import AutoModel, AutoTokenizer
phobert = AutoModel.from_pretrained("vinai/phobert-base-v2")
tokenizer = AutoTokenizer.from_pretrained("vinai/phobert-base-v2")
sentence = 'Chúng_tôi là những nghiên_cứu_viên .'
input_ids = torch.tensor([tokenizer.encode(sentence)])
with torch.no_grad():
features = phobert(input_ids)
py_vncorenlp
を使用する場合
基本的な使用法
import py_vncorenlp
py_vncorenlp.download_model(save_dir='/absolute/path/to/vncorenlp')
rdrsegmenter = py_vncorenlp.VnCoreNLP(annotators=["wseg"], save_dir='/absolute/path/to/vncorenlp')
text = "Ông Nguyễn Khắc Chúc đang làm việc tại Đại học Quốc gia Hà Nội. Bà Lan, vợ ông Chúc, cũng làm việc tại đây."
output = rdrsegmenter.word_segment(text)
print(output)
📚 ドキュメント
事前学習モデル
モデル |
パラメータ数 |
アーキテクチャ |
最大長 |
事前学習データ |
vinai/phobert-base |
135M |
base |
256 |
20GBのWikipediaとニューステキスト |
vinai/phobert-large |
370M |
large |
256 |
20GBのWikipediaとニューステキスト |
vinai/phobert-base-v2 |
135M |
base |
256 |
20GBのWikipediaとニューステキスト + 120GBのOSCAR-2301からのテキスト |
fairseq
を使用する場合
詳細は こちら を参照してください。
🔧 技術詳細
入力テキストが raw
(単語分割されていない)場合、PhoBERTに入力する前に単語分割器を適用して単語分割されたテキストを生成する必要があります。PhoBERTは、事前学習データを前処理するために VnCoreNLP の RDRSegmenter を使用しているため(ベトナム語のアクセント正規化 や単語および文の分割を含む)、入力生テキストに関しては、PhoBERTベースの下流アプリケーションでも同じ単語分割器を使用することをお勧めします。
📄 ライセンス
Copyright (c) 2023 VinAI Research
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.