Skip to content
induwara.lk
Premium
induwara.lkAI · Free

AI Fill-Mask Word Predictor

Put a [MASK] blank anywhere in an English sentence and a BERT masked language model predicts the most likely words to fill it, each with a confidence score. It reads both sides of the blank, runs server-side, and needs no API key — a live demo of how BERT actually works.

By Induwara AshinsanaUpdated Jul 11, 2026
Predict the masked wordBERT · server-side
Sources cited
Exactly one [MASK] per sentence. One blank found — ready.32 / 500

The original BERT. Lowercases text, so predictions come back lowercase. Best all-round English default.

5

How many candidate words to rank (120).

Try a sentence
The model reads both sides of the blank at once (bidirectional) and ranks the whole vocabulary by softmax probability.

What this does

Write a sentence with one blank — for example The capital of France is [MASK]. — and a BERT masked language model predicts the most likely words to fill it, each with a confidence score. It reads the context on both sides of the blank, so it is not the same as next-word autocomplete. No signup, no model download.

Method: masked language modelling (Devlin et al., 2018). The blank is the [MASK] token; the model outputs a softmax probability for every word in its vocabulary and the top-k are shown. Full source list in the page footer.

How it works

This tool is a live demonstration of masked language modelling (MLM), the pre-training objective introduced for BERT by Devlin, Chang, Lee & Toutanova (2018). It is the exact task BERT was trained on — recover a hidden word from its context — exposed as something you can type into.

1. Tokenise and locate the blank

Your sentence is split into WordPiece tokens by the model's tokenizer, which wraps it with a [CLS] start token and a [SEP] end token. The position of your [MASK] token is recorded — that is the only position the model predicts.

2. One forward pass, one logit per word

The tokens pass through BERT's bidirectional Transformer encoder, producing a context vector at the masked position that has absorbed information from every other word — left and right. That vector goes through the MLM head, which emits a logit (a raw, unbounded score) for every one of the roughly 30,522 words in the vocabulary.

3. Softmax, then top-k

The logit vector is turned into a probability distribution with the softmax function pᵢ = exp(zᵢ) / Σⱼ exp(zⱼ), so every word gets a probability and they sum to 1 across the whole vocabulary. The tool sorts descending and shows the top-k. There is no temperature and no sampling, so the same sentence, model, and k always give the same ranking.

tokens   = tokenizer("[CLS] The capital of France is [MASK] . [SEP]")
h_mask   = BERT(tokens)[mask_position]        # bidirectional context
logits   = MLM_head(h_mask)                    # one score per vocab word
probs    = softmax(logits)                      # sum to 1 over ~30,522 words
top_k    = argsort(probs, desc)[:k]             # greedy, reproducible

4. Server-side inference & the shown shares

The model runs on the Hugging Face Inference API — never in your browser — so no hundreds-of-megabytes weight file is downloaded. The shown words rarely sum to 100% on their own because most of the probability mass is spread thinly across thousands of unlikely words; the tool therefore reports how much of the total mass your top-k capture and renormalises the shown words into shares that do sum to 100% for the confidence bars. If the Inference API is out of quota or unreachable, a deterministic grammar baseline — a small local-context frequency table — fills in so the page never dead-ends, clearly labelled so you know it is a fallback and not the neural model.

Worked examples

Factual completion — a peaked distribution

  • Sentence: "The capital of France is [MASK]."
  • Model: BERT base (uncased), top-k = 5
  1. Tokenise → [CLS] the capital of france is [MASK] . [SEP]
  2. Forward pass → logits over ~30,522 words
  3. softmax → paris ≈ 0.87, lyon ≈ 0.03, marseille ≈ 0.02, nantes ≈ 0.01, toulouse ≈ 0.01
  4. Shown top-5 capture ≈ 0.94 of total mass
  5. Renormalise within shown → paris 92.6%, lyon 3.2%, marseille 2.1%, nantes 1.1%, toulouse 1.1% (sum 100%)
  6. Completed: "The capital of France is paris." — one word dominates

Ambiguous completion — a flat distribution

  • Sentence: "I want to [MASK] a cup of coffee."
  • Model: BERT base (uncased), top-k = 5
  1. softmax → have ≈ 0.29, drink ≈ 0.24, make ≈ 0.17, get ≈ 0.11, order ≈ 0.06
  2. Shown top-5 capture ≈ 0.87 of total mass
  3. Renormalise within shown → have 33.3%, drink 27.6%, make 19.5%, get 12.6%, order 6.9% (sum 100%)
  4. No single verb dominates — the model is honestly uncertain
  5. Completed (top-1): "I want to have a cup of coffee."

Edge case — the fallback baseline

  • Sentence: "The capital of France is [MASK]."
  • Inference API out of quota → grammar baseline runs
  1. Read the word before the blank: "is"
  2. Look up local-context table for "is" → a, the, not, still, now, …
  3. Weight by position (10, 9, 8, 7, 6) and normalise
  4. Shares → a 25%, the 22.5%, not 20%, still 17.5%, now 15%
  5. Grammatically plausible but not "paris" — the baseline has no world knowledge, and the page says so

Frequently asked questions

Sources & references

Related tools

Rate this tool
Be the first to rate

Comments & feedback

Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a surprising prediction, edge case, or want a different model?

Email me at [email protected] — most fixes ship within 24 hours.