A Kernelized Stein Discrepancy for Biological Sequences

Alan Nawzad Amin, Eli N Weinstein, Debora Susan MarksICML 2023

Generative AI is revolutionizing protein design and genomics, but evaluating these models remains notoriously difficult. Ideally, we want to know if the distribution of sequences a model produces ($p$) perfectly matches the true distribution found in nature ($q$).

To address this, researchers have introduced KSD-B, a novel divergence measure designed specifically to evaluate generative models of biological sequences like DNA and proteins. It provides a mathematically rigorous "goodness-of-fit" test that works even when a model’s full probability distribution is impossible to calculate, handling variable-length sequences and biological mutations with theoretical guarantees that previous methods lacked.

The Challenge of Evaluating Biological Models

Current evaluation methods for biological generative models have major blind spots:

  1. The Normalizing Constant Problem: Many powerful models, such as energy-based models, can easily output the relative probability of two sequences. However, they cannot calculate the absolute probability because the "normalizing constant" (the sum of all possible sequence probabilities) is mathematically intractable to compute.
  2. Discrete & Variable Space: Biological sequences aren't points in a smooth Euclidean space; they are discrete strings of varying lengths. Most existing statistical tools (like standard Stein Discrepancies) were built for continuous data and fail to provide theoretical guarantees when applied to the "infinite discrete" space of sequences.
  3. Sensitivity: Simple metrics like log-likelihood might tell you which model is better, but they don't provide an absolute measure of whether a model is actually correct or faithful to the underlying biology.

Introducing KSD-B: A Tailored Solution

The authors adapt the Kernelized Stein Discrepancy (KSD) framework specifically for biological sequences. Their approach, KSD-B, involves three key innovations:

  • The Zanella Stein Operator: Instead of using gradients (which don't exist for discrete text or sequences), they define a "Stein operator" based on a stochastic process of biological mutations—specifically substitutions, insertions, and deletions. This allows the measure to naturally handle sequences of different lengths.
  • Vector Field Kernels: Most discrete KSDs use "scalar" kernels. This paper demonstrates that using vector field kernels (which satisfy an anticommutativity property) is essential. These kernels are more sensitive and are theoretically guaranteed to detect when a distribution fails to converge to the target.
  • Stochastic Approximation: Calculating the KSD exactly requires looking at every possible single-mutation neighbor of a sequence, which is computationally expensive for long proteins. The authors introduce a sub-sampling method that approximates the KSD-B efficiently, making it scalable to realistic sequence lengths.

Key Insights: Faithfulness and Vector Fields

A divergence is considered "faithful" if it equals zero if and only if the two distributions are identical. The authors prove that KSD-B is faithful on the infinite space of sequences, provided the kernel has "discrete masses."

Furthermore, for a discrepancy to be reliable, it must account for the "tails" of the distribution—how the probability decays as sequences get very long. The authors show that KSD-B correctly handles these tails, whereas previous discrete methods could be "fooled" by distributions that spread out too much.

Convergence behavior of KSD-B variants. The vector field kernels reliably detect both convergence and non-convergence, unlike some scalar counterparts.

A major breakthrough in the paper is the mathematical proof that scalar field discrepancies cannot reliably detect non-convergence unless they use "unbounded" kernels, which are biologically nonsensical. Vector field kernels solve this by testing for more subtle differences between distributions, ensuring robust evaluation.

Experimental Validation and Results

The researchers validated KSD-B using a combination of synthetic benchmarks (Profile Hidden Markov Models, Potts models, and autoregressive models) and high-stakes real-world biological data, including DNA library designs for human T cell receptor sequences and state-of-the-art deep learning models (Wavenet and Tranception) trained on distinct protein families.

Goodness-of-fit test results across synthetic models (pHMM, Potts, autoregressive). KSD-B variants consistently show higher sensitivity (fraction rejected) to perturbations compared to MMD and BEAR.
  • Superior Sensitivity: In "goodness-of-fit" tests, KSD-B consistently outperformed existing baselines like Maximum Mean Discrepancy (MMD) and BEAR (a Bayesian test), especially when the model's normalizing constant was unknown.
  • Detecting Model Mismatch: When testing state-of-the-art protein models, KSD-B successfully identified that even these high-performing models often fail to perfectly capture the local "fitness landscape" of specific protein families.
  • Efficiency: Their stochastic approximation allowed for an order-of-magnitude decrease in kernel evaluations compared to previous neighborhood-reduction methods, without losing the power to detect model errors.

Limitations and Future Directions

While the approximation helps, KSD-B still scales quadratically ($O(n^2)$) with the number of sequences being evaluated. This makes it difficult to use on massive datasets with millions of sequences without further optimization. Additionally, while the authors provide several biological kernels (Hamming, Alignment, k-mer spectrum), the performance of KSD-B is highly dependent on choosing the "right" kernel for the specific biological task.

Looking forward, KSD-B could be used not just for post-hoc evaluation, but to actively improve training—for example, acting as a loss function for energy-based models or helping to develop better MCMC samplers for exploring biological sequence space.

Summary updated

BibTeX
@inproceedings{amin2023kernelized,
  author = {Alan Nawzad Amin and Eli N Weinstein and Debora Susan Marks},
  title = {{A Kernelized Stein Discrepancy for Biological Sequences}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=8LdBTjylEw},
}
Figure