dpm-solver icon indicating copy to clipboard operation
dpm-solver copied to clipboard

Question regarding likelihood evaluation

Open mickelliu opened this issue 1 year ago • 5 comments

Hi Cheng,

Congrads on your impactful works.

I'm pretty new to this field and want to know if evaluating the negative log-likelihood $(-\log P_\theta ( x_0 | c ) )$ really makes sense to you. I want to compute the exact likelihood of an image being sampled from the denoising process parameterized by $\theta$. I was wondering if this is possible with an ODE solver like DPM-solver.

Thanks.

mickelliu avatar Apr 17 '23 18:04 mickelliu

Hi @mickelliu , what is the dimension of your image? And what do you want to do with your likelihood?

DPM-Solver can also improve the computation speed for evaluating likelihood, but it cannot ensure it is a valid likelihood if the solver does not converge.

LuChengTHU avatar Apr 19 '23 15:04 LuChengTHU

Thanks for you reply!

Hi @mickelliu , what is the dimension of your image?

I'm testing on 512x512 images but I am running stable diffusion v-1-5 which has a latent dimension of 64x64.

And what do you want to do with your likelihood?

I want to estimate the likelihood of generating a bad sample so I can try to minimize it. Or letting people to select between two samples, and award the model for generating good samples relative to the preference score. I'm not sure if there's any other way to do it

DPM-Solver can also improve the computation speed for evaluating likelihood, but it cannot ensure it is a valid likelihood if the solver does not converge.

I actually have very little idea about how to evaluate exact likelihood using the DPM-solver. And I think this paper by Song Yang (Eq. 39) is the only paper that explicitly tells us how to compute the exact log-likehood out of every diffusion papers i have read.

Best,

Mickel

mickelliu avatar Apr 19 '23 16:04 mickelliu

Is it easy to derive a differential form (with dx and dt) of the DPM-solver's equation?

mickelliu avatar Apr 19 '23 16:04 mickelliu

Hi @mickelliu ,

I think in such case, you can easily combine DPM-Solver with likelihood solver. The basic idea is that the likelihood of diffusion ODEs can be solved by a D+1 dimension ODE as following:

dx / dt = f(x, t) (it is the diffusion ODE that dpm-solver solves) d logp / dt = -tr(\nabla f(x,t))

and then (x, logp(x)) is a D+1 dim variable, which follows the above ODE. (In fact, such theory is firstly proposed by "Neural Ordinary Differential Equations".

You can use dpm-solver to approximate the solution, but you need to write another update rule for approximate d logp / dt.

Nevertheless, I will add a feature to dpm-solver to support likelihood computation :)

LuChengTHU avatar Apr 24 '23 10:04 LuChengTHU

Nevertheless, I will add a feature to dpm-solver to support likelihood computation

Thanks for your response, and apologize for the delayed reply.

This would be a very nice addition, but I am curious to know how to do it efficiently. To my knowledge, I think you would have to compute or at least approximate the second-order gradient (d_nabla/d_theta_unet) anyway, and this could be extremely inefficient.

mickelliu avatar May 22 '23 07:05 mickelliu