← All models

fill-mask · text · WASM · ~528 MB

BERTimbau — predict the missing Portuguese word

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.

At a glance

Modelluiseduardobrito/bert-base-portuguese-cased-onnx (ONNX build of neuralmind/bert-base-portuguese-cased — BERTimbau base)
Task / pipelinefill-mask — masked language modelling, loaded via AutoModelForMaskedLM for raw logits
OutputA probability over the whole 29,794-token Portuguese vocabulary at each [MASK]
ArchitectureBERT-base (12 layers, ~110M params), Portuguese-cased WordPiece tokenizer (splits words into ## pieces)
LanguagePortuguese only — trained on Brazilian Portuguese; mask token is [MASK] (BERT/WordPiece style), not <mask>
Quantizationfp32 — the ONNX repo ships only the full-precision graph (no 8-bit build), so this page runs it at full precision
BackendWebAssembly (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
LicenseMIT
Web APIsWebAssembly, Web Workers — all Baseline widely available

Run it

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.

Portuguese-native vs multilingual — on the same sentence

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.

See inside — logits + how Portuguese splits into subwords

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.

WordPiece tokenisation — dashed = a ## continuation of a split Portuguese word

A 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.

Why it matters

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.

Use cases

Basics

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

Practical

A Portuguese writing aid — word-by-word completion and formal-vs-colloquial register comparison.

Wild

Brazilian vs European Portuguese & idioms — does it know "custar os olhos da [MASK]"?

Multi-model

Portuguese-native vs multilingual — run the same mask through both models and measure where they disagree.

How the API works

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".

References