← All models

fill-mask Β· text Β· WASM Β· ~110 MB

CamemBERT β€” predict the missing French word

CamemBERT is a RoBERTa trained on 138 GB of French text and nothing else. Its one job here is masked language modelling: hide a word behind <mask> and it ranks what belongs there β€” with a French-native vocabulary, French idioms and French grammar baked in. Type a sentence with a mask and see its guesses, plus the exact logits it computed. Everything runs on your device.

At a glance

ModelXenova/camembert-base (ONNX build of almanach/camembert-base)
Task / pipelinefill-mask β€” masked language modelling, loaded via AutoModelForMaskedLM for raw logits
OutputA probability over the whole 32,005-token French vocabulary at each <mask>
ArchitectureCamemBERT / RoBERTa-base (12 layers, ~110M params), SentencePiece tokenizer trained on French
LanguageFrench only β€” mask token is <mask> (RoBERTa style), not [MASK]
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~110 MB, cached after first load
LicenseMIT
Web APIsWebAssembly, Web Workers β€” all Baseline widely available

Run it

Write a French sentence containing <mask> (use a sample if you're not sure). CamemBERT predicts the missing word. You can use more than one mask.

French-native vs multilingual β€” on the same sentence

CamemBERT spent its whole 32k-token budget on French. XLM-RoBERTa spread a 250k-token vocabulary across ~100 languages. Load the multilingual model (an extra ~280 MB, on demand) and compare what each one predicts for the same French <mask> β€” the specialist usually offers cleaner, more idiomatic French words, and you can see it in the logits.

The comparison uses whatever sentence is in the box above. Both runs are real, off-thread forward passes β€” nothing is cached or faked.

See inside β€” logits, not just a guess

A language model doesn't output words β€” it outputs a logit (a raw, unbounded score) for every one of its 32,005 French vocabulary tokens at the masked position. We softmax those into probabilities. The bars above show the probability; the logit beside each is the actual number the network produced. Watch how a confident prediction ("capitale") sits far above the pack in logit space, while an ambiguous slot spreads the mass out. The – below is the entropy of the top-k β€” low means CamemBERT is sure, high means it's hedging.

Why it matters

A model trained only on French reads French the way a multilingual model can't afford to β€” every token in its vocabulary is a French subword, so accents, elisions (l', d'), gender agreement and idioms come out cleaner. Because it scores every word in context, you can ask it what fits, how strongly, and compare alternatives β€” all locally, with no prompt engineering and no API bill.

Use cases

Basics

One French mask, ranked predictions with probabilities and the raw logits behind them.

Practical

A French writing aid β€” word-by-word completion and register comparison over ready-made templates.

Wild

French idioms and elisions β€” does CamemBERT know "ce n'est pas la mer à…" ?

Multi-model

Fill the mask, then tag every word's part of speech with a French CamemBERT POS model.

How the API works

The one-liner uses the fill-mask pipeline:

import { pipeline } from "@huggingface/transformers";

const unmask = await pipeline("fill-mask", "Xenova/camembert-base");
const out = await unmask("Paris est la <mask> de la France.");
// β†’ [{ token_str: "capitale", score: 0.71, sequence: "…" }, { token_str: "ville", … }]

For the "see inside" surface we go one level lower β€” AutoModelForMaskedLM β€” so we can read the exact logits tensor ([1, sequence, 32005]), slice the row at the <mask> position, and softmax it ourselves. That's the only way to show the real logit values, not just the pipeline's rounded scores. All of it runs in a Web Worker so the page never janks.

References