What goes in, what comes out

Let's start with what AlphaFold 2 actually does at a high level, before diving into each component.

INPUT 1
Amino acid sequence
Your protein's "recipe" in one-letter code
INPUT 2
MSA (multiple sequence alignment)
Hundreds of evolutionarily related sequences
PROCESS
Evoformer + Structure Module
48 blocks of deep reasoning about sequence & contacts
OUTPUT
3-D atomic coordinates
Plus per-residue pLDDT confidence scores
πŸ”¬
Templates (optional third input) AlphaFold can also use structural templates β€” known 3-D structures of related proteins β€” as a third input, similar to homology modelling. When good templates exist, they improve accuracy. But AlphaFold's remarkable achievement is that it works even without any templates, using evolutionary information alone.

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:

  1. The mutation is lethal: it destroys the protein's function. The organism dies or doesn't reproduce. The mutation is lost from the population.
  2. The mutation is neutral: it doesn't affect function much. It spreads through the population by chance. It's "tolerated."
  3. 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.

πŸ’‘
Analogy: co-evolution as handwriting Imagine you had hundreds of copies of the same letter, each written by a different person but conveying the same message. In every copy, when the word "dear" is shortened to "dr", the greeting at the end also tends to change. Two positions that always change together, across hundreds of copies, are probably structurally linked β€” they're in contact in the 3-D protein. The MSA lets AlphaFold read this "co-evolutionary handwriting."

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) MALSKVELTI
Mouse MALSKVELTV
Zebrafish MAITRLDVSL
Yeast MAV-KIEL-V
Bacteria MALNRVDITL

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.

πŸ’‘
Analogy: learning to recognise cats Show a neural network 10 million labelled photos (cat / not cat). It adjusts its weights so that the correct label comes out. After training, it can recognise cats in new photos it's never seen. It learned the concept of "cat-ness" from data, without being explicitly programmed with rules like "cats have pointy ears." In AlphaFold, the "photos" are MSAs and the "labels" are known 3-D structures.

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.

πŸ’‘
Analogy: attention in translation When translating "I love Paris" to French as "J'aime Paris," an attention mechanism lets the network focus on the most relevant words from the input when generating each output word. To produce "aime," the network pays most attention to "love." To produce "Paris," it focuses on "Paris." Rather than just reading the whole sentence as a fixed vector, attention selectively weighs each input position differently for each output position.

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:

Attention(Q, K, V) = softmax(QKα΅€ / √d) Β· V Where: Q = "what I'm looking for" (the current position's query) K = "what each position offers" (keys for all positions) V = "the actual information" at each position softmax = normalises weights to sum to 1 d = key dimension (for numerical stability)

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.
πŸ”¬
Why two attention directions? Row attention lets AlphaFold ask: "Given that this sequence has R at position 42, does anything else in this sequence change predictably?" Column attention lets it ask: "Across all the sequences in evolutionary history, what combinations of amino acids appear together at position 42?" Together, they extract both within-sequence and across-evolution patterns.

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.

πŸ’‘
Analogy: Google Maps routing If you know the distance from London to Paris, and from Paris to Berlin, you can constrain the possible distance from London to Berlin. A good map is internally consistent β€” no route distances violate the triangle inequality. Triangular updates help AlphaFold build a consistent internal "map" of residue–residue relationships.

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.
πŸ”¬
Diffusion models in brief A diffusion model learns to gradually "denoise" random noise into a structured output. During training: start with the real structure, add noise step by step until it's pure noise, and train the network to reverse this process. During inference: start with random noise and denoise iteratively toward a plausible structure. The key advantage: the model can express uncertainty by generating a distribution of structures rather than a single answer. AlphaFold 3 can output multiple structure samples, reflecting the range of possible conformations.

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.