Emu3: Next-Token Prediction for Image and Video Generation
BAAI's Emu3 (Wang et al., September 2024) is the 2024 result that should have ended the diffusion-versus-autoregressive debate. One Llama-style decoder-only transformer, trained only on next-token prediction over a unified vocabulary of text, VQ image tokens, and 3D VQ video tokens, beats SDXL on image generation and LLaVA-1.6 on perception. There is no CLIP loss and no diffusion schedule. Classifier-free guidance shows up at inference for quality, but training is plain next-token prediction with teacher forcing. The paper was published in Nature. This lesson reads the Emu3 thesis, that a better tokenizer plus scale carries the whole approach, and contrasts it with diffusion.
Learning Objectives
- Explain why Emu3's single-loss next-token objective works despite the long-held assumption that diffusion is required for image quality.
- Describe the 3D video tokenizer: what a spatiotemporal VQ codebook looks like, why patches span time.
- Compare Emu3 vs Stable Diffusion XL on (training compute, inference cost, quality ceiling).
- Name the three roles the same Emu3 model plays: Emu3-Gen (image gen), Emu3-Chat (perception), Emu3-Stage2 (video gen).
The Problem
The conventional wisdom through 2024 was that image generation needs diffusion. Discrete image tokens lose too much information to reconstruct fine detail, the argument went, and autoregressive sampling accumulates error across thousands of tokens. Stable Diffusion, DALL-E 3, Imagen, and Midjourney all use some form of diffusion. Chameleon (Lesson 12.11) partly disproved this at small scale but did not match SDXL on quality.
Emu3 attacked the argument head-on. Its claim: a better visual tokenizer, enough scale, and a next-token loss give diffusion-beating image generation, in the same model that also does perception.
The bet was controversial when it published. Two years on, the open-source unified-generation family (Emu3, Show-o, Janus-Pro, Transfusion) is the default path for research, and production frontier models appear to use some variant of it.
The Concept
The Emu3 tokenizer
The visual tokenizer is the key ingredient. Emu3 trains a custom IBQ-class tokenizer (Inverse Bottleneck Quantizer, SBER-MoVQGAN family) at 8x8 resolution reduction per token. A 512x512 image becomes 64x64 = 4096 tokens at a codebook size of 32768.
That is more than Chameleon's 1024 tokens per 512x512 at K=8192, but each token is cheaper (smaller codebook lookups, simpler codec). The metric to watch is reconstruction PSNR: 30.5 dB, competitive with Stable Diffusion's continuous latent space at 32 dB.
For video, a 3D VQ tokenizer encodes a spatiotemporal patch (4x4x4 pixels) into one integer. A 4s clip at 8 FPS has 32 frames. At 256x256 with 4x spatial and 4x temporal reduction, the token count is (256/4) * (256/4) * (32/4) = 64 * 64 * 8 = 32,768 tokens.
Tokenizer quality sets the ceiling, so part of Emu3's contribution is simply that the team trained a very good tokenizer.
Single-loss training
Emu3 uses one objective: next-token prediction on a shared vocabulary of text tokens, 2D image tokens, and 3D video tokens. Per-modality weights balance each modality's contribution during training, and the loss function itself is the same throughout.
The training mix looks like this:
- Image gen:
<text caption> <image> image_tokens </image> - Image perception:
<image> image_tokens </image> <question> text_tokens - Video gen:
<text caption> <video> video_tokens </video> - Video perception: analogous.
- Text only: standard NTP.
The model learns from the data distribution when to emit image tokens and when to emit text. Generation comes from predicting image tokens after the <image> tag.
Classifier-free guidance and temperature
Autoregressive image generation improves a lot with classifier-free guidance (CFG) at inference. Emu3 generates twice, once with the full caption and once with an empty caption, then mixes the logits with a guidance weight (typically 3.0-7.0). It is the same trick diffusion uses, applied to token logits.
Temperature matters too. Too high gives artifacts, too low gives mode collapse. Emu3 recommends 1.0 for perception and 0.8 for image generation.
Three roles, one model
Emu3 ships as three APIs on one underlying weight set:
- Emu3-Gen. Image generation. Input text, output image tokens.
- Emu3-Chat. VQA and captioning. Input image (tokens), output text.
- Emu3-Stage2. Video generation and video VQA. Input text or video, output text or video.
There are no task-specific heads, only different prompt templates over the same checkpoint.
Benchmarks
From the Emu3 paper (September 2024):
- Image generation: beats SDXL on MJHQ-30K FID (5.4 vs 5.6). On GenEval overall it scores 0.54 vs 0.55, which is a statistical tie. Deep-Eval's composite is on par.
- Image perception: beats LLaVA-1.6 on VQAv2 (75.1 vs 72.4) and roughly matches it on MMMU.
- Video generation: 4-second-clip quality at competitive FVD with Sora-era publicly benchmarked models.
Emu3 does not win everywhere. It gives up a point here for a point there. Even so, the claim that next-token prediction is enough is defensible across these modalities.
Compute cost
Emu3 was trained on roughly 300 billion multimodal tokens with a 7B-parameter model. GPU-hours come out roughly comparable to Llama-2-7B pretraining (2k-4k GPU-years on A100-class silicon). Diffusion models like Stable Diffusion 3 train on similar budgets but need separate text encoders and a more complex pipeline.
At inference, Emu3 is slower than SDXL per image. 4096 image tokens at 30 tok/s is about 2 minutes per 512x512 image, against 2-5 seconds for SDXL. Speculative decoding and KV-cache optimization narrow the gap without closing it. Autoregressive image generation is compute-heavy, and that is the standing trade-off.
Why it matters
The deeper contribution is conceptual. If next-token prediction scales to match diffusion on image generation, the unified-model path (one loss, one backbone, many modalities) is viable. Future models do not need a separate text encoder, a separate diffusion scheduler, or a separate VAE. One transformer, one tokenizer per modality, and scale.
Show-o, Janus-Pro, and InternVL-U all build on or challenge this thesis. Through 2025, Chinese labs (BAAI, DeepSeek) published in this direction more aggressively than US labs.
Use It
code/main.py builds two toy pieces:
- A token-count calculator for 2D image and 3D video tokenizers. Give it a resolution, a spatial reduction, a clip length, an FPS, and a temporal reduction, and it prints token counts plus seconds at 30 tok/s.
- An autoregressive image-token sampler with classifier-free guidance and temperature.
The CFG step follows the Emu3 recipe: mix conditional and unconditional logits with a guidance weight. The sampler draws random logits over a K=16 codebook, so it shows how guidance reshapes a distribution and does not generate real images.
Ship It
This lesson produces outputs/skill-token-gen-cost-analyzer.md. Give it a generation product spec (image or video, target resolution, quality tier, latency budget) and it computes token counts and inference cost, then picks between the Emu3 family and diffusion.
I'd run main.py before reading the paper's numbers. The first table prints token counts and seconds at 30 tok/s for a few configs, and the 2048x2048 row is the one that makes the cost of autoregressive image generation concrete: the count grows with the square of the resolution, and the latency column grows with it.
My bet is that the CFG function is the part worth rereading until it feels boring. cfg_mix is uncond + gamma * (cond - uncond), so gamma=1.0 gives back the conditional logits unchanged, and anything above 1.0 pushes the distribution further away from the unconditional one. The demo_cfg output shows the distribution sharpening as gamma goes up. That also tells you what the guidance weight costs: every sampled token needs two forward passes, one conditional and one unconditional.
I'd also keep the toy in proportion. Its conditional and unconditional logits are random Gaussians, so the sampler tells you nothing about image quality, only about how gamma and temperature reshape a distribution. The Emu3 numbers in the closing printout are hardcoded strings, not measurements from anything the script runs.
Exercises
-
Emu3 produces 4096 tokens per 512x512 image at 8x8 reduction. Compute the equivalent for 1024x1024 and 2048x2048. What happens to inference latency?
-
Read Emu3 Section 3.3 on the video tokenizer. Describe the 3D VQ patch shape and why it is 4x4x4 not 8x8x1.
-
Classifier-free guidance weight 5.0 vs 3.0: what visual effect? Trace the math in
code/main.py. -
Compute training FLOPs for Emu3-7B at 300B tokens and compare to Stable Diffusion 3. Which was more expensive to train?
-
Emu3 beats SDXL on FID but only ties it on GenEval. Explain why the unified-loss approach shows different strengths vs specialists on different benchmarks.
Key Terms
| Term | What people say | What it actually means |
|---|---|---|
| Next-token prediction | "NTP" | Standard autoregressive loss: predict token[i+1] given token[0..i]; works for every modality when tokenized |
| IBQ tokenizer | "Inverse bottleneck quantizer" | A class of VQ-VAE with larger codebooks (32768+) and better reconstruction than Chameleon's |
| 3D VQ | "Spatiotemporal quantizer" | Codebook indexed by (time, row, col); one token covers a 4x4x4 pixel cube |
| Classifier-free guidance | "CFG" | Mix conditional and unconditional logits with weight gamma; boosts image quality at inference |
| Unified vocabulary | "Shared tokens" | Text + image + video all draw from the same integer space; model predicts whichever modality comes next |
| MJHQ-30K | "Image gen benchmark" | Midjourney-quality benchmark with 30k prompts; Emu3 reports FID here |
Code
- main.py (python, 141 lines)