モデル概要
モデル特徴
モデル能力
使用事例
🚀 CAMeLBERT: アラビア語の自然言語処理タスク向けの事前学習モデルコレクション
CAMeLBERTは、異なるサイズとバリアントのアラビア語テキストで事前学習されたBERTモデルのコレクションです。 現代標準アラビア語(MSA)、方言アラビア語(DA)、古典アラビア語(CA)用の事前学習言語モデルをリリースしており、さらにこれら3つの混合データで事前学習されたモデルも提供しています。 また、MSAバリアントの縮小セット(半分、4分の1、8分の1、16分の1)で事前学習された追加のモデルも用意しています。 詳細は論文 "The Interplay of Variant, Size, and Task Type in Arabic Pre-trained Language Models" で説明されています。
このモデルカードでは、DA(方言アラビア語)データセットで事前学習されたCAMeLBERT - DA (bert - base - arabic - camelbert - da
)について説明します。
モデル | バリアント | サイズ | 単語数 | |
---|---|---|---|---|
bert - base - arabic - camelbert - mix |
CA,DA,MSA | 167GB | 17.3B | |
bert - base - arabic - camelbert - ca |
CA | 6GB | 847M | |
✔ | bert - base - arabic - camelbert - da |
DA | 54GB | 5.8B |
bert - base - arabic - camelbert - msa |
MSA | 107GB | 12.6B | |
bert - base - arabic - camelbert - msa - half |
MSA | 53GB | 6.3B | |
bert - base - arabic - camelbert - msa - quarter |
MSA | 27GB | 3.1B | |
bert - base - arabic - camelbert - msa - eighth |
MSA | 14GB | 1.6B | |
bert - base - arabic - camelbert - msa - sixteenth |
MSA | 6GB | 746M |
🚀 クイックスタート
想定される用途
公開されているモデルは、マスク言語モデリングまたは次文予測に使用できます。 ただし、主にNER、POSタグ付け、センチメント分析、方言識別、詩分類などの自然言語処理タスクでファインチューニングすることを想定しています。 ファインチューニングコードは[こちら](https://github.com/CAMeL - Lab/CAMeLBERT)で公開しています。
使い方
このモデルは、マスク言語モデリングのパイプラインで直接使用できます。
>>> from transformers import pipeline
>>> unmasker = pipeline('fill - mask', model='CAMeL - Lab/bert - base - arabic - camelbert - da')
>>> unmasker("الهدف من الحياة هو [MASK] .")
[{'sequence': '[CLS] الهدف من الحياة هو.. [SEP]',
'score': 0.062508225440979,
'token': 18,
'token_str': '.'},
{'sequence': '[CLS] الهدف من الحياة هو الموت. [SEP]',
'score': 0.033172328025102615,
'token': 4295,
'token_str': 'الموت'},
{'sequence': '[CLS] الهدف من الحياة هو الحياة. [SEP]',
'score': 0.029575437307357788,
'token': 3696,
'token_str': 'الحياة'},
{'sequence': '[CLS] الهدف من الحياة هو الرحيل. [SEP]',
'score': 0.02724040113389492,
'token': 11449,
'token_str': 'الرحيل'},
{'sequence': '[CLS] الهدف من الحياة هو الحب. [SEP]',
'score': 0.01564178802073002,
'token': 3088,
'token_str': 'الحب'}]
注意: モデルをダウンロードするには、transformers>=3.5.0
が必要です。そうでない場合は、手動でモデルをダウンロードできます。
以下は、このモデルを使用して与えられたテキストの特徴をPyTorchで取得する方法です。
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained('CAMeL - Lab/bert - base - arabic - camelbert - da')
model = AutoModel.from_pretrained('CAMeL - Lab/bert - base - arabic - camelbert - da')
text = "مرحبا يا عالم."
encoded_input = tokenizer(text, return_tensors='pt')
output = model(**encoded_input)
TensorFlowでの使用方法は以下の通りです。
from transformers import AutoTokenizer, TFAutoModel
tokenizer = AutoTokenizer.from_pretrained('CAMeL - Lab/bert - base - arabic - camelbert - da')
model = TFAutoModel.from_pretrained('CAMeL - Lab/bert - base - arabic - camelbert - da')
text = "مرحبا يا عالم."
encoded_input = tokenizer(text, return_tensors='tf')
output = model(encoded_input)
✨ 主な機能
モデルの詳細
CAMeLBERTは、アラビア語の異なるバリアント(現代標準アラビア語、方言アラビア語、古典アラビア語)とそれらの混合データで事前学習されたBERTベースのモデルです。また、MSAバリアントの縮小セットで事前学習された追加モデルも提供しています。
📦 トレーニングデータ
- DA(方言アラビア語)
- 論文で説明されている方言アラビア語データのコレクション。
🔧 技術詳細
トレーニング手順
事前学習には、Googleが公開した[元の実装](https://github.com/google - research/bert)を使用しています。 特に指定がない限り、元の英語のBERTモデルのハイパーパラメータを事前学習に使用しています。
前処理
- 各コーパスから生テキストを抽出した後、以下の前処理を適用します。
- まず、[元のBERT実装](https://github.com/google - research/bert/blob/eedf5716ce1268e56f0a50264a88cafad334ac61/tokenization.py#L286 - L297)で提供されているユーティリティを使用して、無効な文字を削除し、空白を正規化します。
- アラビア文字が含まれていない行も削除します。
- 次に、[CAMeL Tools](https://github.com/CAMeL - Lab/camel_tools)を使用して、ダイアクリティクスとカシダを削除します。
- 最後に、ヒューリスティックベースの文分割器で各行を文に分割します。
- HuggingFaceのトークナイザーを使用して、語彙サイズ30,000で、全データセット(167GBのテキスト)でWordPieceトークナイザーを学習させます。
- 小文字化やアクセントの除去は行いません。
事前学習
- モデルは、単一のクラウドTPU (
v3 - 8
) で合計100万ステップのトレーニングを行いました。 - 最初の90,000ステップはバッチサイズ1,024でトレーニングし、残りはバッチサイズ256でトレーニングしました。
- 90%のステップでシーケンス長を128トークンに制限し、残りの10%では512に制限しました。
- ホールワードマスキングを使用し、重複係数は10としました。
- 最大シーケンス長が128トークンのデータセットでは、シーケンスあたりの最大予測数を20に設定し、最大シーケンス長が512トークンのデータセットでは80に設定しました。
- 乱数シードは12345、マスク言語モデルの確率は0.15、短いシーケンスの確率は0.1としました。
- 使用するオプティマイザはAdamで、学習率は1e - 4、\(\beta_{1} = 0.9\)、\(\beta_{2} = 0.999\)、重み減衰は0.01、学習率のウォームアップは10,000ステップ、その後は学習率を線形に減衰させます。
📚 評価結果
結果
タスク | データセット | バリアント | 混合 | CA | DA | MSA | MSA - 1/2 | MSA - 1/4 | MSA - 1/8 | MSA - 1/16 |
---|---|---|---|---|---|---|---|---|---|---|
NER | ANERcorp | MSA | 80.8% | 67.9% | 74.1% | 82.4% | 82.0% | 82.1% | 82.6% | 80.8% |
POS | PATB (MSA) | MSA | 98.1% | 97.8% | 97.7% | 98.3% | 98.2% | 98.3% | 98.2% | 98.2% |
ARZTB (EGY) | DA | 93.6% | 92.3% | 92.7% | 93.6% | 93.6% | 93.7% | 93.6% | 93.6% | |
Gumar (GLF) | DA | 97.3% | 97.7% | 97.9% | 97.9% | 97.9% | 97.9% | 97.9% | 97.9% | |
SA | ASTD | MSA | 76.3% | 69.4% | 74.6% | 76.9% | 76.0% | 76.8% | 76.7% | 75.3% |
ArSAS | MSA | 92.7% | 89.4% | 91.8% | 93.0% | 92.6% | 92.5% | 92.5% | 92.3% | |
SemEval | MSA | 69.0% | 58.5% | 68.4% | 72.1% | 70.7% | 72.8% | 71.6% | 71.2% | |
DID | MADAR - 26 | DA | 62.9% | 61.9% | 61.8% | 62.6% | 62.0% | 62.8% | 62.0% | 62.2% |
MADAR - 6 | DA | 92.5% | 91.5% | 92.2% | 91.9% | 91.8% | 92.2% | 92.1% | 92.0% | |
MADAR - Twitter - 5 | MSA | 75.7% | 71.4% | 74.2% | 77.6% | 78.5% | 77.3% | 77.7% | 76.2% | |
NADI | DA | 24.7% | 17.3% | 20.1% | 24.9% | 24.6% | 24.6% | 24.9% | 23.8% | |
詩 | APCD | CA | 79.8% | 80.9% | 79.6% | 79.7% | 79.9% | 80.0% | 79.7% | 79.8% |
結果(平均)
バリアント | 混合 | CA | DA | MSA | MSA - 1/2 | MSA - 1/4 | MSA - 1/8 | MSA - 1/16 | |
---|---|---|---|---|---|---|---|---|---|
バリアントごとの平均[[1]](#footnote - 1) | MSA | 82.1% | 75.7% | 80.1% | 83.4% | 83.0% | 83.3% | 83.2% | 82.3% |
DA | 74.4% | 72.1% | 72.9% | 74.2% | 74.0% | 74.3% | 74.1% | 73.9% | |
CA | 79.8% | 80.9% | 79.6% | 79.7% | 79.9% | 80.0% | 79.7% | 79.8% | |
マクロ平均 | すべて | 78.7% | 74.7% | 77.1% | 79.2% | 79.0% | 79.2% | 79.1% | 78.6% |
[1]: バリアントごとの平均は、同じ言語バリアントのタスクグループ全体の平均を指します。
📄 ライセンス
このプロジェクトは、Apache - 2.0ライセンスの下で公開されています。
謝辞
この研究は、GoogleのTensorFlow Research Cloud(TFRC)から提供されたクラウドTPUでサポートされています。
引用
@inproceedings{inoue-etal-2021-interplay,
title = "The Interplay of Variant, Size, and Task Type in {A}rabic Pre-trained Language Models",
author = "Inoue, Go and
Alhafni, Bashar and
Baimukan, Nurpeiis and
Bouamor, Houda and
Habash, Nizar",
booktitle = "Proceedings of the Sixth Arabic Natural Language Processing Workshop",
month = apr,
year = "2021",
address = "Kyiv, Ukraine (Online)",
publisher = "Association for Computational Linguistics",
abstract = "In this paper, we explore the effects of language variants, data sizes, and fine-tuning task types in Arabic pre-trained language models. To do so, we build three pre-trained language models across three variants of Arabic: Modern Standard Arabic (MSA), dialectal Arabic, and classical Arabic, in addition to a fourth language model which is pre-trained on a mix of the three. We also examine the importance of pre-training data size by building additional models that are pre-trained on a scaled-down set of the MSA variant. We compare our different models to each other, as well as to eight publicly available models by fine-tuning them on five NLP tasks spanning 12 datasets. Our results suggest that the variant proximity of pre-training data to fine-tuning data is more important than the pre-training data size. We exploit this insight in defining an optimized system selection model for the studied tasks.",
}



