BioLoom Models

arXiv 2611.33151 GitHub code Project page Loom52M dataset Evaluation suite

BioLoom is a biomedical dual encoder for image–text retrieval and zero-shot classification, trained on 52.4 million image–text pairs from Loom52M. It uses whole figures, panels, captions, and relationships within scientific articles to supervise contrastive learning. The main models share a BioClinical ModernBERT text encoder and a ViT-L/14 vision encoder, with either randomly initialized or DFN-2B-initialized visual weights.

📦 Model weights

Default model: BioLoom (DFN-2B). The repository root contains its weights and configuration, ready to use with the inference example below.

Each model directory contains the weights, architecture configuration, and evaluation files.

💻 Inference

The examples below use BioLoom (DFN-2B) by default. To use another model, select its folder from the table.

Install the project’s OpenCLIP implementation and its inference dependencies. From its checkout:

pip install -r src/requirements.txt "transformers>=4.48,<5"
export PYTHONPATH="$PWD/src:$PYTHONPATH"

Choose a model folder in the table. The default DFN-2B model is also available at the repository root. Set folder in the example to load its weights and configuration together. The variant name is also the value for --model in the evaluation CLI.

Variant Model folder
dfn2b Root or Main/DFN-2B
scratch Main/Scratch
commonpool Initialization/CommonPool
dinov2 Initialization/DINOv2
vit-s Model-size/ViT-S-14
vit-b Model-size/ViT-B-14
vit-h Model-size/ViT-H-14
import json
from pathlib import Path

import open_clip
import torch
from huggingface_hub import snapshot_download
from open_clip.tokenizer import HFTokenizer
from PIL import Image

folder = ""  # Default: BioLoom (DFN-2B). Use a table path for other variants.
files = ["open_clip_pytorch_model.bin", "open_clip_config.json"]
snapshot = snapshot_download(
    "ChartFoundation/BioLoom-models",
    allow_patterns=[f"{folder}/{name}" if folder else name for name in files],
)
directory = Path(snapshot) / folder
device = "cuda" if torch.cuda.is_available() else "cpu"
model, preprocess = open_clip.create_model_from_pretrained(
    f"local-dir:{directory}", device=device
)
model.eval()
text_cfg = json.loads((directory / "open_clip_config.json").read_text())["model_cfg"]["text_cfg"]
tokenizer = HFTokenizer(text_cfg["hf_tokenizer_name"], context_length=text_cfg["context_length"])

image = preprocess(Image.open("figure.jpg").convert("RGB")).unsqueeze(0).to(device)
tokens = tokenizer(["a microscopy image", "a radiograph"]).to(device)
with torch.inference_mode():
    scores = model.encode_image(image, normalize=True) @ model.encode_text(tokens, normalize=True).T
print(scores.cpu())

🧪 Evaluation

For example, evaluate the downloaded DFN-2B model on the full BioLoomBench gallery from the BioLoom checkout. Set MODEL_DIR to the directory printed by print(directory) in the loading example.

python -m evaluation --model dfn2b --benchmark bioloombench --download \
  --checkpoint "$MODEL_DIR/open_clip_pytorch_model.bin" --output results/dfn2b.json

To evaluate a checkpoint, use the data and protocols in BioLoom-EvalSuite. Load the checkpoint and its matching architecture as shown above, then follow the zero-shot classification, BioMedFlickr, or BioLoomBench guide. Each model’s results/ folder contains three files: zero-shot.json for all 67 classification tasks, biomedflickr-retrieval.json for BioMedFlickr, and bioloom-retrieval.json for BioLoomBench.

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Space using ChartFoundation/BioLoom-models 1

Collection including ChartFoundation/BioLoom-models

Paper for ChartFoundation/BioLoom-models