Skip to content

Control Based Implementations #12

@rsenne

Description

@rsenne

Hi @gdalle — happy new year!

I wanted to get your thoughts on a design question that came up while working on emission models that require exogenous control inputs. The most obvious example is GLMs (and more generally regression-based emissions), but the same issue arises for a broader class of conditional or input-driven emissions.

I really like the way HiddenMarkovModels.jl already exposes control information via the control_seq interface. That said, I’ve found that under the current setup, emission models that depend on control can be a bit awkward to implement in a way that feels fully “first-class,” especially when it comes to integration with Baum–Welch and the emission update interface.

As far as I can see, there are a few possible directions one could take here:

1.) Specialized controlled HMMs
Implement control-aware HMMs with the emission model effectively baked in (e.g. Gaussian GLM-HMM, Bernoulli GLM-HMM, etc.), similar in spirit to the current examples in the documentation. This is straightforward conceptually, but it doesn’t scale particularly well as the space of emission models grows.

2.) Wrapping observations to carry control information
Make emission models operate on observation–control pairs by introducing a lightweight wrapper, e.g

struct GLMObs{T}
    X::Vector{T}
    y::T
end

and then pass this wrapper as the observation type throughout the HMM machinery. This works with the existing interfaces, but it pushes control information into the observation itself, which may not always be desirable from a modeling or ergonomics standpoint.

3.) Extending HiddenMarkovModels.jl to natively support control-aware emissions via multiple dispatch
Introduce an additional (optional) control-aware path upstream, so that when a control_seq is provided, both likelihood evaluation and emission updates can dispatch to methods of the form

logdensityof(emission, obs; control_seq=...)
fit!(emission, obs_seq, weights; control_seq=...)

while preserving the current behavior for emissions that do not require control. This would keep emissions as first-class objects and avoid baking control into the observation representation.

I’m curious what your perspective is on this design space, and whether you see a preferred direction (or an alternative I may be missing). I’d be happy to explore a concrete proposal or PR if you think it’s worth pursuing. I have a good amount of time to luckily spend on this given I'm on break from Ph.D. life and now have some time to pursue passion projects (another PR is on my list for HiddenMarkovModels.jl lol). Let me know what you think! And again happy new year! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions