Beyond Sparse Captions: Aligning Slide-Level Text and Patch-Level Vision in Pathology
NeurIPS 2026 · Spotlight
Daniel Shao*, Dongmin Bang*, Luca L. Weishaupt, Sophia J. Wagner, Nic G. Reitsam,
Ming Y. Lu, Long P. Le, Richard J. Chen†, Faisal Mahmood†
*Co-first authors · †Co-senior authors
Paper · Model weights · Quickstart · Results · Citation
CONCH-Z provides improved text encoding and zero-shot classification capabilities to the existing CONCH v1.5 architecture. By coupling an unchanged vision encoder with a newly aligned text tower, this framework allows researchers to compare pathology image patches directly against natural-language class descriptions, which eliminates the requirement to train task-specific downstream classifiers.
Note
This release focuses on using CONCH-Z. Code for LIMIT training is coming soon.
CONCH-Z is trained with LIMIT (Locked Image Multiple Instance PreTraining), which aligns the text encoder to a frozen visual space using approximately 335,000 clinical pathology reports. The image tower stays frozen and only the text tower is trained. At inference, candidate class descriptions become text queries for zero-shot classification.
LIMIT training and zero-shot slide inference. Tissue regions follow the paper's annotations; animated scores and attention are illustrative.
The model is gated on Hugging Face. Request access on the model page, then log in:
pip install torch torchvision timm transformers huggingface_hub
huggingface-cli loginimport torch
from transformers import AutoModel
model = AutoModel.from_pretrained("MahmoodLab/CONCH-Z", trust_remote_code=True)
model = model.eval().to("cuda")The model has three parts:
| Component | Role |
|---|---|
| Vision encoder | Same as CONCH v1.5 (ViT-L/16 + attentional pooler). Maps a patch to the 768-d feature that the public CONCH v1.5 release and Trident's conch_v15 encoder output. |
Image projection (visual.proj_contrast) |
A 768 × 768 linear map from CONCH v1.5 features into the shared image-text space. It is CONCH v1.5's own contrastive head, kept frozen during LIMIT, but it is not part of the public CONCH v1.5 weights. |
| Text encoder | New in CONCH-Z. Maps a prompt to a 768-d embedding in the shared space. |
Important
Image features must pass through the projection before you compare them with text. encode_image does this for you. For CONCH v1.5 features computed elsewhere, call model.project_image_features first. If you skip it, zero-shot accuracy falls below chance: SPIDER-C balanced accuracy drops from 58.8 to 10.3.
from PIL import Image
image = Image.open("patch.png").convert("RGB")
image = model.eval_transform(image).unsqueeze(0).to("cuda") # (1, 3, 448, 448)
with torch.inference_mode():
image_emb = model.encode_image(image) # (1, 768), projected and L2-normalizedencode_image runs the vision encoder and then the projection. To get the unprojected CONCH v1.5 feature (identical to Trident's conch_v15 output), use model.encode_image_features(image).
If you already have CONCH v1.5 patch features (for example .h5 files from Trident's conch_v15 encoder), you don't need to re-extract them. Project them into the shared space:
import h5py
with h5py.File("slide.h5", "r") as f:
features = torch.from_numpy(f["features"][:]) # (N, 768) CONCH v1.5 features
with torch.inference_mode():
image_emb = model.project_image_features(features) # (N, 768), features @ proj_contrast, L2-normalizedprompts = [
"a lymph node biopsy containing metastatic breast carcinoma",
"a lymph node biopsy containing normal lymphoid tissue",
]
with torch.inference_mode():
input_ids = model.tokenizer(prompts).to("cuda") # (C, 128)
text_emb = model.encode_text(input_ids, normalize=True) # (C, 768)Tip: as in the paper, prepend the tissue or organ type to each class name (e.g. "breast tissue, invasive ductal carcinoma"). This usually helps zero-shot accuracy.
zero_shot_classifier builds one L2-normalized embedding per class. It averages over any number of synonyms per class and prompt templates (CLASSNAME is replaced by each synonym). zero_shot takes projected image embeddings (from encode_image or project_image_features) and returns softmax probabilities scaled by the model's learned temperature:
classnames = [
["metastatic breast carcinoma", "tumor"], # class 0 synonyms
["normal lymph node", "lymphocytes"], # class 1 synonyms
]
templates = ["CLASSNAME", "an image of CLASSNAME", "lymph node, CLASSNAME"]
with torch.inference_mode():
classifier = model.zero_shot_classifier(classnames, templates, device="cuda") # (768, num_classes)
probs = model.zero_shot(image_emb, classifier) # (N, num_classes)
pred = probs.argmax(dim=-1)Zero-shot classification is cosine similarity between projected image embeddings and text embeddings. You can compute it directly, which is handy when you already have a large set of precomputed CONCH v1.5 patch features:
import torch.nn.functional as F
proj = model.visual.proj_contrast # (768, 768) image projection
image_emb = F.normalize(features.cuda() @ proj, dim=-1) # (N, 768) projected patch embeddings
text_emb = F.normalize(text_emb, dim=-1) # (C, 768) one embedding per class
similarity = image_emb @ text_emb.T # (N, C) cosine similarities
pred = similarity.argmax(dim=-1) # predicted class per patchC16 is reported as AUC. SPIDER and CATCH are reported as balanced accuracy, averaged across organs and tasks. The number of classes is in parentheses. Best result in bold. See the paper for per-organ results and bootstrap standard deviations.
| Benchmark | PLIP | QuiltNet | MUSK | MI-Zero | CONCH v1.5 | CONCH-Z |
|---|---|---|---|---|---|---|
| CAMELYON-16, lymph node (2) | 88.4 | 91.7 | 82.7 | 59.9 | 90.3 | 96.7 |
| SPIDER-C, coarse (7–9 per organ) | 34.8 | 30.1 | 51.3 | 44.2 | 49.7 | 58.8 |
| SPIDER-F, fine-grained (13–24 per organ) | 25.6 | 19.7 | 44.1 | 34.9 | 42.9 | 51.3 |
| CATCH, canine skin (2 / 11) | 49.3 | 48.3 | 59.1 | 51.3 | 47.9 | 64.4 |
The model weights are released under CC-BY-NC-ND 4.0 for non-commercial academic research only. The model is not validated for clinical diagnosis.
If you use CONCH-Z or LIMIT in your research, please cite:
@inproceedings{shao2026limit,
title = {Beyond Sparse Captions: Aligning Slide-Level Text and Patch-Level Vision in Pathology},
author = {Shao, Daniel and Bang, Dongmin and Weishaupt, Luca L. and Wagner, Sophia J. and Reitsam, Nic G. and Lu, Ming Y. and Le, Long P. and Chen, Richard J. and Mahmood, Faisal},
booktitle = {Advances in Neural Information Processing Systems},
year = {2026},
url = {https://github.com/mahmoodlab/LIMIT}
}Please open a GitHub issue for questions about using CONCH-Z.