Skip to content

On the sub model syntax #270

@yebai

Description

@yebai

We recently added support for submodels (#233). There are follow-up discussions in #267 (comment) and slack on the proposed submodel syntax. I thought it may be helpful to open an issue for some discussions.

Current syntax:

    @submodel x = model(args...)
    @submodel prefix x = model(args...)
Treats `model` as a distribution, where `x` is the return-value of `model`.

I think we can support both tilde and assignment, but with different semantics, i.e.

  1. @submodel x = model(args...) will assign returned value of model to variable x.
  2. @submodel x ~ model(args...) will assign a named tuple to variable x. This named tuple is a "SimpleVarInfo" style object, e.g. it contains all variables in the sub-model.

Here option 2 is slightly more general since a user can manipulate the returned named tuple x to for specific purposes. It is also more consistent with the Turing modelling syntax.

cc @devmotion @phipsgabler @torfjelde @mohamed82008

EDIT: we can also remove the @submodel annotation eventually, and use a unified notation ~ for both Distributions and sub-models.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions