Contextualizing Biological Language Models across Modalities via Logit-Space Contrastive Alignment

Yanjun Shao, Yundi Chen, Yashvi Patel, Aurelien Pelissier, María Rodríguez Martínez

TL;DR

LogiCA (Logit-space Contrastive Alignment) is a novel framework that aligns biological language models across different modalities—such as proteins and small molecules—by performing contrastive learning directly in the output probability (logit) space. Unlike traditional methods that squash sequences into global vectors, LogiCA preserves the per-token resolution of pretrained models, enabling state-of-the-art performance in context-dependent mutation scoring and drug-resistance prediction.

What Problem Does This Paper Address?

Pretrained biological language models (BioFMs), like ESM-2 for proteins, are incredibly powerful at understanding the "grammar" of life. They provide a likelihood interface: they can tell you how probable a specific amino acid is at a specific position. This is the "gold standard" for predicting the effects of mutations.

However, biology is inherently contextual. A protein mutation might be neutral in a healthy cell but cause total drug resistance in a cancer cell treated with a specific inhibitor. Standard BioFMs are trained on broad, unlabeled corpora and aren't naturally conditioned on these external contexts (drugs, ligands, or interaction partners).

Existing ways to "contextualize" these models usually involve:

  1. Pooled Embeddings: Squashing the entire sequence into a single vector (like CLIP). This loses the fine-grained, token-level detail needed to see exactly how a mutation at one site affects binding.
  2. Conditional MLM: Fine-tuning the model to reconstruct sequences given a context. While this preserves the token interface, the reconstruction loss is often too "weak" to distinguish between a correct biological partner and a slightly mismatched one.

Methods

The authors introduce LogiCA, which shifts the alignment objective from the "latent space" (internal embeddings) to the "logit space" (the final output probabilities).

  • Native-Head Preservation: LogiCA uses gated cross-modal adapters (bidirectional cross-attention blocks) to let two different models "talk" to each other. Crucially, it keeps the pretrained models' original output heads.
  • Logit-Space Contrastive Loss: Instead of making embeddings similar, LogiCA trains the model so that the log-likelihood of a sequence is higher when paired with its correct biological context than with a mismatched one.
  • Mutation-Local Cancellation: The paper proves a beautiful mathematical property: when comparing two variants of the same protein under the same drug, the parts of the score related to the unchanged "wild-type" residues cancel out exactly. This focuses the model’s "attention" entirely on the mutated sites, making it exceptionally precise for variant ranking.
  • Bidirectional Matching: The framework can evaluate compatibility from both sides (e.g., "How likely is this protein given this drug?" and "How likely is this drug given this protein?").

Datasets

The researchers evaluated LogiCA across three major biological domains:

  • Protein–Ligand Binding: Pretrained on ~20M measurements from BindingDB and evaluated on benchmarks like DAVIS and BioSNAP.
  • Drug Resistance: Tested on Deep Mutational Scanning (DMS) assays for 11 oncogenes (e.g., KRAS, EGFR) across 10 different targeted therapies.
  • TCR–Peptide Activity: Evaluated on T-cell receptor (TCR) recognition using benchmarks like ePytope, BATCAVE, and ATLAS.

Key Insights and Ideas

  • Alignment Without a Shared Space: You don't need a shared tokenizer or a shared embedding space to align models. By aligning on the meaning (the probability distribution) of the tokens, LogiCA can bridge models with completely different vocabularies (e.g., amino acids vs. chemical SELFIES tokens).
  • The Power of Contrast: Simply training a model to "reconstruct" a protein given a drug (MLM) isn't enough. By adding a contrastive objective—forcing the model to choose the correct drug over a wrong one—the model learns much sharper biological boundaries.
  • Interpretability by Design: Because LogiCA preserves the token-level interface, you can generate "dependency maps." These maps show exactly which part of a drug molecule is driving the change in probability for a specific amino acid mutation.

Key Results

  • Drug Resistance: On the challenging task of predicting resistance for "held-out" genes (genes the model didn't see during fine-tuning), LogiCA improved the Area Under the Curve (AUC) from a near-random ~0.55 (for latent-space baselines) to ~0.65.
  • Zero-Shot Ranking: In TCR–peptide ranking, LogiCA achieved the strongest correlations to date, significantly outperforming existing specialized models and latent-contrastive baselines.
  • Scaling Laws: The authors found that the "likelihood margin" (how well the model distinguishes matched vs. mismatched pairs) scales predictably with model size, following a power law ($\propto N^{0.16}$) over an 80x range of parameters.

Limitations and Future Work

  • Computational Cost: Because LogiCA requires joint processing of the sequence and the context (cross-attention), it is more computationally expensive than "dual-encoder" models. It is best used as a high-precision re-ranker rather than a first-stage tool for screening billions of molecules.
  • Data Scarcity: While LogiCA performs well with sparse data, the authors note that TCR–peptide data is still so limited that generalizing to entirely "unseen" peptides remains a major frontier for the field.
  • Future Directions: The authors suggest extending LogiCA to other modalities, such as conditioning protein models on cellular states, genomic neighborhoods, or even natural language descriptions of biological experiments.

Summary updated

BibTeX
@inproceedings{shao2026contextualizing,
  author = {Yanjun Shao and Yundi Chen and Yashvi Patel and Aurelien Pelissier and María Rodríguez Martínez},
  title = {{Contextualizing Biological Language Models across Modalities via Logit-Space Contrastive Alignment}},
  booktitle = {GenBio @ ICML},
  year = {2026},
  url = {https://openreview.net/forum?id=oHaY9DxcTN},
}

Loading related content...

Figure