From Flow Matching for Generative Modeling
Conditional Flow Matching objective:
$$ \mathcal{L}{\text{CFM}}(\theta) = \mathbb{E}{t,q(x_1),p_t(x|x_1)} |v_t(x) - u_t(x|x_1)|^2 $$
or the expected difference between vector field and sampling-estimated true field
Essentially, we sample
Note:
Allows easily sampling unbiased estimates provided efficient:
- sampling from
$p_t(x|x_1)$ - computing
$u_t(x|x_1)$
Flow Matching Loss and Conditional Flow Matching loss have identical gradients w.r.t
So optimizing CFM loss is equivalent in expectation to optimizing FM loss
Thus can train CNF to generate marginal probability path
$$\textbf{Theorem 2: } \text{Assuming that } p_t(x) > 0 \text{ for all } x \in \mathbb{R}^d \text{ and } t \in [0,1], \ \text{ then, up to a constant} \text{ independent of } \theta, \mathcal{L}{\text{CFM}} \text{ and } \mathcal{L}{\text{FM}} \text{ are equal. } \ \text{Hence, }\nabla_\theta\mathcal{L}{\text{FM}}(\theta) = \nabla\theta\mathcal{L}{\text{CFM}}(\theta). $$
So, at last, we have our final Flow Matching Method:
- Have a bunch of data samples
$x_1$ which are our desirable instances samples by true desirable distribution$p_1$ - sample from some standard normal
$p_0$ (a bunch of random points weighted according to normal distribution) - Sample
$x$ from$p_0$ and$x_1$ , and now$p_t(x|x_1)$ is some path which is an interpolation between$x$ and$x_1$ (which WE DEFINE however we want as long as it is continuous, thus it is easy to sample from!) - sample a point along that path, and compare our current neural net vector field
$v_t(x)$ with$u_t(x|x_1)$ at that point (we design$u_t(x|x_1)$ , can be simple$(x_1 - x)$ which always pushes points towards$x_1$ , so we always know exactly what it is)