Categorical Normalizing Flows via Continuous Transformations

Phillip Lippe, Efstratios Gavves

Introduction

Normalizing Flows are powerful generative models known for their exact density estimation and fast parallel sampling on continuous data. However, they traditionally struggle with categorical data like graphs or text. The paper introduces Categorical Normalizing Flows (CNF), a framework that uses variational inference to map discrete categories into a continuous latent space. This enables efficient, parallel, and permutation-invariant generation of complex structures, such as molecules.

The Problem with Discrete Data

Normalizing Flows (NFs) rely on the "change of variables" formula, which inherently requires a continuous, differentiable space. When dealing with discrete data, researchers typically use dequantization—adding a small amount of continuous noise to integers.

While dequantization works for ordinal data (like image pixels, where a value of 128 is logically between 127 and 129), it fails for categorical data (like atom types or words). Mapping "Carbon" to 1 and "Oxygen" to 2 implies an arbitrary order and distance that simply does not exist. Furthermore, categorical relationships are often multi-dimensional (e.g., synonyms in language), which a simple 1D noise-filled line cannot adequately capture.

Methods: The CNF Framework

The authors propose treating the mapping of categories to continuous space as a variational inference problem rather than relying on fixed dequantization.

  1. The CNF Framework: Instead of fixed noise, CNF learns an encoder $q(z|x)$ that maps discrete categories to volumes in a continuous latent space.
  2. The Factorized Decoder: The authors enforce a strong inductive bias by using a decoder that is factorized over the variables: $p(x|z) = \prod p(x_i|z_i)$. By forcing the decoder to treat variables as independent, the Normalizing Flow (the prior) is forced to learn all the complex interactions and dependencies, preventing the decoder from "cheating" by modeling local dependencies.
  3. Simplified Optimization: Using a mixture of logistics for the encoder and deriving the decoder via Bayes' rule ensures the encoder and decoder remain "in sync." This simplifies the training objective and makes it more stable than previous "Latent NF" approaches.

GraphCNF: Applying CNF to Graphs

To handle complex relational data like molecules, the authors introduce GraphCNF, which uses a three-step generation process:

GraphCNF Architecture
  • Step 1: Model node types.
  • Step 2: Model edge attributes (for existing edges).
  • Step 3: Model the adjacency matrix (including "virtual" or missing edges).

This stepwise approach is significantly more computationally efficient than attempting to model every possible edge in a sparse graph simultaneously from the first layer.

Key Results and Insights

The authors evaluated CNF across several domains, including molecule generation (Zinc250k, MOSES), graph coloring, language modeling (Wikitext103), and set modeling.

  • Molecule Generation: GraphCNF achieved an impressive 83.4% validity on the Zinc250k dataset, outperforming other one-shot flow models like GraphNVP (42.6%) and the autoregressive GraphAF (68%).
  • Parallelism and Permutation Invariance: Unlike autoregressive models that generate nodes sequentially, GraphCNF generates the entire graph in parallel. On graph coloring tasks, it outperformed RNN-based models because it does not rely on an arbitrary node ordering, which can bias generation.
  • Scalability: CNF successfully handled the 10,000-word vocabulary of Wikitext103, a scale where most discrete NFs struggle due to the complexity of their gradient approximations.
Molecule Generation Examples

Limitations and Future Work

While highly effective, GraphCNF has some limitations. Like many "one-shot" graph generators, it can occasionally generate disconnected components (e.g., multiple small molecules instead of one large one, as seen in the sub-molecule generations above). The authors currently use a simple post-processing trick—taking the largest sub-graph—which bumps validity to 96.3%, but a more principled architectural solution remains a future goal.

Additionally, while more stable than Latent NFs, the model still requires deep, parameter-heavy flows to capture complex distributions. Future work may explore more complex discrete priors to further improve performance on tasks like language modeling.

Summary updated

BibTeX
@inproceedings{lippe2021categorical,
  author = {Phillip Lippe and Efstratios Gavves},
  title = {{Categorical Normalizing Flows via Continuous Transformations}},
  booktitle = {International Conference on Learning Representations},
  year = {2021},
  url = {https://openreview.net/forum?id=o4Z7RKHuVCx},
}
Figure