Normalizing flows have revolutionized how we model continuous data like images and audio, offering a rare combination of exact likelihood evaluation and fast sampling. However, their reliance on continuous bijections makes them notoriously difficult to apply to discrete data like text. In this paper, Zachary Ziegler and Alexander Rush present a clever workaround: instead of flowing the discrete tokens directly, they flow a continuous latent representation within a Variational Autoencoder (VAE) framework.
By using an "inputless" decoder and a novel non-linear flow architecture, they achieve performance on par with LSTMs while enabling significantly faster, non-autoregressive generation.
The Challenge of Discrete Sequences
Deep generative models for text usually fall into two camps:
- Autoregressive models (like LSTMs or Transformers), which are powerful but slow to sample from because they generate one token at a time.
- VAEs, which often suffer from "posterior collapse." In posterior collapse, the decoder becomes so powerful that it ignores the latent code entirely, rendering the latent space useless for representation or controlled generation.
Normalizing flows (NFs) offer a potential solution because they can model highly complex distributions and, in some configurations, allow for parallel (non-autoregressive) sampling. However, NFs require continuous spaces to apply the "change-of-variables" formula. This paper tackles the challenge of using the flexibility and speed of NFs for discrete sequence data without falling into the trap of posterior collapse.
Methods: Lifting Dynamics into Latent Space
The core idea is to "lift" the dynamics of the discrete sequence into a continuous latent space.
Latent Flow VAE and the Inputless Decoder
The model defines a continuous latent sequence $z_{1:T}$ via a normalizing flow prior. The discrete tokens $x_{1:T}$ are then generated from these latents.
To prevent posterior collapse, the authors use a simple, independent emission model $p(x_t | z_t)$. Because the decoder cannot look at previous tokens ($x_{<t}$), the normalizing flow prior is forced to capture all the temporal dependencies and multimodality of the sequence. By stripping the decoder of its autoregressive powers (the "inputless" trick), the latent flow is no longer an optional helper—it becomes the engine of the model.
Flow Architectures
The authors experiment with three configurations to balance flexibility and sampling speed:
- AF/AF: Autoregressive in both time and hidden dimensions. This offers the highest flexibility but the slowest sampling.
- AF/SCF: Autoregressive in time, Split Coupling in hidden dimensions.
- IAF/SCF: Inverse Autoregressive in time, Split Coupling in hidden dimensions. Crucially, this version allows for parallel generation of the entire sequence.
Non-Linear Squared (NLSq) Flow
Standard flows use affine transformations (simple shifts and scales). The authors argue these aren't flexible enough for the "spiky" multimodality of discrete data. Discrete data is inherently "choice-heavy"—at any point in a sentence, there might be five likely next characters and fifty impossible ones. To address this, they introduce NLSq, a five-parameter non-linear transformation that can induce multiple modes even in a single dimension.
Datasets and Key Results
The authors evaluated their models on two distinct types of discrete sequences: character-level language modeling using the Penn Treebank (PTB) dataset, and polyphonic music generation across four standard benchmarks (Nottingham, Piano-midi.de, Musedata, and JSB Chorales).
- Performance Parity: On character-level PTB, the AF/AF model achieved 1.42 bits-per-character (bpc), nearly matching the "gold standard" LSTM baseline of 1.41 bpc.
- Music Modeling: The latent flow models outperformed several specialized baselines (like SRNN and TSBN) on the Nottingham and JSB datasets, proving the architecture generalizes well beyond text.
- Generation Speedup: The non-autoregressive IAF/SCF model showed dramatic speedups. For sequences of length 2000, it was roughly 10x faster to sample from than a standard LSTM, as it can utilize GPU parallelism to generate all time steps simultaneously.
Limitations and Future Work
While the results are promising, there are a few hurdles remaining. First, there is an accuracy gap: the fastest model (IAF/SCF) still lags behind the autoregressive versions in terms of raw likelihood (1.63 bpc vs 1.42 bpc on PTB). Second, this work focused on characters and music bits; scaling this to large-vocabulary word-level modeling may require even more flexible latent distributions. Finally, extending this unconditional generation framework to conditional tasks (like machine translation or summarization) is the next logical step to make this technology practical for real-world NLP pipelines.
Summary updated