빈칸을 채우며 글을 만드는 확산 언어 모델 (MDLM)
원문 저자가 쓴 글을 그대로 옮겼습니다. 용어 설명과 마인드맵의 AI 답은 따로 확인을 거치지 않았습니다.
원문 정보
Simple and Effective Masked Diffusion Language Models
Subham Sekhar Sahoo, Marianne Arriola, Yair Schiff, Aaron Gokaslan, Edgar Marroquin, Justin T Chiu, Alexander Rush, Volodymyr Kuleshov
출처: arXiv 2406.07524 · 라이선스: CC BY 4.0 · 발표 2024-06-11
원문 본문을 그대로 옮기고 용어 링크와 난이도 색을 더했습니다. 그림, 표의 본체, 부록은 옮기지 않고 원문 링크로 대신했습니다.
기초중간심화 어려운 말은 난이도에 따라 색을 달리했습니다. 궁금한 문장은 옆에 나오는 ?를 누르면 마인드맵에서 물어볼 수 있습니다.
1. 이 글을 읽으려면
이 글에 나오는 용어를 먼저 알아야 할 것부터 늘어놓았습니다. 이미 아는 것은 건너뛰세요.
- 벤치마크여러 AI나 방법의 실력을 같은 조건에서 비교하려고 만든 공통 시험 문제 모음입니다.
- 인코더영상·소리·글 같은 입력을 모델이 다루기 좋은 숫자 묶음으로 바꾸는 부분입니다.
- 토큰언어 모델이 글을 읽고 쓸 때 쓰는 가장 작은 단위입니다.
- 확산 모델망가진 데이터를 조금씩 되살리는 연습으로 배우고, 그 과정을 되풀이해 새 데이터를 만드는 모델입니다.
- 마스킹글의 일부 토큰을 가려 빈칸으로 만드는 것입니다. 모델은 빈칸을 맞히면서 배웁니다.
- 언어 모델글에서 다음에 올 말이나 빠진 말을 확률로 예측하는 모델입니다.
- 임베딩토큰이나 영상 조각을 숫자 목록으로 나타낸 것입니다. 비슷한 것끼리는 숫자도 비슷합니다.
- 대형 언어 모델 (LLM)아주 많은 글로 학습한, 매개변수가 수십억 개 이상인 언어 모델입니다.
- 파인튜닝 (추가 학습)이미 학습된 모델을 특정 일에 맞게 조금 더 학습시키는 것입니다.
- 확산 언어 모델문장 전체를 빈칸으로 두고, 여러 번에 걸쳐 빈칸을 채워 글을 만드는 언어 모델입니다.
1.1. 이 글에 나오는 말, 난이도별로
2. Abstract
While diffusion models excel at generating high-quality images, prior work reports a significant performance gap between diffusion and autoregressive (AR) methods in language modeling. In this work, we show that simple masked discrete diffusion is more performant than previously thought. We apply an effective training recipe that improves the performance of masked diffusion models and derive a simplified, Rao-Blackwellized objective that results in additional improvements. Our objective has a simple form---it is a mixture of classical masked language modeling losses---and can be used to train encoder-only language models that admit efficient samplers, including ones that can generate arbitrary lengths of text semi-autoregressively like a traditional language model. On language modeling benchmarks, a range of masked diffusion models trained with modern engineering practices achieves a new state-of-the-art among diffusion models, and approaches AR perplexity. We provide the code, along with a blog post and video tutorial on the project page:
https://s-sahoo.com/mdlm
이 절에서 궁금할 만한 질문
3. Introduction
Diffusion models excel at producing realistic, high-quality images and have received significant attention as potential tools for generating discrete data, such as text [1, 31, 33], biological sequences [2, 47], and graphs [60, 63]. Unlike autoregressive (AR) approaches, diffusion-based methods are not constrained to generate data sequentially, and therefore have the potential to improve long-term planning, controllable generation, and sampling speed. However, discrete diffusion methods exhibit a performance gap relative to AR models [1, 23, 26, 33], especially in language modeling. The standard measure of language modeling performance is log-likelihood: when controlling for parameter count, prior work reports a sizable log-likelihood gap between AR and diffusion models.
In this work, we show that simple masked diffusion language modeling (MDLM) combined with effective training recipes is more performant than previously thought [1, 26, 69]. We develop a well-engineered MDLM implementation that significantly improves discrete diffusion log-likelihood; we further improve likelihood using a simple substitution-based parameterization of the reverse diffusion process that enables deriving a Rao-Blackwellized continuous-time variational lower bound (ELBO) with improved tightness [49]. Interestingly, our objective has a simple form: it is a weighted average of masked language modeling (MLM) losses [15], and can be used to endow BERT-style, encoder-only models with principled generation capabilities. We complement this framework with efficient samplers—including ones that can generate semi-autoregressively like a typical language model.
Our masked diffusion models achieve a new state-of-the-art among diffusion models on language modeling benchmarks and approach the perplexity of AR models within 15-25%. Surprisingly, simple engineering choices significantly improve performance in both our models and simple baselines that were previously thought to perform poorly. Our framework also extends to non-language domains, including biological sequence modeling. We pre-train DNA sequence models and observe similar or higher downstream performance compared to classical BERT-style training, while also introducing generative capabilities that classical masked DNA language models lack.
Contributions
We describe (1) a simple masked diffusion language modeling (MDLM) framework with a well-engineered implementation that outperforms all existing diffusion models across language modeling benchmarks (LM1B [8], OWT [18], DNA [12]), and that significantly improves the performance of existing baselines [1, 26]. Our MDLM framework implements (2a) a substitution-based parameterization (SUBS) of the reverse unmasking diffusion process; SUBS allows us to derive (2b) a simple, continuous-time, Rao-Blackwellized objective that improves tightness and variance of the ELBO, further increasing performance. We complement MDLM with (3) fast samplers that support semi-autoregressive (SAR) generation and outperform previous SAR models.
그림 Figure 1: (Left) Our proposed masked diffusion language model (MDLM) is trained using a weighted average of masked cross entropy losses. (Top Right) In comparison to masked language models (MLM), MDLM’s objective correspond to a principled variational lower bound, and supports generation via ancestral sampling. (Bottom Right) Perplexity (PPL) on One Billion Words (LM1B) benchmark. 원문에서 보기
이 절에서 궁금할 만한 질문
4. Background
4.1. Diffusion Models
Diffusion models are trained to iteratively undo a forward corruption process q that takes clean data {\mathbf{x}} drawn from the data distribution q({\mathbf{x}}) and defines latent variables {\mathbf{z}}_{t} for t\in[0,1] that represent progressively noisy versions of {\mathbf{x}} [27, 54, 56, 66, 48, 19]. The standard forward process for continuous {\mathbf{x}} is
where \bm{\epsilon}\sim\mathcal{N}(\mathbf{0},\mathbf{I}) and (\alpha_{t})_{t\in[0,1]} is a noise schedule, monotonically decreasing in t. The parameterized reverse diffusion model p_{\theta} over {\mathbf{x}} and {\mathbf{z}}_{t} is trained to maximize a variational lower bound on log-likelihood (ELBO). Given a number of discretization steps T, defining s(i)=(i-1)/T and t(i)=i/T, and using D_{\mathrm{KL}}[\cdot] to denote the Kullback–Leibler divergence, the Negative ELBO (NELBO) equals [54]:
For brevity, we drop i from t(i) and s(i) below; in general, s will denote the time step before t.
4.2. Discrete Diffusion Models
Applications of diffusion modeling to discrete data can be broken into two broad categories. First are works that embed discrete structures in continuous space and then perform the Gaussian diffusion defined above on these continuous representations [9, 16, 23, 24, 30, 34, 57]. More related to our method are works that define a diffusion process directly on discrete structures. D3PM [1] introduces a framework with a Markov forward process q({\mathbf{z}}_{t}|{\mathbf{z}}_{t-1})=\text{Cat}({\mathbf{z}}_{t};Q_{t}{\mathbf{z}}_{t-1}) defined by the multiplication of matrices Q_{t} over T discrete time steps. This process induces marginals
that represent the discrete-state form of (1). Extending this formalism to continuous time (as in (1)) relies on continuous time Markov chain (CTMC) theory [5]. The CTMC framework in turns leads to generalizations of the score matching perspective on diffusion modeling [55] to discrete data [33, 59]. Notably, SEDD [33] connects score-based approaches with ELBO maximization, enabling performant likelihood-based training of score-based models.
이 절에서 궁금할 만한 질문
5. Simple Masked Diffusion Models
While previous work on discrete diffusion supports general forward processes (e.g., general Q_{t} in D3PM), absorbing state (i.e., masking) diffusion consistently achieves the best performance [1, 33]. In this work, instead of supporting general noise processes, we focus on masking and derive tight Rao-Blackwellized objectives that outperform general approaches and do not require CTMC theory. In this section, we first define the diffusion process for a categorical random variable. Later in Sec. 3.5, we extend this process to sequences containing multiple such categorical variables. We denote our overall approach as Masked Diffusion Language Models (MDLM).
Notation.
We denote scalar discrete random variables with K categories as ‘one-hot’ column vectors and define \mathcal{V}\in\{{\mathbf{x}}\in\{0,1\}^{K}:\sum_{i=1}^{K}{\mathbf{x}}_{i}=1\} as the set of all such vectors. Define \text{Cat}(\cdot;\text{$\bm{\mathit{\pi}}$}) as the categorical distribution over K classes with probabilities given by \text{$\bm{\mathit{\pi}}$}\in\Delta^{K}, where \Delta^{K} denotes the K-simplex. We also assume that the K-th category corresponds to a special [mask] token and let {\mathbf{m}}\in\mathcal{V} be the one-hot vector for this mask, i.e., {\mathbf{m}}_{K}=1. Additionally, let {\bm{1}}=\{1\}^{K} and \langle\mathbf{a},\mathbf{b}\rangle and \mathbf{a}\odot\mathbf{b} respectively denote the dot and Hadamard products between two vectors \mathbf{a} and \mathbf{b}.
5.1. Interpolating Discrete Diffusion
We restrict our attention to forward processes q that interpolate between clean data {\mathbf{x}}\in\mathcal{V} and a target distribution \text{Cat}(.;\text{$\bm{\mathit{\pi}}$}{}), forming a direct extension of Gaussian diffusion in (1). Let q define a sequence of increasingly noisy latent variables {\mathbf{z}}_{t}\in\mathcal{V}, where the time step t runs from t=0 (least noisy) to t=1 (most noisy). The marginal of {\mathbf{z}}_{t} conditioned on {\mathbf{x}} at time t is
where \alpha_{t}\in[0,1] is a strictly decreasing function in t, with \alpha_{0}\approx 1 and \alpha_{1}\approx 0; see Suppl. E.1 for details. This implies transition probabilities q({\mathbf{z}}_{t}|{\mathbf{z}}_{s})=\text{Cat}({\mathbf{z}}_{t};\alpha_{t|s}{\mathbf{z}}_{s}+(1-\alpha_{t|s})\text{$\bm{\mathit{\pi}}$}{}), where \alpha_{t|s}=\alpha_{t}/\alpha_{s}. This indicates that during each diffusion step from s\to t, a fraction (1-\alpha_{t|s}) of the probability mass is transferred to the prior distribution \bm{\mathit{\pi}}. The reverse posterior is given as (see Suppl. 18 for details):
While (6) and (7) represent a special case of the more general diffusion processes proposed in D3PM [1], we show below that they yield a simplified variational lower bound objective and admit straightforward continuous time extensions.
5.2. Masked Diffusion
Next, we focus on masking processes and derive a simple Rao-Blackwellized objective for this choice of q. This objective incurs lower variance during training and improves tightness.
Forward Masking Process
In masked (i.e., absorbing state) diffusion, we set \text{$\bm{\mathit{\pi}}$}={\mathbf{m}}. At each noising step, t, the input {\mathbf{x}} transitions to a ‘masked’ state {\mathbf{m}} with some probability. If an input transitions to {\mathbf{m}} at any time t^{\prime}, it will remain in this state for all t>t^{\prime}:q({\mathbf{z}}_{t}\mid{\mathbf{z}}_{t^{\prime}}={\mathbf{m}})=\text{Cat}({\mathbf{z}}_{t};{\mathbf{m}}). At time T, all inputs are masked with probability 1.
The marginal of the forward process (6) is given by q({\mathbf{z}}_{t}|{\mathbf{x}})=\text{Cat}({\mathbf{z}}_{t};\alpha_{t}{\mathbf{x}}+(1-\alpha_{t}){\mathbf{m}}). Using properties of the masking process, the posterior q({\mathbf{z}}_{s}|{\mathbf{z}}_{t},{\mathbf{x}}) simplifies (7); see Suppl. A.2:
Reverse Unmasking Process
The reverse process inverts the noise process defined by q. We consider both a finite number of steps T, as well as a continuous time model corresponding to T\to\infty. We begin with the discrete-time case for which the generative model is expressed as {p_{\theta}}({\mathbf{x}})=\int_{\mathbf{z}}{p_{\theta}}({\mathbf{z}}_{1}){p_{\theta}}({\mathbf{x}}|{\mathbf{z}}_{0})\prod_{i=1}^{T}{p_{\theta}}({\mathbf{z}}_{s}|{\mathbf{z}}_{t})\text{d}{\mathbf{z}}_{0:1}.
The optimal form for {p_{\theta}}({\mathbf{z}}_{s}|{\mathbf{z}}_{t}) matches the true posterior in (8): this follows immediately from the definition of the diffusion objective in (2.1), which is a sum of terms of the form \text{D}_{\text{KL}}(q({\mathbf{z}}_{s}|{\mathbf{z}}_{t},{\mathbf{x}})\|{p_{\theta}}({\mathbf{z}}_{s}|{\mathbf{z}}_{t})). However, (8) is conditioned on {\mathbf{x}}, which we do not know. Therefore, we introduce a model {\mathbf{x}}_{\theta}({\mathbf{z}}_{t},t):\mathcal{V}\times[0,1]\rightarrow\Delta^{K} that approximates {\mathbf{x}} with a neural network. We can also omit explicit dependence of {\mathbf{x}}_{\theta} on time t, which simplifies sampling, yielding a 2x inference speed-up (see Suppl. E.2).
SUBS Parameterization
The specific parameterization for {p_{\theta}}({\mathbf{z}}_{s}|{\mathbf{z}}_{t}) that we use is
Furthermore, we induce 2 key properties of the absorbing state diffusion process into our denoising model, \mathbf{x}_{\theta}({\mathbf{z}}_{t},t): an unmasked token remains unchanged during reverse diffusion, and the clean input is never masked. We implement these as substitutions to the output of \mathbf{x}_{\theta}({\mathbf{z}}_{t},t), hence we call our parameterization SUBS.
Zero Masking Probabilities
First, notice that by definition, \langle{\mathbf{x}},{\mathbf{m}}\rangle=0. For this reason, we design the denoising network such that \langle\mathbf{x}_{\theta}({\mathbf{z}}_{t},t),{\mathbf{m}}\rangle=0, i.e., we substitute the logit index corresponding to the [mask] token with -\infty.
Carry-Over Unmasking
Second, if {\mathbf{z}}_{t} is unmasked, then we desire \mathbf{x}_{\theta}({\mathbf{z}}_{t},t)={\mathbf{z}}_{t}, i.e., unmasked latents are ‘carried over’. We accomplish this by substituting the output of our network to simply copy unmasked inputs.
In Suppl. B.1, we show that “Zero Masking Probabilities” property simplifies the D3PM’s NELBO (41) to (43), and “Carry-Over Unmasking” futher simplifies (43) to (45) whose continuous time equivalent is the simplified NELBO (12). Table 8 shows that each simplification leads to an improved likelihood.
5.3. Rao-Blackwellized Likelihood Bounds
Recall from (2.1) that the diffusion traning objective has the form {\mathcal{L}_{\text{recons}}}+{\mathcal{L}_{\text{diffusion}}}+{\mathcal{L}_{\text{prior}}}. For the simplified reverse process in (9), the discrete-time diffusion loss for finite T simplifies to (Suppl. B.1.3):
Note that this objective is simpler and more well-behaved than the expression one would obtain for \text{D}_{\text{KL}}(q({\mathbf{z}}_{s}|{\mathbf{z}}_{t},{\mathbf{x}})\|{p_{\theta}}({\mathbf{z}}_{s}|{\mathbf{z}}_{t})) under the parameterization induced by using {p_{\theta}}({\mathbf{z}}_{s}|{\mathbf{z}}_{t})=q({\mathbf{z}}_{s}|{\mathbf{z}}_{t},{\mathbf{x}}=\mathbf{x}_{\theta}({\mathbf{z}}_{t},t)) from (7), which is similar to what is used by D3PM [1] (see Suppl. A.2.4):
We refer to the process of obtaining (10) in lieu of (11) as a form of Rao-Blackwellization. Specifically, we analytically compute expectations such as \langle\mathbf{x}_{\theta}({\mathbf{z}}_{t},t),{\mathbf{m}}\rangle=0 in order to simplify objective (11) to obtain (10). Without analytical simplifications, a model must learn \theta such that \langle\mathbf{x}_{\theta}({\mathbf{z}}_{t},t),{\mathbf{m}}\rangle=0 holds. Unlike in regular Rao-Blackwellization, simplifications are possible because of modeling choices for \mathbf{x}_{\theta}({\mathbf{z}}_{t},t) (zero masking probabilities and carry-over unmasking). In that sense, our approach has similarities to graphical modeling, where incorporating conditional independencies into {p_{\theta}} sets certain log-likelihood terms to zero. However, our approach also empirically helps reduce variance, hence we refer to it as Rao-Blackwellization, somewhat abusing the usual terminology.
5.4. Continuous-Time Likelihood Bounds
Previous works have shown empirically and mathematically that increasing the number of steps T yields a tighter approximation to the ELBO [29]. Following a similar argument, we form an continuous extension of (10) by taking T\to\infty (see Suppl. B.2), which yields the following NELBO, {\mathcal{L}^{\infty}_{\text{NELBO}}}:
Invariance to the noise schedule
The function \alpha_{t} is invertible due to the monotonicity assumption in Sec. 3.1, and so we can perform the following change of variables in (12): {\bm{\gamma}}\equiv\log(1-\alpha_{t}). Thus, the diffusion loss can be equivalently expressed as {\mathcal{L}^{\infty}_{\text{NELBO}}}=-\mathbb{E}_{q}\int_{{\bm{\gamma}}=-\infty}^{{\bm{\gamma}}=0}\log\langle{\mathbf{x}}_{\theta}({\mathbf{z}}_{\bm{\gamma}},{\bm{\gamma}}),{\mathbf{x}}\rangle{\text{d}}{\bm{\gamma}}; see Suppl. E.1.1 for details. This new formulation demonstrates that the diffusion loss is invariant to the functional form of \alpha_{t}, which we verify empirically in Suppl. E.1.
5.5. Masked Diffusion Language Models
Next, we apply masked diffusion to language modeling over sequences {\mathbf{x}}^{1:L} of L tokens, with {\mathbf{x}}^{\ell} denoting the \ell-th token. We make the assumption that the forward noising process is applied independently across a sequence and that, conditioned on a sequence of latents {\mathbf{z}}_{t}^{1:L}, the denoising process factorizes independently across tokens, i.e., p_{\theta}({\mathbf{z}}_{s}^{1:L}\mid{\mathbf{z}}_{t}^{1:L})=\prod_{\ell=1}^{L}p_{\theta}({\mathbf{z}}_{s}^{\ell}\mid{\mathbf{z}}_{t}^{1:L}). Thus, we use a single model to compute \mathbf{x}_{\theta}^{\ell}({\mathbf{z}}_{t}^{1:L},t) for each \ell from a masked sequence {\mathbf{z}}_{t}, optimizing:
Interestingly, our objective has a simple form: it is the weighted average of masked language modeling (MLM) losses [15]. Thus our work establishes a connection between generative diffusion models and encoder-only BERT models. Our objective enables principled selection of a (randomized) masking rate, and also endows BERT-style models with principled generation capabilities; see Sec. 6. The full training algorithm is provided in Suppl. B.3.
Note: Although (13) imposes a loss on all tokens, unmasked tokens don’t contribute to the loss, as they are copied over by the denoising network due to “carry-over unmasking” (Sec. 3.2.3), effectively reducing \log\langle\mathbf{x}_{\theta}^{\ell}({\mathbf{z}}_{t}^{1:L},t),{\mathbf{x}}^{\ell}\rangle to zero.
Training Considerations for Masked Diffusion
One of the key contributions of our work is a well-engineered implementation of masked diffusion models. Our experiments demonstrate that these improvements greatly boost performance even for methods previously thought to perform poorly, e.g., Austin et al. [1]. Below we briefly summarize these implementation details. First, we find that tokenization is critical to performance. Small vocabularies, such as the 8k vocabulary in Austin et al. [1], result in longer-range dependencies that decrease the performance of both diffusion and AR models. Additionally, by focusing on masked diffusion, we are able to provide a numerically stable implementation of the objective function. Namely, since previous formulations of discrete diffusion were constructed to accommodate a wide range of limiting distributions [1], the objective was implemented by materializing the full transition matrices \bar{Q}_{t} and posterior probabilities. In contrast, we evaluate D_{\mathrm{KL}}[q({\mathbf{z}}_{s}\mid{\mathbf{z}}_{t},{\mathbf{x}})||p_{\theta}({\mathbf{z}}_{s}\mid{\mathbf{z}}_{t})] by examining only the masked token indices rather than comparing the full true and approximate posterior distributions.
Furthermore, we modernize the architecture for the denoising network relative to D3PM [1]. In lieu of the T5 architecture used in D3PM, we use the diffusion transformer (DiT) introduced in Peebles & Xie [42], which integrates time step conditioning into a standard encoder-only transformer [62] and uses rotary positional embeddings [58]. In addition, we implement a low-discrepancy sampler that reduces the variance of the ELBO, similar to Kingma et al. [29] and draws correlated samples t_{i} rather than performing i.i.d. sampling.
이 절에서 궁금할 만한 질문
6. Inference and Sampling in Masked Diffusion Language Models
6.1. Efficient Ancestral Sampling
To generate a sequence of length L, the reverse diffusion process starts with the sequence {\mathbf{z}}^{1:L}_{t=1} where {\mathbf{z}}^{\ell}_{t=1}={\mathbf{m}}, for all \ell\in\{1,\dots,L\}. Then the subsequent latents, {\mathbf{z}}^{1:L}_{t} are generated by discretizing the reverse diffusion process with some finite T. Given {\mathbf{z}}^{1:L}_{t}, we construct {\mathbf{z}}^{1:L}_{s} by sampling each token {\mathbf{z}}^{\ell}_{s} independently from the distribution {p_{\theta}}({\mathbf{z}}^{\ell}_{s}|{\mathbf{z}}^{1:L}_{t}) given in (9).
Note that in the reverse process, unmasked tokens remain unchanged. Thus, if no new tokens in {\mathbf{z}}^{1:L}_{s} become unmasked (which can occur often in early denoising stages for large T), then {\mathbf{z}}^{1:L}_{s}={\mathbf{z}}^{1:L}_{t}. Additionally if the denoising model, \mathbf{x}_{\theta}({\mathbf{z}}^{1:L}_{t}) is not conditioned on time, then we can simply draw a new sample from {p_{\theta}}({\mathbf{z}}^{1:L}_{s-1/T}|{\mathbf{z}}^{1:L}_{s}) using the previously computed and cached value \mathbf{x}_{\theta}({\mathbf{z}}^{1:L}_{t}). This means we have effectively “skipped” over the time step s, saving a function call to the denoising network. Note that SEDD [33] does not support this caching because the denoising network models time-dependent rates, which requires conditioning on time.
6.2. Semi-Autoregressive Masked Diffusion Language Models
Our method also admits an effective semi-autoregressive (SAR) decoding method that allows the model to generate sequences of arbitrary length [24, 52, 53]. Let \tilde{{\mathbf{x}}}^{1:L} represent the output from sampling a sequence of L tokens using the reverse diffusion process described above. To generate additional L^{\prime}<L tokens, we propose a generation algorithm in which the latter L-L^{\prime} tokens \tilde{{\mathbf{x}}}^{L^{\prime}:L} are used as a prefix for an additional round of generation. Given the carry-over unmasking described in Sec. 3.2.3, these prefix tokens will simply be copied over at each decoding step. The remaining tokens are generated as above with {\mathbf{z}}^{\ell}_{s}\sim p_{\theta}({\mathbf{z}}_{s}^{\ell}\mid{\mathbf{z}}_{t}^{L:L+L^{\prime}}) for all \ell\in\{L+1,\ldots,L+L^{\prime}\}, with {\mathbf{z}}_{t=1}^{L-L^{\prime}:L} initialized to \tilde{{\mathbf{x}}}^{L-L^{\prime}:L} as opposed to being initialized as masked tokens {\mathbf{m}}. At the end of this process, we have produced L+L^{\prime} tokens \mathrm{concat}[\tilde{{\mathbf{x}}}^{1:L},\tilde{{\mathbf{x}}}^{L+1:L+L^{\prime}}], where \mathrm{concat}[\cdot] denotes concatenation along the sequence length dimension. This process can repeat indefinitely, with the prefix shifted for every new round of generation.
이 절에서 궁금할 만한 질문
7. Experiments
7.1. Masked Diffusion Language Models
Experimental Setup
We evaluate MDLM as a generative model of language and as a representation model via fine-tuning on downstream tasks.
For language modeling likelihood evaluation, we conduct experiments on two datasets: The One Billion Words Dataset (LM1B; [8]) and OpenWebText (OWT; [18]). We use the bert-base-uncased tokenizer for LM1B, and report perplexities on the test split. Models have a context size of 128. For OWT, which does not have a pre-defined split, we reserve the last 100K documents as a held-out validation set and report perplexities on this set. We use the GPT2 tokenizer [45] for OWT. Models have a context size of 1,024. We utilize the transformer architecture from Lou et al. [33], which augments the diffusion transformer [42] with rotary embeddings [58]. MDLM was trained for 1M or 10M steps (corresponding to 33B, 327B tokens, respectively) on LM1B and 1M steps on OWT (which corresponds to 262B tokens). The corresponding AR baseline was trained for half the number of steps to ensure similar number of tokens seen (details in Suppl. D.2). Full hyperparameters are given in Suppl. D.4. On OWT, we train with and without time step conditioning.
For representation learning, we pre-train models on the C4 dataset [46], then fine-tune and evaluate models on the GLUE benchmark [65]. Models have a context size of 128. We use the bert-base-uncased tokenizer for the representation learning experiments. We utilize the MosaicBERT architecture from Portes et al. [43], an extension of the original BERT architecture [15]. We pre-train a bidirectional MosaicBERT using an MLM objective for 37B tokens of C4, as well as a causal variant on the same data. We further fine-tune MosaicBERT model using the MDLM for 327M tokens, less than 1% of the pre-training data. We provide the full hyperparameters in Suppl. D.6.
표 Table 1: Test perplexities (PPL; \downarrow) on LM1B. †Reported in He et al. [26]. Best diffusion value is bolded. 원문에서 보기
Likelihood Evaluation
On LM1B, MDLM outperforms all previous diffusion methods (Table 1). Compared to the SEDD baseline reported by Lou et al. [33], trained for 33B tokens, MDLM, which we train for the same amount, achieves a 17% improvement on the perplexity bound. Finally, MDLM gets within 14% of an AR baseline and continues to improve with more training. We see the same trend for models trained on OWT, a larger dataset, shown in Table 2 – MDLM outperforms prior diffusion methods, closing the gap towards AR models. In Table 12 we find that models trained with and without time conditioning attain similar perplexities on OWT. Additionally, Figure 3 demonstrates the reduced variance we achieve from our objective, when compared to previous masked diffusion models such as SEDD [33].
Zero-Shot Likelihood Evaluation
표 Table 2: Test perplexities (PPL; \downarrow) on OWT for models trained for 262B tokens. † denotes retrained models. 원문에서 보기
We also explore models’ ability to generalize by taking models trained on OWT and evaluating how well they model unseen datasets. We compare the perplexities of our MDLM with SEDD [1] and an AR Transformer language model. Our zero-shot datasets include the validation splits of Penn Tree Bank (PTB; [36]), Wikitext [38], LM1B, Lambada [41], AG News [68], and Scientific Papers (Pubmed and Arxiv subsets; [10]). Full experimental details are available in Suppl. D.4.
MDLM consistently outperforms the SEDD diffusion parameterization. In some cases, e.g., for Lambada and Scientific Papers, MDLM attains better perplexity than AR. We hypothesize that these datasets are farther from OWT, and that diffusion models may be more robust to out-of-domain evaluation due to the unmasking-based objective.
표 Table 3: Zero-shot perplexities (\downarrow) of models trained for 524B tokens on OWT. All perplexities for diffusion models are upper bounds. 원문에서 보기
표 Table 4: GLUE evaluation results. Evaluation measures (\uparrow) are F1 score for QQP and MRPC, Spearman correlations for STS-B, and accuracy for the rest. For MNLI, we report match/mismatch accuracies. 원문에서 보기
Downstream Task Evaluation
We find that BERT fine-tuned with MDLM to be a generative model results in strong perplexities while preserving performance on downstream tasks. On the C4 validation set, the AR model attains perplexity (PPL) of 22, the pre-trained BERT attains a PPL upper bound of 78 (evaluated using the MDLM variational bound), and BERT + MDLM-FT attains a PPL upper bound of 35. In Table 4, we further find that BERT + MDLM fine-tuning has no degradation in downstream GLUE performance compared to the BERT initialization. While the perplexity of our method is higher than the AR baseline, the downstream task performance is significantly better.
Semi-Autoregressive Modeling
표 Table 5: Semi-AR generative perplexity (Gen. PPL; \downarrow) for sequences of 2048 tokens. 원문에서 보기
To test the SAR decoding algorithm presented in Sec. 4.2, we compare to SSD-LM [24] a diffusion model that was designed to generate blocks of text autoregressively. We generate 200 sequences of length 2048 tokens on a single 3090 GPU and evaluate generative perplexity under a pre-trained GPT-2 [45] model. The SSD-LM sequences are generated using blocks of 25 tokens (as implemented in their pre-trained model) and the MDLM sequences are generated using L^{\prime}=512. In Table 5, we find that in addition to achieving better generative perplexity, MDLM enables \sim25-30x faster SAR decoding relative to SSD-LM.
7.2. Masked Diffusion DNA Models
We also explore applications to the generative modeling of biological sequences [14, 47] using a state space model (SSM) backbone [22]. Namely, we build on the recently-proposed Caduceus DNA language model [50], which uses as a backbone the data-dependent SSM Mamba block [21].
Experimental Setup
We pre-train the encoder-only Caduceus [50], which is an MLM, on the HG38 human reference genome [11] and perform fine-tuning using our diffusion parameterization. We use a context length of 1024 tokens and follow Schiff et al. [50] for the experimental setup, other than learning rate which was reduced to 1e-3. See Suppl. D.7 for full experimental details. We assess both generative performance using perplexity and downstream performance on Genomics Benchmarks [20] across language diffusion paradigms and AR models.
Generative Performance
We fine-tune the Caduceus MLM across diffusion parameterizations and compare perplexities against AR models. We report perplexity values in Table 6. MDLM outperforms all other diffusion language modeling schemes.
표 Table 6: Test perplexities (PPL; \downarrow) of generative fine-tuning of the Caduceus MLM [50] on the HG38 reference genome. Best diffusion model values are bolded. Error bars indicate the difference between the maximum and minimum values across 5 random seeds used for fine-tuning. 원문에서 보기
Downstream Task Fine-tuning
We perform downstream evaluation with the Genomics Benchmarks [20], a recently proposed benchmark with eight regulatory element classification tasks. As shown in Table 7, our generative fine-tuning paradigm preserves or improves upon downstream performance from MLM pre-training. Absorbing-state diffusion methods outperform Plaid across tasks except for the simplest task Human vs. Worm, where all methods have roughly the same performance. For tasks where the input is a biased subsample of the full genome, we observe that the correlation between perplexity and downstream performance is weaker; see Suppl. D.7.
표 Table 7: Genomic Benchmarks. Top-1 accuracy (\uparrow) across 5-fold cross-validation (CV) for a pre-trained AR Mamba, and a pre-trained Caduceus model fine-tuned with different diffusion parameterizations. The best values per task are bolded and the second best are italicized. Error bars indicate the difference between the maximum and minimum values across 5 random seeds used for CV. 원문에서 보기
7.3. Ablation Analysis
표 Table 8: Test perplexities (PPL; \downarrow) for MDLM ablations on LM1B. For the discrete-time models, we use T=1000. Standard deviation is measured over 5 seeds during evaluation. 원문에서 보기
In Table 8, we can see the effect of our streamlined masked diffusion implementation. The improvements described in Sec. 3.5.1 allow us to greatly reduce perplexity of previously discounted models, such as D3PM (see the bottom row of this table, which is mathematically equivalent to the D3PM formulation). While most works assumed that D3PM achieves mediocre log-likelihoods, we show that is incorrect: our re-implementation almost matches state-of-the-art score-based methods. This introduces a new strong baseline that opens new research opportunities. Additionally, in Table 8, we ablate different components of MDLM. We observe that the perplexity for MDLM trained with a discrete T=1000 marginally worsens by 0.1 compared to MDLM trained in continuous time. Additionally, removing the “carry over” operation from the SUBS parameterization increases the perplexity by 1.5 points. However, further removing the “zero masking” operation does not lead to any meaningful change in perplexity. We provide further ablations for the continuous time formulation in the Appendix, showing in Table 11 that for a pre-trained model, at inference, increasing T yields better likelihoods.
이 절에서 궁금할 만한 질문
8. Related Work
Comparison to D3PM Masked diffusion is a strict subset of D3PM [1]; setting Q_{t|s}=\alpha_{t|s}\mathbf{I}+(1-\alpha_{t|s}){\bm{1}}{{\mathbf{m}}^{\top}} in their framework yields our forward diffusion. We improve over D3PM in three ways: (1) we adopt the SUBS parameterization; (2) this allows us to derive a simplified objective that analytically simplifies certain expectations to zero; (3) we adopt well-engineered training recipes that improve performance. Both (1) and (2) are possible because we focus on masking instead of developing a general discrete diffusion framework. Surprisingly, (3) has the largest contribution to performance.
Comparison to CTMC Most implementations of diffusion work best in continuous time. However, extending D3PM in this way requires computing the limit of the product of an infinite number of matrices Q_{T}\cdot Q_{T-1}\cdots Q_{t} as T\to\infty, which requires advanced CTMC theory [5]. Our work describes simple continuous-time formulations for the most common noise processes (e.g., masking and uniform \bm{\mathit{\pi}}), thus helping make an important part of the literature more accessible. In Suppl. C, we show that our results are compatible with CTMC, using the rate forward matrix R_{t}=\frac{\alpha^{\prime}_{t}}{\alpha_{t}}(\mathbf{I}-{\bm{1}}{\mathbf{m}}^{\top}) and the reverse rate \tilde{R}_{t}({\mathbf{y}}^{\prime},{\mathbf{y}}) for the transition {\mathbf{y}}\to{\mathbf{y}}^{\prime}, where {\mathbf{y}},{\mathbf{y}}^{\prime}\in\mathcal{V}:
Comparison to Score Estimation Score-based approaches to diffusion [55] extend to discrete states, although they typically further build upon advanced CTMC theory. In particular, SEDD [33] optimizes an ELBO that is a function of the score model, obtaining state-of-the-art log-likelihoods among diffusion models. Our approach, however, is much simpler and does not require advanced theory. Furthermore, we can extract the score for MDLM (78), as demonstrated in Suppl. C.3, making it compatible with various techniques designed for score-based algorithms, such as samplers [5], score parameterization [33], efficient designs of the denoising network [59], guidance techniques, and more.
Comparison to BERT Our work provides a principled way of making BERT generative when trained with randomized masking rates. Previous work on generating from BERT used Gibbs sampling or ad-hoc methods [17, 32, 64]. The connection between BERT and diffusion was first made by Austin et al. [1]: their objective effectively involves unmasking. He et al. [26] additionally starts training from a pretrained BERT. However, both works use an objective that is similar to (11), which is less numerically stable than our objective (see Section 3.5.1). Austin et al. [1] mention in their appendix that their ELBO simplifies to a weighted masking (MLM) loss similar to (10), but it uses a more complex formula for the weights and is limited to the discrete time setting unlike our work. Furthermore, they do not train with that objective. Our work derives a simpler expression for the average of MLM losses, implements it, and obtains better likelihoods.
Comparision to Latent Diffusion LMs In contrast to this work, which defines diffusion over discrete structures, Plaid [23] and Diffusion LM [30] define a Gaussian diffusion process over word embeddings. Zhang et al. [67] and Hu et al. [28] extend this approach to flow matching over word embeddings, enabling the design of faster samplers. Discrete Flow Matching (DFM) [6] applies flow matching to discrete structures, using a cross-entropy loss as their training objective: -\mathbb{E}_{q,t}\log{p_{\theta}}({\mathbf{x}}^{1:L}|{\mathbf{z}}_{t}^{1:L}). Similar to Chang et al. [7], DFM’s objective, while effective, is not weighted to serve as a proper ELBO. In MDLM, however, we derive a tight, principled lower bound on the log-likelihood.
Concurrent Works Concurrent to our work, Shi et al. [51] and Ou et al. [40] derive a similar simplified objective for masked diffusion processes. While Ou et al. [40] start from a score matching perspective, we tackle this problem from a variational lens similar to Shi et al. [51]. Similar to Ou et al. [40], we formulate efficient samplers in Section 4.1 by leveraging a time-independent denoising network.
A key differentiation between our work and that of Shi et al. [51], Ou et al. [40] is the semi-autoregressive decoding method we present in Section 4.2. While [51, 40] are restricted to sample sequences of a fixed length, we propose samplers to generate arbitrary lengths of text like a traditional language model. Furthermore, we establish the connection between our simplified objective and the masked language modeling (MLM) objective. As a result, we endow BERT-style models with principled generation capabilities while maintaining representation learning capabilities. Whereas [51, 40] only evaluate on NLP datasets, we show that masked diffusion is also effective in modeling biological sequences.
이 절에서 궁금할 만한 질문
9. Conclusion
In this work, we explore masked diffusion. With a well-engineered implementation that supports a simple variational objective, we attain state-of-the-art diffusion perplexities on language benchmarks and demonstrate how to efficiently convert BERT-style encoders into generative models. Given we are working on language modeling, we carry any of the inherent risks and opportunities that come with this line of research.
이 절에서 궁금할 만한 질문
이 글에 대해 알려 주기
읽다가 막힌 곳이나 틀린 곳이 있으면 알려 주세요. 글은 운영자가 확인한 뒤에 고칩니다.
시험판이라 아직 저장되지 않습니다.