Bert Base Arabic Camelbert Msa
CAMeLBERT是針對阿拉伯語NLP任務的預訓練模型集合,本模型為現代標準阿拉伯語(MSA)變體,基於126億詞元訓練
下載量 1,212
發布時間 : 3/2/2022
模型概述
基於現代標準阿拉伯語文本預訓練的BERT模型,支持掩碼語言建模及下游NLP任務微調
模型特點
多方言支持
提供古典阿拉伯語(CA)、方言阿拉伯語(DA)和現代標準阿拉伯語(MSA)三種變體的專用模型
數據規模可擴展
提供從完整數據到1/16數據的多種規模預訓練模型,適應不同計算需求
專業預處理
採用阿拉伯語專用預處理流程,包括變音符號處理和字符規範化
模型能力
阿拉伯語文本理解
掩碼語言建模
命名實體識別
詞性標註
情感分析
方言識別
使用案例
文本分析
阿拉伯語新聞分類
對MSA新聞文本進行主題分類
在ArSAS數據集達93% F1分數
語言研究
古典詩歌分類
識別阿拉伯古典詩歌的時期和風格
APCD數據集上80.9%準確率(CA變體最佳)
🚀 CAMeLBERT:用於阿拉伯語自然語言處理任務的預訓練模型集合
CAMeLBERT 是一系列針對阿拉伯語文本進行預訓練的 BERT 模型,具有不同的規模和變體。我們發佈了針對現代標準阿拉伯語(MSA)、方言阿拉伯語(DA)和古典阿拉伯語(CA)的預訓練語言模型,此外還有一個基於這三種語言混合數據進行預訓練的模型。我們還提供了在縮減版 MSA 變體數據集(二分之一、四分之一、八分之一和十六分之一)上預訓練的額外模型。詳細內容請參考論文 "The Interplay of Variant, Size, and Task Type in Arabic Pre-trained Language Models"。
本模型卡片介紹的是 CAMeLBERT - MSA (bert-base-arabic-camelbert-msa
),這是一個在整個 MSA 數據集上預訓練的模型。
🚀 快速開始
你可以使用發佈的模型進行掩碼語言建模或下一句預測任務。不過,該模型主要用於在自然語言處理任務(如命名實體識別(NER)、詞性標註(POS)、情感分析、方言識別和詩歌分類)上進行微調。我們在 此處 發佈了微調代碼。
✨ 主要特性
- 提供多種阿拉伯語變體(現代標準阿拉伯語、方言阿拉伯語、古典阿拉伯語)的預訓練模型。
- 提供不同規模的模型,包括基於縮減版 MSA 數據集預訓練的模型。
- 可用於多種自然語言處理任務。
📦 安裝指南
要下載我們的模型,你需要 transformers>=3.5.0
。否則,你可以手動下載模型。
💻 使用示例
基礎用法
以下是如何使用該模型進行掩碼語言建模的示例:
>>> from transformers import pipeline
>>> unmasker = pipeline('fill-mask', model='CAMeL-Lab/bert-base-arabic-camelbert-msa')
>>> unmasker("الهدف من الحياة هو [MASK] .")
[{'sequence': '[CLS] الهدف من الحياة هو العمل. [SEP]',
'score': 0.08507660031318665,
'token': 2854,
'token_str': 'العمل'},
{'sequence': '[CLS] الهدف من الحياة هو الحياة. [SEP]',
'score': 0.058905381709337234,
'token': 3696, 'token_str': 'الحياة'},
{'sequence': '[CLS] الهدف من الحياة هو النجاح. [SEP]',
'score': 0.04660581797361374, 'token': 6232,
'token_str': 'النجاح'},
{'sequence': '[CLS] الهدف من الحياة هو الربح. [SEP]',
'score': 0.04156001657247543,
'token': 12413, 'token_str': 'الربح'},
{'sequence': '[CLS] الهدف من الحياة هو الحب. [SEP]',
'score': 0.03534102067351341,
'token': 3088,
'token_str': 'الحب'}]
高級用法
以下是如何在 PyTorch 中使用該模型獲取給定文本特徵的示例:
from transformers import AutoTokenizer, AutoModel
tokenizer = AutoTokenizer.from_pretrained('CAMeL-Lab/bert-base-arabic-camelbert-msa')
model = AutoModel.from_pretrained('CAMeL-Lab/bert-base-arabic-camelbert-msa')
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-msa')
model = TFAutoModel.from_pretrained('CAMeL-Lab/bert-base-arabic-camelbert-msa')
text = "مرحبا يا عالم."
encoded_input = tokenizer(text, return_tensors='tf')
output = model(encoded_input)
📚 詳細文檔
模型詳情
模型 | 變體 | 規模 | 詞數 | |
---|---|---|---|---|
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 |
訓練數據
- 現代標準阿拉伯語(MSA)
訓練過程
我們使用谷歌發佈的 原始實現 進行預訓練。除非另有說明,否則我們遵循原始英文 BERT 模型的超參數進行預訓練。
預處理
- 從每個語料庫中提取原始文本後,我們進行以下預處理步驟:
- 首先,使用 原始 BERT 實現 提供的工具移除無效字符並規範化空格。
- 移除沒有任何阿拉伯字符的行。
- 使用 CAMeL Tools 移除變音符號和 kashida。
- 最後,使用基於啟發式的句子分割器將每行分割成句子。
- 使用 HuggingFace 的分詞器 在整個數據集(167 GB 文本)上訓練一個 WordPiece 分詞器,詞彙表大小為 30,000。
- 我們不將字母小寫,也不去除重音。
預訓練
- 該模型在單個雲 TPU (
v3 - 8
) 上總共訓練了一百萬個步驟。 - 前 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 步內預熱,之後線性衰減。
評估結果
- 我們在五個自然語言處理任務(命名實體識別、詞性標註、情感分析、方言識別和詩歌分類)上評估了我們的預訓練語言模型。
- 使用 12 個數據集對模型進行微調並評估。
- 使用 Hugging Face 的 transformers 庫對我們的 CAMeLBERT 模型進行微調。
- 使用 transformers
v3.1.0
和 PyTorchv1.5.1
。 - 微調是通過在最後一個隱藏層添加一個全連接線性層來完成的。
- 所有任務都使用 \(F_{1}\) 分數作為評估指標。
- 微調使用的代碼可在 此處 獲取。
結果
任務 | 數據集 | 變體 | 混合 | CA | DA | MSA | MSA - 1/2 | MSA - 1/4 | MSA - 1/8 | MSA - 1/16 |
---|---|---|---|---|---|---|---|---|---|---|
命名實體識別 | ANERcorp | MSA | 80.8% | 67.9% | 74.1% | 82.4% | 82.0% | 82.1% | 82.6% | 80.8% |
詞性標註 | 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% | |
情感分析 | 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% | |
方言識別 | 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]:變體平均是指對同一語言變體的一組任務的平均值。
🔧 技術細節
本研究得到了谷歌 TensorFlow 研究雲(TFRC)的雲 TPU 支持。
📄 許可證
本項目採用 Apache - 2.0 許可證。
引用
@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.",
}
Phi 2 GGUF
其他
Phi-2是微軟開發的一個小型但強大的語言模型,具有27億參數,專注於高效推理和高質量文本生成。
大型語言模型 支持多種語言
P
TheBloke
41.5M
205
Roberta Large
MIT
基於掩碼語言建模目標預訓練的大型英語語言模型,採用改進的BERT訓練方法
大型語言模型 英語
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基礎模型的蒸餾版本,在保持相近性能的同時更輕量高效,適用於序列分類、標記分類等自然語言處理任務。
大型語言模型 英語
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一個多語言大語言模型,針對多語言對話用例進行了優化,在常見的行業基準測試中表現優異。
大型語言模型 英語
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基於100種語言的2.5TB過濾CommonCrawl數據預訓練的多語言模型,採用掩碼語言建模目標進行訓練。
大型語言模型 支持多種語言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基於Transformer架構的英語預訓練模型,通過掩碼語言建模目標在海量文本上訓練,支持文本特徵提取和下游任務微調
大型語言模型 英語
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI發佈的開放預訓練Transformer語言模型套件,參數量從1.25億到1750億,旨在對標GPT-3系列性能,同時促進大規模語言模型的開放研究。
大型語言模型 英語
O
facebook
6.3M
198
1
基於transformers庫的預訓練模型,適用於多種NLP任務
大型語言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多語言大語言模型系列,包含8B、70B和405B參數規模,支持8種語言和代碼生成,優化了多語言對話場景。
大型語言模型
Transformers 支持多種語言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基礎版是由Google開發的文本到文本轉換Transformer模型,參數規模2.2億,支持多語言NLP任務。
大型語言模型 支持多種語言
T
google-t5
5.4M
702
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98