Explaining Evoformer and triangle updates
The Evoformer mixes MSA and pair representations via OuterProductMean and pair biases in MSA attention, while triangle multiplicative updates and triangle attention enforce triangle inequality constraints on pair features to ensure spatial and geometric consistency in predicted residue distances.
A central design choice in the AF2 network is to keep two different “views” of the protein in play at all times:
- an (N_{\text{seq}}\times L) “MSA” array that carries per–sequence, per–position features derived from the alignment, and
- an (L\times L) “pair” array that carries features of residue–residue relationships.
The Evoformer block is the basic unit that iteratively refines both of these arrays. In the published implementation a block consists of:
-
Two self‑attention/MLP steps on the MSA: a “row” self‑attention across positions within each sequence and a “column” self‑attention across sequences at each position, each followed by a position‑wise transition. The row attention takes an additive bias derived from the current pair representation so that per‑position updates are aware of what is known about the partner residue.
-
A projection from the MSA to the pair representation: the “outer‑product mean”. For each residue pair ((i,j)) the outer product of the MSA embeddings at (i) and (j) is averaged over the MSA depth and projected, giving a learned summary of co‑variation between (i) and (j). This is the main way in which evolutionary information in the MSA flows into the pair stack.
-
A series of “triangle” updates on the pair representation. There are multiplicative updates (“outgoing” and “incoming”) and attention‑style updates (“starting node” and “ending node”) that, for a given pair ((i,j)), aggregate information over all possible intermediates (k). For example, a triangle multiplicative update computes something like
[
z'{ij} \leftarrow z{ij} + \sum_k \sigma(\cdot),(W_1 z_{ik})\odot (W_2 z_{kj}),
]
which increases the score of ((i,j)) if there is strong evidence for a path (i!\to!k!\to!j). These operations are followed by a small feed‑forward “pair transition”.
Information thus flows in both directions: the pair matrix biases the row‑wise attention over residues, and the MSA drives pair updates through the outer‑product mean. Iterating the Evoformer stack repeatedly mixes and propagates sequence and relational signals.
The “triangle” nomenclature is not accidental. If you think of the pair features as encoding a noisy distance or contact matrix, any three entries form a geometric triangle and must satisfy triangle inequality constraints to be embeddable in 3D. The triangle multiplicative/attention updates are a form of message passing over length‑3 cycles that encourage this consistency: if (i) is close to (k) and (k) is close to (j), then (i) and (j) should not be far apart, and if (i)–(j) is predicted to be very short, not all paths (i!\to!k!\to!j) can be long. Injecting this bias into the network makes it much harder for it to settle on pairwise predictions that violate basic metric properties, and empirically leads to structures whose derived distance matrices are more globally coherent.