What goes in, what comes out
Let's start with what AlphaFold 2 actually does at a high level, before diving into each component.
Multiple Sequence Alignment: reading evolution's lab notebook
The single most important input to AlphaFold is the Multiple Sequence Alignment (MSA). To understand why, we need to think about evolution as a massive uncontrolled experiment.
Every living organism carries proteins that have been optimised by evolution over hundreds of millions of years. When a mutation occurs in a protein β a random change to one amino acid β one of three things happens:
- The mutation is lethal: it destroys the protein's function. The organism dies or doesn't reproduce. The mutation is lost from the population.
- The mutation is neutral: it doesn't affect function much. It spreads through the population by chance. It's "tolerated."
- The mutation is beneficial: it improves the protein's function in some context. It spreads rapidly.
The critical insight: positions in the protein that are important for its 3-D structure are constrained. If a residue is buried in the hydrophobic core, any mutation to a charged residue would be lethal β so that position is "conserved" (essentially the same amino acid across all related species).
Now here's the real magic: co-evolution.
Suppose two residues are in contact in the 3-D structure β say residue 42 and residue 108 form a salt bridge (one positive, one negative). If a mutation changes residue 42 from lysine (+) to arginine (+), the protein still folds fine β both are positively charged, the salt bridge still works. But if residue 42 mutates to aspartate (β), the salt bridge breaks. Unless residue 108 simultaneously mutates from glutamate (β) to lysine (+), restoring the electrostatic interaction. Such compensatory mutations are visible in the MSA: when position 42 changes, position 108 also tends to change, because they co-evolve to maintain their structural contact.
An MSA is built by searching protein sequence databases (like UniRef90 or MGnify) for sequences similar to your target. The sequences are then aligned β corresponding columns represent homologous positions (the "same" position across evolution). A typical MSA might have a few hundred to hundreds of thousands of rows.
| Query (human) | M | A | L | S | K | V | E | L | T | I |
| Mouse | M | A | L | S | K | V | E | L | T | V |
| Zebrafish | M | A | I | T | R | L | D | V | S | L |
| Yeast | M | A | V | - | K | I | E | L | - | V |
| Bacteria | M | A | L | N | R | V | D | I | T | L |
Dark blue = fully conserved (structurally critical). Note positions 5 (K/R β both positive) and 7 (E/D β both negative) co-vary together: when KβR, EβD. This suggests these positions form a salt bridge in 3-D.
From co-evolution to 3-D contacts
Earlier methods (like DCA β Direct Coupling Analysis, and the evolutionary couplings approach) tried to directly compute which pairs of positions were co-evolving, then infer spatial contacts. This worked to some extent but had a fundamental problem: indirect correlations.
If positions A and B are in contact, and positions B and C are in contact, then A and C will appear correlated in the MSA β even if they're not touching in 3-D. These transitive correlations pollute the signal. Previous methods used statistical tricks to try to disentangle direct from indirect couplings, with limited success.
AlphaFold doesn't solve this with statistics β it uses a deep neural network to learn the full mapping from MSA patterns to 3-D contacts, letting the network implicitly handle all the complex dependencies. But to understand how, we need to briefly explain neural networks and attention.
Neural networks in two minutes
A neural network is a mathematical function that learns to map inputs to outputs by adjusting millions of internal parameters (called weights) based on examples.
Networks are built from layers of simple operations: linear transformations (matrix multiplications) interspersed with non-linear activation functions (like ReLU β simply max(0, x)). Deep networks with many layers can learn hierarchically complex patterns. The "deep" in deep learning just means many layers.
AlphaFold 2 was trained on the Protein Data Bank β roughly 170,000 experimentally solved structures β and their corresponding MSAs. The network learned to predict 3-D coordinates for the training structures, adjusting its weights until predictions matched reality. This training took weeks on specialised hardware (TPUs β Tensor Processing Units). Once trained, prediction for a new protein takes minutes.
Attention: selective focus
AlphaFold uses a type of neural network layer called attention β the same mechanism that powers large language models like GPT. Understanding attention is crucial to understanding the Evoformer.
In AlphaFold's context, attention lets the model ask: "To understand position 42 of my protein, which other positions should I look at most carefully?" The answer varies β sometimes nearby positions in the sequence are most relevant; other times, evolutionarily correlated positions far away in the sequence hold the key.
Mathematically, attention computes three projections of the input β Queries (Q), Keys (K), and Values (V) β and produces an output that is a weighted sum of the Values, where the weights come from how well each Query matches each Key:
Multi-head attention runs this computation in parallel with different learned projections, letting the model attend to different types of relationships simultaneously.
The Evoformer: reasoning in two representations
The Evoformer (Evolutionary Transformer) is AlphaFold 2's central innovation. It simultaneously maintains and updates two complementary representations:
MSA representation
A matrix of shape S Γ N (sequences Γ positions). Each row is one aligned sequence; each column is one position in the protein. Captures evolutionary patterns.
Pair representation
A matrix of shape N Γ N (positions Γ positions). Each entry summarises everything known about the relationship between two positions β are they in contact? What's their spatial relationship?
These two representations are updated together through 48 Evoformer blocks stacked in sequence. In each block, information flows between the two representations in both directions. Early blocks focus on gathering evolutionary signals; later blocks increasingly reason about 3-D geometric constraints.
Row attention with column attention
Within the MSA representation, two types of attention operate:
- Row attention (within-sequence): For each sequence in the MSA, positions "talk to" each other along the row. This allows positions within a single sequence to exchange information, building up a picture of intra-sequence relationships and enabling the model to reason about which positions in a single sequence are co-varying.
- Column attention (across-sequences): For each column (each position in the protein), all the sequences "talk to" each other down the column. This allows the model to see the full evolutionary diversity at each position β which amino acids are tolerated here, which are forbidden, which tend to appear together with certain amino acids elsewhere.
Triangular updates: enforcing geometric consistency
The pair representation is where AlphaFold reasons about distances and angles between all pairs of residues. But distances are not independent β they must be geometrically consistent. If residue A is 5 Γ from B, and B is 5 Γ from C, then A and C must be between 0 and 10 Γ from each other (triangle inequality). Random pairs of distance predictions could violate this.
AlphaFold enforces geometric consistency through triangular updates: for every triple of residues (A, B, C), the AβC pair representation is updated using information from both AβB and BβC. The geometry forces a relationship between all three pairs β the model learns to maintain it.
There are two types of triangular update: "triangle multiplication" (faster, multiplicative combination of edges) and "triangular self-attention" (the full attention mechanism applied along triangles). Both enforce consistency from different directions.
The Structure Module: turning representations into atoms
After 48 Evoformer blocks, AlphaFold has built rich representations of the sequence and all pairwise relationships. The Structure Module takes these representations and produces actual 3-D atomic coordinates.
The key challenge: the representation of the protein is abstract β it doesn't live in 3-D space yet. The structure module must somehow "ground" it into physical coordinates, in a way that's independent of the global rotation and translation of the whole protein. (A protein floating in one orientation in a crystal is the same as the same protein in any other orientation β the coordinates change but the structure doesn't.)
Invariant Point Attention (IPA)
The core mechanism is Invariant Point Attention (IPA).
Each residue is assigned a local rigid-body frame β a mini coordinate system attached to its backbone, defined by the positions of its N, CΞ±, and C atoms. The "invariant" means that the attention mechanism operates consistently regardless of the global orientation of the protein. Rotate the entire protein, and the relative relationships within IPA remain unchanged.
IPA works by computing attention scores that incorporate both the abstract pair representations and the 3-D positions of the residue frames. As the network iterates, each residue's frame is updated to better fit its predicted 3-D environment β the frames are refined iteratively through 8 layers of the structure module.
After the structure module, a final step called end-to-end recycling feeds the predicted structure back into the beginning of the Evoformer for a few iterations, allowing the model to refine its predictions. This typically runs 3 recycling iterations.
The FAPE loss
How does AlphaFold know during training whether its predicted structure is good? It uses a custom loss function called FAPE β Frame-Aligned Point Error. FAPE measures the average error in atom positions when the predicted and true structures are aligned using each residue's local frame in turn. This is robust to the global rotation and translation of the whole structure.
Outputs: coordinates and confidence
AlphaFold 2 produces:
- Atomic coordinates: 3-D (x, y, z) positions for every heavy atom (non-hydrogen) of the backbone and side chains, in a standard PDB format.
- pLDDT scores: Per-residue confidence score from 0β100 (higher is better). Stored in the B-factor column of the PDB file. We'll explore this deeply in Part 5.
- PAE matrix: For the full server output, a predicted aligned error matrix (NΓN) measuring inter-domain confidence. Also covered in Part 5.
- pTM / ipTM scores: Overall structure confidence metrics, particularly useful for complexes.
AlphaFold 3: what's different
AlphaFold 3 (2024) keeps the MSA-based evolutionary information but replaces or modifies several components:
- Pairformer: Replaces the Evoformer. More efficient for handling the wider variety of molecular inputs (DNA, RNA, small molecules).
- Diffusion module: Replaces the Structure Module entirely. Instead of directly predicting coordinates, AF3 uses a diffusion model β the same type of AI that powers image generation tools like Stable Diffusion.
AF3's diffusion approach handles the diversity of molecular types elegantly β DNA, RNA, and small molecules all get represented as atoms with appropriate chemical types, rather than requiring separate architectures for each.
Key points from this chapter
- AlphaFold 2 takes a protein sequence and its MSA as input and outputs 3-D atomic coordinates + confidence scores.
- The MSA encodes co-evolutionary signals: positions that change together across evolution tend to be spatially close in 3-D.
- The Evoformer processes two representations simultaneously: an MSA representation (sequences Γ positions) and a pair representation (positions Γ positions).
- Row and column attention let the model learn from patterns both within individual sequences and across the whole evolutionary record.
- Triangular updates enforce geometric consistency: distance predictions for all residue triples must satisfy triangle inequalities.
- Invariant Point Attention in the Structure Module grounds the abstract representations into physical 3-D coordinates.
- AlphaFold 3 replaces the Evoformer with a Pairformer and the Structure Module with a diffusion model, enabling DNA, RNA, and small-molecule predictions.