masked language model Β· protein sequence Β· WASM Β· ~35 MB
A protein language model reads sequences the way an LLM reads text β but its "words" are the 20 amino acids. Mask a position and ESM-2 predicts which residue belongs there; from that same prediction it scores every possible mutation as tolerated or likely-damaging. This is the zero-shot method behind modern variant-effect prediction, running entirely in your browser.
| Model | Xenova/esm2_t12_35M_UR50D (ONNX of Meta esm2_t12_35M) |
|---|---|
| Task | masked language modeling on protein sequences (AutoModelForMaskedLM) |
| Vocabulary | the 20 standard amino acids (+ special tokens) |
| Training | ESM-2, ~65M UniRef protein sequences (Meta AI) |
| Quantization | q8 ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~35 MB, cached after first load |
| License | MIT (ESM-2 upstream) |
Paste a protein sequence or pick an example, then click a residue in the grid. The model masks that position and predicts what belongs there β and how every substitution scores.
log-likelihood vs wild-type β green tolerated, red likely-damaging
Trained only to fill in masked residues across tens of millions of natural proteins, ESM-2 learns which amino acids are compatible with a protein's structure and function. That single skill powers a surprising amount of biology β without any labels, structures, or experiments:
This is a fast, zero-shot signal, not a clinical verdict. The score is the model's sequence likelihood β it has no knowledge of a specific structure, assay, or patient, and the 35M model is the smallest ESM-2 (larger models are more accurate). Use it to explore and prioritise, not to diagnose.
The fill-mask pipeline needs a mask_token this ONNX build omits, so we run the model
directly and read the logits at the masked position:
import { AutoTokenizer, AutoModelForMaskedLM, Tensor }
from "@huggingface/transformers";
const tok = await AutoTokenizer.from_pretrained("Xenova/esm2_t12_35M_UR50D");
const model = await AutoModelForMaskedLM.from_pretrained(
"Xenova/esm2_t12_35M_UR50D", { dtype: "q8" });
const ids = Array.from((await tok(sequence)).input_ids.data).map(Number);
ids[pos + 1] = maskId; // +1 for the leading <cls>
const { logits } = await model({ input_ids: new Tensor("int64", β¦) });
// softmax the logits row β P(amino acid) at that position;
// ln P(mutant) β ln P(wild-type) = the variant-effect score.
Each click is one forward pass, run in a Web Worker so the page stays responsive.