Bayesian variable order Markov models

Christos Dimitrakakis

Abstract

This paper introduces Bayesian Variable Order Markov Models (BVMMs), a novel approach for online sequence prediction. By employing a conditional prior over context depths within a suffix tree structure, BVMMs dynamically adjust their complexity as new data arrives. The model provides a computationally efficient, closed-form solution for updating a mixture of tree experts, offering a robust alternative to traditional sampling-based Bayesian methods.

Introduction

Sequence prediction is a fundamental task in fields ranging from natural language processing to system state estimation. Markov models serve as the cornerstone for these tasks; however, they face a significant challenge in selecting the optimal "order" or context depth. A low-order model may fail to capture long-term dependencies (underfitting), while a high-order model risks overfitting by memorizing noise, especially when data is sparse.

While variable-order models exist, they often rely on batch processing or fixed weighting schemes. Fully Bayesian approaches like Infinite Hidden Markov Models (IHMMs) can adapt dynamically but typically require computationally intensive Markov Chain Monte Carlo (MCMC) sampling. This work addresses the need for a fully Bayesian, online model that can update its parameters exactly and rapidly in $O(D)$ time, where $D$ is the maximum tree depth.

Methodology

BVMMs represent the prediction problem using a suffix tree, where each node corresponds to a specific historical context. Each node acts as a "predictive expert" utilizing a Dirichlet-multinomial distribution to estimate the probability of the next observation.

The primary innovation is the introduction of a conditional prior on the Markov order. The model incorporates an auxiliary "stopping" variable at each depth to determine whether the current context is sufficient or if a deeper history is required. Rather than selecting a single depth, the BVMM maintains a posterior probability distribution over various context depths, effectively acting as a mixture of tree experts. These weights are updated recursively using Bayes' theorem, allowing for efficient, closed-form updates as each new data point is observed.

Experimental Evaluation

Synthetic Data Performance

The model was first tested against stochastically generated Hidden Markov Models (HMMs). This setup allowed for a direct comparison between the BVMM and an "oracle" model (HMM EM) that possessed perfect knowledge of the underlying data distribution.

Regret analysis of BVMM compared to other sequence models across various synthetic HMM configurations.

As shown in the regret plots, the BVMM (dashed green line) effectively tracks the performance of more complex models. While it may converge slightly slower than specialized HMM-based methods initially, it demonstrates consistent learning and eventually matches the performance of models tailored to the specific HMM structure.

Real-World Sequence Prediction

To evaluate practical utility, the BVMM was tested on standard data compression benchmarks, including the calgary and large corpora. On the calgary corpus, the model achieved a competitive average log loss of 2.46 bits/symbol.

A key strength of the BVMM is its robustness to overfitting. Unlike simpler Bayesian Markov Chain Mixtures (BMCM), which often underfit by ignoring deeper contexts, the BVMM maintains high performance even as the maximum allowed depth $D$ increases.

Log loss performance on the book1 dataset as a function of maximum depth D, demonstrating BVMM's ability to leverage deeper contexts compared to BMCM.

As illustrated in the book1 dataset results, the BVMM (dashed green line) achieves a significantly better log loss than the BMCM (solid blue line) as $D$ increases. The Bayesian weighting naturally penalizes overly deep contexts that lack sufficient supporting data, preventing the performance degradation often seen in non-Bayesian high-order models.

Conclusion and Future Work

BVMMs provide an elegant, closed-form solution for online Bayesian sequence prediction. They successfully balance model complexity and data availability, making them highly suitable for real-time applications. While they are competitive in data compression, their true potential likely lies in decision-making and reinforcement learning. Because they provide both accurate predictions and easily computable posteriors, they are ideal candidates for planning in unknown Partially Observable Markov Decision Processes (POMDPs). Future research will focus on extending the model to continuous observation spaces and introducing dependencies between context weights to further enhance predictive accuracy.

Summary updated

BibTeX
@article{dimitrakakis2010bayesian,
  author = {Christos Dimitrakakis},
  title = {{Bayesian variable order Markov models}},
  journal = {AISTATS},
  year = {2010},
}
Figure