In-Context Operator Learning on the Space of Probability Measures

Frank Cole, Dixi Wang, Yineng Chen, Yulong Lu, Rongjie LaiarXiv 2026

TL;DR

This paper introduces a novel framework for learning optimal transport (OT) maps "in-context" using Transformer architectures. By treating few-shot samples from source and target distributions as a prompt, the model can rapidly infer the correct transport map for entirely unseen distribution pairs at test time—completely bypassing the need for expensive gradient updates or re-training.

What Problem Does This Paper Address?

Optimal Transport (OT) is a powerful mathematical tool used to compare, interpolate, and map probability distributions. It is widely applied in machine learning for tasks like generative modeling, image processing, and data assimilation. However, computing the "Monge map"—the function that shifts one distribution into another with minimal cost—is computationally expensive. Traditionally, if the source or target distribution changes, you have to solve a brand-new optimization problem from scratch.

While recent "meta-learning" approaches try to amortize this cost across multiple tasks, they still struggle to generalize flexibly without explicit fine-tuning. Meanwhile, Large Language Models have popularized In-Context Learning (ICL), where a model adapts to a new task at inference time simply by conditioning on a few examples (a prompt).

The authors bridge this gap by asking: Can we design a model that learns the solution operator for optimal transport in-context? The core challenge is that probability measures are infinite-dimensional objects, and unlike standard ICL for regression or classification, there are no paired input-output labels available during training.

Methods

The authors formalize in-context operator learning on probability measure spaces. Instead of feeding the model explicit mathematical descriptions of distributions, they represent distributions using empirical few-shot samples as prompts: $X = \{x_i\}_{i=1}^k \sim \rho_0$ and $Y = \{y_i\}_{i=1}^k \sim \rho_1$.

Key components of their approach include:

  • Transformer Architecture: Transformers are uniquely suited for this task because their attention mechanisms are naturally permutation equivariant (the order of samples in the prompt shouldn't matter) and can handle variable-length inputs (resampling consistency).
  • Unsupervised Loss via MMD: Because paired ground-truth labels do not exist, the authors replace the hard Monge constraint with a soft constraint using Maximum Mean Discrepancy (MMD). This allows the model to be trained end-to-end by comparing the pushed-forward empirical source measure against the target measure.
  • Theoretical Regimes: The paper provides rigorous scaling laws in two settings:
  • Nonparametric: Assuming tasks concentrate on a low-intrinsic-dimensional task manifold, they establish generalization bounds showing how error scales with prompt size, task dimension, and model capacity.
  • Parametric: For centered Gaussian families, they prove that a simplified linear transformer architecture can exactly recover the true OT map in-context.

Datasets

The framework was evaluated on both synthetic and real-world benchmarks:

  • Synthetic Gaussians: 2D Gaussian-to-Gaussian transport problems with either varying target means or varying diagonal covariances.
  • MNIST: 70k handwritten digit images, compressed into a 4-dimensional latent space using a pretrained autoencoder.
  • Fashion-MNIST: 70k grayscale clothing images, compressed into a 15-dimensional latent space.
  • ModelNet10: A 3D point cloud dataset spanning 10 object categories, mapped to a 10-dimensional latent space.

Key Insights and Ideas

  • Attention as Adaptive Kernels: The authors highlight that after training, the attention coefficients act as input-dependent weighted averages of context tokens. This effectively allows the Transformer to dynamically construct specialized averaging kernels tailored to the specific transport task presented in the prompt.
  • Bypassing the Curse of Dimensionality: In the nonparametric setting, the authors show that generalization error depends on the intrinsic dimension of the task manifold rather than the infinite-dimensional density space, explaining why the model can generalize so efficiently.
  • Linear Transformers are Exact for Gaussians: One of the most elegant theoretical findings is that a simplified transformer (pointwise feedforward + linear self-attention without softmax) is mathematically sufficient to implement exact Gaussian-to-Gaussian optimal transport.

Key Results

  • Scaling Law Validation: The empirical results closely match the authors' theoretical predictions. As the prompt length ($n$) increases, both the excess loss and the transport map generalization error decay at the predicted parametric rate of $O(1/n)$ or $O(1/\sqrt{n})$ (see Figure 7).
  • Prompt-Driven Conditional Generation: At test time, simply changing the prompt samples allowed the single, frozen model to switch between generating different digits (MNIST), clothing items (Fashion-MNIST), or 3D shapes (ModelNet10) with high fidelity and low MMD scores (e.g., an overall MMD of 0.419 for MNIST and 0.350 for Fashion-MNIST, scaled by $10^2$).

Limitations and Future Work

  • Latent Space Dependency: For complex datasets like MNIST or ModelNet10, the model operates entirely within a lower-dimensional latent space provided by a pretrained autoencoder. Direct transport on raw, high-dimensional pixel spaces remains a challenge.
  • Idealized Parametric Assumptions: The exact recovery proof for the parametric setting assumes centered Gaussians and simultaneously diagonalizable covariance matrices, which may not hold in highly complex real-world distributions.
  • Future Directions: The authors suggest extending this framework to other operators on probability spaces (such as mean-field games or gradient flows) and integrating these in-context transport operators directly into broader generative modeling pipelines.

Summary updated

BibTeX
@misc{cole2026context,
  author = {Frank Cole and Dixi Wang and Yineng Chen and Yulong Lu and Rongjie Lai},
  title = {{In-Context Operator Learning on the Space of Probability Measures}},
  year = {2026},
  eprint = {2601.09979},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2601.09979},
}
Figure