Blackbox likelihood: Creating an Inference Data object and “Initial evaluation of model at starting point failed”

The second model doesn’t seem equivalent to the initial one. Given the first one works correctly, it means that likelihood returns the log likelihood which can’t be used as a probability as is, so using it as p in the Multinomial ends up with nans or infs. You could exponentate it to make sure the probabilities are in the right 0-1 range (assuming the normalization factor is present) but even then, the model is different than the original one.

To get the log likelihood, you can use a densitydist instead of a potential (making sure all the inputs of observed are actual observed data, see Using a random variable as observed - #5 by OriolAbril, I think you’ll need a lambda on likelihood so the function passed to densitydist doesn’t have params as input).

Or you can also compute the log likelihood manually afterwards. See for example Refitting PyMC3 models with ArviZ (and xarray) — ArviZ dev documentation