- The paper introduces AbICL, a Transformer-based in-context learning model that conditions antibody pairwise affinity rankings on labeled comparisons for the target antigen without gradient updates.
- Episodic meta-training teaches AbICL to use support examples effectively, raising Local Perturbation AUROC from 0.647 to 0.872 on the Balanced benchmark and improving performance under sequence-distribution shifts.
- The method shows that biologically relevant context can improve antigen-specific ranking, although optimal context selection, larger support sets, and extensions to continuous affinity prediction remain open challenges.
AbICL addresses a structural weakness in existing antibody affinity ranking methods: they apply a single, context-independent ranking function to every comparison, ignoring the antigen-specific evidence contained in previously characterized affinity measurements. The paper reframes ranking as an in-context learning (ICL) problem, conditioning predictions on labeled pairwise comparisons supplied at inference time without any gradient updates (2607.05846).
Affinity regression approaches suffer from noisy, assay-dependent, and censored measurements, while ranking-based methods such as WALLE-Affinity learn relative preferences but treat each comparison as an isolated prediction problem. Indirect scoring via protein foundation models (sequence likelihoods, AlphaFold3-style confidence) is not explicitly trained on affinity data. AbICL instead asks whether a small set of labeled comparisons for the target antigen can be exploited as contextual demonstrations, analogous to ICL in LLMs.
The task is formulated as pairwise classification: given two complexes (Ci,Cj) sharing an antigen, predict P(Ci≻Cj) against a binary ground-truth label derived from experimental affinities.
Architecture and training
AbICL has three components:
- Structure encoder: following WALLE-Affinity, separate GCNs encode antibody and antigen molecular graphs (with AntiBERTy and ESM-2 residue embeddings respectively), producing 128-dimensional complex representations fused into 768-dimensional pair tokens.
- Label embedding: each support pair token is augmented with a learnable embedding of its binary ranking label; query pairs receive no label embedding.
- Context ranking head: a 4-layer Pre-LN Transformer encoder (768 hidden, 8 heads) jointly processes support and query tokens. No positional encoding is used, preserving permutation invariance over the unordered support set, following Set Transformer design. Only query outputs are scored via sigmoid.
Training is two-stage. Stage 1 pretrains the encoder with a margin ranking loss; Stage 2 freezes it and trains the context head with antigen-episodic meta-training: each episode is built from one antigen's pairs, randomly split into a support set of size K∼Uniform(0,Kmax) with Kmax=8 and a query set, directly simulating test-time support-query conditions.
Main results on AbRank
Evaluation uses the AbRank benchmark with three training splits of increasing difficulty (Balanced, Hard Ab with <75% antibody sequence identity, Hard Ag with <75% antigen identity) and two test benchmarks (Unrelated Complex for cross-antigen generalization; Local Perturbation for fine-grained discrimination among near-neighbor mutants). Baselines are WALLE-Affinity, ESM-2 + AntiBERTy, and Mint.
| Model |
Balanced |
Hard Ab |
Hard Ag |
| Unrelated Complex |
|
|
|
| AbICL (No-context) |
0.849 |
0.760 |
0.700 |
| AbICL (Training-context) |
0.880 |
0.838 |
0.711 |
| AbICL (Test-context) |
0.888 |
0.904 |
0.749 |
| WALLE-Affinity |
0.866 |
0.763 |
0.746 |
| ESM-2 + AntiBERTy |
0.761 |
0.719 |
0.758 |
| Mint |
0.775 |
0.741 |
0.688 |
| Local Perturbation |
|
|
|
| AbICL (No-context) |
0.647 |
0.490 |
0.572 |
| AbICL (Training-context) |
0.668 |
0.588 |
0.581 |
| AbICL (Test-context) |
0.872 |
0.787 |
0.778 |
| WALLE-Affinity |
0.671 |
0.581 |
0.637 |
Three findings stand out. First, because the authors could not reproduce WALLE-Affinity's warm-start initialization, their No-context variant is weaker than the published baseline — yet Training-context already surpasses WALLE-Affinity on several settings using the same weaker encoder, indicating gains stem from in-context adaptation rather than backbone strength. Second, Test-context consistently outperforms Training-context, showing that demonstration relevance to the target inference distribution matters more than mere availability. Third, the most striking result is on Local Perturbation under Test-context: AUROC jumps from roughly 0.65 to 0.87–0.88 on Balanced, and from ~0.49–0.64 to 0.78–0.79 on the hard splits — improvements of up to 20+ AUROC points where individual pairs alone cannot resolve subtle preference differences. Gains are also larger under distribution shift (Hard Ab/Hard Ag), consistent with contextual evidence complementing a less informative global ranking function.
Ablations
Episodic meta-training is necessary. With identical architecture and parameter count, the non-episodic variant (support size fixed at zero during training) derives almost no benefit from demonstrations (e.g., 0.635 → 0.641 on Perturbation), whereas the episodic model improves from 0.647 to 0.872. The episodic model also outperforms the non-episodic model even with No-context, but the dominant effect is that only episodic training teaches the model to use the context channel.
Context construction is non-trivial. Varying both training support strategy (Intra-Ag, Most-Sim-Ag, Least-Sim-Ag, Random-Ag via MMseqs2 similarity) and inference context source shows that biologically related antigens remain informative even when not identical to the target. On Generalization, Intra-Ag training with Intra-Ag inference performs best (0.877), but least-similar-antigen contexts still beat random ones. Counterintuitively, on Local Perturbation, some less-similar support strategies occasionally outperform Intra-Ag (e.g., 0.7406 vs. 0.6240), which the authors attribute tentatively to greater antigen diversity encouraging more discriminative comparison patterns — an explanation offered as a hypothesis rather than an established mechanism.
Limitations
The paper confines itself to binary pairwise ranking; extension to continuous affinity regression or ΔΔG prediction is left open, though the label embedding could be replaced by a continuous encoder. The principles governing effective context selection are admittedly not fully understood, given the anomalous perturbation-benchmark results. Two further caveats bear on interpretation: the No-context baseline is weakened by the unavailable warm-start initialization, so absolute comparisons against the original WALLE-Affinity carry this confound; and Test-context evaluation assumes experimentally measured pairs exist for the target antigen at inference time, with only about 1.1–1.9 demonstrations per antigen available on average — performance with larger or differently curated context pools is unexplored.
Conclusion
AbICL demonstrates that episodic meta-training can endow a structural ranking model with genuine in-context adaptation capability for antigen-specific antibody affinity ranking, yielding state-of-the-art AUROC on AbRank with the largest gains precisely where fixed ranking functions fail: distribution shift and fine-grained mutant discrimination. The work establishes labeled affinity comparisons as usable contextual knowledge at inference time and leaves open how to optimally construct such contexts and whether the paradigm extends beyond ranking to regression-style affinity prediction.