SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.03024 · NeurIPS · 2023

AstroCLIP: A Cross-Modal Foundation Model for Galaxies

Kyunghyun Cho, Miles Cranmer, Shirley Ho, Siavash Golkar, Francois Lanusse, Alberto Bietti, Michael Eickenberg, Bruno Régaldo-Saint Blancard, Rudy Morel, Mariel Pettee, Geraud Krawezik, Michael Mccabe, and 3 more

arXiv · PDF · Open in the Atlas

Code that ran

2 of 2 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 0 failures of our instrument; 0 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2310.03024.json · badge: /api/ran/2310.03024.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
PolymathicAI/AstroCLIP canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
FunctionStatusWhere it lives
AstroClipModel Ran
ran on a synthesized input · constructed an object; no result was computed
PolymathicAI/AstroCLIP/astroclip/models/astroclip.py
code served (permissive licence) · get_code("788c03b4f5ddff93")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, AstroClipModel: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import lightning as L

torch.manual_seed(0)

# Create minimal encoder modules that satisfy the usage in the code
class MinimalImageEncoder(nn.Module):
    def __init__(self, input_dim=3, output_dim=4):
        super().__init__()
        self.linear = nn.Linear(input_dim, output_dim)
    
    def forward(self, x):
        # x shape: (batch, channels, height, width) or similar
        # Flatten and project to embedding dimension
        batch_size = x.shape[0]
        x_flat = x.reshape(batch_size, -1)
        return self.linear(x_flat)

class MinimalSpectrumEncoder(nn.Module):
    def __init__(self, input_dim=5, output_dim=4):
        super().__init__()
        self.linear = nn.Linear(input_dim, output_dim)
    
    def forward(self, x):
        # x shape: (batch, spectrum_features)
        return self.linear(x)

# Instantiate the encoders
image_encoder = MinimalImageEncoder(input_dim=3, output_dim=4)
spectrum_encoder = MinimalSpectrumEncoder(input_dim=5, output_dim=4)

# Define all parameters for AstroClipModel
ARGS = {
    'image_encoder': image_encoder,
    'spectrum_encoder': spectrum_encoder,
    'temperature': 15.5,
    'lr': 0.0001,
    'weight_decay': 0.05,
    'epochs': 100,
    'eta_min': 5e-07,
    'logit_scale': 15.5,
    'learnable_logit_scale': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
lightning, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type AstroClipModel — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a AstroClipModel output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
CLIPLoss Ran
ran on a synthesized input
PolymathicAI/AstroCLIP/astroclip/models/astroclip.py
code served (permissive licence) · get_code("36c97be9f076b733")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 0, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Tuple

class CLIPLoss(nn.Module):

    def get_logits(self, image_features: torch.FloatTensor, spectrum_features: torch.FloatTensor, logit_scale: float) -> Tuple[torch.FloatTensor, torch.FloatTensor]:
        image_features = F.normalize(image_features, dim=-1, eps=0.001)
        spectrum_features = F.normalize(spectrum_features, dim=-1, eps=0.001)
        logits_per_image = logit_scale * image_features @ spectrum_features.T
        return (logits_per_image, logits_per_image.T)

    def forward(self, image_features: torch.FloatTensor, spectrum_features: torch.FloatTensor, logit_scale: float, output_dict: bool=False) -> torch.FloatTensor:
        logits_per_image, logits_per_spectrum = self.get_logits(image_features, spectrum_features, logit_scale)
        labels = torch.arange(logits_per_image.shape[0], device=image_features.device, dtype=torch.long)
        total_loss = (F.cross_entropy(logits_per_image, labels) + F.cross_entropy(logits_per_spectrum, labels)) / 2
        return {'contrastive_loss': total_loss} if output_dict else total_loss


INIT_ARGS = {}

ARGS = {
    'image_features': torch.randn(2, 4),
    'spectrum_features': torch.randn(2, 4),
    'logit_scale': 100.0,
    'output_dict': False,
}

if __name__ == '__main__':
    model = CLIPLoss(**INIT_ARGS)
    output = model(**ARGS)
    print("Output shape:", output.shape if isinstance(output, torch.Tensor) else type(output))
    print("Output:", output)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)

Also present in other papers' code

Of 2 samples lifted from this paper's linked repositories, 2 carry a function identity and 0 do not. Of the 2 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 2 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

We present AstroCLIP, a single, versatile model that can embed both galaxy images and spectra into a shared, physically meaningful latent space. These embeddings can then be used -without any model fine-tuning -for a variety of downstream tasks including (1) accurate in-modality and cross-modality semantic similarity search, (2) photometric redshift estimation, (3) galaxy property estimation from both images and spectra, and (4) morphology classification. Our approach to implementing AstroCLIP consists of two parts. First, we embed galaxy images and spectra separately by pretraining separate transformer-based image and spectrum encoders in self-supervised settings. We then align the encoders using a contrastive loss. We apply our method to spectra from the Dark Energy Spectroscopic Instrument and images from its corresponding Legacy Imaging Survey. Overall, we find remarkable performance on all downstream tasks, even relative to supervised baselines. For example, for a task like photometric redshift prediction, we find similar performance to a specifically-trained ResNet18, and for additional tasks like physical property estimation (stellar mass, age, metallicity, and sSFR), we beat this supervised baseline by 19% in terms of 𝑅 2 . We also compare our results to a state-of-the-art self-supervised single-modal model for galaxy images, and find that our approach outperforms this benchmark by roughly a factor of two on photometric redshift estimation and physical property prediction in terms of 𝑅 2 , while remaining roughly in-line in terms of morphology classification. Ultimately, our approach represents the first cross-modal self-supervised model for galaxies, and the first self-supervised transformer-based architectures for galaxy images and spectra.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2310.03024")
get_code_for_paper("2310.03024")
have("2310.03024")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2310.03024.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2310.03024.svg)](https://syntology.ai/paper/2310.03024)

Connect an agent — have() is free.