M6-071M6: Multimodal & Generative ModelsFlow Matching & Rectified FlowHard
Mastery:

Flow Matching & Rectified Flow: 解释 Flow Matching 中的路径选择与最优传输。

📐 Mathematical Definition
OT path: min⁡∫∥v∥2 s.t. continuity;straight⇒fewer steps\text{OT path}:\ \min\int\|v\|^2\ \text{s.t. continuity};\qquad \text{straight}\Rightarrow\text{fewer steps}
⚡ Executive Summary
Core Concept: 路径可选直线/扩散/OT;OT 路径(最优传输)使路径尽量不交叉,从而少步采样质量更好。

📌 Key Takeaways

  • •
    直线路径:简单、速度快,但配对独立采样 → 路径交叉
  • •
    扩散路径:兼容预训练、但与扩散等价(步数多)
  • •
    OT 路径:最小化传输代价 → 路径尽量不交叉 → 少步更好

📐 Mathematical Derivations

数学机理:<strong>三类路径</strong>。(1) <strong>直线(linear / independent)路径</strong>——x_t=(1−t)x_0+tx_1,配对 (x_0,x_1) <strong>独立采样</strong>;<strong>优点</strong>——最简单、速度恒定(v=x_1−x_0)、易实现;<strong>缺点</strong>——独立配对使路径<strong>大量交叉</strong>(同一 x_t 对应多个目标速度),导致'边缘速度不唯一'、学到的流'不直'、少步采样差。(2) <strong>扩散路径</strong>——x_t=√ᾱ_t x_0+√(1−ᾱ_t)ε;<strong>优点</strong>——兼容已有的扩散模型/技术、理论成熟;<strong>缺点</strong>——路径'弯曲'(非直线),故需较多步;且等价于扩散(没有 FM 的'直线优势')。(3) <strong>最优传输(OT)路径</strong>——求解<strong>最优传输问题</strong>:找一个'从噪声分布到数据分布'的<strong>联合分布</strong> π(x_0,x_1),使<strong>传输代价</strong>(如 E‖x_1−x_0‖²)最小;用该联合分布定义的直线路径<strong>尽量不交叉</strong>(因为 OT 的'单调性'性质:OT 映射下路径不交叉)。<strong>为什么 OT 路径少步更好</strong>——(a) <strong>路径更直</strong>(OT 的解在'位移插值'下是'单调'的,路径不交叉);(b) <strong>目标速度更一致</strong>(同一 x_t 附近的路径方向一致,故 v_marginal 更'确定');(c) 故 ODE 更易积分(可用更少步)。<strong>OT 路径的计算</strong>——精确 OT 在连续高维空间<strong>不可解</strong>;故用近似:(a) <strong>minibatch OT</strong>——在每个 batch 内用 Sinkhorn 算法求'批内最优配对'(近似 OT),再用这些配对定义路径;<strong>优点</strong>——简单(只改配对方式)、有效;(b) <strong>迭代方法</strong>(Reflow 可视为'迭代逼近 OT');(c) <strong>理论上的'OT-CFM'</strong>(Tong 等 2023)——用 minibatch OT 构造条件路径,论文证明其边缘速度与'独立配对'的 FM <strong>不同</strong>(更接近真实 OT),故效果更好。<strong>实证</strong>——(a) OT-CFM 在同等步数下优于独立配对的 FM;(b) 但<strong>收益在'配对质量'上有上限</strong>(minibatch OT 只是近似);(c) 大规模训练时'独立配对 + 多轮 Reflow'可能是更实用的路线。<strong>与其他路径的对比</strong>——(a) <strong>直线(独立配对)</strong>——最简单,需 Reflow 拉直;(b) <strong>OT-CFM</strong>——用 OT 配对,路径更直;(c) <strong>扩散路径</strong>——兼容预训练;(d) <strong>VP/VE 路径</strong>——方差保持/爆炸(扩散的两种参数化)。<strong>选择依据</strong>——(a) <strong>追求少步生成</strong> → OT-CFM 或 直线 + Reflow;(b) <strong>兼容已有扩散模型</strong> → 扩散路径;(c) <strong>简单快速</strong> → 直线(+ 可选的 Reflow)。<strong>度量</strong>——(a) <strong>步数 vs 质量曲线</strong>;(b) <strong>路径的'直度'</strong>(如 E‖x_1−x_0−v·1‖ 的偏差);(c) <strong>训练稳定性</strong>。

🏭 Production Trade-offs

深度剖析与工程权衡:① <strong>'路径直度决定采样步数'是核心逻辑</strong>——面试中能指出'OT 路径更直故少步更好'是深度理解的标志。② <strong>'minibatch OT 是实用近似'</strong>——精确 OT 不可解;故用'批内 Sinkhorn'近似(简单且有效);这是'用近似换取可行性'的典型。③ <strong>'Reflow 可视为迭代逼近 OT'</strong>——两者目标相同(拉直路径);Reflow 用'模型自生成配对'、OT 用'最优配对';可组合。④ <strong>'收益的上限'</strong>——minibatch OT 只是近似(batch 有限);故'独立配对 + Reflow'在实践中可能更实用(尤其大规模)。⑤ <strong>'与预训练的兼容性'</strong>——扩散路径兼容已有模型(可复用);直线/OT 路径需从头训练(或转换)。⑥ <strong>面试要点</strong>——被问'FM 的路径怎么选',应给出'<strong>直线(简单但交叉)+ 扩散(兼容但弯曲)+ OT(不交叉但需近似)</strong>'与'<strong>路径直度决定步数、minibatch OT 是实用近似、Reflow 可迭代拉直</strong>';能指出'精确 OT 不可解故用近似'是深度理解的标志。
⚠️ Common Interview Pitfalls
  • ✕
    以为精确 OT 可计算(高维不可解,需近似)
  • ✕
    忽略路径直度与采样步数的关系
🎯 Interviewer Follow-ups
  • ?
    OT 路径如何计算?
  • ?
    为什么 OT 路径的采样步数更少?
📚

Associated Knowledge Base Guides & Mindmaps

Explore the comprehensive technical article, exam cards, and global architecture tree.

← PreviousM6-070: Flow Matching & Rectified Flow: 解释 Flow Matching 与 score matching 的关系。📋Back to BankNext →M6-072: Flow Matching & Rectified Flow: 解释 Flow Matching 的采样与求解器选择。