<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="4.4.1">Jekyll</generator><link href="https://xczhai.ccwu.cc/feed.xml" rel="self" type="application/atom+xml"/><link href="https://xczhai.ccwu.cc/" rel="alternate" type="text/html" hreflang="en"/><updated>2026-06-25T04:29:27+00:00</updated><id>https://xczhai.ccwu.cc/feed.xml</id><title type="html">blank</title><subtitle>Personal website of Xiaochen Zhai, an undergraduate student at Nanjing University majoring in Computer Science and Technology (Brain Science and AI). </subtitle><entry><title type="html">FLM - Flow Language Model</title><link href="https://xczhai.ccwu.cc/blog/2026/FLM/" rel="alternate" type="text/html" title="FLM - Flow Language Model"/><published>2026-05-30T04:00:00+00:00</published><updated>2026-05-30T04:00:00+00:00</updated><id>https://xczhai.ccwu.cc/blog/2026/FLM</id><content type="html" xml:base="https://xczhai.ccwu.cc/blog/2026/FLM/"><![CDATA[<p><em>This note covers the key concepts of Flow Language Model (FLM) and Flow Map Language Model (FMLM). <br/> 本文整理了 Flow Language Model (FLM) 和 Flow Map Language Model (FMLM) 的核心概念。</em></p> <h1 id="flm---flow-language-model">FLM - Flow Language Model</h1> <ul id="lang" class="tab" data-tab="2fe15fea-d9a8-4a19-a921-3edc1f021c6d" data-name="lang"> <li class="active" id="lang----"> <a href="#">中文版 </a> </li> <li id="lang-english-version"> <a href="#">English Version </a> </li> </ul> <ul class="tab-content" id="2fe15fea-d9a8-4a19-a921-3edc1f021c6d" data-name="lang"> <li class="active"> <h2 id="一问题定义">一、问题定义</h2> <p>给定词表（token set）$V$，$\lvert V\rvert$ 表示其中 token 的种类数。 记长度为 $L$ 的语句样本（即一个 sentence）为 $y = (y^l)_{l=1}^L \in V^L$.</p> <p>目标是在使用尽量少的计算和推理步数的前提下，预测在$V^L$上的分布 $p(y)$，从而生成一个有意义的样本 $y_{\text{sample}}$.</p> \[\overbrace{\underset{v \in V}{\underline{\text{Mary}}} \text{ is a girl.}}^{y \in V^L}\] <p>考虑的指标：</p> <ul> <li>生成质量</li> <li>推理步数</li> <li>计算开销</li> </ul> <h2 id="二现有方案">二、现有方案</h2> <h3 id="autoregressive-language-models">Autoregressive language models</h3> <p>遵循链式法则，而非 Markov chain， 因为每个 token 的预测都依赖于之前所有 token 的上下文.</p> <p>整体分布可写为：</p> \[p(y) = p(y^1)p(y^2 \mid y^1) p(y^3 \mid y^1,y^2) \cdots p(y^L \mid y^{&lt;L})\] <ul> <li>计算顺序是逐 token 进行从左到右的, 一共需要 $L$ 步</li> <li>每一步都需要从 $V$ 中选择一个 token</li> <li>计算开销可记为 $O(\lvert V\rvert \cdot L)$</li> <li>推理步数为 $O(L)$</li> </ul> <h3 id="discrete-diffusion-language-models">Discrete diffusion language models</h3> <p>思路是通过并行计算多个 token 来加速，通常只有当推理步数小于 $L$ 时，才会有明显加速。</p> <p>在DDLM中，我们定义句子级别的转移密度：</p> \[p_{t \mid s}(y_t \mid y_s), \quad y_s, y_t \in V^L\] \[\text{加噪方式} \left\{ \begin{array}{l c c c c c c c} &amp; t = 0 &amp; \rightarrow &amp; t = 0.3 &amp; \rightarrow &amp; t = 0.7 &amp; \rightarrow &amp; t = 1 \\[1em] \text{masking: } &amp; \text{Mary is a girl.} &amp; \rightarrow &amp; \text{Mary [m] a girl.} &amp; \rightarrow &amp; \text{Mary [m] a [m]} &amp; \rightarrow &amp; \text{[m] [m] [m] [m]} \\[0.5em] &amp; \rlap{\color{gray}{\text{([m]的信息为0，但知道哪些token被破坏)}}} &amp; &amp; &amp; &amp; &amp; &amp; \\[1.5em] \text{uniform randomization: } &amp; \text{Mary is a girl.} &amp; \rightarrow &amp; \text{Mary is a \textbf{boy}.} &amp; \rightarrow &amp; \text{Mary \textbf{angry} a \textbf{boy}} &amp; \rightarrow &amp; \text{\textbf{dog} \textbf{hello} a \textbf{boy}} \\[0.5em] &amp; \rlap{\color{gray}{\text{(不可以推断哪些token被破坏以及原词是什么)}}} &amp; &amp; &amp; &amp; &amp; &amp; \\ \end{array} \right.\] <p>去噪：</p> <p>如果直接在 $V^L$ 空间上计算 $P_{t\mid s}(y_t \mid y_s)$，可写作：</p> \[P_{t\mid s}(y_t \mid y_s) = \prod_{l=1}^{L} P_{t\mid s}(y_t^{l} \mid y_t^{&lt;l}, y_s)\] <p>在这个前提下，每一步$y$的更新，本质上是在完成一个$y_{s} \in V^L \mapsto y_{t} \in V^L$的映射.</p> <ul> <li>计算顺序是所有token同时并发进行的</li> <li>而每一步都需要为$y_{t}$中每一个位置选择一个$V$中的token</li> <li>推理步数为$O(N)$, 为了起到加速作用，$N$应该是一个远小于 $L$ 的常数.</li> <li>计算开销可记为 $O(\lvert V\rvert^L)$</li> </ul> <p>因此通常是不可行的，DDLM通常采用 factorized approximation 方法：</p> \[\widehat{P}_{t\mid s}(y_t \mid y_s) := P_{t\mid s}^1(y_t^1 \mid y_s) P_{t\mid s}^2(y_t^2 \mid y_s) \cdots P_{t\mid s}^L(y_t^L \mid y_s)\] <p>$P_{t \mid s}^{i}$的角标$i$代表概率计算与token所处位置有关。</p> <p>这意味着：</p> <ul> <li>计算量可降到 $O(L \times \lvert V\rvert)$, 但会丢失大量上下文相关性，导致生成质量下降</li> <li>此外每个 token 的预测近似彼此独立, 这点只有在 $t \rightarrow s$ 时才会成立</li> <li>更新步幅小会导致生成时推理步数 $N$ 往往还是很大</li> </ul> <h2 id="二语言的离散化表示">二、语言的离散化表示</h2> <p>这一步是为了完成 $y \in V^L \leftrightarrow$ $x \in \mathcal{X}$ 的映射, 其中 $\mathcal{X}$ 是一个连续空间，通常取高维实数空间$\mathbb{R}^{L \times \lvert V\rvert}$.</p> <p>往往我们采用一个连续的编码器（continuous embedding）$f$ 和一个解码器 $g$ 来完成这个映射：</p> <ul> <li>编码器：$f : y \mapsto x$</li> <li>解码器：$g : x \mapsto y$, 满足 $g(f(y)) = y$.</li> </ul> <p>这样，原来的分布 $p(y)$ 可以由\(p(x) = p(y = g(x))\)诱导出分布 $p(x)$，并通过 $y = g(x)$ 还原。</p> <p>推理和解码过程可重写为：</p> \[\hat{x} \sim p(x), \quad \hat{y} = g(\hat{x})\] <p>即先在连续空间中采样，再映射回离散序列。</p> <p>对于编码方式 $f$，常见选择包括：</p> <ol> <li>Learned Embedding: 每个Token的位置$i$随机初始化一个低维向量$\theta_i$, $\theta$作为模型的一部分参数进行实时更新.</li> </ol> <p>这个方法的表达能力强，但需要 careful regularization, 不然可能会导致所有$\theta_i$趋向于相同的值, 或者 $\lvert\theta\rvert \to \infty$.</p> <ol> <li> <p><strong>Pretrained Embedding</strong>: 实现简单, 可采用已训练好的语言模型如$T_5$(<strong>ELF</strong>)、BERT等的词嵌入层, 继承先验的知识, 训练的时候冻结.</p> </li> <li> <p>One-hot Encoding: 直接把每个 token 映射为一个独热向量（one-hot vector）：</p> </li> </ol> \[f: y \mapsto (\text{onehot}(y^1), \ldots, \text{onehot}(y^L))^\top, \quad V^L \to \mathbb{R}^{L \times \lvert V\rvert}\] \[g: x \mapsto (\arg\max(x^1), \ldots, \arg\max(x^L)), \quad \mathbb{R}^{L \times \lvert V\rvert} \to V^L\] <p>这种表示不需要正则化, 适合 cross-entropy训练, 信息无损但是维度很高, 并且语义相似性不容易直接表达。</p> <h2 id="三flow-language-model">三、Flow Language Model</h2> <p>核心问题变为：在嵌入空间中学习连续数据分布 $p(x)$。</p> <h3 id="1-插值">1. 插值</h3> <p>目标是建立噪声分布$p_0$到数据分布$p_1$的桥梁，定义随时间演化的概率路径。</p> <ol> <li>线性插值：</li> </ol> \[I_t := (1-t)x_0 + tx_1, \quad I_t \sim p_t\] <p>其中：</p> <ul> <li>$x_0 \sim p_0 = \mathcal{N}(0, I)$ 表示噪声</li> <li>$x_1 \sim p_1$ 表示目标样本</li> <li>$t \in [0,1]$ 表示时间变量</li> <li>$I_t$ 表示<strong>训练</strong>时刻 $t$ 的中间状态, 以示区分我们额外定义的 $x_t$ 变量表示<strong>推理</strong>时刻 $t$ 的中间状态</li> </ul> <p>这种方式的速度场容易学习，路径是一条直线，训练通常高效且较稳定。</p> <ol> <li>带噪声的随机插值：</li> </ol> \[I_t = (1-t)x_0 + tx_1 + \sqrt{2t(1-t)}z, \quad z \sim \mathcal{N}(0, I_d)\] <ol> <li>三角插值：</li> </ol> \[I_t = \cos\left(\frac{\pi}{2}t\right)x_0 + \sin\left(\frac{\pi}{2}t\right)x_1\] <p>这个能保证中间状态分布的方差不变，即“变速生成”。</p> <ol> <li>另外也可以考虑编码-解码式路径，例如：</li> </ol> \[I_t = (1-t)x_0 + tx_1 + \sin^2(\pi t)\] <p>直观上：</p> <ul> <li>$t: 0 \to 0.5$ 更像编码 / 破坏过程，编码到纯噪声的latent space</li> <li>$t \to 1$ 更像从 latent space 解码回目标空间</li> </ul> <h3 id="2-概率流与向量场">2. 概率流与向量场</h3> <p>这一部分的目标是从产生的概率路径中学习一个确定性的 ODE / SDE。有点类似world model从轨迹中观察得出物理动力学知识的思想。</p> <p>若采用线性插值，我们引入速度场 $b_t(x_t)$用于描述在时刻 $t$ 下的$x_t$更新方向, 定义为：</p> \[b_t(x_t) = \dot{x_t}\qquad x_0 \sim p_0, t \in [0,1]\] <p>整个模型的flow的动力学可以用一个ODE或SDE来描述：</p> <ol> <li>ODE： \(\frac{d}{dt} x_t = b_t(x_t)\)</li> <li>SDE： \(\frac{d}{dt} x_t = b_t(x_t) + \sqrt{2\epsilon} dW_t\) 其中$W_t$ 是标准布朗运动，$\epsilon$ 是噪声强度，增加随机抖动以增强模型的鲁棒性和泛化能力.</li> </ol> <p>从初始分布 $p_0$ 出发，只需要逐步求解 ODE / SDE 就可以得到最终分布 $p_1$ 的样本，而不需要每一步重新随机采样。</p> <h3 id="3-fitting--mse-loss">3. Fitting &amp; MSE Loss</h3> <p>我们对符号稍作总结：</p> <ul> <li>初始噪声：$x_0$，目标样本：$x_1$，时间变量：$t \in [0,1]$</li> <li>训练中间状态：$I_t := (1-t)x_0 + tx_1$，训练时真实速度场为$\dot{I_t} = x_1-x_0$</li> <li>推理时中间状态$x_t := x_0 + \int_0^t b_s(x_s) \, ds$，$b_t(x_t)$为模型预测的速度场，决定每一步更新方向。</li> </ul> <p>因此只要能够预测或计算 $b_t(x)$，整个 ODE / SDE 的采样过程就被确定下来。</p> <p>针对某一时刻 $t$，可以把所有轨迹经过该点时的速度做条件平均，从而得到：</p> \[b_t(x_t) = \mathbb{E}_{x_t \sim p_t}[\dot{x_t}] = \mathbb{E}_{I_t \sim p_t}[\dot{I_t} \vert I_t = x_t] = \mathbb{E}_{I_t \sim p_t}[I_1 - x_0 \vert I_t = x_t]\] <p>$I_{1}$代表在$I_t = x_t$的条件下，由含$I_t$的训练轨迹预测得到的$t = 1$时的状态，那么对$\forall x \in p_t(x)$有：</p> \[b_t(x) = \mathbb{E}_{I_t \sim p_t}[I_{1} - x_0 \vert I_t = x]\] <p>这也意味着，问题可以被转化为一个回归问题。</p> <p>定义 MSE 损失：</p> \[\mathcal{L}_{\text{MSE}}(\hat{b}) := \int_0^1 \mathbb{E}\left[\left\vert \hat{b}_t(I_t) - \dot{I_t} \right\vert^2\right] dt\] <p>实际实现时，积分通常会离散化为网格：</p> \[0 = t_0 &lt; t_1 &lt; \cdots &lt; t_N = 1\] <p>此时，最优的速度场满足：</p> \[b = \arg\min_{\hat{b}} \mathcal{L}_{\text{MSE}}(\hat{b})\] <h4 id="直接预测速度场的问题">直接预测速度场的问题</h4> <p>这是一个利用flow进行语言生成的独有问题，如果直接预测：</p> \[b = x_1 - x_0\] <p>那么由于 $x_0 \in \mathbb{R}^{L \times \lvert V\rvert}$ 处于高维离散表示空间中，而且高斯噪声$x_0$一般是满秩的，导致对于每个输入输出网络的$b_i \in \mathbb{R}^{\lvert V\rvert}$, 神经网络$\phi: \mathbb{R}^{L \times \lvert V\rvert} \mapsto \mathbb{R}^{L \times d} \mapsto \mathbb{R}^{L \times \lvert V\rvert}$的特征维度（hidden state）$d$ 不足以表达 $b_i$ ($d \ll \lvert V\rvert$). 因此用$b$作为训练对象时一定会出现欠拟合问题。（实验验证，ELF C.1, Figure 10）</p> <p>一个常见观点是：虽然</p> \[x \in \mathbb{R}^{L \times \lvert V\rvert}\] <p>但自然语言样本并不会均匀铺满这个空间，而更可能集中探索在某个低维流形上，因此可以通过更紧凑的表示去学习它。</p> <p>真实的速度场 $\dot{I_t}$ 是一个常数，等于 $x_1 - x_0$，与 $t$ 无关：</p> \[\dot{I_t} = x_1 - x_0,\] <p>预测速度场改写为对终点的预测：</p> \[\hat{b}_t(I_t) = \frac{\hat{x}_1 - x_t}{1-t}\] <p>其中 $\hat{x}<em>1$ 是预测出的最终结果，$\hat{x}_1(x_t) = \mathbb{E}</em>{I_t \sim p_t}[I_1 \mid I_{t} = x_t]$。</p> <p>于是原来的 MSE 目标可改写为：</p> \[\mathcal{L}_{\text{MSE}}(\hat{b}) = \int_0^1 \mathbb{E}\left[\left\vert \hat{b}_t(I_t) - \dot{I_t} \right\vert^2\right] dt = \int_0^1 \mathbb{E}\left[\left\vert \frac{\hat{x}_1 - x_t}{1-t} - (x_1 - x_0) \right\vert^2\right] dt \\ = \int_0^1 \mathbb{E}\left[\left\vert \frac{\hat{x}_1 - x_{1} + ((1-t)x_{0} + tx_{1} - x_t)}{1-t} \right\vert^2\right] dt \\ = \int_0^1 \frac{1}{(1-t)^2}\mathbb{E}\left[(\hat{x}_1 - x_{1})^2\right] dt\] <p>此时训练也可以理解为直接逼近最终目标样本。但是需要注意这里有一个$\frac{1}{(1-t)^2}$使得整个积分成为了一个瑕积分，导致当 $t \to 1$ 时，损失函数的值会趋向于无穷大，这可能会引起训练不稳定。</p> <h4 id="应对措施">应对措施</h4> <ul> <li>FMLM：直接忽略 $\frac{1}{(1-t)^2}$ 这一项，使用近似目标$\int_0^1 \mathbb{E}\left[(\hat{x}<em>1 - x</em>{1})^2\right] dt$；但这未必严格合理，实践中往往更适合配合 CE 使用，而且尽量要让 $t$ 较小。</li> <li>ELF： <ol> <li>不再对 $t \in [0,1]$ 做均匀采样，而是改为从对数正态分布中采样：$t’ \sim \mathcal{N}(P_{mean}, P_{std}^2), t = \sigma(t’)$。</li> <li>直接在 $t$ 接近 $1$ 的位置单独设置一个解码分支，这个位置更适合采用交叉熵CE</li> <li>由于最优预测 $\hat{x}_1$ 一定满足$ \hat{x}_1 - x_1 = O(1 - t) $, 相当于在这里引入了一个隐式的Lipschitz约束，当然我们可以考虑引入一个显式的Lipschitz正则项来强化这个约束，这个可以后面尝试一下。</li> </ol> </li> </ul> <h3 id="4-decoding--ce-loss">4. Decoding &amp; CE Loss</h3> <p>在连续空间中做拟合时，MSE Loss 是最自然的训练目标。但当数据最终要转换成离散表示时，我们可以引入分类指标交叉熵（Cross-Entropy, CE）作为更适配的训练目标。</p> <h4 id="flm-的-ce-目标">FLM 的 CE 目标</h4> <p>FLM 采用 one-hot 编码，即目标 $x_1 \in \mathbb{R}^{L \times \lvert V\rvert}$ 中，每一个分量$x_{1}^l$只有一个元素为 1，其余为 0。</p> <p>FLM 定义了交叉熵目标：</p> <p>\(\mathcal{L}_{CE}(\hat{x_1}) := \int_0^1 \mathbb{E}_{I_t \sim p_t}\left[-\sum_{l=1}^L \log \hat{x_1}(I_t)^l \cdot x_1^l\right] dt\) 其中 \(\log \hat{x_1}(I_t)^l \cdot x_1^l = \log \left( \text{模型预测正确 Token } c \text{ 的概率} \right)\)</p> <p><strong>关键性质：</strong></p> <ol> <li>$\mathcal{L}_{CE}$ 可分解为不可约的条件熵 + 从真实后验到模型分布的 KL 散度之和，因此最小化 CE 本质上在做一个$\hat{x}_1$ 对于$x_1$的分布匹配。</li> <li>若 CE误差 $\Delta_D(\hat{D}) := \mathcal{L}<em>{CE}(\hat{D}) - \mathcal{L}</em>{CE}(D) \leq \varepsilon$，则对于任意 early stopping time $\xi \in (0,1)$：</li> </ol> \[W_2^2(\hat{p}_{1-\xi}, p_{1-\xi}) \leq C\varepsilon\] <p>其中 $C &gt; 0$ 依赖于 $\xi$ 和模型的 Lipschitz 常数。$1-\xi$ 是为了避免转换中的 $(1-t)^{-1}$ 奇异性。简单来讲就是这里的训练损失越低,生成质量一定能更好.</p> <ol> <li><strong>与离散扩散的联系</strong>：最优去噪器隐式地学习了 factorized posterior $p^l_{1\mid t}(x_1^l \mid x_t)$，这与离散扩散模型通过 tokenwise CE 学习 $p^l_{1\mid t}$ 的方式一致。但关键区别在于：离散模型用 $p^l_{1\mid t}$ 做 ancestral sampling（需要完整联合概率密度，受因子化误差影响）；连续模型用 $p^l_{1\mid t}$ 推断精确速度场，从而可以被精确蒸馏为 few-step 生成器。</li> </ol> <p>总而言之FLM 的 CE 是沿整个 flow 轨迹的 per-step 目标，即对所有 $t \in [0,1]$ 都施加 token-level 的交叉熵监督。</p> <h4 id="elf-的-ce-目标">ELF 的 CE 目标</h4> <p><strong>ELF 的 CE 仅在最终时间步 $t = 1$ 处施加</strong>，而非沿整个轨迹的 per-step 目标。这是 ELF 与 FLM 及其他连续 DLM 的核心设计差异。</p> <ol> <li> <p>在 $t = 1$ 时，ELF 将去噪过程自然地视为 continuous-to-discrete 的解码步骤。同一个网络 $\text{net}_\theta$ 在 $t = 1$ 时切换为 “decode” 模式（通过 binary mode token 控制），无需单独的解码器——可以理解为与去噪器共享权重的解码器。</p> </li> <li> <p>当 $t \to 1$ 时，$z_t \to x$（接近干净的 embedding），此时网络输入过于简单（几乎就是答案本身）。因此 ELF 在 $t = 1$ 处引入了一个 token-level 的 corruption process，将干净 embedding 替换为被污染的版本 $\tilde{z}$，以创造有意义的训练信号。</p> </li> <li> <p><strong>CE 损失</strong>：</p> </li> </ol> \[\mathcal{L}_{CE} = \mathbb{E}_{\tilde{z}}\left[\text{CrossEnt}(W\mathbf{x}_\theta(\tilde{z}), s)\right]\] <p>其中：</p> <ul> <li>$\mathbf{x}_\theta(\tilde{z})$ 是网络对 $\tilde{z}$ 的预测（clean embedding）</li> <li>$W$ 是一个可学习的 “unembedding” 矩阵，将 embedding 映射回 logits</li> <li>$s$ 是 ground-truth token（原始离散 token）</li> </ul> <ol> <li><strong>推理时</strong>：仅在最终步 $t = 1$ 计算 $W\mathbf{x}_\theta(z_t)$，然后对 logits 取 argmax 得到离散 token。</li> </ol> <p><strong>ELF 不在中间去噪步骤施加 CE 的理由</strong>：ELF 的去噪轨迹完全在 unrestricted continuous embedding 空间中进行，per-step 的 token-level 监督会使轨迹过度绑定到词表级别的预测，限制了 flow dynamics 的灵活性。仅在 $t = 1$ 处做 discretization，使得 flow 在 $t &lt; 1$ 时享有最大的自由度。</p> <p><strong>核心分歧</strong>：FLM 认为既然最优去噪器天然落在单纯形上，CE 就是最适配的训练目标，应当沿整个轨迹使用；ELF 则认为 per-step CE 会限制 flow dynamics 的灵活性，应当仅在最终步做离散化，中间步骤完全在连续空间中自由演化。</p> <h2 id="四flow-map-language-models">四、Flow map language models</h2> <h3 id="1-引入-flow-map">1. 引入 Flow Map</h3> <p>为了避免仍要计算积分导致无法在 few-step 下收敛，我们引入流映射（flow map）。</p> <p>定义为 $\dot{x}_t = b_t(x_t), \quad x_0 \sim p_0, \quad t \in [0,1]$ 的解算子：</p> \[X_{s,t}(x_s) = x_t, \quad \forall s,t \in [0,1].\] <p>即任意两时刻之间的变换函数。</p> <p>式子也可重写成：</p> \[X_{s,t}(x_s) = x_s + (t-s)v_{s,t}(x_s),\] <p>其中 $v_{s,t}$ 称为 $s$ 到 $t$ 的平均速度或者”mean flow”。</p> <p>给定待采样 $\hat{x}_0$ 后，在有 flow map 的前提下，我们可以离散地取网格 $0 = t_0 &lt; \cdots &lt; t_N = 1$，并依次计算：</p> \[\hat{x}_{t_{i+1}} = X_{t_i, t_{i+1}}(\hat{x}_{t_i})\] <p>得到样本。极端情况下取 $N = 1$，即可单步生成 $\hat{x}<em>1 = X</em>{0,1}(x_0)$。一般来说 $N$ 越大性能越好。</p> <h3 id="2-为学习合理的-flow-map-需要满足的条件">2. 为学习合理的 Flow Map 需要满足的条件</h3> <p><strong>1. 恒等条件：</strong></p> \[X_{s,s}(x) = x, \quad \forall x \in \mathbb{R}^{L \times \lvert V\rvert}, \forall s \in [0,1].\] <p>可知实际上这个条件是平凡的，我们将之整合到后两条约束中作为ODE的常数约束。</p> <p><strong>2. 瞬时速度条件(Lagrangian Equation)：</strong></p> \[\partial_t X_{s,t}(x) = b_t(X_{s, t}(x)) \quad X_{s,s}(x) = x,\quad \forall x \in \mathbb{R}^{L \times \lvert V\rvert}, \forall s,t \in [0,1].\] <p><strong>3. 终点不变条件(Eulerian Equation)：</strong> \(\partial_s X_{s,t}(x) + b_s(x) \cdot \nabla X_{s,t}(x) = 0, \quad X_{t,t}(x) = x,\quad \forall x \in \mathbb{R}^{L \times \lvert V\rvert}, \forall s,t \in [0,1].\)</p> <p><strong>4. 半群条件：</strong></p> \[X_{u,t}(X_{s,u}(x)) = X_{s,t}(x), \quad \forall x \in \mathbb{R}^{L \times \lvert V\rvert}, \forall s,u,t \in [0,1].\] <p>需要补充的是, 后三条本质上是等价的,描述的是完全同一个流的性质. 第二条在极限情况$s \to t$下退化为局部的切线条件(Tangent Condition)： \(\lim_{s \to t} \partial_t X_{s,t}(x) = b_t(x)\) 第三条是由终点$t$不随起点$s$变化的条件得出: \(\frac{d}{ds} X_{s,t}(x) = 0\)</p> <p>根据切线性质和2, 3, 4的依次组合, 我们可以得到三种等价的约束形式：</p> <p>Lagrangian map distillation (LMD) loss: \(\mathcal{L}_{\text{LMD}}(\hat{v}) = \underbrace{\int_0^1 \int_0^t \mathbb{E} \left\vert\partial_t \hat{X}_{s,t}(I_s) - \text{sg}\left(\hat{b}_t\left(\hat{X}_{s,t}(I_s)\right)\right)\right\vert^2 ds dt}_{\text{对应：拉格朗日条件}} + \underbrace{\int_0^1 \mathbb{E} \vert\hat{v}_{t,t}(I_t) - \hat{b}_t(I_t)\vert^2 dt}_{\text{对应：切线条件}}\)</p> <p>Eulerian map distillation (EMD) loss: \(\mathcal{L}_{\text{EMD}}(\hat{v}) = \underbrace{\int_0^1 \int_0^t \mathbb{E} \left\vert\partial_s \hat{X}_{s,t}(I_s) + \text{sg}\left(\hat{b}_s(I_s) \cdot \nabla \hat{X}_{s,t}(I_s)\right)\right\vert^2 ds dt}_{\text{对应：欧拉条件}} + \underbrace{\int_0^1 \mathbb{E} \vert\hat{v}_{t,t}(I_t) - \hat{b}_t(I_t)\vert^2 dt}_{\text{对应：切线条件}}\)</p> <p>progressive map distillation (PMD) loss: \(\mathcal{L}_{\text{PMD}}(\hat{v}) = \underbrace{\int_0^1 \int_0^t \int_s^t \mathbb{E} \left\vert\hat{X}_{s,t}(I_s) - \text{sg}\left(\hat{X}_{t,u}\left(\hat{X}_{s,t}(I_s)\right)\right)\right\vert^2 du ds dt}_{\text{对应：半群条件}} + \underbrace{\int_0^1 \mathbb{E} \vert\hat{v}_{t,t}(I_t) - \hat{b}_t(I_t)\vert^2 dt}_{\text{对应：切线条件}}\)</p> <p>如果是自蒸馏的话,只需要将每个式子的最后一项中的 $\hat{b}_t(I_t)$ 替换为 $\dot{I_t}$ 即可.</p> <p>FMLM选用的是最后一种约束形式：</p> \[\begin{aligned} \mathcal{L}_{\mathrm{MSE}}(\hat v)=&amp; \int_0^1 \int_0^t \int_t^s \mathbb{E}_{I_s} \left[ \left\| \hat X_{s,t}(I_s) - \mathrm{sg}\!\left( \hat X_{u,t} \left( \hat X_{s,u}(I_s) \right) \right) \right\|^2 \right] \,du\,ds\,dt \\ &amp;+ \int_0^1 \mathbb{E}_{I_t} \left[ \left\| \hat v_{t,t}(I_t) - \hat b_t(I_t) \right\|^2 \right] \,dt . \end{aligned}\] <p>第一项为结合律约束，第二项为瞬时速度约束.</p> <p>其中 sg 意为 stop gradient，不反向传播，第一项还可以利用 $X_{s,t}(x_s) = x_s + (t-s)v_{s,t}$ 进一步展开，第二项可以用 $I_t$ 代替预训练得到的 $\hat{b}_t$</p> <p>$X_{s, t}$本身是由 Gaussian Noise 导出的，如果直接约束会面临和直接计算$b_t$一样的问题。为了在概率空间统一 Flow Matching 和 Flow Map，同时利用 One-Hot 编码带来的单纯形约束，FMLM 引入新的优化对象：</p> \[\delta_{s,t}(x_s) := x_s + (1-s)v_{s,t}(x_s).\] <p>可以把它理解成一个矩阵$T \in \mathbb{R}^{N \times N}$：</p> <ul> <li>横纵坐标分别对应时间 $(s,t)$</li> <li>Flow Matching 相当于填写对角线上的值$T_{tt}$（$\hat{b}<em>t = \hat{X}</em>{t,t}$）</li> <li>后者相当于填写矩阵上三角或者下三角区域</li> </ul> <p>这种表示带来的额外好处是不需要再使用 MSE 做数值回归，而可以直接采用 CE（Cross Entropy）做分类， MSE做分类的话会有数值不稳定的问题。</p> <h3 id="3-delta_st-的性质">3. $\delta_{s,t}$ 的性质</h3> <p>FMLM选择的 $\delta_{s,t}$ 有以下性质：</p> <p><strong>性质 1. 与流匹配快速对应：</strong></p> \[X_{s,t}(x) = \frac{1-t}{1-s}x + \frac{t-s}{1-s}\delta_{s,t}(x)\] <p><strong>性质 2. 在单纯形空间上，维数不高：</strong></p> \[\delta_{s,t}(x)^\ell \in \Delta^{\lvert V\rvert-1}, \quad \ell = 1,2,\cdots,L.\] <p>其中 $\Delta^{\lvert V\rvert-1}$ 满足各个值非负且和为1。</p> <p><strong>性质 3. 对角线上对应标值的去噪器 / 填充函数：</strong></p> \[\delta_{s,s}(x) = \mathbb{E}_{I_t \sim p_t}[x_1 \mid I_t = x] = \hat{x}_1, \quad \forall x \in \mathbb{R}^{L \times \lvert V\rvert}, \forall s \in [0,1].\] <p><strong>性质 4. 满足结合律（半群条件）：</strong></p> \[\delta_{s,t}(x) = \gamma \, \delta_{s,u}(x) + (1-\gamma) \, \delta_{u,t}(X_{s,u}(x)),\] <p>其中</p> \[\gamma = \frac{(1-t)(u-s)}{(1-u)(t-s)}.\] <p>Flow Map训练时使用的损失函数为</p> \[\mathcal{L}_{\mathrm{KL}}(\delta) := \mathbb{E}_{t,s,u} \mathbb{E}_{x_0,x_1} \left[ \sum_{\ell=1}^{L} \mathrm{KL}\!\left( \bar{\delta}_{s,t}^{\,\ell} \;\middle\|\; \delta_{s,t}^{\,\ell}(I_s) \right) \right] + \mathbb{E}_t \mathbb{E}_{x_0,x_1} \left[ \sum_{\ell=1}^{L} \mathrm{KL}\!\left( \hat{x}_1(I_t) \;\middle\|\; \delta_{t,t}^{\,\ell}(I_t) \right) \right].\] <p>其中</p> \[\bar{\delta}_{s,t} = \mathrm{sg}\left( \gamma \delta_{s,u}(I_s) + (1-\gamma) \delta_{u,t}(X_{s,u}(I_s)) \right).\] <p>$\bar{\delta}<em>{s,t}$ 是半群条件的目标值, $\mathbb{E}</em>{t,s,u}$是从在${0 \leq s \leq u \leq t \leq 1}$上全支撑(所有情况都能采样到的)的分布采样得出.</p> <p>$\hat{x}<em>1$ 使用 Flow Matching 预测，即作为教师模型，让学生模型 $\delta</em>{s,t}$ 去拟合教师的 $\hat{x}<em>1$ 即可。当然如果将 $\hat{x}_1$ 换成数据集中的原始 $x</em>{1}$ 也可以从零开始直接训练（自蒸馏）。</p> <ul> <li>用 $\hat{x}_i$：用原有 FLM 约束对角线</li> <li>用 $x_i$：从头训练</li> </ul> <h3 id="4-discrete-flow-maps">4. Discrete Flow Maps?</h3> <p>FMLM 指出，在原有的离散状态空间中，虽然整个概率分布的演化在理论上是确定存在的 $\dot{p_t} = Q_t p_t$，但因$Q_t \in \mathbb{R}^{\lvert V\rvert^L \times \lvert V\rvert^L}$, $p_t \ in \Delta^{\lvert V\rvert^L}$维度爆炸而无法计算；而我们真正需要的样本级别（Sample-level）的<strong>确定性</strong>流映射，在数学上被证明是根本不存在的（无法拟合所有目标分布）。因此，直接在纯离散空间做单步确定性生成是一条死路。</p> <h2 id="五算法实现">五、算法实现</h2> <h3 id="1-时间重参数化-taut">1. 时间重参数化 $\tau(t)$</h3> <p>在 FLM和FMLM 的训练和采样中，不同于一般的连续模态如图像，直接在 $t \in [0,1]$ 上均匀采样是低效的。原因在于：在高维 One-hot 空间中，Token 的去噪过程并不均匀——大部分确定性集中在 $t \to 1$ 的极窄窗口内剧烈变化。</p> <p>为此，FLM引入了时间重参数化 $\tau(t)$，定义如下：</p> \[\tau(t) = \frac{P_e(0) - P_e(t)}{P_e(0)} = 1 - \frac{\lvert V\rvert}{\lvert V\rvert - 1} P_e(t)\] <p>其中各符号含义：</p> <ul> <li><strong>$\lvert V\rvert$</strong>：词表大小（Vocabulary Size）。</li> <li><strong>$P_e(t)$</strong>：解码错误率（Decoding Error Rate），定义为：</li> </ul> \[P_e(t) := \frac{1}{L} \sum_{l=1}^L P(g_l(x_t) \neq g_l(x_1))\] <p>$P_e(t)$ 反映的是如果在时间 $t$ 强行终止流、对当前带噪状态 $x_t$ 解码，平均会有多少比例的 Token 被解错，$g(x)$ 在这里就是 <code class="language-plaintext highlighter-rouge">argmax</code> 操作。</p> <p>在端点处：</p> <ul> <li>$P_e(0) = 1 - \frac{1}{\lvert V\rvert}$（纯高斯噪声时，解错率最大）</li> <li>$P_e(1) = 0$（干净数据时，解错率为 0）</li> </ul> <p>根据Figure 9，$P_e(t)$ 在 $t \to 1$ 时急剧下降，<strong>说明大部分 Token 的确定性都集中在这个阶段</strong>。</p> <p>我们可以简单推导一下：由于$g(x) = argmax(x)$, 时刻$t$的插值为$x_t = (1 - t)x_0 + tx_1$, 假设本来应该输出的是第$j$位上的token, 然后混淆成了第$i$位上的token, 那么就有$x_t^i &gt; x_t^j$, 也就是$(1-t)x_0^i + tx_1^i &gt; (1-t)x_0^j + tx_1^j$. 即$x_0^i - x_0^j &gt; \frac{t}{1 - t}$, $\frac{t}{1 - t}$随$t$单调递增, 因此当$t$较大时, 需要更大的噪声差异才能导致解码错误, 因此解码错误率会急剧下降.</p> <p>在伪代码中，”Sample $t$ via $\tau(t) \sim \mathcal{U}[0,1]$” 的含义是：先均匀采样 $\tau$，再通过反函数映射回实际时间 $t$。</p> <h3 id="2-非对角线损失计算时的采样">2. 非对角线损失计算时的采样</h3> <p>在 FMLM 的蒸馏（Distillation）训练中，非对角线损失的核心目的是让学生模型（两点去噪器 $\hat{\delta}_{s,t}$）学习“时空穿梭”的半群性质（Semigroup property）：即要求模型做到从起点 $s$ 直接跳跃到终点 $t$ 的输出结果，必须等于先从 $s$ 跳到中转点 $u$，再从 $u$ 跳到 $t$ 的连续映射结果。</p> <p>为了保证模型在任何时间跨度下都能泛化这一性质，论文在重参数化后的时间轴 $\tau$ 上，采用了一套<strong>连续且对称的时间三元组 $(s, u, t)$ 采样策略</strong>。具体步骤如下：</p> <ol> <li>$h \sim \mathcal{U}[0, 1]$ 从均匀分布中随机抽取一个时间步长 $h$，它代表本次训练要求模型跨越的时间距离。</li> <li>$\tau(s) \sim \mathcal{U}[0, 1 - h]$, $\tau(t) = \tau(s) + h$</li> <li>$\tau(u) = \frac{\tau(s) + \tau(t)}{2}$ 中转点 $u$ 强制取在起点和终点的中间。</li> </ol> <p>相比shortcut model预先指定了固定的时间跨度、训练起点和终点。FMLM 的这种采样方式能够覆盖从极短到极长的所有时间跨度，确保模型在训练过程中见过各种跨度的样本，从而更好地学习半群性质。</p> <h3 id="3-少步骤生成的边界采样">3. 少步骤生成的边界采样</h3> <p>固定以概率p (FMLM中$p$取$\frac{1}{32}$) 直接采样边界对$(s,t) = (0,1)$来保证有足够的训练信号.</p> <h3 id="4-生成时引导">4. 生成时引导</h3> <ol> <li> <p><strong>Autoguidance</strong>, 用于无条件生成</p> <p>\(\hat{b}_t^{\text{(guided)}} = \hat{b}_t^{\text{(weak)}} + \eta (\hat{b}_t - \hat{b}_t^{\text{(weak)}})\)</p> <ul> <li>$\hat{b}_t$ 是主力好模型预测的速度方向。</li> <li>$\hat{b}_t^{\text{(weak)}}$ 是一个“弱模型”（比如训练步数少、网络小、或者加了高 Dropout 变笨的模型）预测的方向。</li> <li>$(\hat{b}_t - \hat{b}_t^{\text{(weak)}})$ 就是“好”减去“坏”，代表着更高质量的方向。</li> <li>$\eta &gt; 1$ 是控制强度的标量。</li> </ul> </li> </ol> <p>在连续空间里，这个结果依然是一个合法的方向；但在离散的 Logit 空间里”强推”（$\eta$ 很大时），会导致某些 token 的概率变得极其极端，破坏句子整体的连贯性。</p> <ol> <li><strong>Reward-guided generation</strong>, 用于控制文本属性的条件生成</li> </ol> <p>这里用到了Flow Map Trajectory Guidance (FMTG)的思想： \(\mathbf{x}_{t_{n+1}} = X_{t_n, t_{n+1}}(\mathbf{x}_{t_n}) + \lambda \nabla_{\mathbf{x}_{t_n}} r(X_{t_n, 1}(\mathbf{x}_{t_n}))\)</p> <ul> <li>下一步怎么走 = 正常按计划走一小步 + $\lambda \times$ <strong>奖励梯度的修正</strong>。</li> <li>$r(X_{t_n, 1}(\mathbf{x}_{t_n}))$表示模型可以看到自己目前预测的<strong>终点</strong>，让奖励模型评价一下好不好，然后计算梯度，反向传播回来微调当前这一小步的方向。</li> </ul> <h2 id="六相关算法伪代码">六、相关算法伪代码</h2> <table style="width: 100%; border-collapse: collapse; border: none;"> <tr> <td valign="top" style="width: 50%; padding-right: 15px; border: none;"> <b>Algorithm 5</b> FLM training <hr style="margin: 5px 0;"/> <b>Require:</b> Dataset $\mathcal{D}$, reparameterization $\tau(t)$, lr $\eta$<br/> <b>Initialize:</b> Denoiser $\hat{D}$<br/> <b>repeat</b><br/> &nbsp;&nbsp;&nbsp;&nbsp;$\mathbf{x}_1 \leftarrow f(\mathbf{y}), \mathbf{y} \sim \mathcal{D}; \quad \mathbf{x}_0 \sim \mathsf{N}(0, I)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;Sample $t$ via $\tau(t) \sim \mathsf{U}[0, 1]$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$I_t \leftarrow (1-t)\mathbf{x}_0 + t\mathbf{x}_1$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\hat{\mathbf{x}}_1 \leftarrow \hat{D}_t(I_t)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;Update $\hat{D}$: $\mathcal{L}_{\text{CE}} = - \sum_l (\mathbf{x}_1^l)^\top \log \hat{\mathbf{x}}_1^l$<br/> <b>until</b> converged <hr style="margin: 5px 0;"/> </td> <td valign="top" style="width: 50%; padding-left: 15px; border: none;"> <b>Algorithm 6</b> FLM sampling <hr style="margin: 5px 0;"/> <b>Require:</b> Trained $\hat{D}$, $\tau(t)$, steps $N$<br/> $\mathbf{x}_0 \sim \mathsf{N}(0, I)$<br/> $t_n \leftarrow t(n/N)$ for $n=0, ..., N$<br/> <b>for</b> $n=0$ to $N-1$ <b>do</b><br/> &nbsp;&nbsp;&nbsp;&nbsp;$\hat{\mathbf{x}}_1 \leftarrow \hat{D}_{t_n}(\mathbf{x}_{t_n})$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\hat{b}_n \leftarrow (\hat{\mathbf{x}}_1 - \mathbf{x}_{t_n})/(1 - t_n)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\mathbf{x}_{t_{n+1}} \leftarrow \mathbf{x}_{t_n} + (t_{n+1} - t_n)\hat{b}_n$<br/> <b>end for</b><br/> <b>Return</b> $g(\mathbf{x}_{t_N})$ <hr style="margin: 5px 0;"/> </td> </tr> <tr> <td valign="top" style="width: 50%; padding-right: 15px; border: none; padding-top: 15px;"> <b>Algorithm 7</b> FMLM training (distillation) <hr style="margin: 5px 0;"/> <b>Require:</b> Dataset $\mathcal{D}$, trained $\hat{D}$, $\tau(t)$, lr $\eta$<br/> <b>Initialize:</b> Two-time denoiser $\hat{\delta}$<br/> <b>repeat</b><br/> &nbsp;&nbsp;&nbsp;&nbsp;$\mathbf{x}_1 \leftarrow f(\mathbf{y}), \mathbf{y} \sim \mathcal{D}; \quad \mathbf{x}_0 \sim \mathsf{N}(0, I)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;<i>Diagonal (anchors to $\hat{D}$):</i><br/> &nbsp;&nbsp;&nbsp;&nbsp;$\tau(s) \sim \mathsf{U}[0, 1]; \quad I_s \leftarrow (1-s)\mathbf{x}_0 + s\mathbf{x}_1$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\mathcal{L}_{\text{diag}} \leftarrow - \sum_l \hat{D}(I_s)^l \cdot \log \hat{\delta}_{s,s}^l(I_s)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;<i>Off-diagonal (semigroup):</i><br/> &nbsp;&nbsp;&nbsp;&nbsp;$h \sim \mathsf{U}[0, 1]; \quad \tau(s) \sim \mathsf{U}[0, 1-h]$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\tau(t) \leftarrow \tau(s) + h; \quad \tau(u) \leftarrow \frac{\tau(s)+\tau(t)}{2}$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\gamma \leftarrow \frac{(1-t)(u-s)}{(1-u)(t-s)}$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\hat{X}_{s,u} \leftarrow \frac{1-u}{1-s}I_s + \frac{u-s}{1-s}\hat{\delta}_{s,u}(I_s)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\bar{\delta} \leftarrow \text{sg}(\gamma\hat{\delta}_{s,u}(I_s) + (1-\gamma)\hat{\delta}_{u,t}(\hat{X}_{s,u}))$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\mathcal{L}_{\text{off}} \leftarrow - \sum_l \bar{\delta}^l \cdot \log \hat{\delta}_{s,t}^l(I_s)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;Update $\hat{\delta}$: $\mathcal{L}_{\text{diag}} + \mathcal{L}_{\text{off}}$<br/> <b>until</b> converged <hr style="margin: 5px 0;"/> </td> <td valign="top" style="width: 50%; padding-left: 15px; border: none; padding-top: 15px;"> <b>Algorithm 8</b> FMLM sampling <hr style="margin: 5px 0;"/> <b>Require:</b> Trained $\hat{\delta}$, $\tau(t)$, steps $N$<br/> $\mathbf{x}_0 \sim \mathsf{N}(0, I)$<br/> $t_n \leftarrow t(n/N)$ for $n=0, ..., N$<br/> <b>for</b> $n=0$ to $N-1$ <b>do</b><br/> &nbsp;&nbsp;&nbsp;&nbsp;$\mathbf{x}_{t_{n+1}} \leftarrow \frac{1-t_{n+1}}{1-t_n}\mathbf{x}_{t_n} + \frac{t_{n+1}-t_n}{1-t_n}\hat{\delta}_{t_n, t_{n+1}}(\mathbf{x}_{t_n})$<br/> <b>end for</b><br/> <b>Return</b> $g(\mathbf{x}_{t_N})$ <hr style="margin: 5px 0;"/> </td> </tr> </table> </li> <li> <h2 id="i-problem-definition">I. Problem Definition</h2> <p>Given a vocabulary (token set) $V$, let $\lvert V\rvert$ denote the number of token types. A sentence sample of length $L$ is denoted as $y = (y^l)_{l=1}^L \in V^L$.</p> <p>The goal is to predict the distribution $p(y)$ over $V^L$ using as few computational and inference steps as possible, to generate a meaningful sample $y_{\text{sample}}$.</p> \[\overbrace{\underset{v \in V}{\underline{\text{Mary}}} \text{ is a girl.}}^{y \in V^L}\] <p>Metrics considered:</p> <ul> <li>Generation quality</li> <li>Inference steps</li> <li>Computational overhead</li> </ul> <h2 id="ii-existing-solutions">II. Existing Solutions</h2> <h3 id="autoregressive-language-models">Autoregressive language models</h3> <p>These follow the chain rule rather than a Markov chain, as the prediction of each token depends on the context of all previous tokens.</p> <p>The joint distribution can be written as:</p> \[p(y) = p(y^1)p(y^2 \mid y^1) p(y^3 \mid y^1,y^2) \cdots p(y^L \mid y^{&lt;L})\] <ul> <li>The computation is performed token-by-token from left to right, requiring $L$ steps in total.</li> <li>Each step requires selecting a token from $V$.</li> <li>The computational overhead is $O(\lvert V\rvert \cdot L)$.</li> <li>Inference steps are $O(L)$.</li> </ul> <h3 id="discrete-diffusion-language-models">Discrete diffusion language models</h3> <p>The idea is to accelerate generation by computing multiple tokens in parallel. Generally, significant speedup is only achieved when the number of inference steps is less than $L$.</p> <p>In DDLMs, we define the sentence-level transition density:</p> \[p_{t \mid s}(y_t \mid y_s), \quad y_s, y_t \in V^L\] \[\text{Corruption process} \left\{ \begin{array}{l c c c c c c c} &amp; t = 0 &amp; \rightarrow &amp; t = 0.3 &amp; \rightarrow &amp; t = 0.7 &amp; \rightarrow &amp; t = 1 \\[1em] \text{masking: } &amp; \text{Mary is a girl.} &amp; \rightarrow &amp; \text{Mary [m] a girl.} &amp; \rightarrow &amp; \text{Mary [m] a [m]} &amp; \rightarrow &amp; \text{[m] [m] [m] [m]} \\[0.5em] &amp; \rlap{\color{gray}{\text{([m] has zero info, but corrupted positions are known)}}} &amp; &amp; &amp; &amp; &amp; &amp; \\[1.5em] \text{uniform randomization: } &amp; \text{Mary is a girl.} &amp; \rightarrow &amp; \text{Mary is a \textbf{boy}.} &amp; \rightarrow &amp; \text{Mary \textbf{angry} a \textbf{boy}} &amp; \rightarrow &amp; \text{\textbf{dog} \textbf{hello} a \textbf{boy}} \\[0.5em] &amp; \rlap{\color{gray}{\text{(Cannot infer corrupted positions nor original tokens)}}} &amp; &amp; &amp; &amp; &amp; &amp; \\ \end{array} \right.\] <p>Denoising:</p> <p>If we directly compute $P_{t\mid s}(y_t \mid y_s)$ in the $V^L$ space, it can be written as:</p> \[P_{t\mid s}(y_t \mid y_s) = \prod_{l=1}^{L} P_{t\mid s}(y_t^{l} \mid y_t^{&lt;l}, y_s)\] <p>Under this premise, updating $y$ at each step is essentially performing a mapping $y_{s} \in V^L \mapsto y_{t} \in V^L$.</p> <ul> <li>The computation is performed concurrently for all tokens.</li> <li>Each step requires selecting a token from $V$ for every position in $y_t$.</li> <li>Inference steps are $O(N)$. For acceleration, $N$ should be a constant much smaller than $L$.</li> <li>The computational overhead is $O(\lvert V\rvert^L)$.</li> </ul> <p>Therefore, this is generally intractable. DDLMs typically adopt a factorized approximation:</p> \[\widehat{P}_{t\mid s}(y_t \mid y_s) := P_{t\mid s}^1(y_t^1 \mid y_s) P_{t\mid s}^2(y_t^2 \mid y_s) \cdots P_{t\mid s}^L(y_t^L \mid y_s)\] <p>The superscript $i$ in $P_{t \mid s}^{i}$ indicates that the probability computation is position-dependent.</p> <p>This means:</p> <ul> <li>The computational overhead drops to $O(L \times \lvert V\rvert)$, but it loses a significant amount of contextual correlation, leading to a degradation in generation quality.</li> <li>Furthermore, the prediction of each token is assumed to be approximately independent, which only holds true when $t \rightarrow s$.</li> <li>The small update step sizes mean that the number of inference steps $N$ during generation remains quite large.</li> </ul> <h2 id="iii-discrete-representation-of-language">III. Discrete Representation of Language</h2> <p>This step aims to establish the mapping $y \in V^L \leftrightarrow x \in \mathcal{X}$, where $\mathcal{X}$ is a continuous space, typically a high-dimensional real coordinate space $\mathbb{R}^{L \times \lvert V\rvert}$.</p> <p>Usually, we use a continuous encoder (embedding) $f$ and a decoder $g$ to perform this mapping:</p> <ul> <li>Encoder: $f : y \mapsto x$</li> <li>Decoder: $g : x \mapsto y$, such that $g(f(y)) = y$.</li> </ul> <p>Thus, the original distribution $p(y)$ can induce a distribution $p(x)$ via \(p(x) = p(y = g(x))\) and can be recovered using $y = g(x)$.</p> <p>The inference and decoding process can be rewritten as:</p> \[\hat{x} \sim p(x), \quad \hat{y} = g(\hat{x})\] <p>That is, sample in the continuous space first, then map back to the discrete sequence.</p> <p>Common choices for the encoding method $f$ include:</p> <ol> <li><strong>Learned Embedding</strong>: A low-dimensional vector $\theta_i$ is randomly initialized for each token index $i$, and $\theta$ is updated in real-time as part of the model parameters.</li> </ol> <p>This method has strong expressive power but requires careful regularization; otherwise, all $\theta_i$ might collapse to the same value, or $\lvert\theta\rvert \to \infty$.</p> <ol> <li> <p><strong>Pretrained Embedding</strong>: Easy to implement. It utilizes the embedding layers of pre-trained language models like T5 (as in <strong>ELF</strong>) or BERT, inheriting prior knowledge, and is frozen during training.</p> </li> <li> <p><strong>One-hot Encoding</strong>: Maps each token directly to a one-hot vector:</p> </li> </ol> \[f: y \mapsto (\text{onehot}(y^1), \ldots, \text{onehot}(y^L))^\top, \quad V^L \to \mathbb{R}^{L \times \lvert V\rvert}\] \[g: x \mapsto (\arg\max(x^1), \ldots, \arg\max(x^L)), \quad \mathbb{R}^{L \times \lvert V\rvert} \to V^L\] <p>This representation requires no regularization and is well-suited for cross-entropy training. It is lossless in information but highly dimensional, and semantic similarity is not easily expressed directly.</p> <h2 id="iv-flow-language-model">IV. Flow Language Model</h2> <p>The core problem now becomes: learning the continuous data distribution $p(x)$ in the embedding space.</p> <h3 id="1-interpolation">1. Interpolation</h3> <p>The goal is to bridge the noise distribution $p_0$ and the data distribution $p_1$, defining a probability path that evolves over time.</p> <ol> <li>Linear Interpolation:</li> </ol> \[I_t := (1-t)x_0 + tx_1, \quad I_t \sim p_t\] <p>Where:</p> <ul> <li>$x_0 \sim p_0 = \mathcal{N}(0, I)$ represents the noise.</li> <li>$x_1 \sim p_1$ represents the target sample.</li> <li>$t \in [0,1]$ is the time variable.</li> <li>$I_t$ denotes the intermediate state at time $t$ during <strong>training</strong>, distinguished from the variable $x_t$ which denotes the intermediate state at time $t$ during <strong>inference</strong>.</li> </ul> <p>The velocity field of this approach is easy to learn, the path is a straight line, and training is generally efficient and stable.</p> <ol> <li>Stochastic Interpolation with Noise:</li> </ol> \[I_t = (1-t)x_0 + tx_1 + \sqrt{2t(1-t)}z, \quad z \sim \mathcal{N}(0, I_d)\] <ol> <li>Trigonometric Interpolation:</li> </ol> \[I_t = \cos\left(\frac{\pi}{2}t\right)x_0 + \sin\left(\frac{\pi}{2}t\right)x_1\] <p>This maintains a constant variance for the intermediate state distributions, yielding “variable-speed generation.”</p> <ol> <li>Additionally, encoder-decoder-style paths can be considered, for example:</li> </ol> \[I_t = (1-t)x_0 + tx_1 + \sin^2(\pi t)\] <p>Intuitively:</p> <ul> <li>$t: 0 \to 0.5$ acts more like an encoding/corruption process, mapping into a pure-noise latent space.</li> <li>$t \to 1$ acts more like decoding from the latent space back to the target space.</li> </ul> <h3 id="2-probability-flow-and-vector-fields">2. Probability Flow and Vector Fields</h3> <p>The goal here is to learn a deterministic ODE/SDE from the generated probability paths. This is somewhat similar to the idea of world models inferring physical dynamics by observing trajectories.</p> <p>If linear interpolation is adopted, we introduce a velocity field $b_t(x_t)$ to describe the update direction of $x_t$ at time $t$, defined as:</p> \[b_t(x_t) = \dot{x_t}\qquad x_0 \sim p_0, t \in [0,1]\] <p>The flow dynamics of the entire model can be described by an ODE or an SDE:</p> <ol> <li>ODE: \(\frac{d}{dt} x_t = b_t(x_t)\)</li> <li>SDE: \(\frac{d}{dt} x_t = b_t(x_t) + \sqrt{2\epsilon} dW_t\) Where $W_t$ is standard Brownian motion and $\epsilon$ is the noise intensity, adding stochastic jitter to enhance the model’s robustness and generalization capability.</li> </ol> <p>Starting from the initial distribution $p_0$, we just need to progressively solve the ODE/SDE to obtain samples from the final distribution $p_1$, without needing to randomly resample at every step.</p> <h3 id="3-fitting--mse-loss">3. Fitting &amp; MSE Loss</h3> <p>Let’s briefly summarize the notation:</p> <ul> <li>Initial noise: $x_0$, target sample: $x_1$, time variable: $t \in [0,1]$.</li> <li>Intermediate state during training: $I_t := (1-t)x_0 + tx_1$, the true ground-truth velocity field during training is $\dot{I_t} = x_1-x_0$.</li> <li>Intermediate state during inference: $x_t := x_0 + \int_0^t b_s(x_s) \, ds$, where $b_t(x_t)$ is the predicted velocity field, determining the update direction at each step.</li> </ul> <p>Thus, as long as $b_t(x)$ can be predicted or computed, the entire ODE/SDE sampling process is determined.</p> <p>For a specific time $t$, we can take the conditional expectation of the velocities of all trajectories passing through that point, yielding:</p> \[b_t(x_t) = \mathbb{E}_{x_t \sim p_t}[\dot{x_t}] = \mathbb{E}_{I_t \sim p_t}[\dot{I_t} \vert I_t = x_t] = \mathbb{E}_{I_t \sim p_t}[I_1 - x_0 \vert I_t = x_t]\] <p>$I_{1}$ represents the state at $t = 1$ predicted from training trajectories containing $I_t$, conditioned on $I_t = x_t$. Then, for $\forall x \in p_t(x)$, we have:</p> \[b_t(x) = \mathbb{E}_{I_t \sim p_t}[I_{1} - x_0 \vert I_t = x]\] <p>This also means the problem can be formulated as a regression problem.</p> <p>Defining the MSE Loss:</p> \[\mathcal{L}_{\text{MSE}}(\hat{b}) := \int_0^1 \mathbb{E}\left[\left\vert \hat{b}_t(I_t) - \dot{I_t} \right\vert^2\right] dt\] <p>In practical implementation, the integral is typically discretized into a grid:</p> \[0 = t_0 &lt; t_1 &lt; \cdots &lt; t_N = 1\] <p>Then, the optimal velocity field satisfies:</p> \[b = \arg\min_{\hat{b}} \mathcal{L}_{\text{MSE}}(\hat{b})\] <h4 id="issues-with-directly-predicting-the-velocity-field">Issues with Directly Predicting the Velocity Field</h4> <p>This is a unique problem when using flow for language generation. If we directly predict:</p> \[b = x_1 - x_0\] <p>Since $x_0 \in \mathbb{R}^{L \times \lvert V\rvert}$ lies in a high-dimensional discrete representation space, and the Gaussian noise $x_0$ is generally full-rank, the neural network $\phi: \mathbb{R}^{L \times \lvert V\rvert} \mapsto \mathbb{R}^{L \times d} \mapsto \mathbb{R}^{L \times \lvert V\rvert}$ has a hidden state dimension $d$ that is insufficient to express each $b_i \in \mathbb{R}^{\lvert V\rvert}$ output from the network ($d \ll \lvert V\rvert$). Thus, using $b$ directly as the training target inevitably leads to underfitting. (Experimentally verified in ELF C.1, Figure 10).</p> <p>A common view is that although $x \in \mathbb{R}^{L \times \lvert V\rvert}$, natural language samples do not uniformly cover this space. They are more likely concentrated on a low-dimensional manifold, so they can be learned through a more compact representation.</p> <p>The true velocity field $\dot{I_t}$ is a constant equal to $x_1 - x_0$, independent of $t$:</p> \[\dot{I_t} = x_1 - x_0,\] <p>The predicted velocity field is rewritten as a prediction of the endpoint:</p> \[\hat{b}_t(I_t) = \frac{\hat{x}_1 - x_t}{1-t}\] <p>Where $\hat{x}<em>1$ is the predicted final outcome, $\hat{x}_1(x_t) = \mathbb{E}</em>{I_t \sim p_t}[I_1 \mid I_{t} = x_t]$.</p> <p>Thus, the original MSE objective can be rewritten as:</p> \[\mathcal{L}_{\text{MSE}}(\hat{b}) = \int_0^1 \mathbb{E}\left[\left\vert \hat{b}_t(I_t) - \dot{I_t} \right\vert^2\right] dt = \int_0^1 \mathbb{E}\left[\left\vert \frac{\hat{x}_1 - x_t}{1-t} - (x_1 - x_0) \right\vert^2\right] dt \\ = \int_0^1 \mathbb{E}\left[\left\vert \frac{\hat{x}_1 - x_{1} + ((1-t)x_{0} + tx_{1} - x_t)}{1-t} \right\vert^2\right] dt \\ = \int_0^1 \frac{1}{(1-t)^2}\mathbb{E}\left[(\hat{x}_1 - x_{1})^2\right] dt\] <p>At this point, training can also be understood as directly approximating the final target sample. However, note that the term $\frac{1}{(1-t)^2}$ turns the integral into an improper integral, causing the loss function value to approach infinity as $t \to 1$, which can lead to training instability.</p> <h4 id="countermeasures">Countermeasures</h4> <ul> <li><strong>FMLM</strong>: Directly ignores the $\frac{1}{(1-t)^2}$ term, using an approximate objective $\int_0^1 \mathbb{E}\left[(\hat{x}<em>1 - x</em>{1})^2\right] dt$. However, this may not be strictly rigorous. In practice, it is often more suitable to use in conjunction with Cross-Entropy (CE), while keeping $t$ relatively small.</li> <li><strong>ELF</strong>: <ol> <li>Instead of uniform sampling for $t \in [0,1]$, it samples from a log-normal distribution: $t’ \sim \mathcal{N}(P_{mean}, P_{std}^2), t = \sigma(t’)$.</li> <li>A separate decoding branch is set up directly at a position where $t$ is close to $1$, which is much more suitable for applying CE loss.</li> <li>Since the optimal prediction $\hat{x}_1$ must satisfy $\hat{x}_1 - x_1 = O(1 - t)$, this is equivalent to introducing an implicit Lipschitz constraint. Naturally, we can consider introducing an explicit Lipschitz regularization term to enforce this constraint, which could be explored later.</li> </ol> </li> </ul> <h3 id="4-decoding--ce-loss">4. Decoding &amp; CE Loss</h3> <p>When fitting in a continuous space, MSE Loss is the most natural training objective. However, when the data ultimately needs to be converted back into a discrete representation, we can introduce Cross-Entropy (CE) as a more suitable training objective.</p> <h4 id="flms-ce-objective">FLM’s CE Objective</h4> <p>FLM uses one-hot encoding, meaning that in the target $x_1 \in \mathbb{R}^{L \times \lvert V\rvert}$, every component $x_{1}^l$ has only one element equal to 1, and the rest are 0.</p> <p>FLM defines the cross-entropy objective as:</p> \[\mathcal{L}_{CE}(\hat{x_1}) := \int_0^1 \mathbb{E}_{I_t \sim p_t}\left[-\sum_{l=1}^L \log \hat{x_1}(I_t)^l \cdot x_1^l\right] dt\] <p>Where</p> \[\log \hat{x_1}(I_t)^l \cdot x_1^l = \log \left( \text{probability of the model predicting the correct Token } c \right)\] <p><strong>Key Properties:</strong></p> <ol> <li>$\mathcal{L}_{CE}$ can be decomposed into an irreducible conditional entropy plus the sum of KL divergences from the true posterior to the model distribution. Therefore, minimizing CE is essentially performing distribution matching of $\hat{x}_1$ to $x_1$.</li> <li>If the CE error $\Delta_D(\hat{D}) := \mathcal{L}<em>{CE}(\hat{D}) - \mathcal{L}</em>{CE}(D) \leq \varepsilon$, then for any early stopping time $\xi \in (0,1)$:</li> </ol> \[W_2^2(\hat{p}_{1-\xi}, p_{1-\xi}) \leq C\varepsilon\] <p>Where $C &gt; 0$ depends on $\xi$ and the model’s Lipschitz constant. The $1-\xi$ term is used to avoid the $(1-t)^{-1}$ singularity during conversion. Simply put, the lower the training loss here, the better the generation quality will definitely be.</p> <ol> <li><strong>Connection to Discrete Diffusion</strong>: The optimal denoiser implicitly learns the factorized posterior $p^l_{1\mid t}(x_1^l \mid x_t)$, which aligns with how discrete diffusion models learn $p^l_{1\mid t}$ via tokenwise CE. The key difference is: discrete models use $p^l_{1\mid t}$ for ancestral sampling (which requires the full joint probability density and is affected by factorization errors); continuous models use $p^l_{1\mid t}$ to infer exact velocity fields, which can then be precisely distilled into few-step generators.</li> </ol> <p>In summary, FLM’s CE is a per-step objective along the entire flow trajectory, meaning token-level cross-entropy supervision is applied for all $t \in [0,1]$.</p> <h4 id="elfs-ce-objective">ELF’s CE Objective</h4> <p><strong>ELF’s CE is only applied at the final time step $t = 1$</strong>, rather than as a per-step objective along the entire trajectory. This is the core design difference between ELF and FLM (or other continuous DLMs).</p> <ol> <li> <p>At $t = 1$, ELF naturally treats the denoising process as a continuous-to-discrete decoding step. The same network $\text{net}_\theta$ switches to a “decode” mode at $t = 1$ (controlled via a binary mode token), eliminating the need for a separate decoder—it can be understood as a decoder sharing weights with the denoiser.</p> </li> <li> <p>As $t \to 1$, $z_t \to x$ (approaching the clean embedding), at which point the network input becomes too trivial (essentially the answer itself). Therefore, ELF introduces a token-level corruption process at $t = 1$, replacing the clean embedding with a corrupted version $\tilde{z}$ to create a meaningful training signal.</p> </li> <li> <p><strong>CE Loss</strong>:</p> </li> </ol> \[\mathcal{L}_{CE} = \mathbb{E}_{\tilde{z}}\left[\text{CrossEnt}(W\mathbf{x}_\theta(\tilde{z}), s)\right]\] <p>Where:</p> <ul> <li>$\mathbf{x}_\theta(\tilde{z})$ is the network’s prediction for $\tilde{z}$ (clean embedding).</li> <li>$W$ is a learnable “unembedding” matrix that maps the embedding back to logits.</li> <li>$s$ is the ground-truth token (the original discrete token).</li> </ul> <ol> <li><strong>During inference</strong>: $W\mathbf{x}_\theta(z_t)$ is computed only at the final step $t = 1$, followed by an argmax over the logits to obtain the discrete token.</li> </ol> <p><strong>Reasoning for why ELF avoids applying CE to intermediate denoising steps</strong>: ELF’s denoising trajectory operates entirely within an unrestricted continuous embedding space. Per-step token-level supervision would overly bind the trajectory to vocabulary-level predictions, restricting the flexibility of the flow dynamics. Performing discretization exclusively at $t = 1$ grants the flow maximum degrees of freedom when $t &lt; 1$.</p> <p><strong>Core divergence</strong>: FLM posits that since the optimal denoiser naturally lies on the simplex, CE is the most suitable training objective and should be used along the entire trajectory. Conversely, ELF argues that per-step CE restricts the flexibility of flow dynamics, and thus discretization should only occur at the final step, leaving intermediate steps to evolve freely in the continuous space.</p> <h2 id="v-flow-map-language-models">V. Flow Map Language Models</h2> <h3 id="1-introducing-the-flow-map">1. Introducing the Flow Map</h3> <p>To avoid having to compute integrals, which prevents convergence under few-step scenarios, we introduce the flow map.</p> <p>Defined as the solution operator for $\dot{x}_t = b_t(x_t), \quad x_0 \sim p_0, \quad t \in [0,1]$:</p> \[X_{s,t}(x_s) = x_t, \quad \forall s,t \in [0,1].\] <p>That is, the transformation function between any two arbitrary moments in time.</p> <p>The equation can also be rewritten as:</p> \[X_{s,t}(x_s) = x_s + (t-s)v_{s,t}(x_s),\] <p>Where $v_{s,t}$ is called the average velocity from $s$ to $t$, or “mean flow”.</p> <p>Given a sample $\hat{x}_0$, with the flow map available, we can discretize a grid $0 = t_0 &lt; \cdots &lt; t_N = 1$ and sequentially compute:</p> \[\hat{x}_{t_{i+1}} = X_{t_i, t_{i+1}}(\hat{x}_{t_i})\] <p>to obtain the sample. In extreme cases, by setting $N = 1$, we can achieve single-step generation $\hat{x}<em>1 = X</em>{0,1}(x_0)$. Generally, a larger $N$ yields better performance.</p> <h3 id="2-conditions-required-to-learn-a-reasonable-flow-map">2. Conditions Required to Learn a Reasonable Flow Map</h3> <p><strong>1. Identity Condition:</strong></p> \[X_{s,s}(x) = x, \quad \forall x \in \mathbb{R}^{L \times \lvert V\rvert}, \forall s \in [0,1].\] <p>It can be seen that this condition is actually trivial. We integrate it into the subsequent two constraints as the constant constraint for the ODE.</p> <p><strong>2. Instantaneous Velocity Condition (Lagrangian Equation):</strong></p> \[\partial_t X_{s,t}(x) = b_t(X_{s, t}(x)) \quad X_{s,s}(x) = x,\quad \forall x \in \mathbb{R}^{L \times \lvert V\rvert}, \forall s,t \in [0,1].\] <p><strong>3. Endpoint Invariance Condition (Eulerian Equation):</strong></p> \[\partial_s X_{s,t}(x) + b_s(x) \cdot \nabla X_{s,t}(x) = 0, \quad X_{t,t}(x) = x,\quad \forall x \in \mathbb{R}^{L \times \lvert V\rvert}, \forall s,t \in [0,1].\] <p><strong>4. Semi-group Condition:</strong></p> \[X_{u,t}(X_{s,u}(x)) = X_{s,t}(x), \quad \forall x \in \mathbb{R}^{L \times \lvert V\rvert}, \forall s,u,t \in [0,1].\] <p>It is worth adding that the latter three are fundamentally equivalent, describing properties of the exact same flow. The second one degenerates into a local tangent condition when taking the limit $s \to t$:</p> \[\lim_{s \to t} \partial_t X_{s,t}(x) = b_t(x)\] <p>The third one is derived from the condition that the endpoint $t$ does not change with the starting point $s$:</p> \[\frac{d}{ds} X_{s,t}(x) = 0\] <p>By combining the tangent property with 2, 3, and 4 respectively, we can obtain three equivalent constraint forms:</p> <p>Lagrangian map distillation (LMD) loss:</p> \[\mathcal{L}_{\text{LMD}}(\hat{v}) = \underbrace{\int_0^1 \int_0^t \mathbb{E} \left\vert\partial_t \hat{X}_{s,t}(I_s) - \text{sg}\left(\hat{b}_t\left(\hat{X}_{s,t}(I_s)\right)\right)\right\vert^2 ds dt}_{\text{Corresponds to: Lagrangian condition}} + \underbrace{\int_0^1 \mathbb{E} \vert\hat{v}_{t,t}(I_t) - \hat{b}_t(I_t)\vert^2 dt}_{\text{Corresponds to: Tangent condition}}\] <p>Eulerian map distillation (EMD) loss:</p> \[\mathcal{L}_{\text{EMD}}(\hat{v}) = \underbrace{\int_0^1 \int_0^t \mathbb{E} \left\vert\partial_s \hat{X}_{s,t}(I_s) + \text{sg}\left(\hat{b}_s(I_s) \cdot \nabla \hat{X}_{s,t}(I_s)\right)\right\vert^2 ds dt}_{\text{Corresponds to: Eulerian condition}} + \underbrace{\int_0^1 \mathbb{E} \vert\hat{v}_{t,t}(I_t) - \hat{b}_t(I_t)\vert^2 dt}_{\text{Corresponds to: Tangent condition}}\] <p>Progressive map distillation (PMD) loss:</p> \[\mathcal{L}_{\text{PMD}}(\hat{v}) = \underbrace{\int_0^1 \int_0^t \int_s^t \mathbb{E} \left\vert\hat{X}_{s,t}(I_s) - \text{sg}\left(\hat{X}_{t,u}\left(\hat{X}_{s,t}(I_s)\right)\right)\right\vert^2 du ds dt}_{\text{Corresponds to: Semi-group condition}} + \underbrace{\int_0^1 \mathbb{E} \vert\hat{v}_{t,t}(I_t) - \hat{b}_t(I_t)\vert^2 dt}_{\text{Corresponds to: Tangent condition}}\] <p>For self-distillation, we just need to replace $\hat{b}_t(I_t)$ in the last term of each equation with $\dot{I_t}$.</p> <p>FMLM adopts the last constraint form:</p> \[\begin{aligned} \mathcal{L}_{\mathrm{MSE}}(\hat v)=&amp; \int_0^1 \int_0^t \int_t^s \mathbb{E}_{I_s} \left[ \left\| \hat X_{s,t}(I_s) - \mathrm{sg}\!\left( \hat X_{u,t} \left( \hat X_{s,u}(I_s) \right) \right) \right\|^2 \right] \,du\,ds\,dt \\ &amp;+ \int_0^1 \mathbb{E}_{I_t} \left[ \left\| \hat v_{t,t}(I_t) - \hat b_t(I_t) \right\|^2 \right] \,dt . \end{aligned}\] <p>The first term is the associativity constraint (semi-group), and the second is the instantaneous velocity constraint.</p> <p>Here, <code class="language-plaintext highlighter-rouge">sg</code> stands for stop-gradient (no backpropagation). The first term can be further expanded using $X_{s,t}(x_s) = x_s + (t-s)v_{s,t}$, and the second term can replace the pre-trained $\hat{b}_t$ with $I_t$.</p> <p>$X_{s, t}$ itself is derived from Gaussian Noise. Directly constraining it would face the same issues as directly computing $b_t$. To unify Flow Matching and Flow Map in the probability space while utilizing the simplex constraint brought by One-Hot encoding, FMLM introduces a new optimization target:</p> \[\delta_{s,t}(x_s) := x_s + (1-s)v_{s,t}(x_s).\] <p>This can be conceptualized as a matrix $T \in \mathbb{R}^{N \times N}$:</p> <ul> <li>The horizontal and vertical axes correspond to time $(s,t)$.</li> <li>Flow Matching is equivalent to filling in the diagonal values $T_{tt}$ (i.e., $\hat{b}<em>t = \hat{X}</em>{t,t}$).</li> <li>The latter is equivalent to filling in the upper or lower triangular regions of the matrix.</li> </ul> <p>An additional benefit of this representation is that we no longer need to use MSE for numerical regression; instead, we can directly use CE (Cross Entropy) for classification. Using MSE for classification can lead to numerical instability.</p> <h3 id="3-properties-of-delta_st">3. Properties of $\delta_{s,t}$</h3> <p>The $\delta_{s,t}$ chosen by FMLM has the following properties:</p> <p><strong>Property 1. Quick correspondence with flow matching:</strong></p> \[X_{s,t}(x) = \frac{1-t}{1-s}x + \frac{t-s}{1-s}\delta_{s,t}(x)\] <p><strong>Property 2. Resides on a simplex, low dimensionality:</strong></p> \[\delta_{s,t}(x)^\ell \in \Delta^{\lvert V\rvert-1}, \quad \ell = 1,2,\cdots,L.\] <p>Where $\Delta^{\lvert V\rvert-1}$ satisfies that all values are non-negative and sum to 1.</p> <p><strong>Property 3. Diagonal matches the target denoiser / imputation function:</strong></p> \[\delta_{s,s}(x) = \mathbb{E}_{I_t \sim p_t}[x_1 \mid I_t = x] = \hat{x}_1, \quad \forall x \in \mathbb{R}^{L \times \lvert V\rvert}, \forall s \in [0,1].\] <p><strong>Property 4. Satisfies associativity (Semi-group condition):</strong></p> \[\delta_{s,t}(x) = \gamma \, \delta_{s,u}(x) + (1-\gamma) \, \delta_{u,t}(X_{s,u}(x)),\] <p>Where</p> \[\gamma = \frac{(1-t)(u-s)}{(1-u)(t-s)}.\] <p>The loss function used during Flow Map training is:</p> \[\mathcal{L}_{\mathrm{KL}}(\delta) := \mathbb{E}_{t,s,u} \mathbb{E}_{x_0,x_1} \left[ \sum_{\ell=1}^{L} \mathrm{KL}\!\left( \bar{\delta}_{s,t}^{\,\ell} \;\middle\|\; \delta_{s,t}^{\,\ell}(I_s) \right) \right] + \mathbb{E}_t \mathbb{E}_{x_0,x_1} \left[ \sum_{\ell=1}^{L} \mathrm{KL}\!\left( \hat{x}_1(I_t) \;\middle\|\; \delta_{t,t}^{\,\ell}(I_t) \right) \right].\] <p>Where</p> \[\bar{\delta}_{s,t} = \mathrm{sg}\left( \gamma \delta_{s,u}(I_s) + (1-\gamma) \delta_{u,t}(X_{s,u}(I_s)) \right).\] <p>$\bar{\delta}<em>{s,t}$ is the target value for the semi-group condition. $\mathbb{E}</em>{t,s,u}$ is sampled from a fully supported distribution over ${0 \leq s \leq u \leq t \leq 1}$ (meaning all combinations can be sampled).</p> <p>$\hat{x}<em>1$ is predicted using Flow Matching, acting as a teacher model, so the student model $\delta</em>{s,t}$ just fits the teacher’s $\hat{x}_1$. Of course, if $\hat{x}_1$ is replaced by the original ground-truth $x_1$ from the dataset, it can also be trained directly from scratch (self-distillation).</p> <ul> <li>Using $\hat{x}_i$: Constrain the diagonal using the original FLM.</li> <li>Using $x_i$: Train from scratch.</li> </ul> <h3 id="4-discrete-flow-maps">4. Discrete Flow Maps?</h3> <p>FMLM points out that in the original discrete state space, although the evolution of the entire probability distribution theoretically exists deterministically as $\dot{p_t} = Q_t p_t$, it cannot be computed due to the dimensional explosion of $Q_t \in \mathbb{R}^{\lvert V\rvert^L \times \lvert V\rvert^L}$ and $p_t \in \Delta^{\lvert V\rvert^L}$. Furthermore, the sample-level <strong>deterministic</strong> flow map we actually need has been mathematically proven to simply not exist (it cannot fit all target distributions). Therefore, directly attempting single-step deterministic generation in a purely discrete space is a dead end.</p> <h2 id="vi-algorithm-implementation">VI. Algorithm Implementation</h2> <h3 id="1-time-reparameterization-taut">1. Time Reparameterization $\tau(t)$</h3> <p>In the training and sampling of FLM and FMLM, unlike typical continuous modalities such as images, uniform sampling over $t \in [0,1]$ is inefficient. The reason is that in the high-dimensional One-hot space, the denoising process of tokens is not uniform—most of the determinism is concentrated and changes drastically within a very narrow window as $t \to 1$.</p> <p>To address this, FLM introduces time reparameterization $\tau(t)$, defined as follows:</p> \[\tau(t) = \frac{P_e(0) - P_e(t)}{P_e(0)} = 1 - \frac{\lvert V\rvert}{\lvert V\rvert - 1} P_e(t)\] <p>Where the symbols denote:</p> <ul> <li><strong>$\lvert V\rvert$</strong>: Vocabulary Size.</li> <li><strong>$P_e(t)$</strong>: Decoding Error Rate, defined as:</li> </ul> \[P_e(t) := \frac{1}{L} \sum_{l=1}^L P(g_l(x_t) \neq g_l(x_1))\] <p>$P_e(t)$ reflects the average proportion of tokens that would be decoded incorrectly if the flow is forcefully terminated at time $t$ and the current noisy state $x_t$ is decoded. Here, $g(x)$ acts as an <code class="language-plaintext highlighter-rouge">argmax</code> operation.</p> <p>At the endpoints:</p> <ul> <li>$P_e(0) = 1 - \frac{1}{\lvert V\rvert}$ (maximum error rate under pure Gaussian noise)</li> <li>$P_e(1) = 0$ (0 error rate for clean data)</li> </ul> <p>According to Figure 9, $P_e(t)$ drops sharply as $t \to 1$, <strong>indicating that the determinism of most tokens is concentrated in this stage</strong>.</p> <p>We can deduce this simply: Since $g(x) = \text{argmax}(x)$, the interpolation at time $t$ is $x_t = (1 - t)x_0 + tx_1$. Assuming the correct output token is at index $j$, but it is confused with the token at index $i$, then we must have $x_t^i &gt; x_t^j$. This means $(1-t)x_0^i + tx_1^i &gt; (1-t)x_0^j + tx_1^j$, which simplifies to $x_0^i - x_0^j &gt; \frac{t}{1 - t}$. Because $\frac{t}{1 - t}$ monotonically increases with $t$, a much larger noise difference is required to cause a decoding error when $t$ is large. Therefore, the decoding error rate drops drastically.</p> <p>In the pseudocode, “Sample $t$ via $\tau(t) \sim \mathcal{U}[0,1]$” means: first uniformly sample $\tau$, and then map it back to the actual time $t$ via the inverse function.</p> <h3 id="2-sampling-for-off-diagonal-loss-computation">2. Sampling for Off-Diagonal Loss Computation</h3> <p>In the distillation training of FMLM, the core purpose of the off-diagonal loss is to make the student model (the two-point denoiser $\hat{\delta}_{s,t}$) learn the semi-group property (“time-space travel”): this requires the model’s output for directly jumping from start point $s$ to endpoint $t$ to perfectly match the continuous mapping result of jumping from $s$ to relay point $u$, and then from $u$ to $t$.</p> <p>To ensure the model generalizes this property across any time span, the paper employs a <strong>continuous and symmetric sampling strategy for the time triplet $(s, u, t)$</strong> on the reparameterized time axis $\tau$. The specific steps are:</p> <ol> <li>$h \sim \mathcal{U}[0, 1]$ Randomly draw a time step size $h$ from a uniform distribution, representing the time distance the model is required to cross in the current training step.</li> <li>$\tau(s) \sim \mathcal{U}[0, 1 - h]$, $\tau(t) = \tau(s) + h$</li> <li>$\tau(u) = \frac{\tau(s) + \tau(t)}{2}$ The relay point $u$ is forcefully placed exactly in the middle of the start and end points.</li> </ol> <p>Compared to shortcut models which pre-specify fixed time spans, training start points, and end points, FMLM’s sampling method can cover all time spans from extremely short to extremely long, ensuring that the model encounters samples of various spans during training to better learn the semi-group property.</p> <h3 id="3-boundary-sampling-for-few-step-generation">3. Boundary Sampling for Few-Step Generation</h3> <p>With a fixed probability $p$ ($p = \frac{1}{32}$ in FMLM), the boundary pair $(s,t) = (0,1)$ is sampled directly to ensure sufficient training signals.</p> <h3 id="4-generation-guidance">4. Generation Guidance</h3> <ol> <li> <p><strong>Autoguidance</strong>, used for unconditional generation</p> <p>\(\hat{b}_t^{\text{(guided)}} = \hat{b}_t^{\text{(weak)}} + \eta (\hat{b}_t - \hat{b}_t^{\text{(weak)}})\)</p> <ul> <li>$\hat{b}_t$ is the velocity direction predicted by the primary, high-quality model.</li> <li>$\hat{b}_t^{\text{(weak)}}$ is the direction predicted by a “weak model” (e.g., a model with fewer training steps, smaller network size, or “dumbed down” by high dropout).</li> <li>$(\hat{b}_t - \hat{b}_t^{\text{(weak)}})$ represents “good” minus “bad”, pointing towards a higher-quality direction.</li> <li>$\eta &gt; 1$ is a scalar controlling the guidance strength.</li> </ul> </li> </ol> <p>In a continuous space, this result is still a valid direction; however, “hard pushing” ($\eta$ is very large) in a discrete Logit space causes the probabilities of certain tokens to become extremely polarized, destroying the overall coherence of the sentence.</p> <ol> <li><strong>Reward-guided generation</strong>, used for conditional generation controlling text attributes</li> </ol> <p>This leverages the idea of Flow Map Trajectory Guidance (FMTG): \(\mathbf{x}_{t_{n+1}} = X_{t_n, t_{n+1}}(\mathbf{x}_{t_n}) + \lambda \nabla_{\mathbf{x}_{t_n}} r(X_{t_n, 1}(\mathbf{x}_{t_n}))\)</p> <ul> <li>How to step forward = taking a small normal scheduled step + $\lambda \times$ <strong>reward gradient correction</strong>.</li> <li>$r(X_{t_n, 1}(\mathbf{x}_{t_n}))$ indicates that the model can foresee its currently predicted <strong>endpoint</strong>, allowing a reward model to evaluate it, compute the gradient, and backpropagate it to fine-tune the direction of the current small step.</li> </ul> <h2 id="vii-pseudocode-for-related-algorithms">VII. Pseudocode for Related Algorithms</h2> <table style="width: 100%; border-collapse: collapse; border: none;"> <tr> <td valign="top" style="width: 50%; padding-right: 15px; border: none;"> <b>Algorithm 5</b> FLM training <hr style="margin: 5px 0;"/> <b>Require:</b> Dataset $\mathcal{D}$, reparameterization $\tau(t)$, lr $\eta$<br/> <b>Initialize:</b> Denoiser $\hat{D}$<br/> <b>repeat</b><br/> &nbsp;&nbsp;&nbsp;&nbsp;$\mathbf{x}_1 \leftarrow f(\mathbf{y}), \mathbf{y} \sim \mathcal{D}; \quad \mathbf{x}_0 \sim \mathsf{N}(0, I)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;Sample $t$ via $\tau(t) \sim \mathsf{U}[0, 1]$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$I_t \leftarrow (1-t)\mathbf{x}_0 + t\mathbf{x}_1$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\hat{\mathbf{x}}_1 \leftarrow \hat{D}_t(I_t)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;Update $\hat{D}$: $\mathcal{L}_{\text{CE}} = - \sum_l (\mathbf{x}_1^l)^\top \log \hat{\mathbf{x}}_1^l$<br/> <b>until</b> converged <hr style="margin: 5px 0;"/> </td> <td valign="top" style="width: 50%; padding-left: 15px; border: none;"> <b>Algorithm 6</b> FLM sampling <hr style="margin: 5px 0;"/> <b>Require:</b> Trained $\hat{D}$, $\tau(t)$, steps $N$<br/> $\mathbf{x}_0 \sim \mathsf{N}(0, I)$<br/> $t_n \leftarrow t(n/N)$ for $n=0, ..., N$<br/> <b>for</b> $n=0$ to $N-1$ <b>do</b><br/> &nbsp;&nbsp;&nbsp;&nbsp;$\hat{\mathbf{x}}_1 \leftarrow \hat{D}_{t_n}(\mathbf{x}_{t_n})$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\hat{b}_n \leftarrow (\hat{\mathbf{x}}_1 - \mathbf{x}_{t_n})/(1 - t_n)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\mathbf{x}_{t_{n+1}} \leftarrow \mathbf{x}_{t_n} + (t_{n+1} - t_n)\hat{b}_n$<br/> <b>end for</b><br/> <b>Return</b> $g(\mathbf{x}_{t_N})$ <hr style="margin: 5px 0;"/> </td> </tr> <tr> <td valign="top" style="width: 50%; padding-right: 15px; border: none; padding-top: 15px;"> <b>Algorithm 7</b> FMLM training (distillation) <hr style="margin: 5px 0;"/> <b>Require:</b> Dataset $\mathcal{D}$, trained $\hat{D}$, $\tau(t)$, lr $\eta$<br/> <b>Initialize:</b> Two-time denoiser $\hat{\delta}$<br/> <b>repeat</b><br/> &nbsp;&nbsp;&nbsp;&nbsp;$\mathbf{x}_1 \leftarrow f(\mathbf{y}), \mathbf{y} \sim \mathcal{D}; \quad \mathbf{x}_0 \sim \mathsf{N}(0, I)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;<i>Diagonal (anchors to $\hat{D}$):</i><br/> &nbsp;&nbsp;&nbsp;&nbsp;$\tau(s) \sim \mathsf{U}[0, 1]; \quad I_s \leftarrow (1-s)\mathbf{x}_0 + s\mathbf{x}_1$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\mathcal{L}_{\text{diag}} \leftarrow - \sum_l \hat{D}(I_s)^l \cdot \log \hat{\delta}_{s,s}^l(I_s)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;<i>Off-diagonal (semigroup):</i><br/> &nbsp;&nbsp;&nbsp;&nbsp;$h \sim \mathsf{U}[0, 1]; \quad \tau(s) \sim \mathsf{U}[0, 1-h]$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\tau(t) \leftarrow \tau(s) + h; \quad \tau(u) \leftarrow \frac{\tau(s)+\tau(t)}{2}$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\gamma \leftarrow \frac{(1-t)(u-s)}{(1-u)(t-s)}$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\hat{X}_{s,u} \leftarrow \frac{1-u}{1-s}I_s + \frac{u-s}{1-s}\hat{\delta}_{s,u}(I_s)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\bar{\delta} \leftarrow \text{sg}(\gamma\hat{\delta}_{s,u}(I_s) + (1-\gamma)\hat{\delta}_{u,t}(\hat{X}_{s,u}))$<br/> &nbsp;&nbsp;&nbsp;&nbsp;$\mathcal{L}_{\text{off}} \leftarrow - \sum_l \bar{\delta}^l \cdot \log \hat{\delta}_{s,t}^l(I_s)$<br/> &nbsp;&nbsp;&nbsp;&nbsp;Update $\hat{\delta}$: $\mathcal{L}_{\text{diag}} + \mathcal{L}_{\text{off}}$<br/> <b>until</b> converged <hr style="margin: 5px 0;"/> </td> <td valign="top" style="width: 50%; padding-left: 15px; border: none; padding-top: 15px;"> <b>Algorithm 8</b> FMLM sampling <hr style="margin: 5px 0;"/> <b>Require:</b> Trained $\hat{\delta}$, $\tau(t)$, steps $N$<br/> $\mathbf{x}_0 \sim \mathsf{N}(0, I)$<br/> $t_n \leftarrow t(n/N)$ for $n=0, ..., N$<br/> <b>for</b> $n=0$ to $N-1$ <b>do</b><br/> &nbsp;&nbsp;&nbsp;&nbsp;$\mathbf{x}_{t_{n+1}} \leftarrow \frac{1-t_{n+1}}{1-t_n}\mathbf{x}_{t_n} + \frac{t_{n+1}-t_n}{1-t_n}\hat{\delta}_{t_n, t_{n+1}}(\mathbf{x}_{t_n})$<br/> <b>end for</b><br/> <b>Return</b> $g(\mathbf{x}_{t_N})$ <hr style="margin: 5px 0;"/> </td> </tr> </table> </li> </ul>]]></content><author><name></name></author><category term="research-notes"/><category term="flow-model"/><category term="diffusion"/><category term="language-model"/><summary type="html"><![CDATA[Study notes on Flow Language Model (FLM) and Flow Map Language Models 关于 Flow Language Model (FLM) 和 Flow Map Language Model 的学习笔记]]></summary></entry></feed>