Hang Le commited on
Commit
c3b5092
1 Parent(s): b40d5d3

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +99 -0
README.md ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: fr
3
+ license: mit
4
+ datasets:
5
+ - flaubert
6
+ metrics:
7
+ - flue
8
+ tags:
9
+ - bert
10
+ - language-model
11
+ - flaubert
12
+ - flue
13
+ - french
14
+ - bert-large
15
+ - flaubert-large
16
+ - cased
17
+ ---
18
+
19
+ # FlauBERT: Unsupervised Language Model Pre-training for French
20
+
21
+ **FlauBERT** is a French BERT trained on a very large and heterogeneous French corpus. Models of different sizes are trained using the new CNRS (French National Centre for Scientific Research) [Jean Zay](http://www.idris.fr/eng/jean-zay/ ) supercomputer.
22
+
23
+ Along with FlauBERT comes [**FLUE**](https://github.com/getalp/Flaubert/tree/master/flue): an evaluation setup for French NLP systems similar to the popular GLUE benchmark. The goal is to enable further reproducible experiments in the future and to share models and progress on the French language.For more details please refer to the [official website](https://github.com/getalp/Flaubert).
24
+
25
+ ## FlauBERT models
26
+
27
+ | Model name | Number of layers | Attention Heads | Embedding Dimension | Total Parameters |
28
+ | :------: | :---: | :---: | :---: | :---: |
29
+ | `flaubert-small-cased` | 6 | 8 | 512 | 54 M |
30
+ | `flaubert-base-uncased` | 12 | 12 | 768 | 137 M |
31
+ | `flaubert-base-cased` | 12 | 12 | 768 | 138 M |
32
+ | `flaubert-large-cased` | 24 | 16 | 1024 | 373 M |
33
+
34
+ **Note:** `flaubert-small-cased` is partially trained so performance is not guaranteed. Consider using it for debugging purpose only.
35
+
36
+ ## Using FlauBERT with Hugging Face's Transformers
37
+
38
+ ```python
39
+ import torch
40
+ from transformers import FlaubertModel, FlaubertTokenizer
41
+
42
+ # Choose among ['flaubert/flaubert_small_cased', 'flaubert/flaubert_base_uncased',
43
+ # 'flaubert/flaubert_base_cased', 'flaubert/flaubert_large_cased']
44
+ modelname = 'flaubert/flaubert_base_cased'
45
+
46
+ # Load pretrained model and tokenizer
47
+ flaubert, log = FlaubertModel.from_pretrained(modelname, output_loading_info=True)
48
+ flaubert_tokenizer = FlaubertTokenizer.from_pretrained(modelname, do_lowercase=False)
49
+ # do_lowercase=False if using cased models, True if using uncased ones
50
+
51
+ sentence = "Le chat mange une pomme."
52
+ token_ids = torch.tensor([flaubert_tokenizer.encode(sentence)])
53
+
54
+ last_layer = flaubert(token_ids)[0]
55
+ print(last_layer.shape)
56
+ # torch.Size([1, 8, 768]) -> (batch size x number of tokens x embedding dimension)
57
+
58
+ # The BERT [CLS] token correspond to the first hidden state of the last layer
59
+ cls_embedding = last_layer[:, 0, :]
60
+ ```
61
+
62
+ **Notes:** if your `transformers` version is <=2.10.0, `modelname` should take one
63
+ of the following values:
64
+
65
+ ```
66
+ ['flaubert-small-cased', 'flaubert-base-uncased', 'flaubert-base-cased', 'flaubert-large-cased']
67
+ ```
68
+
69
+
70
+ ## References
71
+
72
+ If you use FlauBERT or the FLUE Benchmark for your scientific publication, or if you find the resources in this repository useful, please cite one of the following papers:
73
+
74
+ [LREC paper](http://www.lrec-conf.org/proceedings/lrec2020/pdf/2020.lrec-1.302.pdf)
75
+ ```
76
+ @InProceedings{le2020flaubert,
77
+ 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},
78
+ title = {FlauBERT: Unsupervised Language Model Pre-training for French},
79
+ booktitle = {Proceedings of The 12th Language Resources and Evaluation Conference},
80
+ month = {May},
81
+ year = {2020},
82
+ address = {Marseille, France},
83
+ publisher = {European Language Resources Association},
84
+ pages = {2479--2490},
85
+ url = {https://www.aclweb.org/anthology/2020.lrec-1.302}
86
+ }
87
+ ```
88
+
89
+ [TALN paper](https://hal.archives-ouvertes.fr/hal-02784776/)
90
+ ```
91
+ @inproceedings{le2020flaubert,
92
+ title = {FlauBERT: des mod{\`e}les de langue contextualis{\'e}s pr{\'e}-entra{\^\i}n{\'e}s pour le fran{\c{c}}ais},
93
+ 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},
94
+ 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},
95
+ pages = {268--278},
96
+ year = {2020},
97
+ organization = {ATALA}
98
+ }
99
+ ```