arXiv:2605.29208cs.MScs.LG2026-05

高效精确的HMM库,支持多种分布的正确极大似然估计。

libhmm: A Modern C++20 Library for Hidden Markov Models with Correct MLE Emission M-Steps

  • 采用正确极大似然法实现16种发射分布参数估计,避免传统近似方法偏差
  • 支持对角、全协方差和独立分量三类多维观测模型,含加权最大似然步骤
  • 性能优化:全对数空间计算+编译期分发的SIMD加速,适合生产部署

本文介绍libhmm,一个基于C++20的隐马尔可夫模型参数估计、序列解码与模型选择库。该库填补了现有软件中缺乏可嵌入生产系统的零依赖C++ HMM库,以及广泛使用方法矩(MOM)近似发射分布极大似然步的空白。libhmm实现了十六种标量发射分布的正确最大似然估计,包括用于位置尺度学生分布的ECME算法、伽马、贝塔、威布尔和负二项分布的牛顿-拉夫森最大化,以及用于循环数据的冯·米塞斯分布。所有前向-后向与维特比计算均在完整对数空间中进行。通过编译期分发支持AVX-512、AVX2、SSE2和ARM NEON的SIMD加速,附带标量回退。第4版新增通过BasicHmm<Obs>模板支持多维观测,包含三种多维发射族(对角高斯、全协方差高斯、独立分量),每种均具有正确的加权最大似然步骤。可通过配套包pylibhmm获取Python绑定。我们在七个真实数据基准上将libhmm与已建立的C/C++ HMM库及公开的R参考包进行了比较,并讨论了设计中的架构权衡。

原文摘要 · Abstract (English)

We describe libhmm, a C++20 library for Hidden Markov Model parameter estimation, sequence decoding, and model selection. libhmm addresses two gaps in existing software: the absence of a well-maintained, zero-dependency C++ HMM library suitable for embedding in production systems, and the widespread use of method-of-moments (MOM) approximations in the emission distribution M-step of the Baum-Welch algorithm. The library implements correct maximum likelihood estimators for sixteen scalar emission distributions, including an ECME algorithm for the location-scale Student-t distribution, Newton-Raphson maximization for Gamma, Beta, Weibull, and Negative Binomial distributions, and the von Mises distribution for circular data. All forward-backward and Viterbi calculations operate in full log-space. SIMD acceleration is provided for AVX-512, AVX2, SSE2, and ARM NEON via compile-time dispatch with scalar fallback. Version 4 adds multivariate observation support via the BasicHmm<Obs> template, with three multivariate emission families (diagonal Gaussian, full-covariance Gaussian, and independent components) each with correct weighted MLE M-steps. Python bindings are available via the companion package pylibhmm. We compare libhmm against established C and C++ HMM libraries and against published R reference packages on seven real-data benchmarks, and discuss the architectural tradeoffs made in the design.

HMMC++20机器学习库概率建模

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。