When Does Flow Matching Help Deterministic Multimodal Prediction: A Spatial Transcriptomics Study

Haoran Xu, Wei Yuan, Xiao HanNeurIPS 2026

TL;DR

Generative models like flow matching are built to dream up diverse possibilities, yet researchers are increasingly using them for tasks that only have one right answer—and somehow, they still beat standard regression. By investigating how models predict gene expression from tissue images, this paper cracks open the black box to show why generative training helps deterministic prediction. Turns out, it has nothing to do with output diversity; instead, those noisy intermediate steps act as a rich, structured "hint system" during training, provided the model learns to share that context across the whole tissue slide without cheating.

What Problem Does This Paper Address?

Imagine looking at a standard microscope slide of a tumor (an H&E histology image) and trying to guess the exact activity levels of thousands of genes at every tiny coordinate. This is virtual spatial transcriptomics (ST)—a computational shortcut to biological assays that are otherwise wildly expensive.

Recently, researchers started throwing generative models—specifically flow matching, which learns to smoothly transform random Gaussian noise into complex data—at this problem. And it works! But here’s the mystery: when you give a trained flow-matching model the same tissue image and run it 20 times with different random starting noise, it spits out virtually the exact same gene expression map every time.

Figure 2: Sampling noise is orders of magnitude below prediction error and spatial signal. On a held-out IDC slide with fixed histology, we evaluate 200 genes across eight initial-noise seeds. The median sampling variation (standard deviation across seeds) is approximately 523 times smaller than the prediction error and is also much smaller than the spatial variation of measured expression.

If the task is effectively deterministic and output diversity collapses to zero, what is the generative machinery actually doing that simple, direct regression isn't? Furthermore, tissue slides aren't just bags of independent pixels; spots on the same slide share a broader biological microenvironment. The authors set out to disentangle how flow matching interacts with this spatial context to beat strong regression baselines.

Methods

Instead of building a massive, hyper-specialized neural network that might obscure why things work, the authors intentionally designed a clean, minimal gated self-attention architecture to act as a scientific petri dish.

Figure 1: Overview of the minimal gated self-attention architecture used to diagnose flow- matching gains. Given an H&E whole-slide image, patch embeddings are extracted by a pathology foundation model and paired with measured ST profiles. At each epoch, patch-ST pairs are shuffled and grouped into M-sample contexts. For each group, noisy ST states are constructed by interpolating Gaussian noise with the measured expression profiles, then concatenated with histology tokens and processed by gated self-attention. The attention map is decomposed into image-image, image-ST, ST-image, and ST-ST blocks to inspect cross-modal and cross-location interactions.

Here is what is standard versus novel in their setup:

  • Standard: They extract visual embeddings from tissue patches using a pre-trained pathology foundation model and use standard linear-interpolant conditional flow matching (blending Gaussian noise $x_0$ with clean gene targets $x_1$ over time $t$). They use an "$x$-prediction" setup, where the network predicts the clean endpoint directly, supervised by a velocity loss.
  • Novel Diagnostic Setup (Multi-Sample Token Coupling): Rather than predicting one tissue spot in isolation, they shuffle and group $M$ pairs of image patches and noisy gene states ($x_t$) from a slide into a single sequence. Gated self-attention lets image tokens talk to image tokens, gene tokens to gene tokens, and crucially, across modalities.
  • Context-Matched Regression (CM-Regression): To ensure a fair fight, they built a new regression baseline using the exact same multi-token gated backbone, stripping away only the noisy flow states and time conditioning.

Datasets

  • Six Cancer Cohorts: Predefined benchmark splits across six tissue types: colon (COAD), lymph node (LYMPH), lung (LUNG), pancreas (PAAD), prostate (PRAD), and kidney (CCRCC).
  • IDC-80K: A larger dataset of Invasive Ductal Carcinoma (~80,000 spots) constructed by the authors specifically to run deep, controlled ablations and data-scaling experiments.
  • Spatial Proteomics: Used in supplementary evaluations to test if findings hold beyond RNA transcriptomics.

Key Insights and Ideas

  • Noisy states are structured training hints, not diversity generators: In direct regression, the target $x_1$ is only used at the very end to calculate error. In flow matching, noisy versions of the target ($x_t$) are fed into the network during training. When paired data is scarce, these noisy states act as training wheels, carrying biological co-expression signals that guide visual feature extraction.
  • Data scale flips the script: Flow matching isn't universally better. It shines when paired training data is limited, but as you scale up the number of training spots, standard Context-Matched Regression catches up and can even surpass it.
Figure 3: The benefit of flow matching depends on paired-data scale and target determinism. (a) Test PCC as the number of training spots increases. (b) PCC gain over context-matched regression. Gains are positive in several smaller paired-data regimes but diminish and can become negative with more training spots. (c) Test PCC as residual target noise increases (i.e., as the target becomes less deterministic). Curves show mean and standard error over three seeds where applicable.
  • Slide-level vibe > exact spot pairing: If you shuffle the noisy gene states within the same tissue slide, the model still performs great. If you swap in gene states from a different slide, performance tanks. The model uses intermediate states to grasp the global "molecular mood" of the tissue section rather than relying on exact 1-to-1 spot correspondence.
  • Beware the late-time shortcut: If you feed the model noisy states directly per-spot at late time steps ($t$ close to 1, where $x_t$ is almost identical to the clean answer), test accuracy plummets. The model gets lazy, learning to copy the nearly clean hint instead of actually reading the histology image—a trap that fails at inference when starting from pure noise.
  • One-way street at inference: By severing specific attention pathways at test time, the authors found an intriguing asymmetry: blocking histology queries from attending to gene-state tokens hurts spatial correlation significantly, while blocking the reverse direction barely matters.

Key Results

Measured via Pearson Correlation Coefficient (PCC, which captures how well spatial gene patterns match ground truth):

  • Across the six cancer cohorts, the authors' gated flow model achieved a mean PCC-All of 0.4335, beating original PCA-Ridge regression (0.3864), an existing flow baseline STFlow (0.3887), and their own strong CM-Regression (0.4172).
  • Gating is essential: On IDC-80K, pure self-attention got zero benefit from adding flow states (0.643 vs. 0.644 PCC-200). Adding the gating mechanism unlocked the jump to 0.660 (and dropped Mean Squared Error from 1.570 to 1.208).
  • Shortcut degradation: In per-spot setups under velocity loss, allowing training times up to $t_{\max} = 0.95$ caused test PCC to crash from 0.379 (at $t_{\max} = 0.3$) down to 0.274.
  • Routing interventions: Cutting image-to-state attention at inference dropped IDC PCC by 0.041 (and 0.033 on an alternative Qwen-style gated backbone), proving the model actively routes visual queries into the evolving molecular states.

Limitations and Future Work

The authors are admirably candid about where the magic stops:

  • Non-uniform gains: Flow matching didn't win everywhere; kidney cancer (CCRCC) was a notable exception in set-level comparisons, and gains vanished in high-data regimes.
  • Domain scope: While they validated the routing mechanics on a Qwen-style attention backbone and spatial proteomics, this is deeply rooted in 2D tissue biology. Testing whether this "target-side context" mechanism explains flow matching's success in other deterministic domains (like depth estimation or protein folding) is wide open for future work.
  • Clinical reality check: Computationally inferred gene profiles are great for research hypotheses, but they are no substitute for wet-lab measurements in clinical decision-making.

Summary updated

Abstract

Flow matching is increasingly used beyond open-ended generation, including prediction tasks whose outputs are effectively deterministic, yet it remains unclear why flow matching helps when diversity is not the objective. We study this question in histology-conditioned spatial transcriptomics (ST) prediction, a challenging, sparse, high-dimensional task where thousands of spatially correlated spot-level observations arise from a limited number of heterogeneous tissue slides, and direct regression with pathology foundation features is already competitive. Repeated sampling with different initial Gaussian noises under the same histology input produces nearly identical predictions, indicating that output diversity does not explain the benefit of flow matching in this setting. We instead identify intermediate flow states as time-indexed target-side signals: they retain target-related information while remaining mixed with source noise. Their benefit emerges when this information is selectively routed into histology representations while preserving slide-level condition alignment. Guided by this mechanism, we instantiate conditional flow matching with a simple gated self-attention architecture to model interactions between histology tokens and noisy ST states, improving spatial-correlation metrics over regression and flow-based baselines. We further probe this mechanism through component ablations, context analyses, inference-time routing interventions, and additional evaluations in spatial proteomics and with a Qwen-gated-attention backbone. Together, these experiments provide a mechanistic account of when intermediate flow states can serve as structured target-side supervision in deterministic histology-conditioned spatial molecular prediction.
BibTeX
@inproceedings{xu2026when,
  author = {Haoran Xu and Wei Yuan and Xiao Han},
  title = {{When Does Flow Matching Help Deterministic Multimodal Prediction: A Spatial Transcriptomics Study}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=goLFZzz8Fi},
}
Figure