DiScoFormer: Plug-In Density and Score Estimation with Transformers

Vasily Ilin, Peter Sushko (Allen Institute for AI), Ranjay Krishna (Allen Institute for AI)

International Conference on Machine Learning 2026 · Oral

Overview

This talk introduces DiScoFormer, a novel framework developed by researchers at the Allen Institute for AI and the Microsoft Superintelligence Lab that leverages transformer architectures to solve high-dimensional density and score estimation. Traditional statistical methods like kernel density estimation (KDE) struggle catastrophically as dimensionality increases, while modern generative approaches like diffusion models learn high-fidelity distributions but fail to act as plug-in estimators—requiring complete retraining when the underlying data distribution shifts. DiScoFormer bridges this gap by reframing density and score estimation as a sequence-to-sequence modeling task, achieving high-fidelity estimation in high dimensions while retaining the analytical flexibility of a plug-in estimator.

Watch on SlidesLive

Visual summary for DiScoFormer: Plug-In Density and Score Estimation with Transformers by Vasily Ilin, Peter Sushko, Ranjay Krishna
Visual summary for DiScoFormer: Plug-In Density and Score Estimation with Transformers by Vasily Ilin, Peter Sushko, Ranjay Krishna

Key moments

  1. 0:00 Introduction and core motivation of DiScoFormer
  2. 2:00 Defining density estimation and score estimation
  3. 4:00 Framing the problem as a sequence-to-sequence task
  4. 6:00 Empirical results and loss comparison with KDE
  5. 7:00 Theoretical connection between attention and kernel density estimation
  6. 8:00 Empirical findings on attention head specialization
  7. 10:00 Conclusion and summary of takeaways
  8. 10:39 Audience Q&A on multi-headed attention and kernels
  9. 12:00 Audience Q&A on bandwidth and comparisons with KDE baselines

DiScoFormer: Plug-In Density and Score Estimation with Transformers

Speakers: Vasily Ilin; Peter Sushko (Allen Institute for AI); Ranjay Krishna (Allen Institute for AI)

Conference: ICML

YouTube: https://slideslive.com/39083536

Overview

This talk introduces DiScoFormer, a novel framework developed by researchers at the Allen Institute for AI and the Microsoft Superintelligence Lab that leverages transformer architectures to solve high-dimensional density and score estimation. Traditional statistical methods like kernel density estimation (KDE) struggle catastrophically as dimensionality increases, while modern generative approaches like diffusion models learn high-fidelity distributions but fail to act as plug-in estimators—requiring complete retraining when the underlying data distribution shifts. DiScoFormer bridges this gap by reframing density and score estimation as a sequence-to-sequence modeling task, achieving high-fidelity estimation in high dimensions while retaining the analytical flexibility of a plug-in estimator.

The central thesis of the presentation is that standard transformer self-attention mechanisms naturally function as learned, data-adaptive kernel density estimators. By establishing a rigorous mathematical connection between single-layer attention heads and Gaussian kernel weights, the authors demonstrate that transformers possess a powerful inductive bias ideally suited for nonparametric statistical estimation. Empirical results confirm that DiScoFormer consistently outperforms traditional KDE and baseline methods across dimensions, offering significant implications for researchers working in generative modeling, probabilistic inference, and sampling algorithms.

Background

▶ Watch: Introduction and core motivation of DiScoFormer (0:00)

In statistics and machine learning, estimating an unknown probability density function $f$—and its logarithmic gradient, known as the score function $\nabla \log f$—from a finite sample of points is a foundational problem. Score estimation, in particular, plays a critical role in modern generative pipelines such as diffusion models, stochastic differential equation (SDE) solvers, and computing the relative Fisher information.

For low-dimensional data, classical nonparametric methods like KDE work reliably. KDE operates by placing a smooth kernel (typically a Gaussian distribution) on each observed sample point and averaging them to reconstruct the density. However, KDE suffers from the curse of dimensionality, breaking down entirely in high-dimensional spaces. Conversely, deep generative models like diffusion networks achieve exceptional high-fidelity reconstruction in high dimensions, but they are not plug-in estimators. Once a diffusion model is trained, evaluating a modified or shifted density requires expensive retraining from scratch.

The machine learning and systems space has long lacked an estimator that is simultaneously high-fidelity in high dimensions and mathematically plug-in. DiScoFormer addresses this fundamental tension by mapping the statistical estimation problem onto sequence-to-sequence modeling, utilizing the transformer architecture to bypass the scaling limitations of classical nonparametric statistics.

Key Findings

▶ Watch: Framing the problem as a sequence-to-sequence task (4:00)

The primary finding of DiScoFormer is that transformers can accurately estimate densities and scores in high-dimensional Euclidean space ($d \ge 10$) where classical KDE entirely fails.

  • Superior Scaling: Empirical benchmarks comparing DiScoFormer against classical and optimized KDE baselines across dimensions $d=2$ and $d=10$ (with sample sizes ranging from $2^8$ to $2^17$) show that DiScoFormer achieves consistently lower reconstruction loss.
  • Emergent Head Specialization: Without explicit architectural constraints or regularization during training, individual attention heads within the transformer naturally specialize in distinct kernel behaviors. Some heads learn local Gaussian-like kernels with small bandwidths (focusing on nearby points), while other heads learn non-local kernels that attend to distant data points.
  • Data-Adaptive Kernels: Qualitative visualizations of layer-zero attention weights demonstrate that attention patterns adapt dynamically to the local geometry of different data samples, performing in-context adaptation of kernel bandwidths and orientations.

Technical Deep Dive

▶ Watch: Theoretical connection between attention and kernel density estimation (7:00)

The core innovation of DiScoFormer lies in recognizing the mathematical isomorphism between transformer self-attention and kernel density estimation.

Given $n$ sample points in $d$-dimensional Euclidean space sampled from an unknown density $f$, the goal is to estimate $f(x)$ and $\nabla \log f(x)$ at sample locations. By normalizing the input data to reside on a unit sphere (where $\|x\| = 1$), the authors prove mathematically that a single self-attention head with appropriately structured query ($Q$), key ($K$), and value ($V$) matrices can analytically compute Gaussian weights.

The standard Gaussian kernel takes the form $e^{-\|x - y\|^2 / 2\sigma^2}$. Expanding the squared norm yields a cross-term $x^T y$, which corresponds directly to the inner product computed during scaled dot-product attention. Furthermore, the softmax operation in attention mimics the exponential normalization of Gaussian weights.

$$\text{Attention}(Q, K, V) = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right)V$$

By stacking multiple attention heads and leveraging linear combinations across layers, the model implements a hierarchical sequence of data-adaptive kernels. This establishes that transformer attention is a strict generalization of kernel density estimation, where bandwidths and weights are learned dynamically from the context rather than being fixed by rigid hyperparameter heuristics.

Experimental Setup & Results

▶ Watch: Conclusion and summary of takeaways (10:00)

The evaluation compares DiScoFormer against multiple iterations of KDE baselines, including advanced variance-adapted KDE variants proposed in recent literature.

  • Datasets & Dimensions: Experiments test synthetic and structured distributions across low ($d=2$) and moderate-to-high ($d=10$) dimensions. Sample sizes scale exponentially from $n = 2^8$ (256 points) to $n = 2^{17}$ (131,072 points).
  • Evaluation Metrics: Model performance is evaluated using empirical reconstruction loss for density estimation and vector field error for score estimation.
  • Headline Results: Across all tested sample sizes in $d=10$, classical KDE curves diverge due to data sparsity, whereas DiScoFormer maintains stable, low-loss scaling. Furthermore, ablation studies and head-visualization heatmaps confirm that multi-head attention functions as an ensemble of complementary local and long-range density estimators, avoiding the manual cross-validation required to tune bandwidth hyperparameters in traditional KDE.

Practical Implications

▶ Watch: Audience Q&A on bandwidth and comparisons with KDE baselines (12:00)

For machine learning practitioners and model builders, DiScoFormer provides a rigorous bridge between deep learning and classical nonparametric statistics.

  • Plug-In Flexibility: Because DiScoFormer functions as a plug-in estimator, practitioners can evaluate densities and scores on out-of-distribution samples or shifted data distributions without initiating expensive model retraining cycles.
  • Interpretability of Attention: The finding that attention heads specialize into localized and distant density kernels offers a new lens for interpreting transformer internals. Researchers can analyze attention maps in LLMs and vision transformers through the framework of non-parametric density estimation.
  • Limitations: While DiScoFormer successfully scales to moderate dimensions, extending the theoretical guarantees to extremely high-dimensional spaces (e.g., millions of parameters in language models) remains an open challenge, and computational costs scale with sequence length during the forward pass.

Key Takeaways

  • Attention is Learned KDE: A single self-attention head with well-chosen projections can exactly compute Gaussian kernel weights, proving that transformers possess a natural inductive bias for density estimation.
  • Bypassing the Curse of Dimensionality: DiScoFormer successfully scales to high-dimensional spaces ($d \ge 10$) where classical kernel density estimation completely breaks down.
  • Plug-In Versatility: Unlike diffusion models that require retraining under distribution shifts, DiScoFormer evaluates new densities directly as a plug-in estimator.
  • Emergent Specialization: Unsupervised multi-head attention naturally divides labor, with individual heads specializing in local Gaussian kernels and non-local long-range interactions.
  • Cross-Disciplinary Bridge: The mathematical alignment between transformers and KDE opens new pathways for applying classical statistical tools to interpret modern deep learning architectures.

About the Speaker(s)

  • Vasily Ilin: Researcher at Allen Institute for AI and Microsoft Superintelligence Lab working on density and score estimation with transformers.
  • Peter Sushko (Allen Institute for AI): Collaborator on joint work with Vasily Ilin and Ranjay Krishna at Allen Institute for AI and Microsoft Superintelligence Lab on DiScoFormer.
  • Ranjay Krishna (Allen Institute for AI): Collaborator on joint work at Allen Institute for AI and Microsoft Superintelligence Lab on density and score estimation with transformers.

Reviews

→ Top-rated talks at International Conference on Machine Learning 2026

All talks from International Conference on Machine Learning 2026