Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composing models with latent and to_distribution #802

Open
sunxd3 opened this issue Feb 6, 2025 · 2 comments
Open

Composing models with latent and to_distribution #802

sunxd3 opened this issue Feb 6, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@sunxd3
Copy link
Member

sunxd3 commented Feb 6, 2025

#696 introduced several new abstractions for model composition in DynamicPPL.jl:

ReturnedModelWrapper

Wraps a model to treat it as a distribution over its return values instead of its parameters.
Example:

@model function demo()
    x ~ Normal()
    y = x + 1
    return y
end

# ReturnedModelWrapper(demo()) represents distribution over y

Distributional

  • Sampleable <: Distributional:
    • Can be sampled from
    • May not support logpdf computation

Extensions (To be implemented)

  • latent: (vis-a-vis returned)
    • Would view model in terms of its parameters rather than returns
    • Example: For above model, would give distribution over x
  • Another subtype of Distributional that supports sampling and computing logp
  • A high level user facing interface to_distribution that would create proper probability distributions with models
    • Could potentially work with both returned and latent

Integration with NamedTupleVariate

Supporting NamedTupleVariate (#801) would give us a natural interface for to_distribution:

  • Allowing model to be viewed as distributions over model parameters and their values.
  • Notice ProductNamedTupleDistribution is not sufficient, because it assumes independence
  • Limitation is that not all DynamicPPL models can use this interface, as some require the more complex VarName to value mapping rather than simple NamedTuples
@sunxd3
Copy link
Member Author

sunxd3 commented Feb 6, 2025

related issues: #755, TuringLang/Turing.jl#2428, TuringLang/Turing.jl#2425

@sunxd3
Copy link
Member Author

sunxd3 commented Feb 11, 2025

related TuringLang/Turing.jl#2485

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants