Bert Base Arabic Camelbert Da
CAMeLBERT-DA是基于方言阿拉伯语(DA)预训练的BERT模型,属于CAMeLBERT系列模型的一部分,专注于阿拉伯语NLP任务。
下载量 1,756
发布时间 : 3/2/2022
模型简介
该模型是专门针对阿拉伯语方言(DA)文本预训练的BERT模型,可用于掩码语言建模和下游NLP任务的微调,如NER、词性标注、情感分析等。
模型特点
方言阿拉伯语专用
专门针对阿拉伯语方言(DA)进行预训练,能更好地处理方言文本
多任务适配
支持多种阿拉伯语NLP任务的微调,包括NER、词性标注、情感分析等
完整预处理流程
包含阿拉伯语特有的文本预处理步骤,如去除变音符号和连接符
模型能力
掩码语言建模
文本特征提取
阿拉伯语NLP任务微调
使用案例
自然语言处理
命名实体识别
用于识别阿拉伯语方言文本中的人名、地名等实体
情感分析
分析阿拉伯语方言文本的情感倾向
方言识别
识别文本中的阿拉伯语方言特征
🚀 CAMeLBERT:用于阿拉伯语自然语言处理任务的预训练模型集合
CAMeLBERT 是一系列针对阿拉伯语文本进行预训练的 BERT 模型,具有不同的规模和变体。我们发布了针对现代标准阿拉伯语(MSA)、方言阿拉伯语(DA)和古典阿拉伯语(CA)的预训练语言模型,此外还有一个基于这三种语言混合数据进行预训练的模型。我们还提供了在缩减规模的 MSA 变体数据集(二分之一、四分之一、八分之一和十六分之一)上预训练的额外模型。详细内容可参考论文 "The Interplay of Variant, Size, and Task Type in Arabic Pre-trained Language Models"。
📄 许可证
本项目采用 apache-2.0
许可证。
🚀 快速开始
本模型卡片介绍了 CAMeLBERT - DA (bert-base-arabic-camelbert-da
),这是一个在方言阿拉伯语(DA)数据集上预训练的模型。
✨ 主要特性
- 提供多种阿拉伯语变体的预训练模型,包括现代标准阿拉伯语、方言阿拉伯语和古典阿拉伯语。
- 有不同规模的模型可供选择,以满足不同的需求。
- 可用于多种自然语言处理任务,如命名实体识别、词性标注、情感分析等。
📦 安装指南
要下载我们的模型,你需要 transformers>=3.5.0
。否则,你可以手动下载模型。
💻 使用示例
基础用法
你可以直接使用这个模型进行掩码语言建模:
>>> 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': 'الحب'}]
高级用法
以下是如何在 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)
📚 详细文档
模型信息
属性 | 详情 |
---|---|
模型类型 | 一系列基于 BERT 架构的预训练模型 |
训练数据 | 方言阿拉伯语(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)、情感分析、方言识别和诗歌分类。我们在 这里 发布了微调代码。
训练过程
我们使用 Google 发布的 原始实现 进行预训练。除非另有说明,我们遵循原始英文 BERT 模型的超参数进行预训练。
预处理
- 从每个语料库中提取原始文本后,我们进行以下预处理步骤:
- 首先,使用 原始 BERT 实现 提供的工具移除无效字符并规范化空格。
- 移除没有任何阿拉伯字符的行。
- 使用 CAMeL Tools 移除变音符号和 kashida。
- 最后,使用基于启发式的句子分割器将每行分割成句子。
- 使用 HuggingFace 的 tokenizers 在整个数据集(167GB 文本)上训练一个词汇量为 30,000 的 WordPiece 分词器。
- 我们不将字母小写,也不去除重音。
预训练
- 模型在单个云 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 步内预热,之后线性衰减。
评估结果
- 我们在五个自然语言处理任务上评估预训练语言模型:命名实体识别(NER)、词性标注(POS)、情感分析、方言识别和诗歌分类。
- 使用 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 |
---|---|---|---|---|---|---|---|---|---|---|
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]: 变体平均指的是对同一语言变体的一组任务进行平均。
🔧 技术细节
本研究得到了 Google 的 TensorFlow 研究云(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.",
}
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