Flow Matching Neural Processes

Hussen Abu Hamad, Dan Rosenbaum

Abstract

Neural Processes (NPs) offer a flexible framework for modeling distributions over functions, yet existing variants often struggle with a trade-off between expressivity, sampling speed, and implementation complexity. We present FlowNP, a novel generative model that leverages Flow Matching to break this "trilemma." By modeling the velocity of a probability flow rather than sequential dependencies, FlowNP achieves state-of-the-art accuracy across functional and image datasets while enabling efficient parallel sampling via ODE solvers. Our results demonstrate significant improvements in both log-likelihood and inference speed compared to previous autoregressive and diffusion-based approaches.

Introduction

Neural Processes (NPs) are designed to learn distributions over functions, allowing for uncertainty-aware predictions at target locations based on a set of observed context points. However, the field has been limited by three primary challenges: early models like Attentive NPs (ANP) often underfit complex structures; expressive autoregressive models like Transformer NPs (TNP) are computationally slow due to sequential sampling; and diffusion-based models like Neural Diffusion Processes (NDP) require complex auxiliary conditioning methods.

FlowNP addresses these issues by applying the Flow Matching paradigm to the NP framework, resulting in a model that is simple to implement, highly expressive, and capable of parallelized target sampling.

Methods

The Flow Matching Paradigm

Unlike diffusion models that rely on complex noise schedules, Flow Matching defines a smooth, continuous path (a "flow") between a simple Gaussian distribution at $t=0$ and the target data distribution at $t=1$. FlowNP is trained to predict the velocity vector—the direction and speed required to move a point along this path at any given time $t$.

Architecture and Parallel Sampling

FlowNP utilizes a Transformer backbone where input tokens consist of both context observations (fixed at $t=1$) and target points (evolving from noise at $t=0$). Because the Transformer employs full self-attention, the model simultaneously considers all context and target points.

The FlowNP architecture uses a Transformer backbone to predict velocity vectors, which are then integrated via an ODE solver to generate target samples in parallel.

To generate samples, FlowNP uses an ODE solver (e.g., Euler or Midpoint methods) to integrate the predicted velocities over time. This allows all target points to be updated in parallel, circumventing the $O(N)$ sequential bottleneck of autoregressive models.

Experiments and Key Results

FlowNP was evaluated on diverse benchmarks, including 1D Gaussian Processes (RBF, Matern, Periodic kernels), 2D image completion (EMNIST, CelebA), and real-world weather data (ERA5).

Performance and Speed

FlowNP consistently outperformed state-of-the-art models across all metrics:

  • Quantitative Accuracy: On EMNIST, FlowNP achieved a log-likelihood of 2.50, significantly higher than TNP's 2.08.
  • Sampling Efficiency: For EMNIST image completion (748 target points), FlowNP was approximately 15 times faster than the autoregressive TNP, completing the task in 4.6 seconds compared to 72.6 seconds.
  • Qualitative Quality: FlowNP produces sharper, more diverse samples, successfully capturing sharp transitions and multimodal distributions that often cause "blurriness" in earlier models.
Qualitative comparison on EMNIST image completion. FlowNP achieves superior visual quality and significantly faster sampling times compared to TNP and NDP.

Conclusion

FlowNP represents a significant advancement in Neural Processes by combining the efficiency of Flow Matching with the flexibility of Transformers. By enabling amortized conditioning and parallel sampling, it provides a scalable solution for complex function modeling. Future work may explore consistency training to further reduce the number of ODE steps required for inference, potentially enabling near-instantaneous high-quality sampling.

Summary updated

BibTeX
@inproceedings{hamad2025flow,
  author = {Hussen Abu Hamad and Dan Rosenbaum},
  title = {{Flow Matching Neural Processes}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=R8n2h7hzqS},
}
Figure