Generative Flows on Discrete State-Spaces: Enabling Multimodal Flows with Applications to Protein Co-Design
Andrew Campbell, Jason Yim, Regina Barzilay, Tom Rainforth, Tommi Jaakkola
Introduction
Scientific domains often involve continuous atomic interactions with discrete chemical descriptions. Expanding the capabilities of generative models to handle discrete and continuous data, which we refer to as multimodal, is a fundamental problem to enable their widespread adoption in scientific applications (Wang et al., 2023). One such application requiring a multimodal generative model is protein co-design where the aim is to jointly generate continuous protein structures alongside corresponding discrete amino acid sequences (Shi et al., 2022). Proteins have been well-studied: the function of the protein is endowed through its structure while the sequence is the blueprint of how the structure is made. This interplay motivates jointly generating the structure and sequence rather than in isolation. To this end, the focus of our work is to develop a multimodal generative framework capable of co-design.
Diffusion models (Sohl-Dickstein et al., 2015; Ho et al., 2020; Song et al., 2020) have achieved state-of-the-art performance across multiple applications. They have potential as a multimodal framework because they can be defined on both continuous and discrete spaces (Hoogeboom et al., 2021; Austin et al., 2021). However, their sample time inflexibility makes them unsuitable for multimodal problems. On even just a single modality, finding optimal sampling parameters requires extensive re-training and evaluations (Karras et al., 2022). This problem is exacerbated for multiple modalities. On the other hand, flow-based models (Liu et al., 2023; Albergo & Vanden-Eijnden, 2023; Lipman et al., 2023) improve over diffusion models with a simpler framework that allows for superior performance through sampling flexibility (Ma et al., 2024). Unfortunately, our current inability to define a flow-based model on discrete spaces holds us back from a multimodal flow model.
We address this by introducing a novel flow-based model for discrete data named Discrete Flow Models (DFMs) and thereby unlock a complete framework for flow-based multimodal generative modeling. Our key insight comes from seeing that a discrete flow-based model can be realized using Continuous Time Markov Chains (CTMCs). DFMs are a new discrete generative modeling paradigm: less restrictive than diffusion, allows for sampling flexibility without re-training and enables simple combination with continuous state space flows to form multimodal flow models.
Fig. 1A provides an overview of DFMs. We first define a probability flow that linearly interpolates from noise to data. We then generate new data by simulating a sequence trajectory that follows across time which requires training a denoising neural network with cross-entropy. The sequence trajectory could have many transitions or few, a property we term CTMC Stochasticity (Fig. 1B). Prior discrete diffusion models are equivalent to picking a specific stochasticity at training time, whereas we can adjust it at inference: enhancing sample quality and exerting control over sample distributional properties.
Using DFMs, we are then able to create a multimodal flow model by defining factorized flows for each data modality. We apply this capability to the task of protein co-design by developing a novel continuous structure and discrete sequence generative model named Multiflow. We combine a DFM for sequence generation and a flow-based structure generation method developed in Yim et al. (2023a). Previous multimodal approaches either generated only the sequence or only the structure and then used a prediction model to infer the remaining modality (see Sec. 5). Our single model can jointly generate sequence and structure while being able to condition on either modality.
In our experiments (Sec. 6), we first verify on small scale text data that DFMs outperform the discrete diffusion alternative, D3PM (Austin et al., 2021) through their expanded sample time flexibility. We then move to our main focus, assessing Multiflow’s performance on the co-design task of jointly generating protein structure and sequence. Multiflow achieves state-of-the-art co-design performance while data distillation allows for obtaining state-of-the-art structure generation. We find CTMC stochasticity enables controlling sample properties such as secondary structure composition and diversity. Preliminary results on inverse and forward folding show Multiflow is a promising path towards a general-purpose protein generative model.
Our contributions are summarized as follows:
We present Discrete Flow Models (DFMs), a novel discrete generative modeling method built through a CTMC simulating a probability flow.
We combine DFMs with continuous flow-based methods to create a multimodal generative modeling framework.
We use our multimodal framework to develop Multiflow, a state-of-the-art generative protein co-design model with the flexibility of multimodal protein generation.
Background
We aim to model discrete data where a sequence has dimensions, each taking on one of states. For ease of exposition, we will assume ; all results hold for as discussed in App. E. We first explain a class of continuous time discrete stochastic processes called Continuous Time Markov Chains (CTMCs) Norris (1998) and then describe the link to probability flows.
In practice, we need to simulate the sequence trajectory with finite time intervals . A sequence trajectory can be simulated with Euler steps (Sun et al., 2023b)
where the sequence starts from an initial sample at time . The rate matrix along with an initial distribution together define the CTMC.
2 Kolmogorov equation
For a sequence trajectory following the dynamics of a CTMC, we write its marginal distribution at time as . The Kolmogorov equation allows us to relate the rate matrix to the change in . It has the form:
The difference between the incoming and outgoing probability mass is the time derivative of the marginal . Using our definition of , Eq. 5 can be succinctly written as where the marginals are treated as probability mass vectors: . This defines an Ordinary Differential Equation (ODE) in a vector space. We refer to the series of distributions satisfying the ODE as a probability flow.
Discrete Flow Models
A Discrete Flow Model (DFM) is a Discrete data generative model built around a probability Flow that interpolates from noise to data. To sample new datapoints, we simulate a sequence trajectory that matches the noise to data probability flow. The flow construction allows us to combine DFM with continuous data flow models to define a multimodal generative model. Proofs for all propositions are in App. B.
The conditional flow, interpolates from noise to the datapoint . The conditioning allows us to write the flow down in closed form. We are free to define as needed for the specific application. The conditional flows we use in this paper linearly interpolate towards from a uniform prior or an artificially introduced mask state, :
If is a rate matrix that generates the conditional flow , then
Our aim now is to calculate and to plug into Eq. 9. is the distribution predicting clean data from noisy data and in Sec. 3.1.2, we will train a neural network to approximate it. In Sec. 3.2, we will show how to derive in closed form. Sampling pseudo-code is provided in Alg. 1.
We discuss further CTMC sampling methods in App. G. Our construction of the generative flow from conditional flows is analogous to the construction of generative probability paths from conditional probability paths in Lipman et al. (2023), where instead of a continuous vector field generating the probability path, we have a rate matrix generating the probability flow. We expand on these links in Table. 1.
1.2 Training
We train a neural network with parameters , , to approximate the true denoising distribution using the standard cross-entropy i.e. learning to predict the clean datapoint when given noisy data .
2 Choice of Rate Matrix
The missing piece in Eq. 9 is a conditional rate matrix that generates the conditional flow . There are many choices for that all generate the same as we later show in Prop. 3.3. In order to proceed, we start by giving one valid choice of rate matrix and from this, build a set of rate matrices that all generate . At inference time, we can then pick the rate matrix from this set that performs the best. Our starting choice for a rate matrix that generates is defined for as,
Assuming zero mass states, , have , then generates .
as we derive in App. F. Using as a starting point, we now build out a set of rate matrices that all generate . We can accomplish this by adding on a second rate matrix that is in detailed balance with .
3 DFMs Recipe
We now summarize the key steps of a DFM. PyTorch code for a minimal DFM implementaton is provided in App. F.
Define the desired noise schedule (Sec. 3.1).
Train denoising model (Sec. 3.1.2).
Choose rate matrix (Sec. 3.2).
Multimodal Protein Generative Model
We now use a DFM to create a multimodal protein generative model. To generate multimodal data, we will define a multimodal generative flow. We define to factorize over different modalities allowing us to define individually for each one. Our training loss is then simply the sum of the standard flow loss for each modality. At inference time, we can also update each modality individually for each simulation step, using an ODE for continuous data and a CTMC for discrete data. We now apply this capability on protein structure-sequence generation.
A protein can be modeled as a linear chain of residues, each with an assigned amino acid and 3D atomic coordinates. Protein co-design aims to jointly generate the amino acids (sequence) and coordinates (structure). Prior works have used a generative model on one modality (sequence or structure) with a separate model to predict the other (see Sec. 5). Instead, our approach uses a single generative model to jointly sample both modalities: a DFM for the sequence and a flow model, FrameFlow (Yim et al., 2023a), for the structure. We refer to this as co-generating the sequence and structure; hence, the method is called Multiflow.
Sampling. To sample with Multiflow, we integrate along the ODE trajectories for the translations and rotations whilst simultaneously following the CTMC for the amino acid sequence. Each Euler step during sampling has the update:
Related Work
Discrete Diffusion Models. Our continuous time flow builds on work that extends discrete diffusion Hoogeboom et al. (2021); Austin et al. (2021) to continuous time Campbell et al. (2022); Sun et al. (2023b); Santos et al. (2023); Lou et al. (2023) but we simplify and extend the framework. We are not restricted to noising processes that can be defined by a matrix exponential as we just write down directly and we have the freedom to choose at inference time rather than being restricted to the time reversal. We show how DFMs encompasses prior discrete diffusion models in App. H. For molecular retrosynthesis, Igashov et al. (2023) also considered a data conditional process, but did not build a modeling framework around it. Zhang et al. (2023) constructed low-stochasticity rate matrices and their derivation provides the building blocks of Prop. 3.2. Some works have built a multimodal diffusion model for molecule generation (Peng et al., 2023; Vignac et al., 2023b; Hua et al., 2023) whereas we focus on protein co-design using flows. We discuss further related work in App. D.
Protein Generation. Diffusion and flow models have risen in popularity for generating novel and diverse protein backbones (Yim et al., 2023b; a; Bose et al., 2023; Lin & AlQuraishi, 2023; Ingraham et al., 2023). RFDiffusion achieved notable success by generating proteins validated in wet-lab experiments (Watson et al., 2023). However, these methods required a separate model for sequence generation. Some works have focused only on sequence generation with diffusion models (Alamdari et al., 2023; Gruver et al., 2023; Yang et al., 2023; Yi et al., 2023). We focus on co-design which aims to jointly generate the structure and sequence.
Prior works have attempted co-design. ProteinGenerator (Lisanza et al., 2023) performs Euclidean diffusion over one-hot amino acids while predicting the structure at each step with RosettaFold (Baek et al., 2021). Conversely, Protpardelle (Chu et al., 2023) performs Euclidean diffusion over structure while iteratively predicting the sequence. Multiflow instead uses a generative model over both the structure and sequence which allows for flexibility in conditioning at inference time (see Sec. 6.2.1). Luo et al. (2022); Shi et al. (2022) are co-design methods, but are limited to generating CDR loops on antibodies. Lastly, Anand & Achim (2022) presented diffusion on structure and sequence, but did not report standard evaluation metrics nor is code available.
Experiments
We first show that tuning stochasticity at sample time improves pure discrete generative modeling performance by modeling text data. We then evaluate Multiflow, the first flow model on discrete and continuous state spaces. We show Multiflow provides state-of-the-art-performance on protein generation compared to prior approaches that do not generate using a true multimodal generative model. Finally, we investigate Multiflow’s crossmodal properties of how varying the sequence sampling affects the structure.
Results. Text samples are evaluated following Strudel et al. (2022). A much larger text model, we use GPT-J-6B Wang & Komatsuzaki (2021), is used to evaluate the negative log-likelihood (NLL) of the generated samples. The NLL metric alone can be gamed by repeating similar sequences, so the token distribution entropy is also measured. Good samples should have both low NLL and entropy close to the data distribution. For a given value of , we create a Pareto-frontier in NLL vs entropy space by varying the temperature applied to the logits during the softmax operation. Fig. 2 plots the results for varying levels of and sampling temperature. For comparison, we also include results for the discrete diffusion D3PM method with absorbing state corruption Austin et al. (2021). We find the DFM performs better than D3PM due to our additional sample time flexibility. We are able to choose the value of that optimizes the Pareto-frontier at sample time (here ) whereas D3PM does not have this flexibility. We show the full sweep in App. I and show the frontier for in Fig. 2. When , performance is similar due to DFMs being a continuous time generalization of D3PM at this setting, see Sec. H.2. We also include results for an autoregressive model in Fig. 2 for reference; however, we note this is not a complete like-for-like comparison as autoregressive models require much less compute to train than diffusion based models Gulrajani & Hashimoto (2023).
2 Protein generation
Metrics. Evaluating the quality of structure-sequence samples is performed with self-consistency which measures how consistent a generated sequence is with a generated structure by testing how accurately a protein folding network can predict the structure from the sequence. Specifically, either AlphaFold2 (Jumper et al., 2021) or ESMFold (Lin et al., 2023), is first used to predict a structure given only the generated sequence. Our results will use ESMFold but we show results with AlphaFold2 in App. J. Then, we calculate scRMSD: the Root Mean Squared Deviation between the generated and predicted structure’s backbone atoms. The generated structure is called designable if .
Structure-only generative models such as RFdiffusion first use ProteinMPNN (PMPNN) (Dauparas et al., 2022) to predict a sequence given the generated structure in order to then be able to use the self-consistency metric. We present three variants of self-consistency:
Co-design 1: use the sampled (structure, sequence) pair.
PMPNN 8: take only the sampled structure and predict 8 sequences with PMPNN. Then use ESMFold to predict a new structure for each sequence. The final structure-sequence pair is the original sampled structure along with the PMPNN sequence with minimum scRMSD.
PMPNN 1: same as PMPNN 8 except PMPNN only generates one sequence.
PMPNN 8 and PMPNN 1 evaluate only the quality of a model’s generated structures whereas, for co-design models, Co-design 1 evaluates the quality of a model’s generated (structure, sequence) pairs. The comparison between PMPNN 1 and Co-design 1 allows for evaluating the quality of co-designed sequences. PMPNN 8 is the procedure used in prior structure-only works. As our main metric of sample quality, we report designability as the percentage of designable samples. As a further sanity check, designable samples are then evaluated on diversity and novelty. We use FoldSeek (van Kempen et al., 2022) to report diversity as the number of unique clusters while novelty is the average TM-score (Zhang & Skolnick, 2005) of each sample to its most similar protein in PDB.
Training. Our training data consisted of length 60-384 proteins from the Protein Data Bank (PDB) (Berman et al., 2000) that were curated in Yim et al. (2023b) for a total of 18684 proteins. Training took 200 epochs over 3 days on 4 A6000 Nvidia GPUs using the AdamW optimizer (Loshchilov & Hutter, 2017) with learning rate 0.0001.
Distillation. Multiflow with PDB training generated highly designable structures. However, the co-designed sequences suffered from lower designability than PMPNN. Our analysis revealed the original PDB sequences achieved worse designability than PMPNN. We sought to improve performance by distilling knowledge from other models. To accomplish this, we first replaced the original sequence of each structure in the training dataset with the lowest scRMSD sequence out of 8 generated by PMPNN conditioned on the structure. Second, we generated synthetic structures of random lengths between 60-384 using an initial Multiflow model and added those that passed PMPNN 8 designability into the training dataset with the lowest scRMSD PMPNN sequence. We found that we needed to add only an extra 4179 examples to the original set of 18684 proteins to see a dramatic improvement. This procedure can be seen as a single step of reinforced self training (ReST) Gulcehre et al. (2023).
Following RFdiffusion’s benchmark, we sample 100 proteins for each length 70, 100, 200, and 300. We sample Multiflow with 500 timesteps using a temperature of 0.1 (PMPNN also uses 0.1) and stochasticity level . We compare our structure quality to state-of-the-art structure generation method RFdiffusion. For co-design, we compare to Protpardelle and ProteinGenerator. All methods were ran using their publicly released code and evaluated identically.
Our results are presented in Table. 3. We find that Multiflow’s co-design capabilities surpass previous co-design methods, none of which use a joint multimodal generation process. Multiflow generates sequences that are consistent with the generated structure at a comparable level to PMPNN which we see through comparing the Co-design 1 and PMPNN 1 designability. On pure structure generation, we find that Multiflow outperforms all baselines in terms of structure quality measured by PMPNN 8 designability. Multiflow also attains comparable diversity and novelty to previous approaches. We ablate our use of distillation and find that distillation results in overall designability improvements while also improving diversity. Finally, we train our exact same architecture except only modeling the structure on the distilled dataset using the loss presented in Yim et al. (2023a). We find our joint structure-sequence model achieves the same structural quality as the structure-only version, however, additionally including the sequence in our generative process induces extra structural diversity.
Crossmodal modulation. We next investigate how modulating the CTMC stochasticity of the sequence affects the structural properties of sampled proteins. Fig. 3 shows that varying the stochasticity level results in a change of the secondary structure composition (Kabsch & Sander, 1983) of the sampled proteins. This is an example of the flexibility our multimodal framework provides to tune properties between data modalities at inference time.
2.2 Forward and Inverse Folding
Multiflow can achieve state-of-the-art codesign performance, but can accomplish more tasks as described in Fig. 1B and Table. 4. Expanding Multiflow to achieve competitive performance on all tasks is a future work. Here, we take the same model weights for co-design and evaluate forward and inverse folding without additional training. We compare performance to ESMFold and ProteinPMNN which are specialized models for forward and inverse folding. We curated a clustered test-out set of 449 monomeric proteins with length from the PDB using a date split of our training set. Details of forward/inverse folding and these experiments can be found in App. J. We find Multiflow can achieve very close performance with ProteinMPNN while it achieves poor results compared to ESMFold. This highlights a limitation that Multiflow cannot perform competitively at every generation task, but leaves exciting future work for a potential general-purpose generative model.
Discussion
We presented Discrete Flow Models (DFMs), a flow based generative model framework by making analogy to continuous state space flow models. Our formulation is simple to implement, removes limitations in defining corruption processes, and provides more sampling flexibility for improved performance compared to previous discrete diffusion models. Our framework enables easy application to multimodal generative problems which we apply to protein co-design. The combination of a DFM and FrameFlow enables state-of-the-art co-design with Multiflow. Future work includes to develop more domain specific models with DFMs and improve Multiflow’s performance on all protein generation tasks including sidechain modeling.
Acknowledgments
The authors would like to thank Ricardo Baptista, Mathieu Le Provost, George Deligiannidis, Joe Benton, Bowen Jing, Hannes Stärk, Emile Mathieu, Luhuan Wu, Timur Garipov, Rachel Wu, Mingyu Choi, Sidney Lisanza, and Woody Ahern for helpful discussions.
AC acknowledges support from the EPSRC CDT in Modern Statistics and Statistical Machine Learning (EP/S023151/1) JY was supported in part by an NSF-GRFP. JY, RB, and TJ acknowledge support from NSF Expeditions grant (award 1918839: Collaborative Research: Understanding the World Through Code), Machine Learning for Pharmaceutical Discovery and Synthesis (MLPDS) consortium, the Abdul Latif Jameel Clinic for Machine Learning in Health, the DTRA Discovery of Medical Countermeasures Against New and Emerging (DOMANE) threats program, the DARPA Accelerated Molecular Discovery program and the Sanofi Computational Antibody Design grant. IF is supported by the Office of Naval Research, the Howard Hughes Medical Institute (HHMI), and NIH (NIMH-MH129046). The authors would like to acknowledge the use of the University of Oxford Advanced Research Computing (ARC) facility in carrying out this work. http://dx.doi.org/10.5281/zenodo.22558.
Impact statement
In this paper we work to advance general purpose generative modeling techniques, specifically those used for modeling discrete and multimodal data. We apply these techniques to the task of protein generation. Improving protein modeling capabilities can have wide ranging societal impacts and care must be taken to ensure these impacts are positive. For example, improved modeling capabilities can help design better enzymes and drug candidates that can then go on to improve the lives of many people. Conversely, these general purpose techniques could also be misused to design toxic substances. To mitigate these risks, we do not present any specific methods to apply Multiflow to tasks that could be easily adjusted to the design of harmful substances without expert knowledge.
References
Appendix A Organization of Appendix
The Appendix is organized as follows. App. B provides proofs for all propositions in the main text. App. C analyses the cross entropy objective used to train DFM and links controlling the cross entropy to controlling the model log-likelihood. App. D discusses further related work. App. E shows how DFM can be applied to multidimensional data through applying factorization assumptions to . App. F gives concrete realizations with PyTorch code for DFM using the masking or uniform forms for . App. G discusses methods for sampling from CTMCs and discusses their relation to our sampling method. App. H compares DFM to classical discrete diffusion models in discrete and continuous time finding that they can be fit within the DFM framework. App. I gives further details and results for our text experiment. App. J gives further details and results for our protein co-design experiments.
Appendix B Proofs
When writing rate matrices, , we will assume unless otherwise explicitly stated.
We write .
B.1 Proof of Proposition 3.1
B.2 Proof of Proposition 3.2
In the main text we provided the form for under the assumption that for all . Before proving Prop. 3.2, we first give the full form for . First, assuming and we have,
For our proof, we assume that . This assumption means that when we have dead states with zero probability mass, they cannot be resurrected and gain probability mass in the future. We begin the proof with the Kolmogorov equation for processes conditioned on ,
We will now verify that satisfies this Kolmogorov equation and thus generates the desired conditional flow. We will first check that the Kolmogorov equation is satisfied when . With this form of rate matrix, the RHS of equation (30) becomes
In the case that by assumption we have that . We have both and because . Therefore we have and thus the Kolmogorov equation is satisfied.
Intuitively, we require the assumption that dead states cannot be resurrected because is designed such that all states can equally distribute the mass flux requirements of making sure the marginal derivatives are satisfied. If there is a state for which but then this state would require mass from other states but could not provide any mass of its own since . This would then violate the sharing symmetry required for our form of . We note that this assumption is not strictly satisfied for the masking interpolant at or and not satisfied for the uniform interpolant at . However, it is satisfied for any and so we can conceptualize starting our process at , , , approximating a sample from with a sample from and running the process until and stopping here. The approximation can be made arbitrarily accurate by taking .
B.3 Proof of Proposition 3.3
A rate matrix that satisfies the detailed balance condition (13) will result in when simulating with this rate. This can be seen by substituting into the conditional Kolmogorov equation (30)
B.4 Proof of Proposition 3.4
We will assume we have dimensional data with each . We give an overview of how our method operates in the multi-dimensional case in Appendix E. Namely, we assume that our conditional flow factorizes as . We also assume that our rate matrix is for jumps that vary more than dimension at a time. Our optimality results are derived under these assumptions.
We first prove that achieves the minimum number of transitions for the masking interpolant case. We have
with . Substituting in and in the masking case gives
We refer to Appendix F.1 for the details of this derivation. Since depends only on , and and not values in any other dimensions, each dimension propagates independently and we can consider each dimension in isolation. Consider the process for dimension . The CTMC begins in state . We have . Therefore, the only possible next state that the process can jump to is . Once the process has jumped to , the rate then becomes . We also know that the process must jump because , and we know our rate matrix traverses our desired marginals by Proposition 3.2. Therefore, exactly one jump is made in dimension . In total, our dimensional process will make jumps. Under our factorization assumption, during a jump no more than one dimension can change value. Therefore, the absolute minimum number of jumps for any process that starts at with and ends at , is . Our prior distribution is and so for any sample, we will always need to make jumps. Therefore, the minimum expected number of jumps is and achieves this minimum.
B.4.2 Uniform Interpolant
We now prove that achieves the minimum number of transitions for the uniform interpolant case. The conditional flow is
With this interpolant, our rate matrix becomes
B.4.3 Discussion
We have proven conditioned optimality only for the two simple conditional flows featured in the main text and we note that this result in not generally true for any conditional flow. Intuitively this is because treats the distribution of mass symmetrically between states, considering only the local differences in between pairs of states. In general, the optimal rate would need to solve a global programming problem.
Appendix C Analysis of Training Objective
Before beginning the proof, we introduce path space measures for CTMC processes, following the exposition in Del Moral & Penev (2017), Chapter 18. A path of a CTMC is a single trajectory from time to time . The trajectory is a function that is everywhere right continuous and has left limits everywhere (also known as càdlàg paths). Intuitively, it is a function that takes in a time variable and outputs the position of the particle following the trajectory at that time. The càdlàg condition in our case states that at jump time we have taking the new jumped to value and being the previous value before the jump, see Fig. 1B.
For an exponential random variable with time-inhomogeneous rate, the cumulative distribution function is given by
In other words, we simply start a new exponential timer once the previous jump occurs and the same equation carries through.
where is the initial state distribution.
We begin by marginalizing out the latent variables, , for our generative CTMC
We now apply Girsnov’s transformation using our conditioned CTMC
we note at this point that and the two intial distribution terms cancel out. Now, apply Jensen’s inequality
and take the expectation with respect to the data distribution
where we have used our definition of the jump distribution of
Substituting this into our form for given in equation (79) gives
Substituting this into our original bound on the model log-likelihood gives
and is a constant term independent of .
In the next stages of the proof, we going to show that is the weighted cross-entropy, is a regularizer towards the arbitrarily chosen conditioned rate matrix that we argue we can ignore and is a KL term that we will absorb into the bound on the model log-likelihood.
In order to proceed, we will need to make use of Dynkin’s formula
where is a two-argument function. This formula can be understood intuitively as allowing us to switch from a sum over the jump times to a full integral over the time interval appropriately weighted by the probability that a jump occurs and the destination to which a jump goes to.
We first show that is the weighted cross entropy.
We now analyse the term . We will show that it is approximately equal to an objective which at its optimum sets the learned generative rate matrix to have the same overall jump probability as the arbitrarily chosen rate matrix that generates our conditional flow.
We will denote the approximate form of as .
We then split into three terms . We have seen how the term allows us to remove the standard training signal for the denoising model and replace it with the cross entropy, creating the term. This creates a looser bound if we are to train without the term,
We then argue that is close to which is an unnecessary forcing term encouraging our generative rate to achieve a similar jump rate to our chosen even though this matrix is an arbitrary decision and will have a different jump rate depending on which is chosen. We are then left with the standard cross entropy term as our final objective for with a final modification to its unweighted form for implementation ease.
C.2.1 Objective for the Masking Interpolant
In this section we will show that is exactly the weighted cross entropy for the case when we use the masking form for . We note that a similar result has been proven by Austin et al. (2021) for the discrete time diffusion model, and here we verify that this result also holds for our DFM model. We will assume multi-dimensional data, . We refer to Appendix E for the details of the multi-dimensional setting. We will also assume that we use as our rate matrix that generates the conditional flow.
Before we manipulate , we will first find the forms of , and for the masking case. From Appendix F.1, equation (209) we have,
From Appendix F.1, equation (212) we have that,
We now find
where on the final line we have used the fact that .
We are now ready to manipulate the form of . We start with
We now substitute in the masking forms for , and
where we have moved terms that don’t depend on into the constant.
where we have arrived at the weighted cross entropy, weighted by and only calculated for dimensions that are masked in our corrupted sample .
Appendix D Discussion of Related Work
There have been post-hoc changes to the sampling process made in prior work e.g. corrector steps used by Campbell et al. (2022), however due to the ELBO maximizing the model log-likelihood under the assumption of sampling using the time-reversal, the diffusion framework still revolves around one ‘canonical’ sample time process (the time-reversal) whereas DFM makes it clear this choice is arbitrary and the sample process can be chosen at inference time for best performance.
Previous discrete diffusion works have also suggested alternatives to the ELBO. Sun et al. (2023b) introduce a categorical score matching loss that resembles the cross entropy, however, the denoising network is required to make a prediction based only on the other dimensions of the input noisy state, . This requires specialized architectures and methods to remain computationally efficient. Vignac et al. (2023a) propose to learn a diffusion based model solely using the cross-entropy but do not analyse the link between the cross-entropy and the log-likelihood of the model as we do in App. C. Meng et al. (2022) propose to learn a discrete score model based on data ratios using an L2 based loss which has some undesirable properties such as not penalizing mode dropping as described by Lou et al. (2023). Lou et al. (2023) refine this approach and propose to learn data ratios using the score entropy loss which, like the standard cross entropy, does not depend on the choice of forward rate matrix. However, in order for the score entropy to be a true ELBO, the forward rate matrix needs to be used as a weighting factor.
Multimodal diffusion models have been applied to tabular data Kotelnikov et al. (2023) where continuous diffusion is used for continuous features and a uniform style of corruption under a discrete diffusion framework is applied to discrete features. This idea was then expanded to molecule generation where the task is to generate a molecules atom types, their positions and their connectivity. Peng et al. (2023) use a masking process for the discrete atom types and bond types with a continuous space process for the atom positions. Vignac et al. (2023b) use a discrete process converging towards the independent marginal distribution in each dimension (Vignac et al., 2023a) for atom types, bond types and formal charges of the molecules along with a continuous process for atom positions. Hua et al. (2023) use a uniform discrete process for bond types with a continuous space process applied to atom positions as well as atom features embedded in continuous space. These works also investigate the importance of the multimodal noise schedule. Peng et al. (2023) find that corrupting the bonds first and then the atom positions improves performance by avoiding unphysical bonds appearing in the corruption process. Vignac et al. (2023b) have a similar finding that during corruption, the atom types should be corrupted first, then the bond types and finally the atom positions. We generalize these ideas by using the approach of Albergo et al. (2023) and learning our model over all relative levels of noise between our modalities. This allows picking the desired path through the multimodal noise landscape at inference time either performing co-generation, inverse folding or forward folding.
Other approaches for discrete data modelling opt to embed the data into a continuous space in order to still use the continuous diffusion framework Li et al. (2022); Chen et al. (2023); Richemond et al. (2022); Gong et al. (2023); Dieleman et al. (2022); Han et al. (2022); Strudel et al. (2022); Gulrajani & Hashimoto (2023); Floto et al. (2023), however, this loses the discrete structure of the data during generation. This can be important when the quantity that is represented by the discrete variable as algorithmic importance. For example, Qin et al. (2023) perform sparse graph generation where the discrete token represents the existence of an edge. It is then important for the edge to be known to physically exist or not so that sparse graph networks can be applied to the problem.
General Fokker-Planck equations on discrete state spaces Chow et al. (2012) have been used to construct sampling methods for energy functions Sun et al. (2023a). Further, in a generative modelling context, the Kolmogorov equation has been used to construct equivalent diffusion processes with fewer transitions Zhang et al. (2023) making links to optimal transport. We take this idea further to build a generative modelling paradigm around the flexibility of the Kolmogorov equation.
The consideration of flows on discrete state spaces has also been used to construct GFlowNet algorithms Bengio et al. (2023) which aim to sample from a given energy function. Here we instead focus on the the generative modeling context where we aim to sample novel datapoints when only given access to some dataset of training examples. GFlowNets also can use the detailed balance equation Eq. 13 as a training training objective. Detailed balance is also used in Markov Chain Monte Carlo methods (Metropolis et al., 1953; Hastings, 1970) to construct a transition probability with the desired energy function that we wish to sample from as its stationary distribution. In our work, we use the detailed balance condition as a way to increase the inference time flexibility in our framework
Appendix E Multidimensional Data
In this section we derive how we can efficiently model dimensional data, by using factorization assumptions. When we wish to emphasize the multidimensional aspect we can write and use to refer to the value in dimension . We use to denote all dimensions except . To operate in multidimensional spaces, we will make the following assumptions
Assumption 1
Assumption 2
Assumption 3
The first assumption creates independent corruption processes in each dimension, similar to the factorization assumptions made in diffusion models where the forward noising processes proceed independently in each dimension. Assumption 2 is the same assumption we made in order to derive in -dimension but now we assume it individually for every dimension. Finally, assumption 3 states that for our data conditional rate matrix, it decomposes into a sum of rate matrices for each dimension and so the rate for transitions that change more than dimension at a time are 0. This is the same assumption made by Campbell et al. (2022) in order to make calculations tractable. We will enable our process to make multiple dimensional changes simultaneously later when we come to derive our sampling algorithm.
Under these assumptions, we will now derive DFM for the multidimensional case. We start with the data conditional Kolmogorov equation
We now substitute the form for the rate matrix under Assumption 3 into the RHS of (158) to get
where we use to denote a vector of dimension where in the -th dimension it has the value of and in the other dimensions it has values . We now verify that the following form for satisfies the Kolmogorov equation,
where and we only define for off-diagonal entries, remembering that .
We first assume and substitute in into equation (160).
where we have used the fact that .
For the case that there exists a for which we have by assumption. We first examine the LHS of equation (158) in this case.
where we use to mean all dimensions except and . We now examine the RHS of equation (158).
where we have used the fact that because Therefore, for both cases we have satisfies the conditional Kolmogorov equation (158) and thus we have found a rate matrix that generates our desired conditional flow. The final step is to convert this rate matrix conditioned on into an unconditional rate matrix that can be used for generative modeling. We first write down the unconditional multi-dimensional Kolmogorov equation
We now make the following assumption for the form of the unconditional rate matrix and verify that it indeed satisfies the unconditional multi-dimensional Kolmogorov equation, (181).
with being given by (161). Substitute this form into (181)
where we have used Eq. 160 with the fact that we know given by Eq. 161 satisfies the conditional Kolmogorov equation Eq. 158. We have now verified that the rate given by Eq. 182 gives us our desired unconditional flow and we can use it for generative modeling.
In order to approximate the true generative rate matrix given by equation (182), we need approximations to the denoising distributions in each dimension, , for . We can parameterize these conditionally independent distributions through a neural network that outputs logits of shape when given input of shape . We then apply a softmax to the logits to obtain approximate denoising probabilities , of shape . We learn the parameters of the neural network with the cross entropy loss for each dimension
E.2 Sampling
The standard Euler step transition probability for our CTMC defined through our learned denoising model with time step is
We note this sampling method is similar to the tau-leaping method used in prior CTMC based approaches Gillespie (2001); Campbell et al. (2022) however tau-leaping allows multiple jumps to be made in the same dimensions which is unsuitable for categorical data.
E.3 Detailed Balance
In this section we verify that if we achieve detailed balance individually and independently in each dimension, then our full dimensional process will also be in detailed balance.
Consider the multidimensional detailed balance equation
Now, substitute in our factorized forms for and
Now, both sides are for when and differ in more than one dimension. Consider the case when they differ in exactly one dimension, call it . The detailed balance equation simplifies to
which we note is the standard single dimensional detailed balance equation for dimension . Therefore, if our matrices are all in detailed balance with their respective conditional marginals, then the full dimensional rate matrix will also be in detailed balance with the full dimensional conditional marginals .
Appendix F Implementation Details
In this section we provide concrete derivations of our DFM method. We use a masking process in Sec. F.1, a uniform process in Sec. F.2 and explore the general case for any given in Sec. F.3. We also provide minimal PyTorch implementations for our training and sampling loops in each case. We will assume multi-dimensional data under the factorization assumptions listed in App. E.
Notebooks containing these minimal examples can be found at https://github.com/andrew-cr/discrete_flow_models.
Here, we assume the masking form for . We begin by writing this data conditional flow
This is the distribution we will use to train our denoising model . PyTorch code for the training loop is given in Listing LABEL:lst:masking_training
We will also derive the form for . For this we need to find .
We can now find . When working with rate matrices in this section, we will always assume and calculate the diagonal entries as later. We note that for or . Further, our initial distribution . Therefore, at all points in our CTMC, is only ever or . Furthermore, we only ever have to consider transitions to a that is either or . Now, for and we have
We note here that our calculation may not strictly be valid for exactly or but are valid for any and so we can simply ignore these edge cases, see Sec. B.2 for further discussion. Now we find our unconditional rate matrix
Listing LABEL:lst:masking_sample shows PyTorch code that implements this sampling loop.
for some constants and that we must find. Substituting this into the detailed balance equation along with the masking interpolation form for gives
This equation must be true for all . Pick and to get
We now combine this rate with that we calculated previously to find a new unconditional rate matrix with a variable amount of stochasticity.
where on the final line we have used the fact that for and when because if a dimension is unmasked then it must be the true value under our definition of . We now find our transition probabilities
where again we have used the fact that . Inspecting for , we see that if then we have an overall probability of unmasking of and once we do unmask, the new value is drawn from . This is like before but now there is a bonus probability of unmasking of . When then we have a probability of of jumping back to the mask state. This creates a flux of states switching back and forth between masked and unmasked for hence why these processes are more ‘stochastic’. However, because when is increased we also increase the rate at which we unmask, the desired conditional flow is maintained for any value of . Listing LABEL:lst:masking_sample_with_noise shows PyTorch code that implements sampling with this extra stochasticity.
Our method has similarities to other discrete diffusion models when using this form for and we clarify these links in Sec. H.2.
F.1.2 Purity Sampling
When using the masking form for we can also easily implement a purity sampling scheme Tang et al. (2022). This sampling method decides which dimensions to unmask based on an estimate of the model confidence in that dimension’s final value. Currently, our sampling method will uniformly at random choose which dimension to unmask. To improve upon this approach, purity sampling will instead rank dimensions based on which dimension has the highest model probability. More specifically, for each dimension we calculate a purity score for dimension defined as
For the next simulation step, we then decide how many dimensions should be unmasked. The number of dimensions to unmask is binomially distributed with probability of success and number of trials equal to the number of dimensions that are currently masked. Once we have sampled a number of dimensions to unmask from this binomial distribution, we then unmask that number of dimensions starting from the dimension with highest purity score, then the dimension with second highest purity score and so on. We only consider dimensions that are currently masked to be eligible for unmasking. When using , the probability of success in our binomial distribution increases to and so on average more dimensions get unmasked during each simulation step. At the end of each simulation step, we then remask a sample of randomly chosen dimensions which are uniformly chosen at random each with a probability of being chosen.
F.2 Uniform Example
In this section we walk through the derivation and implementation of DFM when using the uniform based interpolation distribution. We start with the data conditional marginal distribution
This distribution is all that is needed to train the denoising model . We give PyTorch code for the training loop with the uniform interpolant in Listing LABEL:lst:uniform_training.
In order to sample our trained model, we will need to derive . The first step is to find ,
We will now find . As before we will always assume and calculate diagonal entries as needed using the relation .
The only non-zero value is when and and so is
We can now find the unconditional rate matrix, still assuming
Listing LABEL:lst:uniform_sample shows PyTorch code that implements this sampling loop.
Now, this equation must be true for any . Pick and to get
This can now be combined with to create a new unconditional rate matrix with a variable amount of stochasticity.
We can interpret this rate, with the first term being the rate at which we should transition to states that are predicted to correspond to the clean data. The second term is a ‘noise term’ which creates transitions away from the current state if it is predicted to correspond to the final clean data. The first term then has additional weighting as is increased to counter act this effect. The effect of the stochasticity is then to create a flux going on and off the predicted final clean state during generation. We now find our transition probabilities
We can find for programmatically as before by requiring that the probability vector sum to . Listing LABEL:lst:uniform_sample_with_noise shows the implementation for the uniform interpolant with noise.
F.3 General Case
We now describe the training and sampling loop for a general conditional flow . We require this interpolant to be factorized, , be differentiable and have . We assume that we have access to functions that can sample from , evaluate and evaluate . Our training loop consists of sampling data, sampling and training with the cross entropy loss, see Listing LABEL:lst:general_training.
Appendix G CTMC Sampling Methods
The form of this update means that we don’t necessarily need to calculate the full expectation over . We can simply sample from and then plug this sample into which we then use in the Euler update. To see that this strategy still samples from the same distribution over , we can write the distribution over as ,
and so can be seen as the marginal of joint distribution . Therefore, to produce a sample from , we can instead sample from the joint distribution , and take only the part of this joint sample.
Another method to simulate a CTMC is -leaping, Gillespie (2001); Campbell et al. (2022) which allows multiple jumps to be made both across dimensions and within each dimension. Multiple jumps within a single dimension does not make sense for categorical data where there is no ordering, however, it can be useful for ordinal data such as a discretized image where the -leaping update allows multiple jumps to be applied at once to cover a larger distance. To calculate a -leaping update, a Poisson random variable needs to be drawn with the rate matrix giving the rate parameter. Therefore, for this type of update, the full unconditional would need to be calculated.
We finally note that there is a body of work creating CTMC samplers for generative models (Sun et al., 2023b; Lou et al., 2023) that may be faster to simulate than the standard Euler step. In this work, we focus on framework simplicity, not optimizing for sampling speed and leave application of these approaches as future work.
Appendix H Comparison with Discrete Diffusion Models
In this section we clarify the relationship between DFM and classical discrete diffusion models. In Sec. H.1 we compare to continuous time models using the uniform corruption process as an example. In Sec. H.2 we compare to discrete time models using the masking process as the example.
Here we compare to continuous time discrete diffusion models (Campbell et al., 2022) using the uniform corruption process as an example. In this section, we will assume is pure noise and is clean data which we note is a flipped definition of time to classical diffusion models to aid in our comparison with DFMs.
To calculate we can use the equation
where and is the element wise exponential. By the symmetry of the problem, we can infer that will have only two possible values. Either and we are finding the probability of staying at , or and we are finding the probability of having left , and since uniform corruption treats all states equally, these will be same quantities for any starting state and any state . So to find our schedule we just need to consider one element of the matrix . Let us consider an off-diagonal element of , which will have probability
We will try and match this to the simple linear schedule that we have had as our running example in the explanation of DFM.
The next step in a discrete diffusion model is to find the time reversed rate matrix which gives a CTMC that runs in the opposite direction to and generates novel data from noise. Here is running from time at noise towards clean data at . From Campbell et al. (2022), we have
We notice a similarity to the DFM equations, where the generative rate is the expectation of a quantity with respect to . Indeed we now show that is a conditioned rate matrix that achieves the conditional flow . Consider the Kolmogorov equation
Substitute in our form for
where on the second to last line we have used the fact that the corruption matrix when started at will evolve the marginals according to because this is how we derived in the first place. Note runs in the reverse direction hence the negative sign.
with and being fully flexible (provided they are positive). Using the form for that we derived in Appendix F.2 we have
which is equal to if we have .
In summary, we have found that classical discrete diffusion models make an implicit choice for which corresponds to a certain level of stochasticity in the CTMC and that the choice is made at training time because the rate matrix is used in the ELBO objective. Further, we have seen it is much harder to derive the noise schedule in classical discrete diffusion models due to the need to be able to apply the matrix exponential to . In DFM, we can simply write down the noise schedule we want and we are not restricted in having to pick that are amenable to matrix exponentiation. We also get to choose any at test time rather than being fixed to the implicit choice of .
H.2 Discrete Time Discrete Diffusion Models
In this section we will clarify the link to the discrete time diffusion method D3PM (Austin et al., 2021) when using the masking process for both methods. Here, we will use the convention from Austin et al. (2021) of using for clean data and for noise.
We will first summarize the key results from Austin et al. (2021) when using the absorbing state process which is a different name for a masking type process (the mask is the absorbing state). can take on any discrete value in . The diffusion model is first defined using a noising transition kernel
From this transition kernel, we can then calculate the noise marginals,
We then define our generative reverse process as
Continuing with the D3PM example using the absorbing state process, we obtain the following form for
When we set , we obtain a linear noise schedule giving
Now, let us define to be the proportion that the process is through the total number of time steps. and if we consider it to be an analogue of our continuous time variable, we can see that the original discretization steps of D3PM correspond to a discretization of the $\Delta t=\frac{1}{T}$. Substituting these definitions into our update step gives,
Appendix I Text Experiment Details
Code for our text experiments can be found at https://github.com/andrew-cr/discrete_flow_models.
For our denoising network we use the transformer architecture Vaswani et al. (2017) as implemented in the nanoGPT repository, https://github.com/karpathy/nanoGPT. We generally follow the smallest GPT2 architecture Radford et al. (2019). At the input we have our input tokens of shape where is the batch size and is the number of dimensions i.e. the sequence length, our time of shape , and, if we are self-conditioning, prior prediction tokens of shape . We embed the and tokens using the same learned embedding, and use a model embedding size of resulting in tensors of shape . We embed the position of each token using a learned embedding for each possible position. We embed the time , using Transformer sinusoidal embeddings following Ho et al. (2020). We train all our diffusion models with self-conditioning Chen et al. (2023). To input the prior prediction, we stack the embedded tensor with the prior prediction token tensor to obtain a tensor of shape . We then apply a linear layer to project down to the model embedding dimension resulting in a tensor of shape . Before applying transformer blocks, we add together the (and ) embedding tensor, the position embedding and the time embedding to obtain the final input tensor.
The transformer stack consists of transformer blocks, each block consisting of a LayerNorm, SelfAttention, LayerNorm, MLP stack. Within our SelfAttention block, we use heads and apply Qk-layernorm Dehghani et al. (2023) to our query and key values as we observed this improved convergence. Our MLP blocks consist of a linear layer, followed by a GELU activation, followed by a linear layer. We do not apply dropout. Our output layer consists of a linear head with output dimension . We use token categories, lower case letters, a whitespace character and a mask token. The model outputs logits of shape which we then apply a softmax to, to obtain probabilities.
The dataset text8 is MB of text data from English Wikipedia. The text is all converted to lower case letters, i.e. capital letters are converted to lower case and numbers are written as text, i.e. becomes ‘eight’.
During training, we use a batch size of with gradient accumulation steps. We train on sequences of length . The model is therefore trained on tokens per gradient update. To train self-conditioning, on of training iterations, we input prior prediction tokens as all masks so that the model learns to be able to predict without any prior information. On the other of training iterations, we perform two model forward passes. We first predict using masks as the prior tokens to obtain an initial set of logits. We then sample from the initial distribution to obtain predicted tokens. We then feed these tokens back into the model through the self-conditioning input and predict the logits once more. These logits are then used in the loss. We only back propagate through the second forward pass of the model.
When training the D3PM model, we found that the default cross entropy weighting of (with a flipped definition of time) resulted in poor convergence and so we applied an equal weighting of the cross entropy across time to be consistent with the DFM loss.
We train our D3PM and DFM models for k iterations on 4 Nvidia A40 GPUs using a learning rate of and linear warm up steps. We use a cosine decay schedule after the initial warm up towards a minimum learning rate of which would be reached at M iterations. We use the AdamW optimizer Loshchilov & Hutter (2017) with weight decay parameter . We monitor the validation loss throughout training. Validation loss continues to drop throughout training and we evaluate the final model in our experiments. When training the autoregressive model, we use the same architecture but find that it begins to overfit the data much faster than the diffusion based models. After iterations the validation loss begins to increase and so we use the model with minimum validation loss in our evaluations. This is consistent with findings that autoregressive models require much less compute to converge than diffusion based models Gulrajani & Hashimoto (2023).
We use the masking interpolant in our DFM with linear interpolant, as described in Appendix F.1. For D3PM, we use the absorbing state corruption process, the links to the DFM process are described in Appendix H.2.
For evaluation, we sample the DFM with . We simulate up to and then for any remaining tokens that are still mask, we set them to the most likely token under the model’s denoising distribution, . We stop simulating at to avoid any singularities similar to how diffusion models stop near . For D3PM we train with timesteps to match DFM.
For each temperature setting applied to the logits, we sample sequences all of length tokens. We then calculate the negative log-likelihood assigned to each sequence using GPT-J-6B Wang & Komatsuzaki (2021) and the BPE tokenizer Radford et al. (2019). We then average the negative log-likelihoods over the sequences. The sample entropy is calculated by first tokenizing with the BPE tokenizer and then calculating the entropy as where is the empirical probability of token estimated using the full set of samples. Tokens for which are not included in the sum. For reference, the dataset achieves a negative log-likelihood of 4.2 as measured by GPT-J-6B.
Here we examine the effect of the noise level on the sample quality of generations from our DFM method. We follow the follow the same procedure as before but vary with values . We plot the results in Figure 4. We find that generally, as the noise level increases, we lower our negative log-likelihood. However, we find that if the noise level is increased too much, then degenerate behaviour can occur, for example when , at high logit temperatures the negative log-likelihood increases and the sample entropy decreases away from the dataset. Observing the samples, we find that the model generates incoherent text at this point. We find that the intermediate noise level provides good sample quality whilst avoiding this behaviour.
I.2 Example Text Generations
In this section we provide non cherry picked generations from the text models. For each model we have swept over the temperature applied to the logits and it would be impractical to include examples for all models for all temperature settings. Instead, we select one temperature setting for each model such that the samples have similar entropy but vary in negative log-likelihood. We show the selected temperature settings in Figure 5.
D3PM Temperature 0.8 Samples: ved as a personal area to form the five counties of the area and a country with their own which is usually called paris gietgothic can also lead an area to work in divisions over a pileur as in the name of man the bears have over the last two years from th one five zero zero zero zero press money to present this to a meschasel linear industrial base ulse sudan expanded its economy and accounts for car prices and two eight five more than one zero zero of the largest industrial inventions over the world were eed alternatively as human being and the anti constitutionalay doctrines a particular example of the concept is one reason for human rights or as in certain regions there is a double constitution more recognized region of europe in this region the glass an DFM Temperature 0.8 Samples: ed era vol seven one nine one one december one nine six one junju that s one of nine one one country page of love footnote pages charles s feadman history of the red sea corea one nine nine one red sea vol one january one nine nine seven flying profiles ch allowes the vectores to be composed as systems of data for example no machine is a computer one would do not know where there are undirected storage of other data storage particularly the computer science eve to substitute such a based data that is one of me io the plate n and feminine along the trail to change the amount of naturated information in the start tape selective figurative memory the mind is determined by the second net on the string c with two buttons the tag retes the header when queued the se Autoregressive Temperature 0.9 Samples: licklyn american football coach to holy roman emperor and roman stories radio and facilities in the u s civil rights movement the dc circuit collection of the witches leading the transissario times and spinoffs to american cartoonists cartoonist kyle marci the british one one eight four minamoto minister or al di nortello ministries son of monte oise klepe which chose to give up its character on the go he was known to publish a wade of white performances started in one eight five one kleine married the gigan mausoleum in one eight one six alabama was engaged by a large scale as we know alabama migration the palace of westminsters and proceeded to father she also learned to speak with the abramic mouth of the space the replica was apparently built de provence g DFM Temperature 0.8 Samples: e curous greek by alexander van hep ven see archaic origin of the word cupola another meaning suggests that the word kupola is the latin word cupei kupolum old german derived from the latin word for the river the name comes from a latin word for tree with es so balloonists refine this combination specifically to preserve your own land in the runner both examples of clean steering creating agout like rods that produced successful rods and for the end the first few pistols compact stunt a musical setting mult by reign over agassi is considered a greatest match by the day he will never play and will continue to be imitated agassi can play determinedly but agassi would always look to the victorious build he should not finish years going up to then that he would b
Appendix J Protein Generation Experiment Details
We present additional experiment details and results for protein generation with Multiflow.
Code for Multiflow and experiments can be found at https://github.com/jasonkyuyim/multiflow
We use an architecture modified from the FrameDiff architecture from Yim et al. (2023b). This architecture consists of Invariant Point Attention (Jumper et al., 2021) combined with transformer blocks, we refer to Yim et al. (2023b) for in-depth details. We modify this network architecture by increasing the number of network blocks to 8, increasing the number of transformer layers within each block to 4, decreasing the number of hidden channels used in the IPA calculation to 16, removing skip connections and removing psi-angle prediction. To enable our model to output logits for the discrete distribution, we add an output 3 layer MLP with the same embedding size as the main trunk. This results in a network with 21.8M parameters.
In Yim et al. (2023b), psi-angle prediction is used to infer the location of oxygen atoms, however, this position can be inferred to high accuracy using prior knowledge of the backbone structure of proteins, following Yim et al. (2023a).
J.2 Additional Multiflow Results
We show results of Multiflow across more lengths than done in Sec. 6.2.1 and show that using the ESMFold oracle for data distillation still gives improved performance when we switch the evaluation oracle to AlphaFold2.
Our results in Sec. 6.2.1 only evaluated 4 lengths (70, 100, 200, 300) to match the benchmark in RFdiffusion. However, other works have evaluated designability across all the lengths the method was trained on. We follow Protpardelle (Chu et al., 2023) to use Multiflow in generating 8 samples per length in the range 50, 51, , 400. Fig. 6 shows the results in the same format as Figure 2B in Protpardelle. We see Multiflow achieves near perfect designability up to around length 350 at which point designability starts to drop. This is expected since Multiflow was only trained on lengths up to 384, but also demonstrates the ability to generalize beyond the lengths it was trained on. We see Multiflow also achieves a desirable spread of secondary structure. We show samples above length 370 with the highest and lowest Co-design 1 RMSD in Fig. 7.
AlphaFold2 evaluation oracle. In Sec. 6.2.1, we presented a distillation technique of filtering out training examples that did not pass the designability criterion. This also involved adding more proteins to the training set after sampling structures with Multiflow and filtering with designability using ProteinMPNN and ESMFold. A potential risk of distillation is our model may overfit to ESMFold since this model is used to filter training data and also for evaluation. We show this is not the case in Table. 5 by presenting the Co-design 1 results using AlphaFold2 (AF2) as an alternative oracle. Our main results do not use AF2 since it is very slow and cumbersome to run and evaluate all our baselines. We evaluated Multiflow with and without distillation to test if distillation with ESMFold provides an improvement regardless of the oracle used at evaluation. Overall designability numbers are lower with AF2; however, in both columns we see there is a two fold improvement regardless of the evaluation oracle. This demonstrates distillation is not overfitting to the oracle used at evalution.
J.3 Uniform Conditional Flow Ablation
We ablate our use of the masking conditional flow and train a version of our Multiflow model using the uniform conditional flow ( see Sec. F.2). We assessed the model’s co-design performance by measuring the Co-Design 1 designability and diversity versus stochasticity level used at inference time. We also measure the secondary structure composition of the generated samples versus stochasticity level. Our results are given in Fig. 8. We find that in general, the Co-Design 1 designability increases with increasing stochasticity whilst the diversity as measured by the number of structural clusters decreases. We can see the reason when examining the secondary structure statistics versus stochasticity. We see that at high stochasticity levels, the model heavily favours generating alpha helices at the expense of beta strands thus reducing the overall structural diversity. This will be due to interactions between errors in the model and the ‘churn’ induced by extra stochasticity. It may be counter-intuitive that extra stochasticity reduces model diversity however we hypothesize that this is linked to the stochasticity inducing the model to converge on local optima in the likelihood landscape. When the model is generating a sample that it is confidence about, extra stochasticity will not shift it away from continuing down this simulation trajectory. However, when the model is exploring lower likelihood regions, the stochasticity can shift the models trajectory until it becomes stuck in a local optima again.
We find an overall worse trade-off between diversity and designability when using the uniform interpolant and so opt to use the masking interpolant in our main models.
J.4 Forward and Inverse Folding Experiments
The goal of our work is to develop the missing piece for a general-purpose framework for protein generation – namely DFM to integrate discrete data generation with a flow model. We combined DFM and FrameFlow to develop Multiflow where we have flexibility at inference time to choose which modality to provide and which to generate. The task we focus on in this work is co-generation where the structure and sequence are jointly sampled rather than one after the other as done in prior works. The other useful tasks in protein modeling are forward and inverse folding. The two tasks are briefly described as follows; more in-depth description can be found in Gao et al. (2020).
Forward folding: the task is to take the sequence as input and predicts the most thermodynamically plausible structure of the sequence. During evaluation, the ground truth structure is known, so we calculate the aligned structure erorr between the prediction and the ground truth. Several metrics exist to compute structure error, such as the Global Distance Test (GDT) commonly used in biophysical modeling (Pereira et al., 2021). We choose to use the aligned backbone RMSD error to keep our analysis simple and intuitive. The most well-used methods are AlphaFold2 (Jumper et al., 2021), RosettaFold (Baek et al., 2021), and ESMFold (Lin et al., 2023). AlphaFold2 and RosettaFold rely on using evolutionary information which our model does not have access to (though can be extended to use). We compare against ESMFold, which does not use explicit evolutionary information, and due to its speed.
Inverse folding: the task is to use the structure as input and predict the most likely sequence that would forward fold into the structure. By this definition, the most sensible metric is the designability metric also used for co-generation. Specifically, the inverse folding model generates a sequence and we use ESMFold to predict the structure given this generated sequence. We call the self-consistency RMSD (scRMSD) as the RMSD between the structure predicted by ESMFold and the original input structure (Trippe et al., 2022). The objective is to minimize scRMSD. The de facto method for inverse folding is ProteinMPNN (Dauparas et al., 2022). Hence we compare against ProteinMPNN.
It is important to emphasize that different deep learning models have been specifically developed for forward and inverse folding, but no method can accomplish both tasks nor co-generate both sequence and structure. Multiflow is unique in this regard to be able to perform co-generation, forward folding, and inverse folding. We leave improving forward and inverse folding performance as a future work. Our aim is to demonstrate baseline performance of using a co-generation method to perform forward and inverse folding. We hope others can aid in advancing general purpose protein generative models.
ESMFold and ProteinMPNN have their own training and test sets which makes rigorous comparison impossible. Re-training ESMFold and ProteinMPNN with the same training set of Multiflow is beyond the scope of our work. Our results are a initial baseline of how Multiflow generally fares to specialized models on forward and inverse folding.
Our test set is based on a time-based split of the PDB. We downloaded structures and sequences from the PDB that were released between 1st September 2021 and 28th December 2023. This time-based split ensures that none of the test set proteins are present in the training data for Multiflow, ProteinMPNN or ESMFold. We then select all single chain monomeric proteins with length between 50 and 400 inclusive. We further filter out proteins that are more than 50% coil residues and proteins that have a radius of gyration in the 96th percentile of the original dataset or above. We also filter out structures that have missing residues. We cluster proteins using the 30% sequence identity MMSeqs2 clustering provided by RCSB.org. We take a single protein from each cluster that matches our filtering criteria. This gives us a test set of 449 proteins with minimum length 51 and maximum length 398.
J.4.1 Forward Folding Results
In Fig. 9 we examine the distribution of errors on our test set for both ESMFold and Multiflow. We find that generally Multiflow can have some success with proteins of smaller length but struggles with longer proteins. We investigate salient test examples from the plot to understand success and failure modes of our model. Multiflow is generally able to predict realistic protein structures with often similar secondary structure distributions as to the ground truth example seen by having similar proportions of non-loop residues between the ground truth and predicted structure. However, Multiflow often fails to predict the exact folded structure with high accuracy.
We quantify the secondary structure prediction accuracy in Fig. 10 by comparing the secondary structure present in the ground truth versus the structure predicted by Multiflow. We find good correlation between the predicted secondary structure and ground truth highlighting that Multiflow is able to use information present within the given sequence to generate structures.
J.4.2 Inverse Folding Results
We plot our results in Fig. 11. We find that Multiflow performs competitively with PMPNN across a wide range of protein lengths with PMPNN achieving slightly lower scRMSD values on average. For both models, scRMSD tends to cluster around 1 to 2 scRMSD. There are test proteins for which PMPNN achieves a lower scRMSD and also cases protein for which Multiflow acheives the lower scRMSD.