Paper · 2019-12-11 · cs.CL, cs.LG
FlauBERT: Unsupervised Language Model Pre-training for French
Pre-trains a BERT-style masked language model on 71 GB of cleaned French text, in base (138M) and large (373M) sizes, and evaluates it on FLUE, a new six-dataset French benchmark. Author-reported: both sizes outperform multilingual mBERT on most tasks; large has the top score on CLS, dependency parsing and both WSD tasks.
Language model pretrainingMasked language modelingTransfer learningDependency parsingpretraininglanguage-modelfrenchbenchmark
arXivPDFCodeMarkdown13 min read
AI-compiled by claude-haiku-5-5 on 2026-10-18, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
FlauBERT is a language model for French, built the same way as BERT, the English model that started a wave of pre-trained language models. It reads a large amount of ordinary French text and learns to guess words that have been hidden from it. The trained model is then reused: a small extra layer is added on top and the whole network is tuned on one specific task, such as judging whether a product review is positive.
The authors trained two sizes on a large, mixed French corpus. They also assembled a suite of French language tasks, called FLUE, so that French models can be compared on the same tests. On those tasks their models usually beat a multilingual model that covers many languages at once. The code and the training recipe are published, but the code is licensed for non-commercial use only.
TL;DR
- FlauBERT is a BERT-style Transformer encoder, pre-trained only with masked language modelling on a 71 GB French corpus, in a base (12 layers, hidden 768) and a large (24 layers, hidden 1024) size §3.2 tab. 1.
- The authors also release FLUE, six French datasets covering classification, paraphrase, inference, parsing and word-sense disambiguation §4 tab. 2.
- Author-reported: both sizes beat mBERT on most tasks; the large model has the top score on CLS, dependency parsing and both WSD tasks §5 tab. 3, 7, 8, 9.
- Before you reproduce anything: the paper's classification head is not the one the shipped FLUE runner uses, and the large-model settings are not in the repository. See Paper vs code.
Problem
Contextual pre-trained encoders had given large gains on English NLP tasks, but most pre-trained models for other languages were multilingual, with one shared vocabulary for many languages §1 §2.2. The authors argue that a model trained only on French should do better on French tasks. At the time they wrote, they knew of no multi-task evaluation suite for French comparable to GLUE for English §2.3.
Method
Pre-training corpus §3.1 app. A
- The corpus has 24 sub-corpora from three sources: monolingual French data from the WMT19 shared tasks, French corpora from the OPUS collection, and Wikimedia projects §3.1 tab. 10.
- Before preprocessing the text is 270 GB. Common Crawl, the largest sub-corpus, is reduced from 215 GB to 43.4 GB by aggressive cleaning §3.1.
- Preprocessing removes very short sentences and repetitive or non-meaningful content such as telephone numbers and e-mail addresses, normalizes Unicode, and tokenizes with the Moses tokenizer §3.1.
- The final corpus is 71 GB, about 12.79 B tokens and about 488.78 M sentences tab. 10 app. A.
- Per-sub-corpus sizes, token counts and sentence counts are listed in tab. 10. Common Crawl is the largest at 43.4 GB tab. 10.
Architecture §3.2 tab. 1
- FlauBERT uses BERT's architecture: a multi-layer bidirectional Transformer encoder §3.2.
- Base: L = 12 blocks, hidden size H = 768, A = 12 attention heads. Large: L = 24, H = 1024, A = 16 §3.2.
- Parameter counts: 138 M (base) and 373 M (large) tab. 1.
- Vocabulary: 50K byte-pair-encoding units, learned after Moses tokenization §3.2.
- Masking: dynamic, sub-word masking tab. 1. The masking rate is not stated in the text.
Objective §3.2
- Only masked language modelling (MLM) is used. Next-sentence prediction (NSP) is dropped; the authors cite later studies that found removing NSP does not hurt, and that the original loss may have been applied with a bad input format §3.2.
- The loss is computed only at the positions chosen for masking §3.2.
# Masked-language-model step, pre-training [§3.2]
# Input: token_ids (B, T) from BPE over Moses-tokenized French
# Output: scalar loss over the masked positions
def mlm_step(token_ids):
# Choose ~15% of positions as targets [code: README.md#L303]
targets = sample_positions(token_ids, rate=0.15)
# Of the chosen tokens: 80% -> mask, 10% -> random token, 10% unchanged
# [code: train.py#L102]
inputs = corrupt(token_ids, targets) # (B, T)
# Encode the corrupted sequence with the bidirectional Transformer [§3.2]
hidden = transformer_encoder(inputs) # (B, T, H)
# Predict the original token only at the chosen positions [§3.2]
logits = output_projection(hidden[targets])
return cross_entropy(logits, token_ids[targets])The paper does not state the 15% rate or the 80/10/10 split; the values above come from the released command and the argument default in the code.
Optimization §3.2
- Optimizer: Adam with beta1 = 0.9, beta2 = 0.98, epsilon = 1e-6 and weight decay 0.01, for both sizes §3.2.
- Warmup and peak learning rate: base 24k steps and 6e-4; large 30k steps and 3e-4 §3.2.
- The paper does not say how the learning rate decays after warmup. The repository uses an inverse-square-root decay (see the pseudocode below and Paper vs code).
# Learning rate of the repo's Adam schedule [code: xlm/optim.py#L96-L100]
# Input: update step (int); base warmup W = 24000 steps, peak 6e-4 [§3.2]
# Output: learning rate for this step
def learning_rate(step):
# Linear warmup from the initial rate 1e-7 to the peak
# [code: xlm/optim.py#L97] [code: README.md#L295]
if step < warmup_steps:
return init_lr + step * (peak_lr - init_lr) / warmup_steps
# After warmup, decay with 1 / sqrt(step) [code: xlm/optim.py#L100]
return peak_lr * sqrt(warmup_steps) / sqrt(step)Large model stability §3.2
- Training the large model with the BERT-large or RoBERTa-large configurations diverged early §3.2.
- The authors use pre-norm attention (layer normalization before each sub-layer) and stochastic depth, with a layer-dropping rate of 0.2 §3.2.
- The paper says the rate is 0.2 "in all the experiments". It is ambiguous whether this applies to the base model too. The normalization placement for base is not stated.
Compute §3.2
- Batch: an effective batch of 8192 sequences for both sizes §3.2.
- Base: 32 Nvidia V100 GPUs for 410 hours. Large: 128 GPUs for 390 hours §3.2.
- Derived from those numbers (not stated in the paper): about 13,120 GPU-hours for base and about 49,920 GPU-hours for large.
FLUE benchmark §4 tab. 2
| Dataset | Domain | Train | Dev | Test |
|---|---|---|---|---|
| CLS-FR: books / DVD / music | Product reviews | 2,000 / 1,999 / 1,998 | - | 2,000 each |
| PAWS-X-FR | General domain | 49,401 | 1,992 | 1,985 |
| XNLI-FR | Diverse genres | 392,702 | 2,490 | 5,010 |
| French Treebank | Daily newspaper | 14,759 | 1,235 | 2,541 |
| FrenchSemEval (verbs) | Diverse genres | 55,206 | - | 3,199 |
| Noun Sense Disambiguation | Diverse genres | 818,262 | - | 1,445 |
Source: tab. 2.
- CLS (§4.1): binary sentiment on Amazon reviews. Three-star reviews are dropped; the French portion is used. Metric: accuracy §4.1.
- PAWS-X (§4.2): paraphrase identification. The French dev and test sets are human-translated; the training set is machine-translated. Metric: accuracy §4.2.
- XNLI (§4.3): entailment, contradiction or neutral for a premise-hypothesis pair. Training data is the machine-translated French version. Metric: accuracy §4.3.
- Parsing (§4.4 and §5.4 to §5.5): the French Treebank in the SPMRL 2013 version, with a standard split. Constituency F1 and POS accuracy, plus UAS and LAS for dependency parsing §4.4 §5.5.
- Verb WSD (§4.5): FrenchSemEval, 3,199 annotations over 66 verbs. The sense inventory is a Wiktionary dump; the inventory's examples serve as training data §4.5.
- Noun WSD (§4.5): 306 sentences and 1,445 nouns, annotated with WordNet 3.0 sense keys. BabelNet keys were converted to WordNet where a mapping exists and dropped otherwise. Training data is SemCor and the WordNet gloss corpus, translated to French with a machine-translation system and aligned to the English sense keys §4.5.
Fine-tuning §5
- CLS (§5.1): the standard BERT fine-tuning process. The input is a text paired with an empty second segment. The head is dropout, linear, tanh, dropout, linear, with dropout 0.1 §5.1. Training: 30 epochs, batch 16, grid search over four learning rates (1e-5, 5e-5, 1e-6, 5e-6), with a random 20% of the training data as validation and the best checkpoint evaluated on test §5.1.
- PAWS-X (§5.2): the same setup, but the input is a sentence pair and the hyperparameter search uses the dev set, with no extra split §5.2.
- XNLI (§5.3): a sentence pair as input. The head is one dropout layer and one linear layer. Epoch count and learning rate are not stated in the text §5.3.
- Constituency parsing (§5.4): the self-attentive chart parser of Kitaev and Klein, with POS tagging as a second task. The parser's default hyperparameters for the first two settings; for the language models, the hyperparameters of Kitaev et al. (2019, multilingual), except that large uses learning rate 1e-5, batch 8 and skips training sentences longer than 100 tokens §5.4. Each setting is trained three times with different seeds and the run with the best dev F1 is kept §5.4.
- Dependency parsing (§5.5): a parser that follows Dozat (2017) and decodes trees with a maximum spanning tree. Word input is the concatenation of trained word and tag embeddings plus at most one pre-trained vector. Word and tag embeddings use dropout 0.5; the BERT representations get no dropout §5.5. Predicted tags come from the shared task §5.5.
- Verb WSD (§5.6): no training of the classifier. Each sense is represented by the mean of the contextual embeddings of its inventory examples; a test instance gets the sense with the highest cosine similarity §5.6.
- Noun WSD (§5.6): a classifier over the pre-trained model's output: six Transformer encoder layers with feed-forward size 3072 and 12 heads, then a softmax over synsets. Eight models are trained per experiment; the mean and standard deviation of single models are reported, plus an ensemble that averages the softmax outputs §5.6.
# Classification head for CLS, as the paper describes it [§5.1]
# Input: pooled encoder output (B, H), H = hidden size
# Output: class logits (B, 2)
# The shipped FLUE runner uses only dropout and one linear layer
# [code: xlm/evaluation/flue.py#L106-L110]
def classify(pooled):
# Dropout with rate 0.1 [§5.1]
hidden = dropout(pooled, rate=0.1) # (B, H)
# Linear layer, output size H [§5.1]
hidden = linear(hidden) # (B, H)
# tanh activation [§5.1]
hidden = tanh(hidden) # (B, H)
# Dropout again [§5.1]
hidden = dropout(hidden, rate=0.1) # (B, H)
# Final linear layer to the classes [§5.1]
return linear(hidden) # (B, 2)The paper does not say which token is pooled; it only refers to the standard BERT fine-tuning process §5.1.
Hyperparameters
| Name | Value | Where | Notes |
|---|---|---|---|
| Base architecture | L 12, H 768, A 12 | §3.2 tab. 1 | BERT-style encoder |
| Large architecture | L 24, H 1024, A 16 | §3.2 | |
| Parameters | 138 M / 373 M | tab. 1 | base / large |
| Vocabulary | BPE, 50K units | §3.2 | after Moses tokenization |
| Optimizer | Adam, beta1 0.9, beta2 0.98, eps 1e-6 | §3.2 | both sizes |
| Weight decay | 0.01 | §3.2 | repo applies it decoupled, see Paper vs code |
| Warmup steps | base 24k; large 30k | §3.2 | repo command: warmup_updates=24000 README.md |
| Peak learning rate | base 6e-4; large 3e-4 | §3.2 | repo command: lr=0.0006 README.md |
| Post-warmup schedule | not stated | §3.2 | repo: inverse square root optim.py |
| Effective batch | 8192 sequences | §3.2 | repo: 16 per GPU x 16 accumulation README.md README.md |
| GPUs | base 32, large 128 | §3.2 | GPU count not in the repo command |
| Max sequence length | not stated | §3.2 | repo: bptt 512 README.md |
| Dropout (hidden, attention) | not stated | §3.2 | repo: 0.1 and 0.1 README.md |
| Activation | not stated | §3.2 | repo: GELU README.md |
| Masking rate | not stated | tab. 1 | repo: 0.15 README.md |
| Mask split 80/10/10 | not stated | §3.2 | repo default train.py |
| Layer dropping (large) | 0.2 | §3.2 | repo default 0 train.py |
| Pre-norm | large | §3.2 | repo default off train.py |
| CLS batch / epochs / LR | 16 / 30 / grid {1e-5, 5e-5, 1e-6, 5e-6} | §5.1 | example config: batch 8, LR 5e-6 cls_books_lr5e6_xlm_base_cased.cfg |
| CLS validation split | 20% of train | §5.1 | |
| PAWS-X epochs / LR | not stated | §5.2 | example config: 10 epochs, batch 8, LR 5e-6 pawsx_lr5e6_xlm_base_cased.cfg |
| XNLI epochs / LR | not stated | §5.3 | example config: 10 epochs, batch 8, LR 5e-6 xnli_lr5e6_xlm_base_cased.cfg |
| Constituency LR / batch | 1e-5 / 8 (large only) | §5.4 | large skips sentences over 100 tokens |
| Dependency dropout | 0.5 on word and tag embeddings | §5.5 | none on BERT representations |
| Noun WSD layers / FFN / heads | 6 / 3072 / 12 | §5.6 | repo script: same values 3.train_model.sh |
Results
Author-reported. Setup: French test sets from FLUE, fine-tuned FlauBERT base and large against mBERT and CamemBERT (a concurrent French BERT). Some baseline rows are taken from earlier papers and are marked as such in the source.
Text classification, CLS accuracy (%) tab. 3
| Model | Books | DVD | Music |
|---|---|---|---|
| MultiFiT (reported in the MultiFiT paper) | 91.25 | 89.55 | 93.40 |
| mBERT (reported in the MultiFiT paper) | 86.15 | 86.90 | 86.65 |
| CamemBERT | 92.30 | 93.00 | 94.85 |
| FlauBERT-base | 93.10 | 92.45 | 94.10 |
| FlauBERT-large | 95.00 | 94.10 | 95.85 |
Paraphrase, PAWS-X accuracy (%) tab. 4
| Model | Accuracy |
|---|---|
| ESIM (reported in the PAWS-X paper) | 66.20 |
| mBERT (reported in the PAWS-X paper) | 89.30 |
| CamemBERT | 90.14 |
| FlauBERT-base | 89.49 |
| FlauBERT-large | 89.34 |
Natural language inference, XNLI accuracy (%) tab. 5
| Model | Accuracy |
|---|---|
| XLM-R large (reported by its authors) | 85.2 |
| XLM-R base (reported by its authors) | 80.1 |
| mBERT (reported by CamemBERT) | 76.9 |
| CamemBERT (reported by its authors) | 81.2 |
| FlauBERT-base | 80.6 |
| FlauBERT-large | 83.4 |
Constituency parsing and POS tagging (F1, POS accuracy) tab. 6
| Model | Dev F1 | Dev POS | Test F1 | Test POS |
|---|---|---|---|---|
| Best published | - | - | 87.42 | - |
| No pre-training | 84.31 | 97.6 | 83.85 | 97.5 |
| fastText embeddings | 84.09 | 97.6 | 83.64 | 97.7 |
| mBERT | 87.25 | 98.1 | 87.52 | 98.1 |
| CamemBERT | 88.53 | 98.1 | 88.39 | 98.2 |
| FlauBERT-base | 88.95 | 98.2 | 89.05 | 98.1 |
| FlauBERT-large | 89.08 | 98.2 | 88.63 | 98.2 |
| Ensemble FlauBERT-base + CamemBERT | 89.32 | - | 89.28 | - |
Dependency parsing (UAS, LAS) tab. 7
| Model | UAS | LAS |
|---|---|---|
| Best published | 89.19 | 85.86 |
| No pre-training | 88.92 | 85.11 |
| fastText pre-training | 86.32 | 82.04 |
| mBERT | 89.50 | 85.86 |
| CamemBERT | 91.37 | 88.13 |
| FlauBERT-base | 91.56 | 88.35 |
| FlauBERT-large | 91.61 | 88.47 |
Verb sense disambiguation, F1 (%) tab. 8
| Model | F1 |
|---|---|
| fastText (averaged window) | 34.90 |
| mBERT | 49.83 |
| CamemBERT | 50.02 |
| FlauBERT-base | 43.92 |
| FlauBERT-large | 50.48 |
Noun sense disambiguation, F1 (%) tab. 9
| Model | Single mean | Single std | Ensemble |
|---|---|---|---|
| No pre-training | 45.73 | 1.91 | 50.03 |
| fastText | 44.90 | 1.24 | 49.41 |
| mBERT | 53.03 | 1.22 | 56.47 |
| CamemBERT | 52.06 | 1.25 | 56.06 |
| FlauBERT-base | 51.24 | 1.33 | 54.74 |
| FlauBERT-large | 53.53 | 1.36 | 57.85 |
Paper vs code
The repository is getalp/Flaubert (linked from the paper's footnotes) at commit ab48ced2aba5ba0933378fef8c9967a15d780ec1. The repository LICENSE is CC BY-NC 4.0, so the code is non-commercial; nothing from it is quoted here.
- Classification head. The paper describes dropout, linear, tanh, dropout, linear §5.1. The FLUE runner executes only dropout and one linear layer; the two-layer tanh version is commented out flue.py flue.py. The Hugging Face variant of the CLS config was not checked.
- CLS batch size. The paper states batch 16 §5.1. The example config for books uses batch 8 with 30 epochs and learning rate 5e-6 cls_books_lr5e6_xlm_base_cased.cfg. The example is one setting, not necessarily the one behind the reported numbers.
- Learning-rate decay. The paper states warmup and peak only §3.2. The repo uses an inverse-square-root decay after warmup optim.py README.md.
- Weight decay. The paper states 0.01 §3.2. The repo applies it as decoupled decay, scaled by the learning rate optim.py. The earlier gradient-based variant is commented out optim.py.
- Layer dropping. The paper says the authors "randomly drop a number of (attention) layers" §3.2. The active code drops the whole block: it runs the layer and then, with probability
layerdrop, replaces its output with its input transformer.py. The per-layer early-skip version is commented out transformer.py. Compute is not saved in the active version. - Pre-norm. The paper uses pre-norm for large only §3.2. Repo default is post-norm train.py; the post-norm branch is at transformer.py and pre-norm at transformer.py.
- Released base command. The repo gives one pre-training command, for base README.md. It sets dropout, GELU, batch and optimizer, but not pre-norm or layer dropping. The large-model command is not in the repository, so the large settings in the paper cannot be checked against code.
- Settings not in the paper. Dropout 0.1, GELU, maximum sequence length 512, masking rate 0.15 and the 80/10/10 split appear only in the repo command or defaults README.md train.py.
- Noun WSD ensemble. The paper says eight models per experiment, averaged §5.6. The training script trains one model per run 3.train_model.sh. The averaging step is in other scripts, which were not checked.
- Parsers. The dependency-parsing model §5.5 and the constituency parser §5.4 are not in this repository. The repository links external parser code only in its README.
- Data pipeline. The repo's cleaning and tokenization scripts exist preprocess.sh. The filter thresholds and the BPE vocabulary are not in the repo and were not verified against §3.1.
Pitfalls
- The head you implement changes the CLS numbers. The paper's head has an extra tanh layer, but the shipped runner does not. Pick one and say which in your reproduction.
- Large-model settings are paper-only. The repo has no large command, so warmup, learning rate, pre-norm and layer dropping for large cannot be checked against code.
- The layer-dropping sentence is ambiguous. "In all the experiments" could mean base too. The base config in the repo leaves it at 0.
- Weight decay is decoupled in the code. An implementation that adds weight decay to the gradient will not match the repo's behaviour.
- Inverse-square-root decay is unstated in the paper. Without it, post-warmup learning rates will differ a lot.
- Compute is large. The derived GPU-hour totals (about 13,120 base, about 49,920 large) are not in the paper; plan budgets accordingly.
- Verb WSD depends on the sense inventory. It has no trained parameters; its F1 depends on the Wiktionary examples and on cosine similarity over the model's contextual embeddings §5.6.
- Noun WSD changed the sense labels. Senses without a WordNet mapping were removed, and the training data is machine-translated §4.5. Results are not comparable to other WSD sets without that caveat.
- Common Crawl was heavily cleaned. The cleaning rules are described only as aggressive §3.1. Expect a corpus that differs from raw Common Crawl.
- Licensing is not settled for commercial use. The paper is CC BY 4.0, but the code is CC BY-NC 4.0 and the model weights are not covered by any license in the paper. The corpora come from WMT, OPUS and Wikimedia, each with its own terms §3.1. Check the weights' license and each corpus before commercial use.
Lineage
- Builds on: BERT's architecture and MLM objective §3.2; the RoBERTa training recipe, minus next-sentence prediction §3.2; the XLM code base §3.2 README.md.
- Compared against: mBERT and XLM-R on XNLI §5 tab. 5; CamemBERT, a French BERT published concurrently §2.2 §5.
- Superseded by: not stated in this paper.
Source and license
Adapted from “FlauBERT: Unsupervised Language Model Pre-training for French” by Hang Le, Loïc Vial, Jibril Frej, Vincent Segonne, Maximin Coavoux, Benjamin Lecouteux, Alexandre Allauzen, Benoît Crabbé, Laurent Besacier, Didier Schwab (arXiv:1912.05372), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/getalp/Flaubert at commit ab48ced2aba5 (CC BY-NC 4.0 (non-commercial)). Any quoted code is shown under that license.