TL;DR
Reconstructing the evolutionary family tree of DNA or protein sequences usually requires calculating mathematical likelihoods—a step so computationally brutal it forces biologists to pretend different parts of a gene evolve completely independently. Phyloformer 2 bypasses likelihood calculations altogether, using deep learning to estimate the entire probability distribution of possible evolutionary trees directly from sequences. It runs 10 to 100 times faster than gold-standard tools while unlocking the ability to use realistic, complex evolutionary models that were previously mathematically untouchable.
What Problem Does This Paper Address?
Imagine trying to reconstruct a massive family tree using only the DNA of living cousins. In genomics, this bifurcating tree is a phylogeny, and building one is how we track viral epidemics or understand how life evolved.
State-of-the-art methods rely on probabilistic models of how sequences mutate over time, searching for the tree that maximizes the likelihood of the observed data, or sampling from a Bayesian posterior distribution. There is a massive catch: evaluating the likelihood function is painfully expensive, and the number of possible tree topologies explodes super-exponentially as you add species—specifically, $(2N-5)!!$ trees for $N$ species.
To make the math computable at all, traditional tools rely on biological fictions—assuming, for instance, that every single position in a protein evolves independently of its neighbors. When real-world biology violates these assumptions (such as when two amino acids co-evolve to maintain a protein’s 3D structure), traditional tree-builders produce artifacts.
Simulation-based Neural Posterior Estimation (NPE) offers a clever way out: even if we cannot evaluate the likelihood of a complex evolutionary model, it is very cheap to simulate sequences evolving under it. Previous deep learning attempts either maxed out at tiny four-leaf trees ("quartets") or, like the original Phyloformer, only predicted flat point-estimates of pairwise evolutionary distances. Nobody had figured out how to parameterize a neural network to output a valid, full probability distribution over arbitrary phylogenetic trees.
Methods
Phyloformer 2 (PF2) is an amortized NPE network—meaning you pay a heavy upfront cost to train it on simulated data, after which inference on new sequences is practically instantaneous. It combines two novel modules:
- evoPF (The Encoder): Taking a page out of AlphaFold 2’s playbook, evoPF is a "transposed" version of the EvoFormer. While AlphaFold tracks spatial distances between pairs of amino acids, evoPF tracks evolutionary relationships between pairs of species. It maintains two parallel representations that constantly talk to each other: a sequence alignment stack (using row- and column-wise axial self-attention) and a lightweight pair stack (one embedding per pair of sequences).
- BayesNJ (The Tree Distribution): How do you turn sequence embeddings into a probability distribution over discrete branching trees and continuous branch lengths? BayesNJ builds trees bottom-up via a succession of $N-3$ pairwise merges—like a probabilistic version of classic hierarchical clustering. At each step, a softmin over learned bilinear scores picks which two nodes to merge into a common ancestor, while shifted Gamma and Beta distributions model the two new branch lengths.
Crucially, because multiple merge orders can accidentally build the exact same tree, summing over all paths would be intractable. The authors enforce a canonical merge order: always merge the pair of available nodes with the smallest cherry (sum of branch lengths) first, updating minimum-length constraints as the tree grows. This ensures every valid phylogeny maps to a single, unique merge path.
Datasets
- Simulated Tractable Data: Trained on $\approx 1.3 \times 10^6$ 50-taxa trees (rescaled birth-death prior) under the standard LG+G8 protein evolution model, fine-tuned on 10–170 taxa, and tested on 10–200 taxa alignments from the original Phyloformer benchmark. An additional uniform-prior dataset was simulated for Bayesian MCMC comparisons.
- Simulated Intractable Data: Evaluated on existing benchmarks featuring site-dependencies (Cherry model) and heterogeneous amino acid distributions (SelReg model). The authors also introduce a new benchmark simulated under a Potts model, capturing realistic co-evolution in the PF00072 protein family.
- Empirical Data: Tested on real-world cyanobacteria gene families and five diverse protein datasets (BoroA6, NagyA1, ShenA9, WhelA7, StruA5), comparing inferred gene trees against reference species trees.
Key Insights and Ideas
- No discrete backpropagation required: Even though building a tree involves discrete choices, during training the ground-truth simulated tree dictates the canonical merge order. The network simply evaluates the log-probability of that known sequence of merges, sidestepping the need to differentiate through discrete sampling operations.
- Loss function beats encoder size for topology: In an ablation study, pairing the shiny new evoPF encoder with the old Phyloformer’s pairwise-distance loss yielded no topological improvement. The massive leap in tree accuracy comes directly from BayesNJ framing the problem as end-to-end posterior tree estimation.
- Distributions beat point estimates: Sampling 100 trees from PF2's posterior and summarizing them into a greedy-consensus tree consistently beats taking a single greedy Maximum A Posteriori (MAP) tree—even outperforming gold-standard likelihood tools on their own home turf.
Key Results
- Accuracy & Speed on Tractable Models: On LG+GC simulations up to 130 leaves, PF2 greedy-MAP matches maximum-likelihood titans IQTree and FastTree in topological accuracy (Robinson-Foulds distance), while running 1 order of magnitude faster than FastTree and 2 orders faster than IQTree. Summarizing 100 posterior samples beats both methods on trees up to 150 leaves.
- Memory Scaling: Despite having 1,000$\times$ more parameters than the original Phyloformer, PF2’s evoPF architecture uses less memory, scaling to >250 sequences (length 500) or >350 sequences (length 250) on a single 16GB V100 GPU.
- Dominance on Intractable Models & Real Data: Under complex co-evolutionary models (Cherry, SelReg, Potts) where likelihood methods are mathematically misspecified, PF2 significantly outperforms all baselines in topological accuracy. It also achieves the best accuracy on empirical cyanobacteria data and 4 out of 5 diverse protein datasets.
- Calibrated Posteriors: Compared against long RevBayes MCMC runs (50,000 iterations), PF2 produces well-calibrated, slightly conservative (mode-covering) branch support probabilities orders of magnitude faster.
Limitations and Future Work
- VRAM bottlenecks: Attention over sequence pairs still limits PF2 to roughly 250–350 sequences on a 16GB GPU, preventing massive thousand-taxon analyses without future work on leaner encoders or divide-and-conquer tree heuristics.
- Static recursion & parametric rigidity: To save compute, BayesNJ does not update the embeddings of unmerged nodes as the tree is built, and forces branch lengths into strict Gamma/Beta shapes, slightly limiting distribution expressivity.
- Out-of-distribution blindness: Like all neural estimators, PF2 can fail silently if fed biological sequences that look nothing like its simulated training priors. Adding uncertainty quantification, handling unaligned raw sequences, and training on richer population-genetics simulators are the clear next frontiers.
Summary updated