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.
@submodel x = model(args...) will assign returned value of model to variable x.
@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.
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:
I think we can support both tilde and assignment, but with different semantics, i.e.
@submodel x = model(args...)will assign returned value ofmodelto variablex.@submodel x ~ model(args...)will assign a named tuple to variablex. 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
xto for specific purposes. It is also more consistent with the Turing modelling syntax.cc @devmotion @phipsgabler @torfjelde @mohamed82008
EDIT: we can also remove the
@submodelannotation eventually, and use a unified notation~for both Distributions and sub-models.