Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path →
AlphaFold 2,
explained.
A protein is a chain of amino acids that folds, in a fraction of a second, into a precise 3D shape that determines everything it does. Predicting that shape from the sequence alone had defeated biology for fifty years. AlphaFold 2 cracked it — and its key trick isn't chemistry, it's reading evolution. When two spots on the chain touch in the folded protein, they tend to mutate together across related species, because a change in one must be compensated by the other. Find those correlated positions in a family of sequences and you've found the protein's contacts — the scaffold of its shape. Here's how AlphaFold turns that signal into structure.
What changes against message passing: the graph is what is being predicted
Rung 1 is given a graph and learns features on it. Here the structure is the output: the input is a one-dimensional amino-acid sequence and the target is the three-dimensional arrangement it folds into. There is no adjacency matrix to normalise, because which residues touch in space is exactly the unknown.
The change that makes it tractable is where the information is found. A single sequence is not enough, but the same protein in thousands of species is: if two positions are in contact, a mutation at one tends to be compensated by a mutation at the other, because the contact must be preserved for the protein to work. So a multiple-sequence alignment across evolutionary relatives carries a statistical shadow of the 3D contacts, and the model's job becomes reading structure out of coevolution. This is a data insight, not an architectural one, and it is the load-bearing part.
Two further choices are what turn a contact signal into coordinates. The network maintains two representations that talk to each other — one over the alignment and one over residue pairs — and updates the pair representation with operations built around triples of residues, so that the implied distances are pushed toward satisfying the triangle inequality. The geometry is enforced inside the attention rather than repaired afterwards. And the final module emits coordinates end to end, rather than predicting a contact map and handing it to a separate folding program, with a per-residue confidence that turned out to be calibrated — which is why it is arguably the most practically important number the system produces.
A 50-year problem
The protein-folding problem — predict a protein's 3D structure from its amino-acid sequence — was one of biology's great open challenges. Structure determines function: how an enzyme catalyzes, how a receptor binds a drug, how a mutation causes disease. But determining structure experimentally (X-ray crystallography, cryo-EM) is slow and expensive, taking months to years per protein, while sequences pile up by the millions. The dream was to skip the lab and compute the shape.
It resisted because the search space is astronomical and the physics is subtle — a chain can fold countless ways, and predicting the one it actually adopts from first principles is intractable. AlphaFold 2's breakthrough was to sidestep brute-force physics and instead learn from two rich sources of information: the evolutionary record of related proteins, and the accumulated experimental structures. Deep learning tied them together; evolution supplied the crucial constraints.
Residues that touch in a folded protein mutate together across evolution; extract those correlations from a family of sequences, refine them with attention, and predict the 3D structure.
Evolution encodes structure
Here's the central biological insight AlphaFold exploits. Gather a multiple-sequence alignment (MSA): the same protein from many species, lined up position by position. Now look at two columns of that alignment — two residue positions. If those two residues are physically in contact in the folded structure, they're under a joint constraint: a mutation at one that would disrupt the fold tends to be accompanied by a compensating mutation at the other. So over evolutionary time, contacting positions coevolve — they mutate together.
That turns a structural question into a statistical one you can read off the alignment: columns that covary flag residues that touch. Measure the correlation between two columns across the family; high correlation predicts a contact.
A single sequence tells you nothing — covariation only appears across a family, which is why deep MSAs (thousands of related sequences) matter so much. This coevolution-to-contact idea predates AlphaFold, but AlphaFold learned to use it far more powerfully than hand-crafted statistics could. The runnable version below detects a covarying (contacting) pair of columns and shows a single sequence yields no signal.
The Evoformer
AlphaFold 2's engine is the Evoformer, a deep stack of attention blocks — the same attention mechanism behind transformers, adapted to biology. It maintains and refines two coupled representations:
The clever part is the two-way flow: coevolution signals from the MSA sharpen the pair representation, and geometric constraints in the pair representation feed back to interpret the MSA. Iterated many times, this produces a pair representation that encodes, for every pair of residues, a rich prediction of their spatial relationship — the distilled structural knowledge that the next stage turns into actual coordinates.
Structure and confidence
The structure module takes the Evoformer's refined representations and predicts the 3D structure directly — not a contact map to be folded afterward, but the structure itself. It represents each residue as a frame (position + orientation), predicts torsion angles to place the side-chain heavy atoms, and uses invariant point attention, an attention variant that respects 3D geometry (the prediction is the same however you rotate or translate the whole protein). The whole pipeline is then recycled — its output fed back as input several times — to iteratively refine the structure.
Crucially, AlphaFold reports pLDDT, a calibrated per-residue confidence from 0 to 100. High pLDDT means the model is sure of that residue's position; low pLDDT flags uncertain regions, often genuinely flexible or disordered parts of the protein. That confidence is a practical gift: it tells a biologist exactly which parts of a predicted structure to trust, turning a prediction into a usable scientific tool rather than a black-box guess.
How AlphaFold 2 goes from sequence to structure, step by step
AlphaFold 2 (Jumper, Evans, Pritzel and colleagues at DeepMind) maps an amino-acid sequence to 3D coordinates for every heavy atom with one network trained end to end. The steps:
- Search for relatives and templates. The input sequence is searched against large sequence databases (UniRef90, MGnify, BFD and Uniclust30, using jackhmmer and HHblits) to build a multiple sequence alignment (MSA), and against structures in the PDB to find up to four templates.
- Embed two representations. The MSA representation holds one vector per sequence per residue (Nseq × Nres, 256 channels); the pair representation holds one vector per pair of residues (Nres × Nres, 128 channels), initialized from the sequence, relative positions and template features. Very deep alignments are subsampled, with an extra, cheaper stack reading many more sequences.
- Run 48 Evoformer blocks. Each block applies, in order: row-wise attention over the MSA with a bias computed from the pair representation; column-wise attention across sequences; an MSA transition; an outer product mean that turns pairs of MSA columns into an update for the pair representation; two triangle multiplicative updates (outgoing and incoming edges); two triangle self-attentions (around the starting and the ending node); and a pair transition.
- Build the structure. The structure module, 8 blocks with shared weights, treats each residue as a rigid frame (a rotation and a translation), all starting at the origin. Invariant point attention updates a per-residue representation using the pair representation and 3D points expressed in each residue's local frame, so the result does not change when the whole protein is rotated or moved. Each block updates the frames, and predicted torsion angles place the side-chain atoms.
- Recycle. The outputs, including the predicted structure, are fed back as inputs and the whole network runs again; inference uses three recycling iterations. During training the number of iterations is random and only the last one is backpropagated, which keeps the cost manageable.
- Train with several losses. The main loss is FAPE, on the final structure and on each structure-module layer, plus a distogram loss (binned inter-residue distances predicted from the pair representation), a masked-MSA loss (predicting randomly masked alignment entries, in the style of BERT) and a loss for the confidence head. Fine-tuning adds a penalty for physical violations such as clashes.
- Self-distill. A first model predicted structures for roughly 350,000 diverse sequences from Uniclust30; the confident predictions were mixed with real PDB structures to train the final model.
- Report confidence. pLDDT, a per-residue estimate of local accuracy from 0 to 100, comes from the structure module's representation. The predicted aligned error (PAE), from the pair representation, estimates for every pair of residues the position error at one when the structure is aligned on the other, and from it comes a predicted TM-score.
Training used PDB structures released before the end of April 2018, with chains cropped to a few hundred residues to fit in memory.
FAPE and the triangle multiplicative update
Ti— the predicted frame of residue i (rotation and translation);xj— the predicted position of atom j; the superscript true marks the experimental structure.Ti^−1 ∘ xj— atom j as seen from residue i's local frame. Comparing these local views for every frame and atom makes the loss independent of where the whole protein sits in space, with no superposition step, while still telling a structure from its mirror image.dclamp, Z— errors are capped at 10 Å so a few wildly misplaced atoms cannot dominate, and the result is divided by 10 Å to make it unitless.zij— the pair representation for residues i and j;a, b, g— gated linear projections of the pair representation; ⊙ is elementwise multiplication.
The triangle update makes edge ij depend on the two other edges of every triangle ijk, which is how evidence that i is near k and k is near j reaches the estimate for i and j. At the extremes, a protein with no informative alignment gives these updates little to combine, and for long chains the sum over k, Nres^3 operations per channel, is among the most expensive parts of the Evoformer.
What AlphaFold 2 measured at CASP14 and after
The headline test was CASP14 in 2020, a blind assessment in which structures were predicted before the experimental ones were released. The paper reports accuracy as r.m.s.d.95, the root-mean-square deviation of Cα atoms (or of all heavy atoms) over the best-fitting 95 percent of residues.
| CASP14 measure | AlphaFold 2 | Next best method |
|---|---|---|
| Median backbone error, Cα r.m.s.d.95 | 0.96 Å | 2.8 Å |
| Median all-atom error, r.m.s.d.95 | 1.5 Å | 3.5 Å |
For scale, a carbon atom is about 1.4 Å wide, so the median backbone error was smaller than one atom. To rule out a CASP-specific result, the authors also evaluated chains deposited in the PDB after the training cutoff and found the accuracy held, with pLDDT tracking the measured local accuracy closely enough to tell users which regions to trust.
The ablations changed one component at a time and retrained. Self-distillation, recycling, the triangle operations, invariant point attention and the masked-MSA objective each contributed, and no single trick carried the result. The clearest negative result concerns the input: accuracy fell sharply when the alignment held fewer than about 30 effective sequences, the orphan-protein case in which coevolution has little to say, while gains flattened at greater depths. Accuracy was also lower for chains whose shape depends on contacts with other chains, since the model saw one chain at a time; the AlphaFold-Multimer follow-up addressed complexes directly.
What the authors admit, and what happened next
The dependency on evolutionary depth is stated, and it is the sharpest limitation: accuracy degrades where the alignment is shallow, which means orphan sequences, fast-evolving regions and de novo designed proteins with no natural relatives are exactly the hard cases. A method that reads evolution cannot help where there is no evolution to read.
Two more scope limits are explicit. The output is a single structure, not the ensemble of conformations a real protein moves through, so function that depends on motion is outside what is predicted. And complexes — several chains bound together, which is how most biology actually happens — were not the target and needed separate later work. The confidence score is what makes both survivable in practice, because a user can tell which parts of a prediction to trust.
How it held up: about as well as any result on this site. The benchmark margin was decisive rather than incremental, the released predicted structures changed day-to-day practice in structural biology, and the work was recognised with a Nobel Prize in Chemistry in 2024. The one claim worth handling carefully is the framing that the folding problem is "solved": the system predicts the outcome of folding without modelling the process, and those are different questions — one about a mapping, one about a mechanism. The papers are careful about this distinction in a way that much of the coverage was not.
Read contacts out of evolution
The coevolution insight is a correlation you can compute. This takes a tiny multiple-sequence alignment where two positions mutate together and one mutates on its own, and shows that the covarying columns correlate strongly (predicting a 3D contact) while the independent pair does not. It also shows the catch — a single-sequence alignment carries no covariation signal, so deep families matter — and computes mean pLDDT, AlphaFold's per-residue confidence. Edit the alignment and watch which pairs light up as contacts.
Write the body of correlation. Everything else in the file is
already written; this is the function the paper is about. Press ▶ Run to check it against
the 5 assertions below — they start red.
- Covarying columns have high correlation
- Independent columns have ~0 correlation
- Contact prediction fires for the covarying pair only
- A single-sequence MSA gives no covariation signal
- Mean pLDDT is a confidence in [0,100]
What it changed
AlphaFold 2 transformed structural biology and drug discovery, and it opened a wave of AI-for-science built on the same ingredients: AlphaFold-Multimer for complexes, AlphaFold 3 extending to proteins with DNA, RNA, and small molecules, and a broad "structure prediction" toolkit now standard in labs. It showed that deep learning could deliver not just useful predictions but scientific discovery.
Its deeper lesson is about where information hides. The structure a protein folds into isn't written explicitly anywhere you can read — but it's implicit in the evolutionary record, encoded in which mutations co-occur across millions of years and species. AlphaFold's genius was recognizing that a physics problem could be solved by learning to read that record, and building an architecture that could. Whenever a hard problem has left statistical fingerprints in abundant data, "learn to read the fingerprints" is a strategy AlphaFold made canonical.
AlphaFold works best when a protein has many evolutionary relatives to build a deep MSA; for proteins with few known homologs (orphans) the coevolution signal is weak, which is a known limitation of the approach.
Questions people ask about AlphaFold 2
What is the triangle multiplicative update in AlphaFold 2?
It is one of the two kinds of triangle operation in each Evoformer block that update the pair representation. To update the entry for residues i and j, it takes, for every third residue k, gated projections of the entries for the edges i–k and j–k, multiplies them elementwise and sums over k; a second version does the same with the incoming edges k–i and k–j. The motivation is geometric: distances between residues must satisfy the triangle inequality, so what the network believes about i–k and k–j should constrain i–j. Because it sums over all k for every pair, its cost grows with the cube of the sequence length.
What is the FAPE loss in AlphaFold?
FAPE, frame aligned point error, is AlphaFold 2's main structural loss. For every residue frame i and every atom j, it expresses the atom's predicted position in the predicted local frame of residue i, does the same for the true structure, and measures the distance between the two. These distances are capped at 10 Å, averaged and divided by 10 Å. Because every atom is compared from every residue's point of view, the loss needs no global superposition and is unchanged by rotating or moving the whole prediction, yet it distinguishes a structure from its mirror image, which purely distance-based losses cannot. It is applied to the final structure and, as an auxiliary loss, to intermediate layers.
What is the difference between pLDDT and PAE in AlphaFold?
pLDDT is a per-residue score from 0 to 100 estimating local accuracy, specifically the lDDT of that residue's Cα atom: how well its distances to nearby atoms match the true structure. It answers whether a residue's local environment is right, and low values often mark disordered regions. PAE, predicted aligned error, is a matrix over residue pairs: the expected error in residue j's position, in ångströms, when the prediction and the true structure are aligned on residue i. It answers whether parts are placed correctly relative to each other, so two confident domains can both have high pLDDT and still show a high PAE between them when their relative orientation is uncertain.
What is self-distillation in AlphaFold 2?
After training a first model on experimental structures from the PDB, the authors used it to predict structures for roughly 350,000 diverse sequences from the Uniclust30 database. They kept the confident predictions and trained a new model on a mixture of these predicted structures and the real PDB data. The point is to use far more of sequence space than the PDB covers: unlabeled sequences become extra training examples, labeled by the model itself. In the paper's ablations, removing self-distillation reduced accuracy, so the final model owes part of its performance to learning from its own confident predictions.
How many Evoformer blocks does AlphaFold 2 use, and what is recycling?
The main trunk has 48 Evoformer blocks, preceded by a smaller extra stack that reads additional alignment sequences and followed by a structure module of 8 blocks that share their weights. Recycling runs the whole network again, feeding in the previous pass's outputs, including the predicted structure and representations, as extra inputs. At inference there are three recycling iterations, four passes in total, which lets the model refine its own prediction. During training the number of iterations is sampled at random and gradients flow only through the last one, which keeps training affordable while teaching the model to improve whatever estimate it is handed.
4 questions to test what you just read
Work each one out before you open it — a number, a prediction or a reason, not a definition. Producing the answer is what makes it stick. Your progress is kept on this device.
For a 400-residue protein, how many entries does the pair representation hold, and how many products per channel does one outgoing triangle update compute?
Show answer
400² = 160,000 pair entries, and each sums over 400 values of k, so 400³ = 64 million products per channel. Doubling the length multiplies that by eight, which is why long chains are expensive and why training crops them.
Why does FAPE compare atoms in each residue's local frame instead of comparing raw coordinates?
Show answer
Raw coordinates depend on where the whole structure is placed, so comparing them needs a superposition step. Expressing atoms in local frames makes the loss invariant to global rotation and translation by construction, and because frames have a handedness it still penalizes a mirror-image fold, which a loss built only on distances would not.
AlphaFold 2's median backbone error at CASP14 was 0.96 Å against 2.8 Å for the next best method. How do both compare with the roughly 1.4 Å width of a carbon atom?
Show answer
0.96 / 1.4 ≈ 0.7 of an atom's width, against 2.8 / 1.4 = 2 atom widths for the runner-up: an error about 2.9 times smaller, which puts the typical backbone error below the size of a single atom.
Predict: an orphan protein whose alignment holds only 10 sequences. Should you expect high or low pLDDT, and why?
Show answer
Low, in most cases. With so few relatives there is little covariation for the Evoformer to read, and the paper found accuracy dropped sharply below about 30 effective sequences. The confidence head was trained to predict accuracy, so it should flag the weaker prediction with lower pLDDT.
Structure, not sequence
What to do when the data is a graph rather than a line of tokens — message passing, and the protein-folding system built on it.
- 1Graph Neural Networks2017
- 2AlphaFold 22021
Explore the topic
See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.
More Paper Breakdowns
- Attention Is All You NeedThe paper that introduced the Transformer — the architecture underneath GPT, BERT, Claude, and Gemini. Self-attention, Query/Key/Value, multi-head attention, positional encoding, and the real BLEU results, explained in depth with analogies and animated visuals, not just equations.Read →
- Word2VecHow words became math. Dense word vectors learned from the company a word keeps, so king − man + woman lands near queen. Skip-gram, CBOW, the distributional hypothesis, and the origin of every embedding model powering search and RAG.Read →
- ResNetThe skip connection that made deep learning deep. Why stacking layers made networks worse, and how residual learning let them reach 150+ layers and win ImageNet — the identity shortcut every Transformer still uses inside every block.Read →
- Vision Transformer (ViT)When an image became 16×16 words. Cut a picture into patches, treat each patch as a token, and feed them to a plain Transformer — no convolutions. Patch embeddings, the class token, and why data scale lets attention beat the CNNs that ruled computer vision for a decade.Read →
- Latent DiffusionThe paper behind Stable Diffusion. Compress an image into a small latent space with a VAE, run the diffusion denoising there instead of on pixels for a tens-of-times efficiency win, and steer it with text via cross-attention. The architecture that put text-to-image generation on consumer GPUs.Read →
- DDPMThe original denoising diffusion math — the paper that made diffusion work. A fixed forward process adds Gaussian noise over many steps; a U-Net learns the reverse. The masterstroke: train the network to simply predict the added noise with a plain MSE loss. The foundation under every modern image generator.Read →