fill-mask · text · WASM · ~528 MB
BERTimbau is a BERT trained on brWaC — 2.7 billion tokens of Brazilian Portuguese and
nothing else. Its one job here is masked language modelling: hide a word
behind [MASK] and it ranks what belongs there — with a Portuguese-native vocabulary,
accents, the cedilla and everyday Brazilian words baked in. Type a sentence with a mask and see its
guesses, the exact logits it computed, and how it chops Portuguese words into subword
pieces. Everything runs on your device.
| Model | luiseduardobrito/bert-base-portuguese-cased-onnx (ONNX build of neuralmind/bert-base-portuguese-cased — BERTimbau base) |
|---|---|
| Task / pipeline | fill-mask — masked language modelling, loaded via AutoModelForMaskedLM for raw logits |
| Output | A probability over the whole 29,794-token Portuguese vocabulary at each [MASK] |
| Architecture | BERT-base (12 layers, ~110M params), Portuguese-cased WordPiece tokenizer (splits words into ## pieces) |
| Language | Portuguese only — trained on Brazilian Portuguese; mask token is [MASK] (BERT/WordPiece style), not <mask> |
| Quantization | fp32 — the ONNX repo ships only the full-precision graph (no 8-bit build), so this page runs it at full precision |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~528 MB (fp32), cached after first load — a heavier one-time download than the q8 pages here; a Wi-Fi first visit is recommended |
| License | MIT |
| Web APIs | WebAssembly, Web Workers — all Baseline widely available |
Write a Portuguese sentence containing [MASK] (use a sample if you're not
sure). BERTimbau predicts the missing word. You can use more than one mask.
BERTimbau spent its whole 29k-token budget on Portuguese. mBERT
(bert-base-multilingual-cased) spread a 119k-token vocabulary across ~104 languages. Load the
multilingual model (an extra ~180 MB, on demand) and compare what each one predicts for the
same Portuguese [MASK] — the specialist usually offers cleaner, more idiomatic
Portuguese words, and you can see it in the logits. Both use [MASK], so the comparison
is apples-to-apples.
The comparison uses whatever sentence is in the box above. Both runs are real, off-thread forward passes — nothing is cached or faked.
A language model doesn't output words — it outputs a logit (a raw, unbounded
score) for every one of its 29,794 Portuguese 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. The
– below is the entropy of the top-k — low means BERTimbau is sure, high means
it's hedging.
top-k entropy: – bits · top-1 carries – of the shown mass
## continuation of a split Portuguese wordA Portuguese-only vocabulary keeps common words whole and breaks longer ones (eletroencefalografista, otorrinolaringologista) into a handful of Portuguese subwords instead of spelling them out letter by letter.
A model trained only on Portuguese reads Portuguese the way a multilingual model can't afford to — every token in its vocabulary is a Portuguese subword, so accented vowels, the cedilla (ç), nasal diphthongs (ão, õe) and everyday Brazilian words (ônibus, feijoada, saudade) 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.
One Portuguese mask, ranked predictions with probabilities and the raw logits behind them.
A Portuguese writing aid — word-by-word completion and formal-vs-colloquial register comparison.
Brazilian vs European Portuguese & idioms — does it know "custar os olhos da [MASK]"?
Portuguese-native vs multilingual — run the same mask through both models and measure where they disagree.
The one-liner uses the fill-mask pipeline:
import { pipeline } from "@huggingface/transformers";
const unmask = await pipeline("fill-mask", "luiseduardobrito/bert-base-portuguese-cased-onnx");
const out = await unmask("A capital do Brasil é [MASK].");
// → [{ token_str: "Brasília", score: 0.72, sequence: "…" }, { token_str: "Salvador", … }]
For the "see inside" surface we go one level lower — AutoModelForMaskedLM — so we can
read the exact logits tensor ([1, sequence, 29794]), 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. This repo ships only the full-precision ONNX graph, so we load it with
dtype: "fp32".