Abstract
Stochastic gradient MCMC (SG-MCMC) algorithms have proven useful in scaling Bayesian inference to large datasets under an assumption of i.i.d data. We instead develop an SG-MCMC algorithm to learn the parameters of hidden Markov models (HMMs) for time-dependent data. There are two challenges to applying SG-MCMC in this setting: the latent discrete states, and the need to break dependencies when considering minibatches. We consider a marginal likelihood representation of the HMM and propose an algorithm that harnesses the inherent memory decay of the process. We demonstrate the effectiveness of our algorithm on synthetic experiments and ion channel recording data, with runtimes significantly outperforming batch MCMC.
Introduction
Hidden Markov Models (HMMs) are fundamental tools for sequential data analysis, yet scaling Bayesian inference for HMMs to massive datasets remains a significant challenge. Standard MCMC methods, such as Gibbs sampling, require $O(T)$ computation per iteration for a sequence of length $T$, making them impractical for very long sequences. While Stochastic Gradient MCMC has revolutionized inference for independent (i.i.d.) data, its application to HMMs is hindered by discrete latent states and temporal dependencies that prevent simple random minibatching.
Methodology
To overcome these hurdles, we propose a scalable SG-MCMC framework for HMMs based on three core components:
- Marginalization: We marginalize out the discrete hidden states $x_t$ to work directly with the continuous parameter space of the marginal likelihood. This allows for the direct calculation of gradients required by SG-MCMC.
- Buffering via Memory Decay: To process minibatches without introducing massive bias, we utilize the "forgetful" property of Markov chains. By adding buffers of length $B$ to both ends of a subsequence of length $2L+1$, we ensure that local forward-backward messages accurately approximate global ones.
- Riemannian Geometry: We employ Stochastic Gradient Riemannian MCMC (SG-RMCMC) to ensure that transition parameters remain on the probability simplex during the sampling process.
Experiments and Results
We evaluated our approach on several synthetic datasets—including "diagonally dominant" and "reversed cycles" sequences—and a real-world 1MHz ion channel recording.
Key findings include:
- Efficiency: On the ion channel dataset, our Stochastic Gradient Riemannian Langevin Dynamics (SG-RLD) algorithm achieved a 1,000x speedup over traditional batch MCMC.
- Non-Conjugate Flexibility: Unlike many variational methods, our approach handles non-conjugate emission distributions (e.g., log-normal) with ease. As shown in our synthetic experiments, the SG-MCMC approach correctly identifies the true number of hidden states ($K=2$), whereas standard conjugate models may fail to converge or overfit.
Conclusion
By leveraging marginalization and a principled buffering strategy, we enable the application of SG-MCMC to HMMs. This approach provides a massive computational advantage for large-scale sequential data while maintaining the flexibility to handle complex, non-conjugate models. Future work will explore extending these buffering techniques to other dependent data structures, such as Markov Random Fields.
Summary updated