Abstract
Neural Processes (NPs) are powerful models for in-context learning, but high-capacity variants like Attentive Neural Processes (ANPs) often suffer from "in-context overfitting" when faced with noisy observations. We present a simple, zero-overhead modification to the NP training objective that significantly improves robustness. By excluding context points from the reconstruction loss and penalizing excessive pointwise variance, our robust models maintain high performance even in high-noise regimes across 1D and 2D datasets.
Introduction
Neural Processes (NPs) learn distributions over functions, enabling rapid adaptation to new tasks via a small set of context observations. However, real-world data is frequently contaminated with noise. While attention mechanisms have improved NP performance on clean data, they introduce a vulnerability: the model may over-adapt to noisy context points rather than capturing the underlying signal. This phenomenon, termed "in-context overfitting," leads to erratic predictions that track outliers and fail to generalize the smooth underlying function.
Methodology: The Noise-Robust Objective
To address in-context overfitting, we propose two "plug-and-play" modifications to the standard Evidence Lower Bound (ELBO) used for training NPs:
- Disjoint Context and Target Sets: Standard training often includes context points in the reconstruction loss. In noisy settings, this encourages the model to memorize noise. We propose computing reconstruction loss exclusively on target points that are disjoint from the context set, effectively framing the task as denoising.
- Pointwise Variance Penalty: To prevent the model from simply increasing local uncertainty ($\sigma^2$) to explain noise, we add a penalty term ($w_\sigma \bar{\sigma}^2$). This forces the model to capture uncertainty globally through latent variables, representing a distribution over possible functions rather than just "blurring" specific points.
These changes require no architectural modifications and add no additional training time.
Experimental Results
We evaluated our approach on 1D Gaussian Processes (using RBF, Matern, and Periodic kernels) and 2D image completion (CelebA).
1D Gaussian Processes
Our robust Attentive Neural Process (r-anp) consistently outperformed standard baselines. As shown below, standard models experience a sharp decline in log-likelihood as noise levels increase, particularly when both context and target are noisy.
In contrast, r-anp maintains superior performance across all tested kernels. The figure below demonstrates that r-anp (green line) provides a significant margin over standard ANP and other variants, especially in high-noise scenarios (e.g., noise level 0.99).
2D Image Completion
On the CelebA dataset, the robust model (r-banp) produced much clearer, more recognizable faces from noisy pixel contexts compared to standard models, which either produced blurry averages or overfitted to "salt and pepper" noise. Ablation studies confirmed that both the disjoint context/target sets and the variance penalty are necessary for this success.
Discussion and Conclusion
High-capacity models like ANPs are susceptible to the "attention trap," where their flexibility becomes a liability under noise. Our findings suggest that robust in-context learning requires a distinction between global function uncertainty and local observation noise. While our current study focused on Gaussian noise and 1D/2D modalities, future work will explore other noise types (e.g., adversarial) and modalities such as audio or video. By penalizing pointwise variance and ensuring disjoint context/target sets, we can leverage the power of attention while maintaining stability in real-world, noisy environments.
Summary updated