Few-shot Protein Fitness Prediction via In-context Learning and Test-time Training

Felix Teufel, Aaron Kollasch, Yining Huang, Ole Winther, Kevin K. Yang, Pascal Notin, Debora S. Marks · DOI

Presented at the NeurIPS 2025 AI for Science Workshop, this work introduces PRIMO (PRotein In-context Mutation Oracle), a framework designed to predict protein fitness in scenarios where experimental data is extremely scarce. By combining in-context learning (ICL) with test-time training (TTT), PRIMO adapts to new tasks on the fly, outperforming traditional supervised models and zero-shot baselines.

The Challenge of Low-Data Fitness Prediction

In protein engineering, "fitness"—encompassing traits like binding affinity, thermostability, or enzymatic activity—is the primary metric for success. While high-throughput variant generation is possible, experimental measurement remains a bottleneck due to cost and time. Existing computational methods typically fall into two categories:

  1. Zero-shot models: These leverage Protein Language Models (pLMs) to infer fitness from evolutionary patterns without requiring labels, but often lack the precision needed for fine-tuning.
  2. Supervised models: These learn directly from experimental data but usually require hundreds of samples and separate validation sets to avoid overfitting—resources rarely available in early-stage engineering.

Furthermore, many models are restricted to single-letter substitutions and struggle with insertions and deletions (indels). PRIMO addresses these gaps by providing high-accuracy predictions from as few as 4 to 32 samples while maintaining flexibility across diverse mutation types.

Methods: Architecture and Adaptation

PRIMO is a transformer-based masked language model that processes sets of protein variants. Its architecture is built on several key innovations:

  • Unified Tokenization: A "sample" in PRIMO integrates the amino acid sequence (embedded via ESM-2), a target fitness label, a property type ID, and auxiliary zero-shot scores from ProGen.
  • Lightweight Inter-sequence Attention: To manage the computational cost of comparing multiple sequences, PRIMO uses a pooling mechanism. Each sequence attends to a fixed-size "pooled" representation of the entire set, allowing the model to learn relative fitness context efficiently.
  • Preference-Based Loss: Rather than standard regression, the model employs a ranking loss to predict which of two variants is superior, a more robust approach for engineering tasks.
  • Test-Time Training (TTT): This is the core mechanism for adaptation. When presented with a new assay, PRIMO performs gradient descent on its own weights using the available few-shot labeled samples. This allows the model to adjust to the specific distribution of a new experiment before making final predictions.
The PRIMO architecture and pipeline, illustrating how sampled sequences and labels are processed through lightweight attention layers for masked token and preference prediction.

Datasets and Evaluation

The model was pre-trained on diverse Deep Mutational Scanning (DMS) assays from ProteinGym, covering stability, binding, and enzymatic activity. To ensure rigorous evaluation, the authors used a curated hold-out set with no high-sequence-identity overlap with the training data, avoiding the "inflated" performance metrics common in the field.

Additionally, a new Natural Evolution Benchmark was introduced. This benchmark uses assays (Chorismate mutase, Rubisco, and PPAT) that span broad fitness landscapes of natural sequences, testing the model's ability to extrapolate far beyond a single wild-type starting point.

Key Results

PRIMO (TTT) consistently outperformed zero-shot baselines and standard supervised models like Ridge Regression and Gaussian Processes across diverse protein families.

Comparative performance of PRIMO (ICL and TTT) against traditional supervised baselines across different shot regimes and fitness categories.
  • Few-Shot Superiority: On average, PRIMO improved Spearman correlation from 0.51 (zero-shot) to 0.67 (with 128 shots).
  • Robustness in Low-Data Regimes: At 4 or 8 shots, traditional models often perform worse than random due to overfitting, whereas PRIMO maintains or improves upon zero-shot performance.
  • Indel Flexibility: Unlike models relying on fixed-position column attention, PRIMO's architecture naturally handles sequences of varying lengths, making it applicable to a wider range of engineering tasks.

Insights and Future Directions

The research highlights that while In-Context Learning (ICL) provides a baseline, it is Test-Time Training that truly allows the model to leverage few-shot data effectively. By updating weights for specific tasks, the model overcomes the distribution shifts inherent in new experimental assays.

Future work may involve scaling the base pLMs beyond 650M parameters, incorporating 3D structural data, or using natural language metadata to help the model better understand experimental protocols.

Summary updated

BibTeX
@inproceedings{teufel2025few,
  author = {Felix Teufel and Aaron Kollasch and Yining Huang and Ole Winther and Kevin K. Yang and Pascal Notin and Debora S. Marks},
  title = {{Few-shot Protein Fitness Prediction via In-context Learning and Test-time Training}},
  booktitle = {AI4Science @ NeurIPS},
  year = {2025},
  url = {https://openreview.net/forum?id=N9Yl5252wc},
}
Figure