RxInfer.jl icon indicating copy to clipboard operation
RxInfer.jl copied to clipboard

Pushing custom information to the InferenceResult

Open ThijsvdLaar opened this issue 1 year ago • 3 comments

I'm looking for a way to insert "probes" into update rules such that custom information can be passed back to the InferenceResult object. This would allow for a user to inspect (and visualize) information on the rule/message level, which would be helpful when developing custom rule implementations.

I currently have two use-cases in mind:

  1. Message statistics can be written to the probe so that the user can inspect (specific) messages;
  2. Custom information during rule computations can be returned, for example to check for convergence when iterating within a rule computation.

In a similar way that Meta and Pipeline objects offer context for inbounds collection and rule computation, a probe might be passed to an update rule. Custom information can then be written to the probe, which is returned to the InferenceResult object (perhaps similar to how posteriors are returned).

ThijsvdLaar avatar Jan 16 '24 10:01 ThijsvdLaar

We offer partial support for this functionality through addons, although the documentation is currently limited. In essence, addons enable the insertion of custom steps both before and after invoking the rule function. The existing use cases for addons align closely with the points you've proposed:

  • Debugging information can be incorporated into the messages to trace how, where, and with what arguments they were computed. An illustrative example is available here.
  • Addons can also be utilized to compute the log-scale of the messages, proving useful in subsequent stages of the inference process. (not documented)

bvdmitri avatar Jan 18 '24 09:01 bvdmitri

@bvdmitri is this a matter of updating documentation or is there additional functionality required?

wouterwln avatar Mar 15 '24 12:03 wouterwln

I think this is a matter of updating the documentation, because both of the use-cases provided can be covered by the addons.

bvdmitri avatar Mar 15 '24 16:03 bvdmitri