Controllable and Compositional Generation with Latent-Space Energy-Based Models

Weili Nie, Arash Vahdat, Anima Anandkumar

TL;DR

LACE (LAtent Controllable EBM) enables high-resolution, controllable image generation by training energy-based models in the latent space of pre-trained generators like StyleGAN. By treating sampling as an Ordinary Differential Equation (ODE) problem, the method achieves state-of-the-art results in zero-shot attribute composition and sequential editing with significantly faster training and inference than previous approaches.

The Challenge of Controllable Generation

While deep generative models (like GANs) can produce stunningly realistic images, controlling what they generate remains difficult. Most existing "controllable" models are conditional—meaning they are trained to recognize a fixed set of attributes (e.g., "smiling," "wearing glasses"). This leads to two major issues:

  1. Rigidity: You cannot easily add new attributes without retraining the entire model from scratch, which is computationally expensive.
  2. Poor Compositionality: These models struggle to generate "unseen" combinations, such as a specific age, hair color, and accessory combo that wasn't present in the training data.

Previous attempts to use Energy-Based Models (EBMs) for this task were limited because they operated in the pixel space, making them incredibly slow to sample and nearly impossible to scale to high-resolution images (like 1024x1024).

Introducing LACE: Latent Controllable EBMs

To overcome these limitations, the authors introduce LACE (LAtent Controllable EBM). Instead of trying to define energy functions over millions of pixels, they define them in the much smaller latent space of a pre-trained, fixed generator (like StyleGAN2).

Key components of the methodology include:

  • Joint EBM Formulation: LACE models the joint distribution of data and attributes. Crucially, they show that if the generator is fixed, "training" the EBM simplifies to just training a simple attribute classifier in the latent space.
  • ODE-based Sampling: Traditional EBMs use Langevin Dynamics (LD), which is noisy and sensitive to hyperparameters. LACE instead uses a probability flow ODE (inspired by score-based diffusion models). This allows for the use of adaptive ODE solvers, which are faster, more stable, and more robust.
  • Logical Composition: Because EBMs represent distributions as energy functions, they can be combined using logical operators. For example, to generate someone who is "wearing glasses AND NOT smiling," you simply add and subtract the corresponding energy functions.

Key Insights and Advantages

  • Latent Space Efficiency: By moving the "control" mechanism to the latent space, the model inherits the high-quality image priors of the pre-trained generator while avoiding the computational nightmare of pixel-level optimization.
  • The Classifier is the Controller: One of the most elegant findings is that a simple classifier trained on latent vectors acts as a perfect energy function for steering the generator.
  • ODE Solvers are "Smarter" Samplers: The shift from Langevin Dynamics to ODE solvers is a major win for usability. ODE solvers automatically adjust their step sizes, meaning researchers don't have to spend days "hand-tuning" sampling parameters.
  • Zero-Shot Power: LACE can generate attribute combinations it has never seen before (zero-shot) simply by composing energy functions at inference time.

Experimental Results

The researchers evaluated LACE across several diverse datasets, including CIFAR-10, FFHQ (high-resolution human faces), MetFaces, and AFHQ-Cats. LACE consistently outperformed existing baselines like StyleFlow and JEM across multiple metrics:

  • Speed: Training is 25x faster than StyleFlow on FFHQ. Inference (sampling) is 49x to 876x faster than pixel-space EBMs and score-based models.
  • Controllability: On FFHQ, LACE achieved near-perfect conditional accuracy (0.998) while maintaining lower FID scores (better image quality) than competitors.
  • Compositionality: LACE succeeds in zero-shot generation where baselines like StyleFlow fail to either maintain image quality or follow the attribute prompts.
Zero-shot results showing LACE successfully combining rare attributes compared to baselines.
  • High Resolution: LACE is the first to demonstrate complex logical compositions (AND, OR, NOT) at 1024x1024 resolution.
Logical compositions of attributes at 1024x1024 resolution.

Limitations and Future Work

  • Generator Bottleneck: LACE is only as good as its pre-trained generator. If the underlying StyleGAN cannot generate a specific feature (e.g., a very rare hat), LACE cannot "force" it to appear.
  • Label Requirement: Training the attribute classifier still requires a labeled dataset. The authors suggest that future work could integrate semi-supervised or self-supervised learning to reduce this dependency.
  • Inherited Bias: Since LACE uses pre-trained models, it naturally inherits any social or demographic biases present in those original datasets.

Summary updated

BibTeX
@inproceedings{nie2021controllable,
  author = {Weili Nie and Arash Vahdat and Anima Anandkumar},
  title = {{Controllable and Compositional Generation with Latent-Space Energy-Based Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=kcI3T5qe1jr},
}
Figure