Main
Models of protein evolution describe how protein sequences evolve over time under mutation and various selective pressures. These models are at the core of most applications in evolutionary biology, and act as the engine that powers a variety of phylogenetic methods1,2,3,4,5,6,7. Classical models of protein evolution date back to Margaret Dayhoff8, and further refinements of her seminal work have proceeded in lockstep with ever-increasing data in sequencing databases9,10,11. These methods typically use continuous-time Markov chains (CTMCs) to model protein evolution. A CTMC is parametrized by a rate matrix (frequently denoted by Q) that describes the relative mutation rates and transition probabilities of different amino acids as a function of evolutionary time. Until now, the models of protein evolution used most widely are the WAG10 and LG11 models, both parametrized by a rate matrix Q that is learned using maximum likelihood methods. The LG model generalizes WAG by adding the notion of site-rate variation, in which different sites are allowed to evolve with different overall rates, providing a means to deal with different patterns of conservation across sequences.
Although successful, these classical models come with two important shortcomings: they require sequences to be pre-aligned with gap characters (‘–’) to ensure equal length, and they assume that each site evolves independently of all other sites. Although alignment errors can lead to incorrect inference of evolutionary patterns and the independent-sites assumption is biologically unrealistic, these simplifications have remained standard in phylogenetics due to computational tractability. If a model of protein evolution is viewed as translating between ‘past’ and ‘future’ versions of a protein, then the independent-sites assumption is analogous to translating a sentence between languages one word at a time, without considering the surrounding context.
Although some early models relaxed the independent-sites assumption by enlarging the evolutionary unit either to paired sites in a structure12 or to entire structure-dependent sequences13, these models were, by and large, computationally intractable, and efforts in the field turned instead towards developing more sophisticated substitution rate matrices (Fig. 1a). In particular, this led to the advent of biologically motivated mixture models that combine a base substitution matrix with learned amino acid profiles to generate a set of related rate matrices that better capture the selective pressures experienced in different structural and functional environments14. The most sophisticated versions of these models estimate site- and family-specific profiles using a combination of single-site and pairwise interaction terms15.

a, Top: classically, models of protein evolution learn the parameters for a shared rate matrix that describes how each site in a protein’s MSA evolves over time. Bottom: the problem of learning from evolution can be recast as learning transitions between full sequences in the cherries of the tree. b, Our PEINT transformer learns to model evolutionary transitions in these cherries, accounting for mutations, insertions and deletions. PEINT does not require the sequences to be aligned. S, M and E denote Start, Masked and End tokens, respectively.
In a different vein, probabilistic models over sequence distributions have made great strides capturing epistatic signals in protein sequences. Historically, these models also relied on multiple sequence alignments (MSAs), starting from the Potts model16 to its neural analogue—the MSA transformer that serves as the backbone of the MSA processing module in AlphaFold models17,18 and is used widely as a stand-alone MSA processing architecture19,20. More recent work has highlighted the promise of using techniques from natural language processing to learn probabilistic models from single protein sequences21,22,23,24. Although these models can capture interactions between residues, they do not model explicitly how proteins evolve over time under structural and functional constraints. Moreover, treating sequences as independent ignores their phylogenetic relatedness and biases learned distributions toward overrepresented lineages25,26. Clustering sequence databases mitigates this bias but also removes variation important for specialized functions within protein families27,28.
Here we demonstrate how to achieve the best of both worlds: by integrating principled evolutionary reasoning with modern protein language models (pLMs), we introduce a new framework for learning models of ‘protein evolution in time’ that is alignment-free and accounts for higher-order interactions. This enables us to make use of epistatic signals within sequences to build more sophisticated models of variation between sequences. We show that our approach can make use of evolutionary data at scale, leading to models that show substantially improved performance at modelling both retrospective and prospective evolution. We anticipate that further work along these lines will lead to new insights about the evolution that has led to our current protein universe, as well as models that can predict more accurately forward evolution of proteins involved in disease processes.
The PEINT framework
The objective of evolutionary modelling is to estimate a likelihood over a set of sequences that are related under a phylogenetic tree (for a more thorough treatment, see Supplementary Text). The difficulty arises from the fact that we typically only have access to the leaves of the tree (extant sequences) and ancestral sequences must be integrated out. This computation is tractable only for independent-sites models29, which, by definition, cannot accurately model the higher-order epistatic interaction patterns that are known to be essential for protein structure and function. Recent work has shown that one can instead ignore the ancestral states completely, by using a composite likelihood over cherries, and learn models of protein evolution that move beyond the independent-sites assumption30. The composite likelihood approach recasts the problem of learning a complicated joint probability over many sequences to one of learning many conditional probability paths between pairs of sequences—termed ‘cherries’—on a tree. Intuitively, this can be thought of as decomposing a larger tree into many smaller trivial trees—‘sticks’—in which both the root and leaf are observed, assuming time-reversibility. This allows us to train a model using a negative composite log-likelihood loss:
In equation (1), a triple (x, y, t) makes up a cherry and p(y|x, t) quantifies the conditional probability of observing a sequence y given a starting sequence x and the time t on the tree that separates them. The composite likelihood formulation has a key advantage: in sidestepping the ancestral state integration step, evolutionary transitions are no longer constrained to occur between aligned positions in an MSA. This has two important consequences. First, it allows for the use of arbitrary model classes, including deep neural networks, to learn directly from evolutionary transitions across entire sequences in one go. Second, it removes the constraints of relying on a precomputed alignment, which may contain errors, and in doing so enables models to learn more natively from insertion and deletion (indel) processes within protein families. Despite their outsized importance in evolution31, indels have traditionally been difficult to incorporate into classical models of evolution.
Here we present the protein evolution in time (PEINT) framework, a deep neural network that learns explicit models of full protein sequence evolution in time (Fig. 1b). The PEINT model uses a coupled encoder–decoder transformer—the standard architecture in the field of machine translation32—and is aptly suited to learning under a composite likelihood framework that recasts the fitting of protein evolutionary models into a direct sequence-to-sequence setup33. Concretely, the transformer parametrizes the transition probability in a single cherry as \(p({y|x},t)=\prod _{i\in \text{sites}(y)}p({y}_{i}|{y}_{1:i-1},x,t)\), that is, for each site i in sequence y, estimating its likelihood given the conditioning sequence x, the branch length t and the already generated positions in y ({1, ..., i − 1}). We found that overall model performance was correlated with the strength of the encoder module and therefore used a pretrained, frozen 150 million (150 M)-parameter evolutionary scale modelling 2 (ESM2) encoder22 to provide rich representations of the input sequence x. The resulting PEINT model adds 5 encoder and decoder layers with approximately 57 million trainable parameters and is trained on TrRosetta evolutionary transitions using a composite task of masked language modelling of x and autoregressive prediction of y (Supplementary Methods and Supplementary Fig. 1).
We note that, as a general framework, PEINT is agnostic to the particular choice of encoder model. To demonstrate encoder modularity, we also trained a second PEINT model on the same data, termed ‘PEINT (ESMC)’ after the base encoder ESMC34 (Extended Data Fig. 1), which was released while this manuscript was in revision, and we show its evaluations throughout. Architectures, training configurations and computational costs are summarized in Supplementary Table 1. Models typically converged in a matter of 1–2 days on 2 × A100 graphics processing units.
Evaluating evolutionary transitions
A model of protein evolution should be able to reason over various combination of its inputs, that is, a pair of sequences (x, y) and the branch length that separates them (t). By varying which inputs were provided to PEINT, we assayed its ability to reconcile how evolutionary time is related to mutational burden across protein families.
First, we evaluated the composite likelihood function on held-out transitions from real data. To build intuition for this task, we can compare with the uniform random guess model—a trivial model of evolution which assumes that each site in a protein will mutate randomly to any of the 20 amino acids regardless of how much time has passed. This model would assign a uniform data likelihood of \(\frac{1}{20}\) (\(=\,0.05\)) across all times (Fig. 2a, dotted grey line). A more sophisticated model should be able to reason about the kinds of mutations that are most likely to occur (or not occur) over various evolutionary distances. The classical models WAG10 and LG11 show good performance at short divergence times, and the LG model in particular improves upon WAG by incorporating site-rate variation to better account for patterns of conservation across sites in protein families (Fig. 2a). The PEINT transformer shows superlative performance across all time ranges assayed (Fig. 2a). Most importantly, this improvement persists even on transitions from trees held out during training (Fig. 2a, right), highlighting the ability of PEINT to generalize evolutionary insights across protein families.

Models of protein evolution must learn to relate sequences and evolutionary times. a, Given held out evolutionary transitions from subtree splits (left) and entirely held-out trees (right), PEINT outperforms classical models (WAG and LG) substantially in terms of data likelihood over all evolutionary times. b, Given a pair of sequences x and y, PEINT can estimate the time separating them by maximizing \(p({y|x},t)+p({x|y},t)\) over t (left). This procedure can be applied at scale to pairs of sequences in a single tree (middle), as well as across 150 held-out families (right, Pearson’s r = 0.95). c, Given a starting sequence and time, PEINT generates new sequences with defined mutational loads that mirror those of classical models (left). Compared with independent-sites models, PEINT generates structurally coherent sequences (right). Each point shows the mean and s.d. of ten independent samples from the model.
Ablation studies showed that masked language modelling stabilized training, whereas low-rank adaptation (LoRA)35 fine-tuning provided no measurable benefit (Extended Data Fig. 2). We report the decoder depth analysis in Supplementary Fig. 2. See Supplementary Methods for the full ablation discussion, including the role of additional encoder layers in early training.
PEINT can infer branch lengths
Intuitively, a model of protein evolution should learn a notion of the evolutionary time that separates sequences based on the number and types of mutation that occur between them. Classically, one can obtain a maximum likelihood estimate of the evolutionary time separating a pair of aligned sequences x,y in an MSA using classical models by maximizing p(y|x,t). This information is the basis for neighbour-joining tree reconstruction algorithms36. Similarly, one can use PEINT to estimate \({{\rm{argmax}}}_{t}\{p({y|x},t)+p({x|y},t)\}\), that is, the time that maximizes the transition probability between a pair of observed sequences (in both directions), even in the absence of an explicit alignment. Empirically we found that PEINT generates concave likelihood curves as a function of time, so we used gradient ascent on the likelihood to solve this optimization problem (Fig. 2b, left). We carried out this procedure on cherries from held-out families—for a specific held-out family (Fig. 2b, middle) and also across 150 randomly selected held-out families (Fig. 2b, right)—and observed strong correlations between PEINT’s time estimates and those from classical models (Pearson’s r = 0.95). This strong correlation suggests that PEINT is able to provide consistent estimates of evolutionary distances within the time framework in which it is trained, even in trees it has not seen. As PEINT estimates are obtained from unaligned sequences, our results indicate the potential of deep models of protein evolution to more accurately reconstruct phylogenies that reflect the full spectrum of mutational processes—mutations, insertions and deletions.
Mutational load and structure quality
Models of protein evolution are fundamentally generative in that they can be used to propose a distribution over sequences given a starting sequence and a branch length (that is, the evolutionary time separating those sequences). Unlike classical models, which sample substitutions for each position in the protein’s alignment as a function of branch length, PEINT can generate new sequences with both substitutions as well as new indels. We compared the generative capabilities of the classical models WAG and LG, as well as PEINT, by fixing a starting sequence (x) and decoding a distribution of sequences with progressively larger branch lengths (longer t) (Fig. 2c). We evaluated these sequences for their mutational load, as well as the structural confidence score—predicted local distance difference test (pLDDT)—assigned to them using OmegaFold37, a structure prediction model that uses single sequences as input. All model classes showed similar behaviour in that the average mutational load increased monotonically with evolutionary time and generated comparable numbers of mutations across the evaluated time range (Fig. 2c, left).
However, we found that the quality of generated sequences differed greatly, even controlling for numbers of mutations, with PEINT generating consistently high quality sequences even at high mutational loads (Fig. 2c, right) whereas the classical models show a marked drop in the predicted folding quality of their sampled sequences. We surmise that the ability of a deep learning model such as PEINT to capture epistatic interactions allows it to generate compensatory mutations that account for already mutated positions and thus maintain functionally important contacts. This is a crucial aspect that is new to deep models of evolution, and prompted further investigation into the ability of PEINT to simulate evolution within protein families.
Simulating realistic evolution on trees
Simulations on trees are central to developing and benchmarking phylogenetic methods because true evolutionary histories are generally unknown38. Yet classical independent-sites models often generate sequences that are easily distinguishable from naturally evolved proteins39 and struggle to model realistic indel processes, sometimes relying on insertion patterns extracted from individual alignments40.
We therefore tested whether the ability of PEINT to generate realistic sequences, including indels, along individual branches (Fig. 2c) extends to entire phylogenetic trees (Fig. 3a). We compared PEINT with widely used classical models WAG, LG, LG4X, LG + C60 and LG + S256, spanning single-rate matrix approaches, models with among-site rate variation and increasingly flexible mixture models that capture variation in amino acid preferences across sites (Supplementary Methods). All models produced comparable mutational loads along single branches and throughout the entire pathway down the tree (Extended Data Fig. 3a–c), and generated sequences with generally less than approximately 50% identity to natural sequences (Extended Data Fig. 3d).

a, Simulation setup—existing trees are re-rooted on a randomly chosen leaf sequence. From this root sequence, all internal and leaf nodes are generated progressively using classical (LG or WAG) or PEINT evolutionary models. To account for normal variation within each family, a subtree is retained for evaluation—its distance to the new root node remains unchanged. b, PEINT generates sequences that maintain amino acid usage at conserved sites, whereas simulations using classical models (LG) do not. Example shown for a single family, Human TRAAK. c, J–S divergence of amino acid usage at conserved sites compared with real sequences, aggregated across 545 simulation trees. d, PEINT faithfully recapitulates family-specific indel rates (number of indels per family; each dot represents a family). e, Per-event indel length (number of amino acids inserted or deleted) distribution from PEINT simulation matches closely that inferred from real data. f, When evaluated using AF2Rank, PEINT-generated leaf sequences have pLDDTs that are almost identical to real sequences, and markedly higher than those generated using the best classical model (LG + S256). g, Similar analysis as in f, evaluated using OmegaFold. Boxplots show the median value as the centre, and the box is bounded by Q1 (25th percentile) and Q3 (75th percentile). The whiskers extend to the furthest data point within 1.5× the interquartile range (IQR), with outliers beyond the minimum and maximum of the whiskers shown as individual points.
Sequence evaluation metrics
We first examined whether simulations faithfully capture amino acid usage patterns at conserved sites. For example, the mechanosensitive human TRAAK channel41 has many conserved residues in the selectivity filter of its ion conducting pore, as well as pore-adjacent domains that regulate channel currents42 (Fig. 3b). The expected level of divergence can be captured by examining the real sequences from the evaluation subtree, which show relatively little divergence relative to the other subtree, with a mean Jensen–Shannon (J–S) divergence across sites of around 0.2 (Fig. 3b). PEINT-simulated sequences show a similar level of J–S divergence (around 0.25), mostly with subtle differences in non-pore residues that show lower conservation in natural sequences. In contrast, the LG + S256 model—despite having access to conservation statistics and optimal per-site residue frequencies—struggles to maintain these functionally important sites across the tree and generates sequences with highly dissimilar patterns of amino acid usage across all conserved positions, reflected in a much higher J–S divergence of around 0.42. In general, mutations at highly conserved sites are not tolerated, and it is likely that this level of divergence would lead to non-functional proteins. These results hold over the remaining 545 held-out simulation trees (Fig. 3c and Extended Data Fig. 1b). PEINT accurately recapitulates real patterns of amino acid usage at conserved sites, whereas the classical models show more divergent amino acid usage profiles at these highly conserved positions for each protein family. A complementary analysis of conserved structural environments, represented by Foldseek 3Di states43, supported this finding (Extended Data Fig. 4a,b). Furthermore, PEINT simulations accurately reflect family-specific indel rates (Fig. 3d and Extended Data Fig. 1e–g) and lengths (Fig. 3e). Notably, this correlation is explained only partially by sequence length (Extended Data Fig. 4c) and indicates that PEINT can match the indel dynamics of different protein families in simulation.
Structural confidence scores
We evaluated simulated leaf sequences using both forward-folding models (OmegaFold37 and AF2Rank44) and an inverse-folding model (ESM-IF45) to provide structural confidence scores using models with varying reliance on homology. Across pLDDT from forward-folding (Fig. 3f,g) and structure-conditioned likelihood and sequence recovery from inverse folding (Extended Data Fig. 5d,e), PEINT-generated sequences scored similarly to natural sequences from the same families. PEINT (ESMC), which uses an encoder with better structural understanding at scale than the ESM2 series, further improved upon PEINT (ESM2). In contrast, classical model simulations yielded sequences with poor folding propensity; median pLDDT scores were around 50, with few sequences exceeding 80.
To mitigate the confounding effects of homology biases and the boost of a strong template, we used AlphaFold2 (ref. 17) as an unbiased discriminator by providing MSAs constructed from simulated leaf sequences. MSAs based on classical model-driven simulations frequently yielded low-confidence structure predictions, whereas PEINT-generated MSAs produced substantially higher-confidence predictions, with many falling within the range observed for natural MSAs, despite the latter being explicitly represented in the AlphaFold2 training set (Extended Data Fig. 5).
Because PEINT’s performance tracks the characteristics of their pretrained encoder, what then is the benefit of training PEINT on evolutionary transitions? Indeed, others have explored the use of a base pLM to perform Markov chain Monte Carlo (MCMC) ‘evolutionary’ sampling in sequence space46,47 (Extended Data Fig. 6a). We replicated these approaches in our simulation setup. We found that the strength of the language model was important for judicious evaluation of mutation proposals (Extended Data Fig. 6b), with strong pLM-based energy terms leading to more realistic evolutionary endpoints, but at substantially higher computational cost to reach the expected number of mutations for a given branch (Extended Data Fig. 6c–e). This runtime difference reflects a fundamental distinction between a model of protein sequences and a model of protein evolution. Although both are ultimately trained on the same data (extant protein sequences), PEINT learns directly from evolutionary transitions and conditions explicitly on evolutionary time, effectively amortizing iterative rejection sampling into a single proposal. Consequently, its runtime is constant with respect to branch length. Furthermore, because PEINT places no restrictions on the types of evolutionary transition used for training, it natively generates indels, whereas the MCMC approaches tested here are limited to substitutions.
We further evaluated how these results generalize beyond the train and/or test split we used. We stratified performance by family based on their degree of similarity to training sequences (Extended Data Fig. 7). PEINT simulations remained broadly comparable with natural sequences even for families more divergent from the training data. Inverse-folding scores decreased modestly for these families, but similar decreases occurred for natural sequences, suggesting that they are also challenging for the evaluation models themselves. Together, these results indicate that PEINT captures key features of natural protein evolution and generalizes beyond the sequences it was trained on.
PEINT generates functional enzymes
Carbonic anhydrases are a ubiquitous family of enzymes that catalyse the hydration of carbon dioxide into aqueous bicarbonate. These enzymes balance an exceptional turnover rate (kcat) with poor affinity for substrate (KM)—carbon dioxide is a small, linear molecule with negligible dipole moment. We reasoned that carbonic anhydrase would present a stringent test of the ability of PEINT to realistically simulate evolution while preserving function across large sequence distances. To ensure the generalizability of these results, we selected a held-out tree, and simulated from its seed sequence—that of the β-carbonic anhydrase sequence from cultivated pea (Pisum sativum) (Fig. 4a). Although other β-carbonic anhydrases were present in the training set, by design they show minimal sequence identity to this family, as they come from stringent clustering of the underlying fold space, with a maximal percent identity of approximately 60% to any sequence in the training set. All leaves showed exceptional designability metrics, with OmegaFold pLDDT values above 85 and exact maintenance of the enzyme’s catalytic site (Fig. 4b). This contrasts with simulations using the LG model to suggest substitutions, in which the generated sequences show notably worse structural confidence scores, despite showing similar mutational event burdens (Fig. 4c, top). We also highlight how most leaves generated using either model showed 40–50% sequence identity to any known gene in the National Center for Biotechnology Information nonredundant database, indicating how PEINT naturally explores new regions of sequence space in the process of simulating evolution down a tree (Fig. 4c, bottom). We selected 20 leaves randomly from the PEINT simulation tree for experimental characterization.

a, Starting from the sequence of the P. sativum (pea) β-carbonic anhydrase (β-CA), PEINT and LG simulations were carried out on the same tree without filtering. Simulated leaves are coloured by pLDDT (colour bar). b, Structural predictions of the PEINT-generated leaves are shown, coloured by pLDDT (scale as in a). All sequences maintain the catalytic site (inset) but show structural variation at neighbouring sites that is predicted to maintain protein fold with high confidence. In comparison, the LG simulation leads to sequences with poor structural confidence metrics (pLDDT dots in a). c, Top: both PEINT- and LG-simulated sequences show similar numbers of mutations compared with pea β-carbonic anhydrase, but LG-generated sequences have substantially worse pLDDT scores. Bottom: PEINT-generated sequences show low sequence identity to any extant sequence in BLAST databases, despite their high pLDDT. d, Growth over time in the carbonic anhydrase-free functional complementation assay. Six simulated leaves show growth between that of the pea β-carbonic anhydrase and D152N mutation. Curves show the mean and s.d. from three independent growth measurements. e, In vitro CO2 hydration shows a similar trend. Each curve shows the mean behaviour from n = 4 independent measurements. f, Distribution of kcat parameters for natural carbonic anhydrase enzymes (n = 57) span a large range. To roughly situate PEINT-simulated sequences, empirical kcat values of D152N site mutations are shown (yellow lines). The boxplot shows the median value as the centre, with the box bounded by Q1 (25th percentile) and Q3 (75th percentile). The whiskers extend to the furthest data point within 1.5× the IQR. a.u., arbitrary units; OD600, optical density at 600 nm.
As an initial assay to test the functionality of the simulated carbonic anhydrase genes, we used a functional complementation assay in the Escherichia coli carbonic anhydrase-free48,49 background. This engineered bacterial strain is deficient in endogenous carbonic anhydrase genes and cannot grow in low CO2 concentration in the absence of an exogenously provided functional carbonic anhydrase gene. We transformed the 20 selected leaves, the root sequence50 as a wild-type control and a previously characterized mutant at a conserved aspartic acid residue, D152N (D162N in our construct) that is shown to yield slower, but still marginally functional, carbonic anhydrase enzymes51,52,53. At an intermediate, but not growth-permissive, CO2 concentration of 1%, we found that 6 of the 20 designs could rescue growth better than the D152N mutation (Fig. 4d), although all intriguingly showed a long lag phase phenotype. We followed this growth-based functional complementation assay with an in vitro characterization of CO2 hydration rates. We expressed and purified the wild-type pea β-carbonic anhydrase and the D152N mutant, as well as one of our growth-rescuing simulation endpoints, seq1360, and measured the rate of hydration using the pH indicator assay54 at a saturating concentration of 17 mM CO2 (Supplementary Fig. 3). This assay validated our results from functional complementation, with seq1360 showing a slower rate of hydration than the wild-type enzyme (despite being assayed at a higher concentration), but faster reaction kinetics than the D152N mutant, which is only marginally faster than the uncatalysed reaction (Fig. 4e).
Despite a historical notion that carbonic anhydrase is essentially a perfect enzyme, carbonic anhydrases across the tree of life are not universally perfect in their rates55, with many possessing more modest kcat values in the approximately 104 s−1 range (roughly 1% of the well-known human carbonic anhydrase II enzyme) (Fig. 4f). Although we did not measure full kinetic curves, we can place our functional PEINT-generated sequences approximately relative to independent measurements of the kinetics of mutations at the conserved aspartic acid (D152) in orthologous enzymes from spinach53 and the archaeon Methanobacterium thermoautotrophicum52 (Fig. 4f, yellow dashed lines), which implies that our designed enzymes’ kcat values should fall within the range that is naturally observed in different organisms. It is possible that, by training more broadly on evolutionary transitions across the tree of life, PEINT has learned patterns of evolution from organisms for which the rapid hydration of CO2 is not as imperative as it is in human and plant metabolism, and may predominantly generate enzymes with modest, but measurable, activity.
PEINT improves variant effect prediction
As the need to maintain function constrains protein evolution, extant protein families contain a partial record of millions of years of evolutionary trial and error selecting for a given function. Density models fit on evolutionarily related sequences, either for specific families56 or across the whole tree of life57 have shown to be strong zero-shot variant effect predictors, which means that they do not require access to assay-labelled training data to score variant effects. However, recent works also suggest that increasing scaling of pLMs does not necessarily translate to increased performance on variant effect prediction (VEP) tasks58,59, due potentially to its likelihood being biased towards certain evolutionary neighbourhoods25, suggesting that better accounting for phylogenetic relationships might be a promising approach for improving the performances of these models for VEP. Although some approaches have been proposed to improve VEP with pLMs by accounting for wild-type preference58 or injecting information from homologous sequences at inference time59, our approach can be viewed as a complementary approach, with the potential benefit of more fully leveraging the phylogenetic information from evolutionary data with a flexible model coupled with a principled training objective.
Herein we explored ways to leverage the PEINT framework to predict the effect of substitutions in families from ProteinGym60—a standardized benchmark for protein VEP—by training smaller PEINT models on top of a base pLM (for example, ESM2-150) using cherries from each family in the ProteinGym substitution benchmark. Following ref. 61, we score mutants (mut) using \(\log \left[\frac{p({x}^{\text{mut}}|{x}^{\text{wt}},t)}{p({x}^{\text{wt}}|{x}^{\text{wt}},t)}\right]\), where t is a hyper-parameter controlling the size of the evolutionary neighbourhood around the wild type (wt). At t = 0, all mutants should have zero probability and, as t increases from 0, mutant sequences will be assigned non-zero probabilities, and the extent to which these probabilities change depends on how likely it is that the mutant could have arisen from the process of mutation and selection according to the model.
Each family in the ProteinGym substitution benchmark has been categorized by the assay type of the deep mutational scanning. We found that PEINT offers the largest performance gains on datasets where the assays measure the extent to which mutations affect the growth rate of an organism (Fig. 5a), while improving on the pretrained backbone model ESM2 across all mutational depths (Fig. 5b). The growth rate is a more holistic proxy for the overall fitness constraints imposed on an organism compared with other molecular phenotypes (for example, binding and stability); hence, it stands to reason that a model that is better able to extract information from evolutionarily related sequences would be a better zero-shot variant effect predictor. We saw that PEINT was able to rescue performance in many families where ESM2-150M struggled to generate reasonable predictions (Spearman’s ρ < 0.2) (Fig. 5c,d).

a, Mean Spearman correlation on 201 families in the ProteinGym substitution benchmark60. The families are stratified by assay type: organismal fitness (n = 69), stability (n = 66), expression (n = 16), activity (n = 38) and binding (n = 12). The height of each bar represents the mean of the per-family Spearman correlations for each assay type. Error bars, s.d. across proteins within each assay type. For each model, the average over the mean Spearman correlations for the five assay types is shown in the key on the figure. ESM2, the 150 M parameters ESM2 model; PEINT, a PEINT model trained on transitions of the deep mutational scanning families, using the frozen 150 M parameters ESM2 in its encoder. b, Mean Spearman correlation stratified by mutational depths across 201 substitution assays, with mean and s.e.m. shown for each depth. c, Spearman correlation for each family in the ProteinGym substitution benchmark with the assay type ‘organismal fitness’, where the assays measure the extent to which mutations affect an organism’s growth rate. Each protein family is denoted by its identifier in the ProteinGym dataset. d, ESM2 versus PEINT Spearman correlation for each family in the ProteinGym substitution benchmark with the assay type ‘organismal fitness’.
As the PEINT framework refines the learned representation of ESM2 in its encoder, it can in principle leverage more performant encoders to achieve better performance. To test this hypothesis, we trained additional PEINT models on the larger 650 M parameter ESM2, as well as the recently released 300 M parameter ESMC (Extended Data Fig. 8a). Although both ESM2-650M and ESMC were already more performant than ESM2-150M on the ProteinGym benchmark, in both cases training a PEINT model on these pretrained pLMs led to substantial improvements in predicting the outcomes of organismal fitness assays (Extended Data Fig. 8a,c). In this light, one can view PEINT as a general and principled framework to align pretrained pLMs with evolutionary information and thereby improve their VEP performance to be among the best single-sequence input models on the benchmark (Extended Data Fig. 8a,b).
Mechanistic interpretation of PEINT
Previous studies in mechanistic interpretability of pLMs have focused primarily on encoder-only (bidirectional encoder representations from transformers (BERT)) architectures, revealing that the masked language modelling objective naturally drives such models to learn rich sequence–structure relationships62,63. As PEINT uses the more elaborate encoder–decoder architecture, we focused our attention on the decoder module, as well as inter-module communication. The ‘categorical Jacobian’ calculation, first introduced by Zhang and colleagues63, mutates each position in an input to a deep neural network systematically and measures how these perturbations propagate through the model. It provides a fully unsupervised means to evaluate the inner workings of models that operate on protein sequences. We first applied this technique to investigate the Transformer decoder module of PEINT. As the PEINT decoder works in an autoregressive manner, we perturbed positions in the input to the decoder systematically (that is, the already generated tokens) and measured their effect on downstream model outputs (Extended Data Fig. 9a). This decoder categorical Jacobian63 calculation reveals a highly structured pattern of inter-residue couplings that captures the topological structure of a protein’s contact map (Extended Data Fig. 9b). Evaluated on a larger scale, we find that the strongest couplings learned by the PEINT decoder do correlate with structure, but more weakly than those learned by encoder-only models such as ESM2 (Extended Data Fig. 9c). Indeed, previous work showed that the outputs of ‘mutant cycles’ carried out using autoregressive models are less attuned to direct structural contacts than masked language models64 and we hypothesize that functionally linked, but structurally dispersed, allosteric networks may be a large source of false positives when assayed against a static contact map.
We next investigated how the representations learned by PEINT’s encoder are shared with its decoder module. In the PEINT model for p(y|x,t), we systematically identified positions in the output y that were most affected by perturbations in the input sequence x (Extended Data Fig. 9d). The cross-module categorical Jacobian couplings strongly resembled pairwise alignment trace matrices, suggesting that a large driver of PEINT’s ability to model evolution comes from its learned ability to align representations of the target sequence y with the source sequence x during decoding (Extended Data Fig. 9e). Across around 900 examples of curated alignments from the Pfam-A seed alignments65, we find that PEINT encoder–decoder categorical Jacobian couplings natively recover ground truth alignments with similar accuracy as gold standard dynamic programming based alignment algorithms66 (Extended Data Fig. 9f), despite not being explicitly trained to do so. Taken together, these results suggest that the PEINT encoder and decoder modules serve fairly distinct purposes: the encoder builds a structural representation of the input sequence, whereas the decoder learns to align the target sequence to this representation while also learning patterns of evolution reflective of subfamily specialization.
Discussion
Here we show how to use the composite likelihood objective over pairs of sequences to train a deep model of protein evolution with the PEINT transformer. By moving beyond the independent-sites assumption that has stymied classical models for decades, PEINT demonstrates superlative performance across all facets of evolutionary modelling. The transformative potential of deep models of protein evolution is perhaps best exemplified by PEINT’s capacity for prospective evolutionary simulations. We demonstrate that PEINT naturally simulates evolutionary trajectories that explore new regions of sequence space while maintaining fold and function. The ability to generate realistic evolutionary trajectories at will has many implications for evaluating and improving phylogenetic inference methods, and synergizes particularly well with recent forays into using deep neural networks for this task67. Along similar lines, realistic simulations allow us to ‘replay the tape of life’ under controlled conditions and can help generate testable hypotheses about the evolutionary forces that shape protein families68. By innately capturing higher-order epistatic interactions and indel processes that classical models ignore, deep evolutionary models promise to provide new avenues to advance our understanding of how proteins evolve in nature.
Although classical models learn predominantly general trends of evolutionary drift, deep models of protein evolution can capture both general and family-specific selective pressures critical for maintaining function. This dual capability endows models such as PEINT with the ability to balance exploration and exploitation—as evidenced by maintaining function in evolutionary trajectories that explore new regions of sequence space that are substantially different from known proteins. This outcome naturally lends itself to protein engineering, especially within the machine learning-guided directed evolution framework69. In this context, the ability to generate diverse starting points enables design efforts that can traverse a protein’s functional landscape more efficiently.
Current methods aiming to better align pLMs with variant effect data show mixed results. Simple model scaling yields diminishing returns and leads frequently to overfitting25,26, whereas protein-specific fine tuning can be challenging and unstable57. By conditioning on wild-type sequences and evolutionary time, PEINT provides an encoder-agnostic framework for aligning general pLMs with family-specific evolutionary information. The PEINT framework offers a principled alternative to previous approaches, with a lightweight training scheme that yields substantial performance gains in a matter of hours on a single graphics processing unit. These benefits are most pronounced when evaluating variants encompassing several mutations, as well as on assays representative of general protein function, and showcase how PEINT can tune broadly pretrained pLMs by grounding them in local evolutionary neighbourhoods. As we demonstrated using different ESM models, we note that PEINT is a general framework that can use any pretrained BERT-style pLM as the base encoder model.
In sum, our work lays the foundation for understanding and training deep models of protein evolution on sequence data at scale, and demonstrates their effectiveness across key tasks relevant to interpreting natural protein evolution. We anticipate that future work will refine this framework for specific applications of interest.
Architecturally, we use an autoregressive decoder for its simplicity and access to exact likelihoods for comparison with classical models. However, other generative architectures may be more suitable for simulating sequences with user-defined constraints or incorporating experimental data to bias outputs in specific directions70.
We note that by adopting a more flexible architecture, we trade certain theoretical properties for increased expressivity. For example, we lose the guarantee of time consistency inherent to CTMC-based formulations, in which evolving a sequence from x to y directly over time t1 + t2 is identical in distribution to evolving x for time t1 to an intermediate state z, and then for an additional t2 to reach y. Although PEINT does not explicitly enforce such path composability across intermediate time points, this trade-off allows it to directly model complex indels and non-Markovian sequence dependencies. In practice, we found the resulting deviations from time consistency to be relatively minor over short branch lengths. A principled middle ground is to treat the alignment as a fixed input to a neural network that can learn powerful site-specific evolutionary operators15,71.
On the data front, future work is needed to develop more principled strategies for combining information from different sources. In this study, we train the PEINT transformer on evolutionary transitions spanning a variety of protein families. The importance of this diversity for modelling a given single protein family remains not well understood, and identifying optimal strategies for a user’s protein of interest will require further investigation. This may be especially important for modelling rapid evolutionary processes, such as those seen in viral proteins.
Finally, our current PEINT framework treats protein folds and families as independent evolutionary units. We believe that extending this approach to model protein complexes and multi-domain proteins in a principled way presents both a challenge and an exciting direction for future research.
Methods
Methodological details can be found in the Supplementary Methods, including details about dataset creation, model design and implementation, evaluation of transition likelihoods, ablation studies, simulation of evolution along single branches, branch length estimations, MCMC sampling of evolutionary trajectories, simulation of evolution on phylogenetic trees, simulation benchmarking, assessment of the generalizability of PEINT, model interpretation, variant effect prediction and in vivo and in vitro characterizations of carbonic anhydrases.
Reporting summary
Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.