메뉴
HN
Hacker News • 30일 전

비디오 모델을 더 빠르고 잘 학습시키는 법

IMP
7/10
핵심 요약

이 글은 이미지·비디오 생성 모델의 성능 향상이 아키텍처 변화가 아닌 데이터 개선(필터링, 어노테이션, 합성 데이터 생성)에서 비롯된다고 분석합니다. 특히 2024년 CPU 기반 전통적인 컴퓨터비전 알고리즘(PySceneDetect 등)으로 수백억 개의 이미지·비디오를 저비용으로 필터링한 실무 경험을 소개합니다. 자체 생성 모델을 학습시키려는 실무자에게 실용적인 가이드가 될 수 있습니다.

번역된 본문

이미지와 비디오 모델은 지난 몇 년간 크게 발전했지만, 이 모델들의 내부 구조는 Stable Diffusion 3 이후 크게 바뀌지 않았습니다. 물론 GPT-Image가 대중화한 자기회귀(auto-regressive) 디퓨전 같은 작은 변형들은 있었습니다. 하지만 큰 틀에서 보면 거의 모든 모델이 트랜스포머 백본과 v-prediction 목적 함수를 사용하는 플로우 매칭(flow matching)입니다. 우리의 경험상 대부분의 성능 향상은 세 가지 유형의 데이터 개선에서 직접적으로 비롯됩니다. RL(강화학습)도 일부 개선을 이뤘지만, 이미지와 비디오에서 진정으로 작동하기 시작한 것은 최근 몇 달의 일입니다.

데이터 필터링 및 리밸런싱: 노이즈 데이터를 제거하고 전략적으로 데이터를 재샘플링하여 모델이 더 효과적으로 학습하도록 합니다.

데이터 어노테이션: 더 풍부한 캡션, 바운딩 박스, 폰트 정보 같은 더 나은 어노테이션을 수집하면 모델이 시각적 개념을 더 쉽게 구분할 수 있습니다. LLM은 지난 12개월간 이미지 캡셔닝에서 비약적으로 발전했습니다. 비디오는 덜하지만, 그건 다른 이야기입니다.

합성 데이터 생성: 자연적으로 거의 존재하지 않는 훈련 데이터(예: 나노바나나 스타일 모델을 위한 이미지 편집/레퍼런스 컨디셔닝)를 만들기 위해 기존 생성 모델들의 앙상블을 파인튜닝합니다. 보통 매우 특정한 작업을 위해 학습된 취약한 LoRA 모델들의 모음과, 나쁜 합성 데이터를 걸러내도록 파인튜닝된 LLM으로 구성됩니다.

몇 년 전만 해도 모든 생성 모델 분야(텍스트, 이미지, 오디오)의 지배적인 통념은 사전학습을 위해 최대한 많은 데이터를 모으는 것이었습니다. 다행히 이 분야는 이에 대해 훨씬 똑똑해졌습니다. 저품질 데이터(예: 과도하게 압축된 JPEG)를 사전학습에 넣으면, 모델은 이런 데이터를 흉내 내는 데 상당한 용량을 낭비하게 됩니다. 데이터셋을 잘 필터링하면 모델이 배우길 원하는 것을 훨씬 쉽게 학습할 수 있습니다. 이것은 당연하게 들리지만, 실제로 실행하는 것은 훨씬 어렵습니다. 다시 말하지만, 모든 좋은 조언은 돌이켜보면 당연해 보이는 법입니다. 오늘 우리는 2024년 이후 데이터 필터링 접근 방식이 어떻게 발전해왔는지 안내해 드리겠습니다. 그리고 나중에 여러분이 직접 생성 모델을 학습시키게 될 때 몇 가지 두통을 예방할 수 있기를 바랍니다.

[2024] 저예산 필터링 — CPU에서 동작하는 전통적인 컴퓨터비전

첫 시도에서 우리는 원시 데이터셋을 구식 컴퓨터비전 알고리즘으로 처리하기로 했습니다. 이렇게 하면 멀티모달 LLM을 돌리는 어마어마한 수의 GPU 대신 저렴한 CPU 인스턴스 클러스터로 해결할 수 있었습니다. 아니면 수백만 달러의 GPT-4 토큰 비용을 쓰는 대신 말이죠.

장면 감지

우리는 사전학습 데이터셋을 만들기 위해 수백억 개의 이미지와 비디오를 필터링해야 합니다. 이미지는 특별한 전처리가 필요 없지만, 원시 비디오는 그렇지 않습니다. 생성 비디오 모델을 학습시킬 때는 먼저 이미지 생성으로 사전학습해야 합니다. 모델이 동사를 배우기 전에 명사를 먼저 배우면 더 잘(그리고 더 빨리) 수렴하는 경향이 있습니다. 다음에 TV 쇼나 영화를 볼 때 카메라가 컷을 바꾸는 빈도를 세어보세요. 최근 20년간 만들어진 것을 보고 있다면 5초마다 컷이 바뀌는 것을 볼 가능성이 높습니다. 언제 어떻게 컷을 바꿀지는 감독의 결정이지, 생성 비디오 모델이 임의로 해야 할 일이 아닙니다. 따라서 비디오를 필터링하기 전에 샷 경계를 기준으로 비디오를 클립으로 잘라내야 합니다.

CPU만 사용하는 저렴한 방침에 따라 우리는 PySceneDetect를 선택했습니다. 개략적으로 이 도구는 K개 프레임의 롤링 윈도우를 유지하다가, K+1번째 프레임의 이미지 통계가 크게 다르면 그 프레임을 컷으로 분류합니다. 기반이 되는 머신러닝 모델은 없습니다. 매우 빠르게 실행되지만 디졸브, 페이드, 지터 컷 같은 일반적인 전환에서는 어려움을 겪습니다(이건 은근히 큰 문제입니다).

데이터를 알아가기

새 데이터를 받을 때마다 며칠을 들여 랜덤 샘플을 검토하고, 유지하고 싶은 것과 그렇지 않은 것을 목록화해야 합니다.

원문 보기
원문 보기 (영어)
Image and video models have gotten a lot better over the last few years, even though the internals of these models haven't changed much since Stable Diffusion 3. Of course, there have been small variants like the auto-regressive diffusion that GPT-Image popularized. But at a high level, it's pretty much all flow matching with a transformer backbone and a v-prediction objective. In our experience, most of the gains are directly attributable to 3 flavors of data improvements: RL has driven some improvement, but it's only started truly working for image and video in the past few months. Data Filtering & Rebalancing : Remove noisy data and resample your data strategically so your model learns more effectively Data Annotation : Gather better annotations like richer captions, bounding boxes, and font details so that it's easier for your model to disambiguate visual concepts LLMs have gotten infinitely better at image captioning in the last 12 months. Less so for video, but that's for another time. Synthetic Data Generation : Finetune an ensemble of existing generative models to create training data for which there is little-to-no naturally occurring data (e.g. image editing / reference-conditioning for Nano-Banana style models) Often a collection of brittle LoRAs trained for very specific tasks and an LLM finetuned to filter out bad synthetic data. A couple of years ago, the prevailing wisdom across all generative models (be it text, image, audio) was to aggregate as much data as humanly possible for pre-training. Luckily, the field has gotten a lot smarter about this. If you throw a bunch of low-quality data (e.g. heavily compressed JPEGs) into pre-training, your model is going to waste a significant amount of its capacity learning how to mimic this slice of data. If you filter your dataset well, your model will have a lot easier time learning what you want it to learn. We know this sounds obvious, but it's a lot harder to do in practice. Then again, all good advice should seem obvious in retrospect. Today we're going to walk you through how our approach to data filtering has evolved since 2024. And, hopefully we'll save you from a couple of headaches if you end up training your own generative models down the line. [2024] Filtering on a budget — Traditional CV on CPUs On the first go around, we decided to push our raw dataset through old-school computer vision algorithms. This way we could get away with a cluster of cheap CPU instances instead of an unholy number of GPUs running a multimodal LLM. Or, spending several million in GPT-4 tokens. Scene detection We need to filter down tens of billions of images and videos to create our pre-training dataset. Images don't really require any specific pre-processing, but raw videos do. When you train a generative video model, you first need to pre-train on image generation. If the model learns nouns before it learns verbs, it tends to converge better (and faster). Next time you watch a television show or movie, track how often the camera cuts. If you're watching something made in the last twenty years, more likely than not you'll see a cut every 5 seconds. When to cut and how to cut is an authorial decision, not something a generative video model should do arbitrarily. So, we need to slice n' dice our videos on shot boundaries into video clips before we can filter them down. With our cheapskate CPU-only agenda, we picked up PySceneDetect . At a high level it maintains a rolling window of K-frames and if the K+1 frame has significantly different image statistics, it categorizes the frame as a cut. There's no underlying machine learning model. It runs really fast but struggles with common transitions like dissolves, fades, and jitter cuts (which low key is a huge issue). Getting to know your data Whenever you get new data, you should spend a few days reviewing random samples, listing what you'd like to keep and what you'd like to throw out. Ideally, you take the time to draft an ontology of categories within "good" and "bad" and track the relative sizes of these categories. At some point during the data filtering process, your engineer brain will take over, and you'll spend way too much time tuning the knobs of your heuristics (or LLMs), chasing that "perfect" decision boundary. These notes are going to save you from yourself down the line. They'll give you the facts you'll need to talk yourself out of trying "one more idea", when the answer is clearly "no". Plus, understanding the shape of the data distribution will really help with dataset rebalancing. Certain categories are overrepresented in the natural distribution of all videos. We need to subsample and suppress this signal, otherwise it will dominate training and our model will struggle to learn the long-tail of people/places/things/actions that we need in order to generate anything. Sieving out the un-captionable Generative video models are primarily limited by what we can describe correctly and consistently in words. Or more precisely, what LLMs can annotate for us cheaply. Text provides a pretty good scaffold to understand the visual world, but it's by no means the correct conditioning mechanism for all aspects of video generation. Details like camera trajectories in space-time and the nuances of an actor's performance are simply indescribable in natural language. Reference-driven video generation is currently in-vogue. It's the first articulation of a control for these ineffable properties of videos, but we don't think it's a very good control per se. It's sufficient for autogenerated and remixed content like memes and brainrot, but it doesn't allow for the level of fine-grained direction necessary to convey authorial intent. It doesn't enable us to create the compelling stories that this technology should herald. For now, we need to filter out clips where the primary "thing" that makes the video clip interesting is un-captionable. Without a crystal clear text description, it's just noise to our text-to-video model. Text-heavy For example, we want to filter out text-heavy videos. It's still hard for LLMs to caption motion graphics that are constantly changing on screen. Reading the screen isn't the hard part, it's establishing a clear description of when and how the text changes on screen. We don't want to waste capacity in our 2B parameter model learning motion graphics when it could be allocated instead to learning actions. Zooming out, our goal is creative tools for animation. Text and motion graphics aren't a priority right now. To do this, we sampled frames from each video and ran a tiny EAST Detector to extract bounding boxes for text. From there, we filtered out text heavy videos based on the percentage of the frames that had text and the percentage of each frame covered in text. Using a CNN for this task was a good idea, but the specific choice was wrong. In order to run tens of billions of frames on CPUs, we had to resize the frames aggressively. So, a lot of text-heavy samples with small fonts fell through the cracks. Small text goes undetected, after EAST image pre-processing Original EAST input Original (zoomed) EAST input (zoomed) EAST is a pretty old model from 2017. It's small and far from the state of the art on text detection. Getting it to run efficiently on CPUs without cache-thrash and thread oversubscription was a challenge. Even after performance optimizations, it was still the largest bottleneck for this version of the data pipeline. It took us weeks to run EAST on our dataset, across a massive cluster of CPUs. Indescribable actions When there's not much happening on the screen (e.g. close-up on a person's face), it's hard to describe the specific action taking place. If there's too much happening (e.g. extremely shaky camera, a soccer match with a