Skip to content

add faq about ssm integration#685

Merged
penelopeysm merged 2 commits intoTuringLang:mainfrom
hardik-xi11:docs-ssm-integration
Mar 31, 2026
Merged

add faq about ssm integration#685
penelopeysm merged 2 commits intoTuringLang:mainfrom
hardik-xi11:docs-ssm-integration

Conversation

@hardik-xi11
Copy link
Copy Markdown
Contributor

fixes TuringLang/Turing.jl#2428.

i have added a small faq in the documentation that explains GeneralisedFilters and ssm problems using the Turing.@addlogprob! macro.

i have implemented this instead of writing a full wrapper method instead and properly explained how the integration works

Copy link
Copy Markdown
Member

@penelopeysm penelopeysm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hardik-xi11! While this is a nice and simple bit of example code, I worry that it will become out of date, and if that happens, there's no way for us to find out (because this code isn't executed). Maybe it would be good to make this an actual example, perhaps on its own page? And also it could be extended with a HiddenMarkovModels.jl extension?

I recognise this is scope creep and am not saying that that should all be done in this PR, but maybe we can try to move in that direction. For example, adding a page under the Usage section that's called something like 'external models', and then having a minimal but runnable example of SSMProblems with addlogprob! might be a good target.

@hardik-xi11
Copy link
Copy Markdown
Contributor Author

Yess i get that so should I first work on writing up the documentation by adding a new page like this usage/external-likelihoods/index.qmd instead of the current changes i pushed.

This is the code example I came up with

using Turing, Distributions

# This represents an external filtering algorithm (for example from
# packages such as SSMProblems.jl or GeneralisedFilters.jl).
# For this runnable example we implement a simple function that returns
# a log-marginal likelihood.
function run_external_filter(data, θ)
    return -0.5 * sum((data .- θ).^2)
end

@model function external_model(data)
    # Prior over model parameters
    θ ~ Normal(0, 1)

    # Compute marginal log-likelihood using the external filter
    logZ = run_external_filter(data, θ)

    # Add the likelihood contribution to the model
    Turing.@addlogprob! logZ
end

# Creating a 100-element sample vector data
data = randn(100)

model = external_model(data)

# Run the inference
chain = sample(model, NUTS(), 100)

If im on the same page as you I can implement this example on a new page and make it runnable and push the changes for a review.

After that is done I can later work on adding another example on the same page that can use the HMM library

@hardik-xi11 hardik-xi11 force-pushed the docs-ssm-integration branch from 5a4645e to 90cbe4c Compare March 29, 2026 19:26
@hardik-xi11 hardik-xi11 requested a review from penelopeysm March 29, 2026 19:28
Copy link
Copy Markdown
Member

@penelopeysm penelopeysm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @hardik-xi11, this reads nicely!

I believe, most of the docs are formatted with semantic linebreaks (i.e., one sentence per line), rather than with a fixed character width. Could I get you to format as such? Would be happy to merge after that, and after checking the docs build.

@hardik-xi11 hardik-xi11 requested a review from penelopeysm March 30, 2026 16:44
@penelopeysm
Copy link
Copy Markdown
Member

Thanks! Happy to approve once CI finishes (so that'll probably be tomorrow).

@penelopeysm
Copy link
Copy Markdown
Member

The CI failures aren't related to docs build, so will merge. (Those CI things should probably be fixed...)

@penelopeysm penelopeysm merged commit 7234d1f into TuringLang:main Mar 31, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate SSMProblems & GeneralisedFilters with Turing.jl

2 participants