메뉴
HN
Hacker News • 26일 전

확산 언어 모델(Diffusion LM) 만드는 법

IMP
8/10
핵심 요약

GPT류의 자기회귀(autoregressive) 모델 대신 이미지 생성에 쓰이는 확산(diffusion) 기법을 텍스트에 적용한 '확산 언어 모델'의 원리와 최신 연구 성과를 소개하는 글입니다. 2024년 품질 경쟁력을 확보한 뒤 2026년에는 Mercury 2, Gemma Diffusion, Nemotron Diffusion 등 상용 모델이 등장했으며, 이 글은 단순 마스킹 확산부터 반복 정제, 사후 학습, 가변 길이 생성까지 핵심 구성 요소를 다룹니다.

번역된 본문

확산 언어 모델 만드는 법

확산 언어 모델에 대한 소개와 오늘날 확산 기반 대규모 언어 모델(LLM)의 기반이 되는 연구 진전을 다룹니다. 단순한 마스킹 확산에서 출발하여, 반복적 정제(iterative refinement), 사후 학습(post-training), 가변 길이 생성 기법 등 최근 오픈소스 모델의 구성 요소들을 설명합니다. 자료는 ICLR 2026 및 MLSS 2026 워크숍 발표와 강의에서改编되었습니다.

서론: 자기회귀 언어 모델과 확산 언어 모델

오늘날 널리 쓰이는 생성형 AI 알고리즘은 크게 두 계열입니다. 이미지나 비디오 같은 연속(continuous) 데이터의 경우 최고 수준의 접근법은 확산 모델(diffusion model)에 기반합니다. 텍스트나 코드 같은 이산(discrete) 데이터의 경우 표준 접근법은 대신 자기회귀(autoregressive) 모델입니다. 이 글은 이산 데이터를 위한 대안, 즉 현대적인 확산 패러다임 위에 세워진 접근법을 탐구합니다.

주류 언어 모델은 자기회귀 방식입니다. 즉 왼쪽에서 오른쪽으로 한 번에 토큰 하나씩, 이전 토큰들을 조건으로 삼아 생성합니다. 이 방식은 강력하지만 고유한 한계도 있습니다:

  • 오류 수정 불가: 한 번 출력된 토큰은 수정할 수 없어 초기 실수가 누적됩니다.
  • 느린 생성: 시퀀스를 만들려면 토큰 수만큼의 단계가 필요하며, 빠른 병렬 생성에 자연스럽게 맞지 않습니다.
  • 인과적(causal) 어텐션: 생성 시 오직 뒤만 볼 뿐 미래 문맥은 보지 못합니다.

확산 모델은 다른 접근을 취합니다. 한 번에 토큰 하나씩 텍스트를 만드는 대신, 초기 추측에서 시작해 여러 단계에 걸쳐 반복적으로 정제하며 전체 시퀀스를 한꺼번에 생성합니다. 이는 여러 장점을 열어줍니다. 단계 수를 줄이거나 늘려 속도와 품질을 조절할 수 있고, 과정 중에 실수를 수정할 수 있으며, 매 단계가 양방향 문맥에 주목(attend)할 수 있습니다.

언어에 확산을 적용하는 것은 오랫동안 미해결 문제였습니다. 2024년 이 분야는 전환점을 맞아 확산 모델이 품질 면에서 자기회귀 모델과 경쟁할 수 있게 되었습니다. 2026년에 이르러 확산 LLM은 현실이 되었으며, 주요 기업 연구소들이 Mercury 2 (Inception Labs), Gemma Diffusion (Google), Nemotron Diffusion (NVIDIA) 등을 출시했습니다. 이 글은 이러한 현대 모델들의 기반이 되는 아이디어와 논문들을 따라갑니다.

배경: 가우시안 확산

언어를 위한 확산을 소개하기 전에, 이미지 생성을 위한 가우시안 확산을 간략히 살펴봅니다. 그다음 유추를 통해 이산 확산을 구축해 나갈 것입니다.

반복적 디노이징으로 생성하기

확산 모델의 핵심 개념은 디노이징(잡음 제거, denoising)입니다. 확산 모델은 이미지를 한 번에 그려내는 대신, 순수한 무작위 잡음에서 시작해 매 단계마다 조금씩 잡음을 제거하며 단계적으로 이미지를 만들어, 결국 일관된 이미지가 드러나게 합니다. 많은 작은 단계를 거쳐 이미지를 생성하는 것이 한 번에 전부 만들어내는 것보다 훨씬 간단하다는 것이 밝혀졌고, 이것이 확산 모델을 그토록 효과적으로 만듭니다.

모델은 어떻게 디노이징을 배울까요? 핵심은 잡음이 점차 이미지로 변환되는 예시를 보여주며 가르치는 것입니다. 확산은 두 개의 상보적 과정을 통해 이를 달성합니다. 첫째, 순방향 과정(forward process)은 깨끗한 원본 이미지를 가져와 한 단계씩 순수한 잡음으로 바꿉니다. 둘째, 역방향 과정(reverse process)은 이 변환을 뒤집는 법을 학습하여 순수한 잡음을 다시 이미지로 되돌립니다. 역방향 과정은 순방향 과정이 만든 이미지→잡음 궤적으로 학습됩니다.

순방향 과정

순방향 과정은 깨끗한 학습 이미지를 받아, 깨끗한 데이터에서 순수 잡음까지 이어지는 경로를 따라 점점 잡음이 많아지는 이미지들의 시퀀스를 만듭니다. 각 단계에서 점점 더 많은 무작위 가우시안 잡음을 섞어 넣어, 이미지가 완전한 스태틱(정적 잡음)으로 녹아들 때까지 진행합니다. 이 단계에는 전혀 학습이 필요 없습니다. 단지 잡음을 더하는 것뿐이지만, 이미지가 잡음으로 변환되는 예시(그리고 그 반대)를 무한히 만들어내는 훈련 데이터 공급원이 된다는 점에서 엄청나게 유용합니다.

역방향 과정

역방향 과정이 실제 학습이 일어나는 곳입니다. 잡음을 이미지로 변환하도록 모델을 학습시킵니다.

원문 보기
원문 보기 (영어)
How to Build a Diffusion Language Model An introduction to diffusion language models and the research advances that underlie today's diffusion LLMs. We describe the building blocks of recent open-source models, starting from simple masking diffusion, and including techniques for iterative refinement, post-training, and variable-length generation. Material is adapted from workshop talks and lectures at ICLR 2026 and MLSS 2026 . Introduction: Autoregressive and Diffusion Language Models Two families of generative AI algorithms are widely used today. For continuous data such as images or video, the state-of-the-art approach is based on diffusion models . For discrete data such as text or code, the standard approach is instead autoregressive models . This article explores an alternative for discrete data, one built on the modern paradigm of diffusion. Mainstream language models are autoregressive: they generate tokens left-to-right, one at a time, each conditioned on the tokens before it. This approach is powerful, but it also has inherent limitations: No error correction : once a token is emitted it cannot be revised, so early mistakes compound. Generation is slow : producing a sequence takes as many steps as there are tokens, and does not naturally lend itself to fast, parallel generation. Causal attention : generation only ever looks backward, never at future context. Diffusion models take a different approach. Rather than producing text one token at a time, they generate the whole sequence at once, starting from an initial guess and iteratively refining it over a number of steps. This unlocks several advantages: generation can trade off speed and quality by using fewer or more steps, mistakes can be corrected along the way, and every step attends to bidirectional context. Applying diffusion to language had long been an open problem. In 2024 the field reached a turning point, as diffusion models became competitive with autoregressive models on quality. By 2026, diffusion LLMs are a reality, with releases from leading industry labs — Mercury 2 (Inception Labs) , Gemma Diffusion (Google) , and Nemotron Diffusion (NVIDIA) . This article traces the ideas and papers that underlie these modern models. Background: Gaussian Diffusion Before introducing diffusion for language, we start with a brief overview of Gaussian diffusion for image generation. We will then build up discrete diffusion by analogy. Generating by iterative denoising The central concept underlying diffusion models is denoising . Instead of painting an image in one shot, a diffusion model produces images step by step, starting from pure random noise and removing a little of it at every step until a coherent image emerges. Generating an image through many small steps turns out to be far simpler than producing it all at once, and this is what makes diffusion models so effective. How does a model learn to denoise? The trick is to teach it by showing examples of noise being gradually transformed into an image. Diffusion achieves this via two complementary processes. First, a forward process takes a clean source image and turns it into pure noise, one step at a time. Second, a reverse process learns to invert this transformation, turning pure noise back into an image; it is trained on the image-to-noise trajectories produced by the forward process. Forward process The forward process takes a clean training image and produces a sequence of increasingly noisy images that trace a path from clean data to pure noise. It does this by mixing in a growing amount of random Gaussian noise at each step, until the image dissolves into pure static. This step requires no learning at all — we are simply adding noise — yet it is enormously useful, because it manufactures an endless supply of training data: examples of images being transformed into noise, and vice versa. Reverse process The reverse process is where the actual learning happens. We train a model to transform noise into images by following the steps produced by the forward process in reverse. Concretely, given a noisy image, we train a machine learning model to separate the noise from the underlying image or, equivalently, to predict either the noise that was added or the clean image itself, since given the noisy input, knowing one determines the other. Once the model can do this, generation is simple: start from pure noise, ask the model to estimate and strip away a bit of it, and repeat. Each pass nudges the sample a little closer to something that looks like real data, until a clean image remains. This forward/reverse recipe — corrupt data with noise, then learn to reverse the corruption one step at a time — is the blueprint for every diffusion model. Simple Masked Diffusion Models The main obstacle in bringing diffusion to language is deciding what "noise" should mean for discrete tokens. For example, the noise used in classical diffusion is Gaussian, and adding continuous Gaussian noise to categorical variables is not well-defined. Below we introduce one simple yet effective approach that defines noise via masking . Our group popularized this approach , and it now forms the basis of most open-source diffusion language models. Masked Diffusion in a Nutshell The easiest way to understand masked diffusion is as an unmasking transformer . We train the model by taking clean sequences, masking a random fraction of their tokens, and asking a bidirectional transformer to fill in the blanks. If you know BERT, this is essentially BERT with a randomized masking rate — but unlike BERT, the resulting model is generative. You can think of masked diffusion as a generative BERT . Once we trained the unmasking transformer, we can generate text by starting from a fully masked sequence and repeating two steps many times: Infilling : Ask the model to fill in every blank in the current sequence, yielding a rough guess of the clean tokens. Remasking : Randomly re-noise the infilled sequence by replacing tokens with masks, but keep a few more tokens unmasked than in the previous round. Each round leaves fewer positions masked, until the sequence converges to a clean sample from the model. Generation thus amounts to starting from a sequence full of blanks and gradually filling in words in an arbitrary order. Understanding Masked Diffusion: A Probabilistic Perspective We can also understand a bit better why this process works by framing it as an analog of the Gaussian diffusion model we saw earlier. Just like Gaussian diffusion, masked diffusion can be described as a model consisting of a forward and a reverse process. Forward process The goal of the forward process is to generate training data for the reverse process. Its output is a trajectory that starts from a datapoint and ends at a sequence of pure noise; the reverse process will then be trained to produce this trajectory in reverse. The key challenge is deciding what "noisy" should mean. In Gaussian diffusion, we added varying amounts of white noise to an image. In masked diffusion, we instead randomly mask a fraction of the tokens in a discrete sequence. The amount of masking is governed by a schedule $\alpha_t$ — the probability that a given token remains unmasked — which plays the role of the signal-to-noise ratio in Gaussian diffusion. It starts at $1$ when $t = 0$ (a clean sequence) and decreases to $0$ when $t = 1$ (a fully masked sequence). The time variable $t$ indexes a path from clean to noisy data, and at time $t$ a partially masked sequence $z_t$ has, in expectation, a fraction $\alpha_t$ of its tokens unmasked. We implement this process as a Markov chain over a sequence of variables $z_t$ indexed by $t$, with $z_0$ being the clean, unmasked sequence. For $s < t$, the chain defines $q(z_t \mid z_s)$ by masking each still-unmasked token of $z_s$ with probability $(\alpha_s - \alpha_t)/\alpha_s$. Running this Markov chain for a number of steps produces a trajectory going from clean data to fully maske