- predictions_json
Fill Mask is the party trick of the NLP nodes: you give it a sentence with a [MASK] hole in it, and it suggests what belongs there. "The capital of France is [MASK]." → "Paris." It's masked language modeling, the exact task BERT was trained on, and it's the most satisfying way to show someone what a language model actually knows inside a ComfyUI graph.
The node wraps the fill-mask pipeline from Hugging Face, defaulting to bert-base-uncased. BERT is the granddaddy of encoder language models, and the fill-mask task is its home turf: it looks at the context on both sides of the mask and scores candidate tokens. The node runs your text, asks for the top candidates, and returns the full prediction objects as JSON - token, text, and score for each.
The inputs and output
- text - your sentence with a
[MASK]token in it, multiline. This is where the magic happens; no mask, no predictions. - model_name - Hub model ID as a string, default
bert-base-uncased. RoBERTa-style models use<mask>instead, so match the mask token to the model. - top_k - how many candidates to return, default 5, range 1–20.
The single output, predictions_json, is a STRING with the ranked candidates and their scores. It's JSON, so you're reading it in a display node or parsing it downstream rather than wiring it into a typed slot.
How to install it
Standard pack install - ComfyUI Manager (search "ComfyUI-Transformers") or:
cd ComfyUI/custom_nodes
git clone https://github.com/kadirnar/ComfyUI-Transformers
Restart ComfyUI. BERT-base uncased is about 440MB on first download, and requirements.txt already covers the transformers stack it needs.
Where people get burned
The subtle trap is mask-token mismatch. BERT uses [MASK], but many modern checkpoints use <mask> or something else, and the pipeline will fail or return garbage if you don't match the model's convention. Beyond that, BERT's suggestions are context-triggered associations, not reasoning - fill-mask will happily suggest "Paris" for a geography question but it won't surprise you with genuine comprehension. And scores in this task are notoriously concentrated: the top candidate often blows past 0.9 while the rest trail far behind, so the ranking is more informative than the raw numbers. Fun, cheap, and a great way to peek at what a masked-language model learned - just don't build your whole pipeline around it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | The capital of France is [MASK]. | — |
| model_name | STRING | bert-base-uncased | — |
| top_k | INT | 51–20 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| predictions_json | STRING | — |