1.9 KiB
1.9 KiB
title, created, updated, type, tags, sources
| title | created | updated | type | tags | sources | |||||
|---|---|---|---|---|---|---|---|---|---|---|
| Flow Matching | 2026-05-13 | 2026-05-13 | concept |
|
|
Flow Matching
Flow Matching 是一种连续时间生成建模框架,通过学习速度场(velocity field)来定义从噪声到数据的连续变换路径。
核心公式
给定数据分布 p_data(x) 和噪声分布 p_noise(ε)(通常 ε ~ N(0,I)),定义线性插值路径(rectified-flows):
z_t = t·x + (1-t)·ε, t ∈ [0,1]
速度场定义为 z_t 对时间的导数:
v = dz/dt = x - ε
训练目标是最小化预测速度与真实速度的 MSE:
L_MSE = E_{t,x,ε} ||v_θ(z_t, t) - v||²
x-prediction vs v-prediction
由于 v = (x - z_t)/(1-t),网络可以直接预测 x(x-prediction-parameterization)而非 v:
x_θ = net_θ(z_t, t)
v_θ = (x_θ - z_t) / (1-t)
x-prediction 在 embedded-language-flows 中至关重要:它与解码任务(预测干净离散 token)的语义一致,使得共享权重设计可行。
推理
通过求解 ODE dz_t/dt = v_θ(z_t, t) 从 z_0 ~ N(0,I) 逐步推进到 z_1 ≈ x。可使用欧拉求解器或更高级的数值方法。
与其他框架的关系
- DDPM:离散时间步,高斯前向过程 + 去噪后向过程
- Score-based models:通过 score function ∇log p_t(z) 参数化;Flow Matching 可统一在此框架下
- Rectified Flows:Flow Matching 的特例,使用直线插值路径
在语言建模中的应用
embedded-language-flows 将 Flow Matching 应用于语言生成:离散 token → T5 编码 → 连续嵌入空间 → Flow Matching 去噪 → 最后一步解码回 token。
参考
- Lipman et al., "Flow Matching for Generative Modeling", ICLR 2023
- Albergo & Vanden-Eijnden, "Stochastic Interpolants", JMLR 2025