NAS-X: Neural Adaptive Smoothing via Twisting

Dieterich Lawson, Michael Li, Scott Linderman

TL;DR

NAS-X (Neural Adaptive Smoothing via Twisting) is a new framework for training sequential latent variable models that combines the stability of Reweighted Wake-Sleep (RWS) with the power of smoothing Sequential Monte Carlo (SMC). By using neural "twists" to incorporate future observations into current inference steps, NAS-X achieves significantly lower bias and variance than existing methods, proving particularly effective for complex, high-dimensional mechanistic models like neuronal dynamics.

What Problem Does This Paper Address?

Sequential Latent Variable Models (SLVMs) are the workhorse of time-series analysis, used in everything from tracking financial volatility to modeling brain activity. However, as these models become more complex (nonlinear, high-dimensional, or discrete), two major hurdles emerge:

  1. Inference is hard: Standard Sequential Monte Carlo (SMC) often suffers from "particle degeneracy," where most samples become irrelevant over time because they ignore future data.
  2. Learning is unstable: Variational Inference (VI) methods, which minimize the exclusive KL divergence, often struggle with discrete variables (requiring high-variance gradient estimates) and can be numerically unstable when dealing with "stiff" systems like biological simulators.

Existing Reweighted Wake-Sleep (RWS) approaches for sequences typically rely on filtering (looking only at past data), which introduces significant bias into the learning process.

Methods

NAS-X bridges the gap between RWS and smoothing SMC. Its core components include:

  • Twisted SMC: The authors use "twists"—functions that approximate the lookahead distribution (how future observations depend on the current state). This effectively turns a standard particle filter into a smoother that accounts for the entire data sequence.
  • Density Ratio Estimation (DRE): Rather than manually deriving these twists, NAS-X learns them by training a simple neural classifier to distinguish between real model trajectories and "shuffled" ones. This makes the method "adaptive."
  • RWS Framework: Unlike VI methods that maximize the ELBO, NAS-X uses the smoothing SMC particles to estimate gradients for the inclusive KL divergence. This is generally more stable for discrete latent variables and provides a lower-variance signal for learning proposal distributions.
  • Strang Splitting: To handle the "stiff" differential equations found in neuronal models, the authors implemented a specialized numerical integrator that allows for much larger time steps without sacrificing stability.

Datasets

The authors evaluated NAS-X across three distinct regimes:

  1. Linear Gaussian State Space Model (LG-SSM): A controlled environment where the true posterior is known, used to verify that the algorithm can recover exact posterior marginals.
  2. Switching Linear Dynamical Systems (SLDS): A "NASCAR" track simulation involving both continuous movement and discrete "switching" states (e.g., which lane the car is in).
  3. Hodgkin-Huxley (HH) Neuronal Models:
    • A 4D model of a squid giant axon.
  4. A highly complex 18D model of a mouse pyramidal neuron with 38 learnable parameters, using real data from the Allen Institute Brain Atlas.

Key Insights and Ideas

  • Smoothing is Non-Negotiable: The paper demonstrates that filtering-based methods (like NASMC) fundamentally fail to capture the true posterior variance because they are "blind" to the future. NAS-X fixes this by using twisted targets.
  • Inclusive KL for Stability: A major "aha" moment is that RWS-based learning is often more robust than VI for complex simulators. VI methods (like SIXO) tend to encourage high-entropy proposals that can lead to biophysically impossible states (causing simulators to crash with NaNs), whereas NAS-X stays more focused and stable.
  • Extreme Particle Efficiency: Because the twists guide the particles so effectively, NAS-X can achieve better results with just 4 particles than standard filtering methods can achieve with 256.
Figure 1: Comparison of NAS-X and baseline methods on inference in LG-SSM. (left) Comparison of log-marginal likelihood bounds (lower is better), (middle) proposal parameter error (lower is better), and (right) learned proposal variances. NAS-X outperforms all baseline methods and recovers the true posterior marginals.

Key Results

  • Neuronal Modeling: In the challenging 18D mouse neuron task, NAS-X captured the number of spikes and cross-correlation of the voltage traces significantly better than SIXO.
  • Robustness: NAS-X had a much lower failure rate (runs that crashed due to numerical instability) compared to SIXO (18.9% vs 25.2%).
  • Inference Accuracy: In Hodgkin-Huxley models, NAS-X was found to be roughly 64x more particle-efficient than filtering-based RWS and 2x more efficient than its closest smoothing competitor, SIXO.
Figure 3: Qualitative comparison of inferred voltage traces. SIXO (top) suffers from frequent resampling and a mistimed spike, while NAS-X (bottom) perfectly tracks the true voltage with almost no resampling needed.

Limitations and Future Work

  • Computational Overhead: While NAS-X is particle-efficient, training the twists requires an additional neural network and a separate optimization step (DRE), which takes about 3.5x longer per global training step than simpler filtering methods.
  • Twist Parameterization: The success of the method depends on choosing a flexible enough architecture for the twists. While the authors used RNNs and MLPs successfully, very high-dimensional or non-Markovian systems might require even more complex architectures.
  • Future Directions: The authors suggest exploring how these adaptive twists could be applied to even larger-scale models in healthcare or climate science where long-term dependencies are critical.

Summary updated

Abstract

Sequential latent variable models (SLVMs) are essential tools in statistics and machine learning, with applications ranging from healthcare to neuroscience. As their flexibility increases, analytic inference and model learning can become challenging, necessitating approximate methods. Here we introduce neural adaptive smoothing via twisting (NAS-X), a method that extends reweighted wake-sleep (RWS) to the sequential setting by using smoothing sequential Monte Carlo (SMC) to estimate intractable posterior expectations. Combining RWS and smoothing SMC allows NAS-X to provide low-bias and low-variance gradient estimates, and fit both discrete and continuous latent variable models. We illustrate the theoretical advantages of NAS-X over previous methods and explore these advantages empirically in a variety of tasks, including a challenging application to mechanistic models of neuronal dynamics. These experiments show that NAS-X substantially outperforms previous VI- and RWS-based methods in inference and model learning, achieving lower parameter error and tighter likelihood bounds.
BibTeX
@inproceedings{lawson2023nas,
  author = {Dieterich Lawson and Michael Li and Scott Linderman},
  title = {{NAS-X: Neural Adaptive Smoothing via Twisting}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=A9mHph8GJk},
}
Figure