NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

TraDE: Transformers for Density Estimation

Rasool Fakoor, Pratik Chaudhari, Jonas Mueller, Alexander J. SmolaarXiv 2020

Abstract

Density estimation is a fundamental task in machine learning, yet existing methods like normalizing flows and auto-regressive RNNs often struggle with architectural constraints or memory bottlenecks. We present TraDE (Transformers for Density Estimation), a novel auto-regressive architecture that leverages self-attention and GRU-based embeddings to model complex probability distributions. TraDE achieves state-of-the-art results on tabular and image benchmarks, demonstrating robustness across diverse data types and downstream tasks.

Introduction: The Density Estimation Challenge

Estimating a probability density $p(x)$ from data is critical for applications ranging from synthetic data generation to anomaly detection. However, current paradigms face significant limitations:

  1. Normalizing Flows require invertible transformations and tractable Jacobians, restricting their architectural flexibility.
  2. Auto-regressive RNNs suffer from a "memory bottleneck," where all previous information must be compressed into a fixed-size hidden state, hindering long-range dependency capture.
  3. Tabular Data lacks natural ordering, making models sensitive to arbitrary variable sequences.

TraDE addresses these issues by providing a flexible, order-agnostic model capable of handling both continuous and discrete data without the vanishing gradient problems of the past.

Methods: Adapting Transformers for Density

TraDE re-imagines the Transformer architecture for density estimation through several key innovations:

  • Masked Self-Attention: By using a masked self-attention mechanism, TraDE allows each variable to attend to all preceding variables directly, ensuring the auto-regressive property while bypassing the memory constraints of RNNs.
  • GRU-based Input Embedding: Unlike standard NLP models that use Fourier position encodings, TraDE employs a Gated Recurrent Unit (GRU) at the input layer. This implicitly encodes feature positions, which proved significantly more effective for density estimation.
  • Gaussian Mixture Model (GMM) Outputs: For continuous data, the model predicts parameters for a GMM for each conditional probability.
  • Hybrid Training Objective: The model is trained using Maximum Likelihood Estimation (MLE) combined with a Maximum Mean Discrepancy (MMD) penalty. This regularization ensures that generated samples closely resemble the training distribution, improving overall fidelity.
Visualizations of complex distributions and high-fidelity synthesis achieved by TraDE.

Key Results

TraDE was rigorously evaluated against standard benchmarks, including UCI tabular datasets and binarized MNIST.

Tabular Benchmarks

TraDE established new state-of-the-art log-likelihoods on four out of five standard UCI tabular benchmarks, outperforming established flow-based and RNN-based models.

Comparison of TraDE against baseline models on standard UCI tabular datasets.

Image and Synthesis Performance

On binarized MNIST, TraDE achieved a negative log-likelihood of 78.92, surpassing PixelRNN (79.20) and various VAE architectures. Furthermore, in downstream regression tasks using synthetic data, TraDE-generated samples yielded a Mean Squared Error (0.780) nearly identical to real data (0.773), highlighting its high-fidelity synthesis capabilities.

Conclusion

TraDE demonstrates that self-attention, when combined with appropriate embedding strategies like GRU-based position encoding, offers a powerful alternative to traditional density estimation models. By eliminating the memory bottleneck and providing a flexible framework for complex distributions, TraDE sets a new standard for both tabular and high-dimensional data modeling. Future work will explore scaling TraDE to even larger synthesis tasks where long-range dependencies are paramount.

Summary updated

BibTeX
@misc{fakoor2020trade,
  author = {Rasool Fakoor and Pratik Chaudhari and Jonas Mueller and Alexander J. Smola},
  title = {{TraDE: Transformers for Density Estimation}},
  year = {2020},
  eprint = {2004.02441},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2004.02441},
}
Figure