메뉴
HN
Hacker News 24일 전

디퓨전 모델의 적분 학습과 플로우 맵

IMP
8/10
핵심 요약

디퓨전 모델의 샘플링 속도를 획기적으로 높이기 위해 중간의 반복적인 단계를 건너뛰고 적분값을 직접 예측하는 '플로우 맵(Flow Map)' 기술을 소개하는 글입니다. 플로우 맵은 단순히 샘플링 속도만 개선하는 것을 넘어 보상 기반 학습의 효율성과 샘플링 제어 능력을 향상시키는 등 다양한 장점을 제공합니다. 최근 AI 연구 분야에서 매우 주목받고 있으며, 기존 디퓨전 모델의 한계를 극복할 대안으로 떠오르고 있습니다.

번역된 본문

디퓨전 모델(diffusion model)에서 샘플링하는 것은 반복적인 과정입니다. 각 단계에서 디노이저(denoiser)는 입력 공간을 지나는 경로의 접선 방향(tangent direction)을 추정합니다. 우리는 이 방향으로 작은 단계를 반복적으로 밟아 나가며 이동하며, 결과적으로 노이즈 수준에 걸친 적분(integral)을 계산하게 됩니다. 이것은 단순한 노이즈 분포의 샘플들을 대상 분포(target distribution)의 샘플들로 점진적으로 변환하며, 그것들을 연결하는 경로를 그려냅니다.

이러한 반복 과정을 거치지 않고, 샘플링 속도를 높이기 위해 신경망이 이 적분을 직접 예측하도록 학습시킬 수 있을까요? 네, 가능합니다. 플로우 맵(Flow Map)의 세계로 오신 것을 환영합니다!

디퓨전 모델이 부상한 이래로, 사람들은 더 빠르고 저렴하게 샘플링할 수 있는 방법을 모색해 왔습니다. 약 2년 전, 저는 고품질 샘플을 얻는 데 필요한 단계 수를 줄이는 주요 도구 중 하나인 디퓨전 증류(diffusion distillation)에 대한 블로그 글을 쓴 적이 있습니다. 다양한 증류 방법의 근본적인 원리는 변하지 않았지만, 그 이후로 수많은 새로운 변형이 등장했습니다.

이 블로그 글에서는 플로우 맵에 대해 자세히 살펴보고자 합니다. 디퓨전 모델이 경로상의 각 지점에서 접선 방향을 예측하여 노이즈와 데이터 사이의 경로를 설명하는 반면, 플로우 맵은 동일한 경로상의 한 지점에서 다른 지점을 직접 예측할 수 있습니다. 이는 더 빠른 샘플링에 사용될 수 있을 뿐만 아니라, 더 효율적인 보상 기반 학습(reward-based learning)과 향상된 샘플링 제어 능력(steerability) 등 다른 기교들도 가능하게 합니다. 최근 이 분야는 매우 인기 있는 연구 주제가 되었습니다.

플로우 맵이 무엇인지 정의하는 것은 비교적 간단하지만, 이를 구축하고 학습시키는 방법은 매우 다양합니다. 게다가 디퓨전 모델 자체와 마찬가지로 문헌마다 다른 형식과 용어가 난무하여, 모든 것들이 어떻게 결합되어 있는지 이해하려고 할 때 혼란스러울 수 있습니다. 저는 주로 Boffi 등이 제안한 분류법(taxonomy)을 바탕으로 이를 명확히 정리해 보겠습니다.

플로우 맵은 디퓨전 모델의 기본 아이디어를 바탕으로 구축되므로, 이러한 개념에 대해 어느 정도 익숙하다고 가정하겠습니다. 벡터 미적분학(vector calculus)에 능숙하다면 학습 과정을 이해하는 데 도움이 되겠지만, 그렇지 않더라도 이 블로그 글의 다른 부분들은 여전히 흥미로울 것입니다. 배경 지식을 위해 제가 예전에 작성한 블로그 글(예: 'Perspectives on diffusion')을 다시 읽어보는 것을 추천합니다. 또는 최근 Chieh-Hsin Lai와 동료들이 디퓨전 모델에 대한 포괄적인 모노그래프를 출판했는데, 이는 수학적 엄밀함과 직관적인 설명을 결합한 훌륭한 자료입니다. 복습용이나 입문용으로 모두 강력히 추천합니다.

아래는 목차입니다. 각 섹션을 클릭하면 해당 부분으로 바로 이동할 수 있습니다.

  • 노이즈에서 데이터로 가는 경로 매핑하기
  • 세 가지 일관성(Consistency) 개념
  • 역전파(Backprop)를 할 것인가, 말 것인가?
  • 플로우 맵 처음부터 학습시키기
  • 실전 속의 플로우 맵
  • 응용 프로그램 및 확장
  • 대체 전략들
  • 맺음말
  • 감사의 말
  • 참고문헌

노이즈에서 데이터로 가는 경로 매핑하기

플로우 맵을 이해하기 위한 핵심은 디퓨전 모델을 '노이즈와 데이터 사이의 전단사(bijection)를 정의하는 것'으로 바라보는 관점입니다. 이는 각 분포의 샘플 쌍을 연결하는 고유한 경로가 있으며, 이 경로들은 서로 절대 교차하지 않는 방식입니다. 따라서 먼저 디퓨전 샘플링 알고리즘을 자세히 살펴보고, 이를 바탕으로 플로우 맵으로 나아가 보겠습니다.

디퓨전 모델에서의 샘플링

오늘날 디퓨전 모델을 위한 다양한 샘플링 알고리즘이 존재하지만, 이들은 모두 확률적(stochastic) 방식과 결정론적(deterministic) 방식 중 하나로 나뉩니다. 결정론적 샘플링의 경이로움에 대해서는 예전에도 작성한 적이 있지만, 플로우 맵의 발전에 기초가 되는 개념이므로 여기서 다시 요약해 보는 것이 좋겠습니다.

요점은 다음과 같습니다. 만약 우리가 노이즈가 섞인 관측치 (\mathbf{x}_t)가 주어졌을 때, 깨끗한 원본 데이터의 기댓값 (\hat{\mathbf{x}}_0 = \mathbb{E}\left[ \mathbf{x}_0 \mid \mathbf{x}_t \right])을 예측하는 디노이저 모델을 가지고 있다면, 우리는

원문 보기
원문 보기 (영어)
Sampling from a diffusion model is an iterative process: at each step, the denoiser estimates the tangent direction to a path through input space. We move along this path by repeatedly taking small steps in this direction, effectively calculating an integral across noise levels . This gradually transforms samples from a simple noise distribution into samples from a target distribution, and traces out the path that connects them. Can we train neural networks to directly predict this integral instead, in order to speed up sampling? Yes we can – welcome to the world of flow maps ! Ever since the rise of diffusion models, people have sought ways to make them faster and cheaper to sample from. About two years ago, I wrote a blog post about diffusion distillation , which is one of the main tools used to reduce the number of steps required to obtain high-quality samples. Although the core principles underlying various distillation methods have not changed, a lot of new variants have popped up since. In this blog post, I want to take a closer look at flow maps. While diffusion models describe paths between noise and data by predicting the tangent direction at each point along the path, flow maps are instead able to predict any point on a path from any other point on that same path . They can be used for faster sampling, but they also have some other tricks up their sleeve, enabling more efficient reward-based learning and improved sampling steerability, among other things. They have recently become a very popular subject of study. While it is relatively straightforward to define what a flow map is, there turn out to be many different ways to build and train them. On top of that, as with diffusion itself, the literature is once again rife with different formalisms and terminology, which makes for a confusing experience when trying to learn how everything fits together. I will do my best to clear things up a bit, based primarily on the taxonomy proposed by Boffi et al. 1 2 . Flow maps build on the ideas behind diffusion models, and as usual, I will assume some familiarity with these ideas. Being comfortable with vector calculus will also help to understand how they are trained, but if that’s not you, hopefully the other parts of this blog post will still be interesting to you. You may want to consider (re-)reading some of my earlier blog posts for context (e.g. Perspectives on diffusion ). Alternatively, Chieh-Hsin Lai and colleagues recently published a comprehensive monograph on diffusion models 3 , which combines math and rigour with intuitive explanations – highly recommended, both as a refresher and as a starting point. Below is a table of contents. Click to jump directly to a particular section of this post. Charting paths from noise to data Three notions of consistency To backprop or not to backprop? Training flow maps from scratch Flow maps in practice Applications and extensions Alternative strategies Closing thoughts Acknowledgements References Charting paths from noise to data The key to understanding flow maps is the perspective of diffusion models as defining a bijection between noise and data, with unique paths connecting pairs of samples from each distribution, in such a way that they never cross each other. Therefore, let’s first take a closer look at diffusion sampling algorithms, and build towards flow maps from there. Sampling from diffusion models There are many different sampling algorithms available for diffusion models nowadays, but they all fall into one of two categories: stochastic or deterministic . The miracle of deterministic sampling is something I have written about before , but it is worth recapping here, as it is fundamental to the development of flow maps. The gist of it is as follows: if we have a denoiser model that predicts the expected value of the clean original data \(\hat{\mathbf{x}}_0 = \mathbb{E}\left[ \mathbf{x}_0 \mid \mathbf{x}_t \right]\), given a noisy observation \(\mathbf{x}_t\), we can construct two distinct iterative generative procedures . The stochastic one is the most intuitive: at each iteration, we sample from a conditional distribution of slightly less noisy examples, given the current noisy observation, \(p(\mathbf{x}_{t-1} \mid \mathbf{x}_t)\), to reverse the corruption process one step at a time. Conveniently, we can construct an approximation of this distribution using the denoiser model prediction \(\hat{\mathbf{x}}_0\). The smaller the interval between the noise levels at time steps \(t\) and \(t-1\), the more accurate the approximation will be. After many iterations, the noise fades, and we end up with a sample from the clean data distribution at \(t=0\). This is, in a nutshell, how the original DDPM 4 algorithm works. Sampling algorithms based on the stochastic differential equation (SDE) formalism of diffusion models 5 produce similar stochastic trajectories in input space. The deterministic procedure does not involve drawing random samples at any point, except at the very start: given the current noisy observation \(\mathbf{x}_t\) and the prediction \(\hat{\mathbf{x}}_0\) from the denoiser, there is a deterministic update rule that gives us \(\mathbf{x}_{t-1}\), which we can recursively apply until we get to \(\mathbf{x}_0\). Because every step of the procedure is deterministic, there is no randomness anywhere: from a given starting point \(\mathbf{x}_t\), we can only ever end up in one specific end point \(\mathbf{x}_0\). Such an update rule can be derived in the probabilistic framework (i.e. DDIM 6 ), or using the ordinary differential equation (ODE) formalism 5 . The default sampling algorithm used in Flow Matching 7 is another instance of the deterministic procedure. Here, the neural network is typically parameterised to predict the velocity \(\mathbf{v}_t = \mathbb{E}\left[\mathbf{x}_T - \mathbf{x}_0 \mid \mathbf{x}_t \right]\) instead of the clean input \(\mathbb{E}\left[ \mathbf{x}_0 \mid \mathbf{x}_t \right]\) (with \(t=T\) the time step corresponding to the maximal noise level, i.e. pure Gaussian noise). However, as there is a linear relationship between \(\mathbf{v}_t\), \(\hat{\mathbf{x}}_0\) and \(\mathbf{x}_t\), this just yields a variant of the same underlying algorithm (see also this discussion of different diffusion model output parameterisations in an earlier blog post ). All these algorithms have in common that the marginal distributions of noisy examples \(p(\mathbf{x}_t)\) at each time step \(t\) are preserved: the distribution of \(\mathbf{x}_t\) does not depend on whether you chose to use a deterministic or stochastic sampling algorithm! This is of course not true at all for the conditional distributions \(p(\mathbf{x}_t \mid \mathbf{x}_T)\), which collapse to delta distributions in the deterministic case (all probability mass is on a single option). This preservation of the marginal distributions is also true for the special cases \(p(\mathbf{x}_0)\) and \(p(\mathbf{x}_T)\), at the data and noise sides respectively. If we look at specific individual examples rather than distributions, however, the path in input space traced out by the sampling process will look quite different. Below is a visualisation of the sampling process: stochastic on the left, deterministic on the right. I decided to show this for both a 1D example (top) and a 2D example (bottom), because I believe the insights they provide are complementary. In both cases, the target distribution is a mixture of two Gaussians. We start with samples from our noise distribution, which is a single Gaussian. As sampling progresses, the distribution gradually transforms into the target mixture. The path a single sample traverses is quite jagged and erratic in the stochastic case, but smooth and gently curved in the deterministic case. Two very different microscopic behaviours give rise to the exact same macroscopic behaviour! Dead reckoning: tracking paths with a diffusion model An important implication of the exist