Skip to main content

Vision-Language Model for Computational Pathology

Project description

ANTONI-Alpha

Vision-Language Model for Computational Pathology

Resources

Authors

Computational Pathology Group RadboudUMC

Model Information

ANTONI-Alpha is a vision-language model for computational pathology. It combines Prism vision embeddings (1280-dim) with MedGemma-2B language model through a learned cross-attention projector, enabling natural language interactions with whole slide images.

Architecture:

  • Vision encoder: Prism (produces tile-level embeddings)
  • Language model: MedGemma-2B (4-bit quantized with LoRA)
  • Projector: Cross-attention with 256 learnable query tokens

Training:

  • Stage 1: Projector alignment (frozen LLM)
  • Stage 2: Instruction tuning (LoRA fine-tuning)
  • Dataset: HISTAI-Instruct (multilingual, multimodal)

Installation

From PyPI (recommended for running the model):

pip install antoni-alpha

From source (for development or training):

git clone https://github.com/computationalpathologygroup/ANTONI-Alpha.git
cd ANTONI-Alpha
pip install -e .

Optional: Flash Attention 2

For improved performance on compatible hardware, install Flash Attention 2:

pip install flash-attn==2.8.3 --no-build-isolation

The --no-build-isolation flag allows the build process to use your installed PyTorch. Flash Attention 2 requires CUDA-capable hardware and will be used automatically if installed.

How to Use

import torch
from pathlib import Path
from antoni_alpha.models.antoni_pretrained import AntoniAlphaPreTrained

# Load model
model = AntoniAlphaPreTrained.from_pretrained(
    "SaltySander/ANTONI-Alpha",
    device_map="auto",
    torch_dtype=torch.bfloat16
)

# Load slide features (Prism embeddings: [num_tiles, 1280])
slide_features = torch.load("slide_features.pt")
slide_latents = slide_features.unsqueeze(0)  # Add batch dimension
slide_latents = slide_latents.to(next(model.projection_layer.parameters()).device)

# Run inference
conversation = [{"role": "user", "content": "What tissue is this?"}]

with torch.no_grad():
    output_ids = model.generate(
        slide_latents=slide_latents,
        conversations=[conversation],
        max_new_tokens=200,
        do_sample=False,
    )

response = model.processor.batch_decode(output_ids, skip_special_tokens=True)[0]
print(response)

See examples/inference_example.py for a complete multi-turn conversation example.

Input/Output Structure

Input:

  • slide_latents: Tensor of shape [batch_size, num_tiles, 1280] (Prism embeddings)
  • conversations: List of conversation lists in OpenAI format

Output:

  • Generated text response from the language model

Training

# Configure training
python train.py --config config/finetune.yaml

Training configurations available in config/ directory.

License

This model is released under the Health AI Developer Foundations License.

Citation

@inproceedings{moonemans2025open,
  title={Democratizing Pathology Co-Pilots: An Open Pipeline and Dataset for Whole-Slide Vision-Language Modeling},
  author={Sander Moonemans and Sebastiaan Ram and Fr{\'e}d{\'e}rique Meeuwsen and Carlijn Lems and Jeroen van der Laak and Geert Litjens and Francesco Ciompi},
  booktitle={Submitted to Medical Imaging with Deep Learning},
  year={2025},
  url={https://openreview.net/forum?id=aGPowreqPi},
  note={under review}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

antoni_alpha-0.1.1.tar.gz (34.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

antoni_alpha-0.1.1-py3-none-any.whl (36.4 kB view details)

Uploaded Python 3

File details

Details for the file antoni_alpha-0.1.1.tar.gz.

File metadata

  • Download URL: antoni_alpha-0.1.1.tar.gz
  • Upload date:
  • Size: 34.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for antoni_alpha-0.1.1.tar.gz
Algorithm Hash digest
SHA256 061e7d61934955cfff3c55ecf9c0437c2c1cd7f89bee6f6168d4752c65889aa1
MD5 b2516063827b2234be695c1904cf4db5
BLAKE2b-256 7896afcc9e8e3810d645547a07ff5f5515a5ec02f2ec93cf8beb5348ef853f40

See more details on using hashes here.

File details

Details for the file antoni_alpha-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: antoni_alpha-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 36.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for antoni_alpha-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a9607ae210270b0e851ae82d47285340aaf47b802a2208e5bb4d3c2dda6b150e
MD5 9c20fc0e685b55c1f257261e9a8902c2
BLAKE2b-256 e310eecc49f2e4d80c56d33fd90cf328b65c19205f096d095cde80c9463156e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page