Quick objective:
We are given a distribution , and we want to find a diffeomorphism map such that:
To recall what a diffeomorphism map is, it basicly mean:
- is invertible
- is
- is
Normally, it is not likely to find such a map that satisfy the aforementioned properties, and the space of diffeomorphism map is unsurprisingly large. So instead, math approach only try to have a family of diffeomorphism map parameterized by a parameter .
Note: is a multi-dimensional parameter, not just a scalar value.
And they find by maximum-likelihood method:
Still, this is far from being practical. Particularly:
- Computing inverse is costly
- Computing Jacobian matrix is costly
- Computing determinant of Jacobian matrix is costly.
Expressive flows relying on a residual connection have been proposed as an interesting middle-ground between expressivity and efficient determinant estimation. They take the form:
where unbiased estimate of the log likelihood can be obtained
We can also compose such flows to get a new flow:
This can be a useful way to construct move expressive flows! The model’s log-likelihood is then given by summing each flow’s contribution
where
Their explanation about the following part is quite vague, so I gonna try to comprehend on my own:
- Instead of think about as a sequence, we think of it as a function:
Setting and let under certain conditions, we can make the domain of function to get as close to the interval as possible (it never be but is dense, so we can assume that.
Now we have a "continuous" (not guaranteed but I have strong hope) function with domain . We calculate its derivative:
If you recall the formula of I mentioned just above, in discrete version (finite ), the derivative would be exactly .
Or this simply mean:
So the flow should satisfy the ODE:
I think I am making thing a bit complicated, and kind of "reverse engineering" the discretized version of flow model. I hope this is getting somewhere later in the blog.
Continuous change-in-variables
Of course, this only defines the map . For this to be a useful normalising flow, we still need to compute the log-abs-determinant of the Jacobian!
I did some serious calculation by myself, but got stuck when it come to calculate determinant of the Jacobian matrix and the limit calculation at the same time (maybe it would be some trick with Taylor expansion, but I do not really want to get further.
In the blog that I am reading, they just skip this step and give me the formula for derivative of the density function:
This statement on the time-evolution of is generally known as the Transport Equation. We refer to as the probability path induced by .
And computing this in log-space give us:
This gives us the log density:
So, the target is quite clear now, which is finding a high-dimensional parameter such that:
Obviously, we only have "samples" that help us to know the data distribution better. This brings us back to SGD (Stochastic Gradient Descent) methods. But simply calculating is still computationally expensive because of getting requires expensive computation for integration. And this is where Flow Matching comes into the scene.
Flow Matching (FM)
Instead of calculating with with large step of integration, FM instead learn the "flow" (no doubt why it is named Flow Matching) . But where does it get the reference from? They simply do an interpolation between the sample from distribution and the sample from data distribution :
- Sample
- Sample
- Sample
Here, FM try to approximate to the linear "bridge" between and (I am not so convinced myself here cause intuitively it will just look like a straight line connecting the "dense" part of 2 distribution. But it worked so I have no voice here).
The loss function is defined as:
Of course, this requires knowledge of a valid , and if we already have access to , there’s no point in learning an approximation in the first place! But as we will see in the next section, we can leverage this formulation to construct a useful target for witout having to compute explicitly .
This is where Conditional Flow Matching (CFM) comes to the rescue.
Conditional Flow Matching
Note that we had an ODE for and :
I can't believe I am saying this but I get a bit tired of the Math amount behind this paper. So I gonna summarize the rest part. And I may get back to this to complete it when I got more energy.
Summary
Target:
Learn the parameter of a parametric flow model such that:
Training process:
- Step 1: Sample .
- Step 2: Sample .
- Step 3: Sample .
- Step 4: The sampled is simply .
- Step 5: The referenced vector field is also simply .
- Step 6: Calculate and respective loss function.
We have differential loss function. The rest is just the very well-known gradient descent. Intuitively, they are trying to connect the point from to by just some straight line.

Inference
- Step 1: Sample
- Step 2: Use a solver to solve the integral
One note here is that we cannot predict the noise at level and subtract directly from in one step, but still we have to do this in multiple steps. The reason is quite simple. This is more or less like a linear approximation. The more you discretize the approximation, the more accurate it is. And the noise we predict will never be so accurate, but we can only approximate it to a certain level, so we "walk slowly in the right direction, and see where it brings us instead".