Context-Adaptive Inference: A Unified Statistical and Foundation-Model View

Yue Yao, Caleb N. Ellington, Jingyun Jia, Baiheng Chen, Dong Liu, Rikhil Rao, Jiaqi Wang, Samuel Wales-McGrath, Yixin Yang, Zhiyuan Li, Eric P. Xing, Ben LengericharXiv 2026

TL;DR

This paper establishes a unifying mathematical framework called "context-adaptive inference" that bridges classical statistics, meta-learning, and large foundation models. The authors prove that explicit parameter adaptation (like statistical varying-coefficient models) and implicit routing (like transformer attention mechanisms) are fundamentally equivalent to kernel ridge regression on the joint features of inputs and context.

What Problem Does This Paper Address?

Standard machine learning and statistics often rely on the assumption that data is independent and identically distributed (i.i.d.), allowing a single global model to make predictions across all data points. However, real-world data is inherently heterogeneous, collected across diverse individuals, environments, and tasks.

Forcing a single global model onto heterogeneous data leads to severe systematic failure modes:

  • Mode Collapse: The dominant group drives the fit, leaving minorities underrepresented.
  • Outlier Sensitivity: Extreme points disproportionately distort the global model.
  • Phantom Populations: The model converges to a non-existent average case that represents no actual subgroup.
  • Simpson’s Paradox / Hidden Confounding: Aggregate trends completely reverse when looking at specific subgroups.
Figure 1: Failure Modes of Population Models. Illustrative schematics of common failure types when fitting a single global model to heterogeneous data. (A) Mode Collapse: the dominant group drives the fit, underrepresenting the minority. (B) Outlier Sensitivity: extreme points distort the global line, shifting predictions away from the majority. (C) Phantom Populations: the global fit represents no actual subgroup, but an artificial average. (D) Hidden Confounding / Simpson’s Paradox: aggregate trends reverse subgroup trends, obscuring true relationships.

To capture this heterogeneity, different fields have independently developed adaptive methods—such as varying-coefficient models in statistics, meta-learning in machine learning, and in-context learning (ICL) via prompting in foundation models. This paper addresses the lack of a shared theoretical foundation between these disparate traditions.

Methods

The authors formalize context-adaptive inference under a common objective: mapping a context $c$ to adapted parameters $\theta(c)$, and then predicting an outcome via $f(x; \theta(c))$.

They organize context awareness along a spectrum of assumptions:

The spectrum of context awareness in modeling, from global to latent models.

The core contribution of the paper is a Theoretical Bridge (Proposition 1). Under the assumptions of squared loss, linear prediction heads, and fixed features, they prove a strict mathematical equivalence:

  1. Explicit varying-coefficients optimized with a ridge penalty yield a kernel ridge regression (KRR) solution on the joint features of inputs and context.
  2. Implicit adaptation via linear ICL in a transformer layer implements the exact same KRR form, using a learned dot-product attention kernel over the support set.

Building on this bridge, the authors propose a unified framework for evaluating these models using three practical metrics:

  • Adaptation Efficiency: Measuring how effectively a model specializes its behavior given a limited number of context-specific samples.
  • Routing Stability: Quantifying whether small, behavior-preserving perturbations (like reordering prompt examples or jittering context variables) cause erratic changes in model behavior.
  • Context-Specific Robustness: Evaluating how well the adaptive mechanism holds up under context distribution shifts.

Datasets

As a theoretical review and synthesis paper, it does not introduce new empirical datasets or benchmarks. Instead, it contextualizes existing frameworks, referencing benchmarks like WILDS (for subgroup heterogeneity) and real-world biomedical data structures like TCGA cancer genomics to illustrate practical implementations.

Key Insights and Ideas

  • Two Paths, Same Estimator: The emergent capability of transformers to learn in-context without weight updates is not magic; it is functionally identical to classical statistical kernel smoothing in a joint input-context space.
  • Attention as a Learned Kernel: While statisticians must manually choose a kernel function to define context similarity, a transformer's attention mechanism implicitly learns this kernel from vast amounts of pretraining data.
  • Retrieval and Gating are Measure Choices: The paper demonstrates that choosing a support set via Retrieval-Augmented Generation (RAG) or routing inputs through a Mixture-of-Experts (MoE) model mathematically corresponds to changing the empirical measure or kernel used by a joint KRR.
  • Missingness as Context: An elegant practical insight highlighted is treating data missingness patterns as context. Instead of discarding incomplete data, models can dynamically adapt their parameterization based on which specific features are observed.

Key Results

  • The Equivalence Proof: The primary result is the formal proof that explicit parameter mapping and implicit transformer routing coincide with KRR on joint features.
  • A Unified Audit Toolkit: The paper successfully translates abstract notions of "adaptivity" into verifiable mathematical metrics (e.g., the Routing Stability score, $RSt(c)$), providing engineers with concrete tools to debug brittle in-context learners or mixture-of-experts models.

Limitations and Future Work

  • Linearity Constraints: The current theoretical bridge assumes a linear prediction head and fixed features. It abstracts away non-quadratic losses (like logistic regression) and nonlinear prediction heads (like deep MLPs), which introduce complex model curvature.
  • Multi-Modal Contexts: The fixed-kernel view struggles to fully capture multi-modal context encoders (e.g., combining text, graphs, and images), which alter both the neighborhood definitions and regularizers.
  • Open Challenges: The authors identify critical open frontiers in establishing strong guarantees for structural identifiability, achieving robustness under severe distribution shifts, and managing the environmental/computational costs of large-scale adaptation.

Summary updated

BibTeX
@misc{yao2026context,
  author = {Yue Yao and Caleb N. Ellington and Jingyun Jia and Baiheng Chen and Dong Liu and Rikhil Rao and Jiaqi Wang and Samuel Wales-McGrath and Yixin Yang and Zhiyuan Li and Eric P. Xing and Ben Lengerich},
  title = {{Context-Adaptive Inference: A Unified Statistical and Foundation-Model View}},
  year = {2026},
  eprint = {2607.23304},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.23304},
}
Figure