Paper · 2019-11-10 · cs.CL
CamemBERT: a Tasty French Language Model
CamemBERT is a monolingual French RoBERTa (BASE, 110M params) pretrained with whole-word masked language modeling on 138GB of web-crawled OSCAR text. It beats mBERT, XLM and XLM-R BASE on French POS tagging, parsing, NER and XNLI (82.5% acc). A 4GB web-crawl sample performs about as well as the full 138GB, and web data beats Wikipedia.
Language model pretrainingMasked language modelingDataset curationpretrainingencoderfrenchmonolingualnlp
AI-compiled by claude-opus-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
Big pretrained language models like BERT and RoBERTa were, at the time, mostly available for English, or as "multilingual" models that split their capacity across about a hundred languages. If you worked on French text, you either used an English-centric model or a multilingual one that was larger and often worse at French specifically.
CamemBERT is simply RoBERTa retrained from scratch on French. The authors took French text scraped from the web (the OSCAR corpus), cut it into subword pieces with SentencePiece, and trained the model to fill in hidden words. When a word is split into several pieces, they hide all of its pieces together, so the model cannot cheat by looking at the rest of the word.
The resulting model did better than the multilingual competitors on French grammar tagging, syntactic parsing, named entity recognition and sentence-pair reasoning. The more surprising part is the data study: a random 4GB slice of web text worked about as well as the full 138GB, and messy, varied web text worked better than clean Wikipedia text of the same size. That suggests a language with only a few gigabytes of web text can get a strong model of its own.
TL;DR
A RoBERTa-BASE (and one LARGE) encoder trained only on French, with a 32k SentencePiece vocabulary and whole-word masking, using fairseq. Pretraining is 100k steps at batch 8192 x 512 tokens, peak LR 7e-4, on 256 V100s for about a day. Fine-tuned, it is reported as state of the art on four French UD treebanks (UPOS/LAS), FTB NER and French XNLI. The ablations are the reusable part: Common Crawl beats Wikipedia at equal size, 4GB of diverse web text is close to 138GB, whole-word masking helps NLI slightly but not the low-level tasks, and LARGE helps NLI/NER but not tagging/parsing.
Problem
Pretraining needs hundreds of gigabytes of text and hundreds of GPUs, so strong monolingual models existed mostly for English; multilingual models such as mBERT or XLM-R are larger and, for a high-resource language like French, can trail a monolingual model §1. The paper asks whether a RoBERTa-style model can be trained for another language (French) and how much and what kind of pretraining data it needs §1 §6.
Method
CamemBERT reuses RoBERTa's recipe with two changes: SentencePiece tokenization instead of WordPiece, and whole-word masking §4.3.
Data. French part of OSCAR, a Common Crawl corpus filtered only by a fastText
language classifier (176 languages), with no further filtering. The non-shuffled
version is used: 138GB of raw text, 32.7B tokens after subword tokenization
§4.1. Alternative corpora for the ablations: French Wikipedia 2019 dump
(cleaned with WikiExtractor, 4GB) and CCNet (the head split, top 33% of
documents by filtering perplexity, 135GB) §6. Corpus statistics are in tab. 6.
Tokenization. SentencePiece, 32k vocabulary, learned on 10^7 sentences sampled randomly from the pretraining data; no subword regularisation §4.2.
Architecture. BERT-BASE (12 layers, hidden 768, 12 heads, 110M params) or BERT-LARGE (24 layers, hidden 1024; 335M params per tab. 8) §4.3.
Objective. MLM with dynamic masking (masks resampled each time rather than fixed in preprocessing), no next-sentence prediction §4.3.
Algorithm: whole-word masking for one sequence [§4.3]
Input: raw text line(s), SentencePiece tokenizer
1. Split the untokenized text on whitespace to define words.
2. Tokenize each word into subword tokens.
3. Sample 15% of the words uniformly at random.
4. Every subword token of a sampled word becomes a prediction target
(overall this is close to 15% of tokens).
5. For each target token: replace with <MASK> (80%), keep unchanged (10%),
or replace with a random token (10%).
6. Loss = cross-entropy of predicting the original tokens at target positions.
Masks are redrawn dynamically every time a sequence is used.Sequences. At most 512 tokens per sequence; each sequence contains only complete paragraphs, which are lines of the pretraining file §4.3.
Optimisation. Adam, warmup 10k steps to peak 7e-4, then polynomial decay to zero, 100k steps, batch 8192 sequences, fairseq RoBERTa implementation, 256 V100 32GB GPUs for one day §4.3. The authors note performance was still rising when they stopped §4.3.
Downstream use §4.4:
- Fine-tuning: for sentence classification a linear layer on the last hidden
state of
<s>; for token labeling a linear layer on the last hidden state of the first subword of each word; for dependency parsing a biaffine graph head following Dozat and Manning; for XNLI a head of one hidden layer with a non-linearity plus a linear projection, with input dropout on both. Adam with a fixed learning rate, grid search over learning rate and batch size, best validation checkpoint among the first 30 epochs. No weight decay, warmup or discriminative fine-tuning except for NLI, which uses fairseq's RoBERTa MNLI defaults. POS/parsing/NER use Hugging Face Transformers; NLI uses fairseq. - Feature-based embeddings: a word's vector is obtained by averaging each subword's representations over the last four Transformer layers, then averaging over the word's subwords. These feed UDPipe Future (tagging, parsing) or an LSTM+CRF (NER).
Hyperparameters
| Name | Value | Where | Notes |
|---|---|---|---|
| Architecture (BASE) | 12 layers, hidden 768, 12 heads, 110M params | §4.3 | |
| Architecture (LARGE) | 24 layers, hidden 1024, 335M params | §4.3 tab. 8 | text also says "12 attention heads, 110M parameters" for LARGE, an evident copy error; head count for LARGE not reliably stated |
| Vocabulary | 32k SentencePiece | §4.2 | trained on 10^7 random sentences; no subword regularisation |
| Max sequence length | 512 tokens | §4.3 | complete paragraphs only |
| Masking rate | 15% of words (whole-word) | §4.3 | 80% <MASK> / 10% unchanged / 10% random |
| NSP | removed | §4.3 | |
| Optimizer | Adam, β1 = 0.9, β2 = 0.98 | §4.3 | ε and weight decay not stated |
| Batch size | 8192 sequences | §4.3 | |
| Steps | 100k (one CCNet BASE model at 500k) | §4.3 tab. 8 | |
| Warmup | 10k steps | §4.3 | |
| Peak LR | 7e-4 | §4.3 | polynomial decay to zero; decay power not stated |
| Dropout | not stated | ||
| Hardware | 256 x V100 32GB, ~1 day (BASE, 100k steps) | §4.3 | |
| Epoch length (one run) | 8360 steps per epoch | app. D | which corpus this refers to is not stated |
| Fine-tune optimizer | Adam, fixed LR, grid over LR and batch size | §4.4 | grid values not stated |
| Fine-tune epochs | best on validation within first 30 | §4.4 | |
| NLI fine-tuning | fairseq RoBERTa MNLI defaults | §4.4 | values not restated in the paper |
| Embedding extraction | mean of last 4 layers, then mean over subwords | §4.4 |
Results
Author-reported. Main CamemBERT is BASE, OSCAR 138GB, whole-word masking, 100k steps. POS/parsing on UD v2.2 test sets with gold tokenization; best of 4 runs selected on validation tab. 2. NER on FTB, best of 4 tab. 3. NLI on French XNLI test, best of 10 tab. 4.
POS tagging (UPOS) and dependency parsing (LAS) tab. 2:
| Model | GSD UPOS | GSD LAS | Sequoia UPOS | Sequoia LAS | Spoken UPOS | Spoken LAS | ParTUT UPOS | ParTUT LAS |
|---|---|---|---|---|---|---|---|---|
| mBERT (fine-tuned) | 97.48 | 89.73 | 98.41 | 91.24 | 96.02 | 78.63 | 97.35 | 91.37 |
| XLM MLM-TLM (fine-tuned) | 98.13 | 90.03 | 98.51 | 91.62 | 96.18 | 80.89 | 97.39 | 89.43 |
| UDify | 97.83 | 91.45 | 97.89 | 90.05 | 96.23 | 80.01 | 96.12 | 88.06 |
| UDPipe Future | 97.63 | 88.06 | 98.79 | 90.73 | 95.91 | 77.53 | 96.93 | 89.63 |
| + mBERT + Flair (emb.) | 97.98 | 90.31 | 99.32 | 93.81 | 97.23 | 81.40 | 97.64 | 92.47 |
| CamemBERT (fine-tuned) | 98.18 | 92.57 | 99.29 | 94.20 | 96.99 | 81.37 | 97.65 | 93.43 |
| UDPipe Future + CamemBERT (emb.) | 97.96 | 90.57 | 99.25 | 93.89 | 97.09 | 81.81 | 97.50 | 92.32 |
NER F1 on FTB tab. 3:
| Model | F1 |
|---|---|
| SEM (CRF) | 85.02 |
| LSTM-CRF | 85.57 |
| mBERT (fine-tuned) | 87.35 |
| CamemBERT (fine-tuned) | 89.08 |
| LSTM+CRF+CamemBERT (embeddings) | 89.55 |
French XNLI test accuracy tab. 4:
| Model | Acc. | #Params |
|---|---|---|
| mBERT | 76.9 | 175M |
| XLM MLM-TLM | 80.2 | 250M |
| XLM-R BASE | 80.1 | 270M |
| CamemBERT (BASE, fine-tuned) | 82.5 | 110M |
| XLM-R LARGE | 85.2 | 550M |
| CamemBERT LARGE (CCNet, fine-tuned) | 85.7 | 335M |
Corpus origin and size, BASE, 100k steps, validation sets, mean of 4 runs (10 for NLI) tab. 5:
| Setting | Corpus | Size | Avg UPOS | Avg LAS | NER F1 | NLI Acc. |
|---|---|---|---|---|---|---|
| Fine-tuning | Wiki | 4GB | 97.45 | 88.75 | 89.86 | 78.32 |
| Fine-tuning | CCNet | 4GB | 97.67 | 90.04 | 90.46 | 82.06 |
| Fine-tuning | OSCAR | 4GB | 97.71 | 89.87 | 90.65 | 81.88 |
| Fine-tuning | OSCAR | 138GB | 97.79 | 89.88 | 91.55 | 81.55 |
| Embeddings | Wiki | 4GB | 97.21 | 88.64 | 91.23 | - |
| Embeddings | CCNet | 4GB | 97.81 | 90.04 | 92.30 | - |
| Embeddings | OSCAR | 4GB | 97.82 | 90.05 | 91.90 | - |
| Embeddings | OSCAR | 138GB | 97.77 | 89.84 | 91.83 | - |
Per-treebank numbers for these runs are in tab. 5.
Design-choice ablations, validation sets, POS/parsing averaged over the 4 treebanks tab. 8:
| Block | Dataset | Masking | Arch. | #Param. | #Steps | UPOS | LAS | NER | XNLI |
|---|---|---|---|---|---|---|---|---|---|
| Masking | OSCAR | Subword | BASE | 110M | 100K | 97.78 | 89.80 | 91.55 | 81.04 |
| Masking | OSCAR | Whole-word | BASE | 110M | 100K | 97.79 | 89.88 | 91.44 | 81.55 |
| Model size | CCNet | Whole-word | BASE | 110M | 100K | 97.67 | 89.46 | 90.13 | 82.22 |
| Model size | CCNet | Whole-word | LARGE | 335M | 100k | 97.74 | 89.82 | 92.47 | 85.73 |
| Dataset | CCNet | Whole-word | BASE | 110M | 100K | 97.67 | 89.46 | 90.13 | 82.22 |
| Dataset | OSCAR | Whole-word | BASE | 110M | 100K | 97.79 | 89.88 | 91.44 | 81.55 |
| Steps | CCNet | Whole-word | BASE | 110M | 100k | 98.04 | 89.85 | 90.13 | 82.20 |
| Steps | CCNet | Whole-word | BASE | 110M | 500k | 97.95 | 90.12 | 91.30 | 83.04 |
Test-set means for all six pretrained variants in both fine-tuning and embedding settings, per treebank, are in tab. 7; e.g. fine-tuned XNLI test accuracy is 81.18 (OSCAR subword), 81.92 (OSCAR whole-word), 83.43 (CCNet whole-word 500k) and 85.29 (CCNet LARGE) tab. 7.
Findings the authors draw: Common Crawl data (4GB OSCAR or CCNet) beats 4GB Wikipedia, with the largest gaps on Spoken and XNLI §6.1; 4GB OSCAR is close to 138GB except NER, where 138GB is +0.9 F1 §6.2; whole-word masking gives +0.5 XNLI and little elsewhere app. A; LARGE gives 19.7% and 23.7% error reduction on NLI and NER but no significant gain on POS/parsing app. B; 500k vs 100k steps adds +0.84 XNLI and little on POS/parsing app. D; parsing and NER plateau around 22k steps while NLI is still rising at 100k app. D fig. 1.
Paper vs code
No official code. The paper states it used the RoBERTa implementation in fairseq for pretraining and NLI and an extended Hugging Face Transformers for the other tasks §4.3 §4.4, and that checkpoints are distributed via fairseq, Hugging Face and camembert-model.fr under MIT §8; no author training repository with configs is linked, so nothing was compared.
Pitfalls
- LARGE spec is garbled. §4.3 gives LARGE as "24 layers, 1024 hidden dimensions, 12 attention heads, 110M parameters"; tab. 8 and tab. 4 say 335M. Head count for LARGE is therefore not reliably stated in the paper.
- The LARGE model is trained on CCNet, not OSCAR §5, so the 85.7 XNLI result is not "CamemBERT on OSCAR at larger scale".
- Best-of-N vs mean. Headline tables tab. 2 tab. 3 tab. 4 report the best run selected on validation out of 4 or 10; tab. 5 and tab. 8 are validation means; tab. 7 is test means. E.g. fine-tuned GSD LAS is 92.57 in tab. 2 but 92.30 (OSCAR whole-word) in tab. 7. Compare like with like.
- Internal inconsistencies in tab. 8. The CCNet BASE whole-word 100k model appears with UPOS/LAS 97.67/89.46 in the size and dataset blocks but 98.04/89.85 in the steps block. Also, tab. 5 gives OSCAR 138GB fine-tuned NER as 91.55, which tab. 8 assigns to the subword model while whole-word gets 91.44.
- Whole-word masking needs word boundaries from the raw text. Words are defined by whitespace in the untokenized input §4.3, so the subword-to-word mapping must be kept through tokenization. How it is recovered is not stated.
- Masking granularity for 80/10/10 is unstated. Under whole-word masking it is unclear whether the mask/keep/random choice is drawn per word or per subword token; the whole-word paragraph also omits the 10% random figure, which is given only in the token-level description §4.3.
- Single pretraining seed. Each pretrained model was trained once; the authors attribute OSCAR-4GB beating OSCAR-138GB on XNLI (81.88 vs 81.55) to pretraining seed §6.2. Small differences between corpora are within noise.
- Under-training. 100k steps over 4GB is about 400 epochs and validation loss was still falling §6.2; the full-corpus model was also stopped while improving §4.3. The "4GB is enough" claim is at a fixed 100k-step budget and BASE size only.
- Sequences are paragraph-aligned. Each 512-token sequence holds only whole paragraphs (lines) §4.3; how lines longer than 512 tokens are handled is not stated.
- Spoken treebank is uncased and unpunctuated, while CamemBERT was trained on cased text; the authors suggest this explains its weaker UPOS there §5.
- Fine-tuning grids are not given. Learning rates and batch sizes searched are not listed §4.4; NLI defers to fairseq's MNLI defaults.
- FTB is research-only. The NER dataset was used under a research-only agreement §3.
- Unshuffled OSCAR. The pretraining corpus is the non-shuffled French OSCAR §4.1; how 4GB subsets were drawn is "random at the document level" §6.
Lineage
- Builds on: RoBERTa (arXiv:1907.11692) and BERT (arXiv:1810.04805); changes are SentencePiece tokenization, whole-word masking and French-only data §4.3. Whole-word masking follows the updated BERT release and SpanBERT (arXiv:1907.10529) §4.3.
- Data: OSCAR (Ortiz Suárez et al. 2019) and CCNet (arXiv:1911.00359) §4.1 §6.
- Compared against: mBERT, XLM (arXiv:1901.07291), XLM-R (arXiv:1911.02116), UDify, UDPipe Future (+ mBERT + Flair), CRF and LSTM-CRF NER baselines §3.
- Related French model: FlauBERT (arXiv:1912.05372), named in §7.
Source and license
Adapted from “CamemBERT: a Tasty French Language Model” by Louis Martin, Benjamin Muller, Pedro Javier Ortiz Suárez, Yoann Dupont, Laurent Romary, Éric Villemonte de la Clergerie, Djamé Seddah, Benoît Sagot (arXiv:1911.03894), used under CC BY-SA 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. This page is licensed under CC BY-SA 4.0.