🚀 FlauBERT:面向法语的无监督语言模型预训练
FlauBERT 是一个在超大规模且多样化的法语语料库上训练的法语BERT模型。不同规模的模型借助法国国家科学研究中心(CNRS)的 让·扎伊 超级计算机进行训练。
与FlauBERT一同推出的还有 FLUE:这是一个用于法语自然语言处理系统的评估框架,类似于广受欢迎的GLUE基准测试。其目标是在未来推动更多可复现的实验,并促进法语语言模型和研究进展的共享。更多详情请参考 官方网站。
✨ 主要特性
- 基于大规模且多样化的法语语料库进行训练,能更好地适应法语语言特点。
- 提供不同规模的模型,可根据具体需求选择。
- 配套有专门的法语评估框架FLUE,方便进行模型评估。
📦 安装指南
文档未提及具体安装步骤,可参考相关依赖库(如Hugging Face的Transformers)的官方安装说明进行安装。
💻 使用示例
基础用法
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}
}