🚀 FlauBERT:面向法语的无监督语言模型预训练
FlauBERT 是一个在非常庞大且多样化的法语语料库上训练的法语 BERT 模型。不同规模的模型借助法国国家科学研究中心(CNRS)的 Jean Zay 超级计算机进行训练。
与 FlauBERT 一同推出的还有 FLUE:这是一个用于法语自然语言处理系统的评估框架,类似于广受欢迎的 GLUE 基准测试。其目标是在未来开展更多可复现的实验,并在法语领域共享模型和研究进展。更多详情请参考 官方网站。
✨ 主要特性
- 基于大规模且异构的法语语料库进行预训练,能更好地适应法语语言特点。
- 提供不同规模的模型,可根据具体需求选择。
- 配备类似 GLUE 基准测试的 FLUE 评估框架,方便进行模型评估和比较。
📦 安装指南
文档中未提及具体安装步骤,可参考官方网站获取安装信息。
💻 使用示例
基础用法
import torch
from transformers import FlaubertModel, FlaubertTokenizer
modelname = 'flaubert/flaubert_base_cased'
flaubert, log = FlaubertModel.from_pretrained(modelname, output_loading_info=True)
flaubert_tokenizer = FlaubertTokenizer.from_pretrained(modelname, do_lowercase=False)
sentence = "Le chat mange une pomme."
token_ids = torch.tensor([flaubert_tokenizer.encode(sentence)])
last_layer = flaubert(token_ids)[0]
print(last_layer.shape)
cls_embedding = last_layer[:, 0, :]
注意事项
⚠️ 重要提示
如果你的 transformers
版本小于等于 2.10.0,modelname
应取以下值之一:
['flaubert-small-cased', 'flaubert-base-uncased', 'flaubert-base-cased', 'flaubert-large-cased']
📚 详细文档
FlauBERT 模型
模型名称 |
层数 |
注意力头数 |
嵌入维度 |
总参数数量 |
flaubert-small-cased |
6 |
8 |
512 |
54 M |
flaubert-base-uncased |
12 |
12 |
768 |
137 M |
flaubert-base-cased |
12 |
12 |
768 |
138 M |
flaubert-large-cased |
24 |
16 |
1024 |
373 M |
⚠️ 重要提示
flaubert-small-cased
模型是部分训练的,因此不能保证其性能。建议仅将其用于调试目的。
📄 许可证
本项目采用 MIT 许可证。
📖 参考文献
如果你在科学出版物中使用了 FlauBERT 或 FLUE 基准测试,或者认为本仓库中的资源很有用,请引用以下论文之一:
LREC 论文
@InProceedings{le2020flaubert,
author = {Le, Hang and Vial, Lo\"{i}c and Frej, Jibril and Segonne, Vincent and Coavoux, Maximin and Lecouteux, Benjamin and Allauzen, Alexandre and Crabb\'{e}, Beno\^{i}t and Besacier, Laurent and Schwab, Didier},
title = {FlauBERT: Unsupervised Language Model Pre-training for French},
booktitle = {Proceedings of The 12th Language Resources and Evaluation Conference},
month = {May},
year = {2020},
address = {Marseille, France},
publisher = {European Language Resources Association},
pages = {2479--2490},
url = {https://www.aclweb.org/anthology/2020.lrec-1.302}
}
TALN 论文
@inproceedings{le2020flaubert,
title = {FlauBERT: des mod{\`e}les de langue contextualis{\'e}s pr{\'e}-entra{\^\i}n{\'e}s pour le fran{\c{c}}ais},
author = {Le, Hang and Vial, Lo{\"\i}c and Frej, Jibril and Segonne, Vincent and Coavoux, Maximin and Lecouteux, Benjamin and Allauzen, Alexandre and Crabb{\'e}, Beno{\^\i}t and Besacier, Laurent and Schwab, Didier},
booktitle = {Actes de la 6e conf{\'e}rence conjointe Journ{\'e}es d'{\'E}tudes sur la Parole (JEP, 31e {\'e}dition), Traitement Automatique des Langues Naturelles (TALN, 27e {\'e}dition), Rencontre des {\'E}tudiants Chercheurs en Informatique pour le Traitement Automatique des Langues (R{\'E}CITAL, 22e {\'e}dition). Volume 2: Traitement Automatique des Langues Naturelles},
pages = {268--278},
year = {2020},
organization = {ATALA}
}