🚀 FlauBERT:法语无监督语言模型预训练
FlauBERT 是一个在非常庞大且多样化的法语语料库上训练的法语BERT模型。不同规模的模型借助法国国家科学研究中心(CNRS)的 让·扎伊 超级计算机进行训练。
与 FlauBERT 一同推出的还有 FLUE:一个类似于流行的 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}
}