🚀 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}
}