Introduction to Foundation Models

Francois Lanusse


SOS 2026 Summer School, Aussois, June 2026
The Deep Learning Boom in Astrophysics

astro-ph abstracts mentioning Deep Learning, CNN, or Neural Networks
The vast majority of these results has relied on supervised learning and networks trained from scratch.
The Limits of Traditional Deep Learning
-
Limited Supervised Training Data
- ​Rare or novel objects have by definition few labeled examples
- In Simulation Based Inference (SBI), training a neural compression model requires many simulations
- ​Rare or novel objects have by definition few labeled examples
-
Limited Reusability
- Existing models are trained supervised on a specific task, and specific data.


=> Limits in practice the ease of using deep learning for analysis and discovery
Can we make use of all the unlabeled data we have access to?
The Rise of The Foundation Model Paradigm
-
Foundation Model approach
- Pretrain models on pretext tasks, without supervision, on very large scale datasets.
- Adapt pretrained models to downstream tasks.
- Combine pretrained modules in more complex systems.

The Advantage of Scale of Data and Compute

Linearly Accessible Information

- Backbone of modern architectures embed input images as vectors in where d can typically be between 512 to 2048.
- Linear probing refers to training a single matrix to adapt this vector representation to the desired downstream task.

Rethinking the way we use Deep Learning
Conventional scientific workflow with deep learning
- Build a large training set of realistic data
- Design a neural network architecture for your data
- Deal with data preprocessing/normalization issues
- Train your network on some GPUs for a day or so
- Apply your network to your problem
-
Throw the network away...
=> Because it's completely specific to your data, and to the one task it's trained for.

Conventional researchers @ CMU
Circa 2016



CMU DeepLens (Lanusse et al 2017)
Rethinking the way we use Deep Learning
Foundation Model-based Scientific Workflow
- Build a small training set of realistic data
- Design a neural network architecture for your data
- Deal with data preprocessing/normalization issues
- Adapt a model in a matter of minutes
- Apply your model to your problem
- Throw the network away...
=> Because it's completely specific to your data, and to the one task it's trained for.
Already taken care of
What This New Paradigm Could Mean for Us
-
Never have to retrain my own neural networks from scratch
- Existing pre-trained models would already be near optimal, no matter the task at hand
-
Saves a lot of time and energy
- Practical large scale Deep Learning even in very few example regime
- Searching for very rare objects in large surveys like Euclid or LSST becomes possible
-
Pretraining on data itself ensures that all sorts of image artifacts are already folded in the training.
- If the information is embedded in a space where it becomes linearly accessible, very simple analysis tools are enough for downstream analysis
- In the future, survey pipelines may add vector embedding of detected objects into catalogs, these would be enough for most tasks, without the need to go back to pixels

... but how does it work?
Before we dive in...
A short primer on Transformers
Attention is all you need
Vaswani, Shazeer, Parmar, Uszkoreit, Jones, Gomez, Kaiser, Polosukhin (2017)




A Minimal Code Example
import jax
import jax.numpy as jnp
import optax
import flax.linen as nn
class MLP(nn.Module):
features: int
@nn.compact
def __call__(self, x):
x = nn.Dense(self.features)(x)
x = nn.relu(x)
x = nn.Dense(self.features)(x)
return x
class TransformerBlock(nn.Module):
d_model: int
num_heads: int
@nn.compact
def __call__(self, x, mask):
z = nn.LayerNorm()(x)
z = nn.MultiHeadDotProductAttention(num_heads=self.num_heads)(z, mask=mask)
x = x + z
z = nn.LayerNorm()(x)
x += MLP(self.d_model)(z)
return x
class LightCurveTransformer(nn.Module):
d_model: int
num_heads: int
num_layers: int
@nn.compact
def __call__(self, x, mask):
# Building attention mask
attention_mask = nn.make_attention_mask(mask, mask)
# Positional embedding
pos = get_positional_encoding(self.d_model)(x)
# Embedding layer
x = nn.Dense(self.d_model)(x[:,:,1:5]) # Extracting the flux light curves
x += pos
# Transformer blocks
for i in range(self.num_layers):
x = TransformerBlock(self.d_model, self.num_heads)(x, attention_mask)
# Global average pooling
x = jnp.mean(x, axis=1)
# Output layer
x = nn.Dense(1)(x)
return x.squeeze()
More about positional embedding:

Vision Transformer (ViT) (Dosovitskiy et al. 2020)

Text
Masked Modeling
Sometimes, the simplest things just work...
An idea that comes from language models

i.e. BERT (Devlin et al. 2018)
Masked Autoencoders Are Scalable Vision Learners (He et al. 2021)


Masked Auto Encoding (MAE)
How to use such a model for classification

Credit: (Liang et al. 2022)

Application to Dense Prediction Tasks


Example of Application on Astronomical Data: Specformer

- Pre-Training Galaxy Spectra Representation by Masked Modeling


Multi-View Self-Supervised Contrastive Learning
MultiView Contrastive Learning e.g. SimCLR (Chen et al. 2000)



Contrastive Learning in Astrophysics

Self-Supervised similarity search for large scientific datasets (Stein et al. 2021)
Detecting Galaxy Tidal Features Using Self-Supervised Representation Learning

Project led by Alice Desmons, Francois Lanusse, Sarah Brough








DiNOv2 (Oquab et al. 2023)


PCA of patch features
Dense Semantic Segmentation
Dense Depth Estimation


Dinov3 (Siméoni et al. 2025)

Weakly Supervised Contrastive Learning
Or what you can do when you do have independent views of an object...
Contrastive Language Image Pretraining
Contrastive Language Image Pretraining (CLIP)
(Radford et al. 2021)



The Information Point of View
- The InfoNCE loss is a lower bound on the Mutual Information between modalities


Shared information

One model, many downstream applications!
Flamingo: a Visual Language Model for Few-Shot Learning (Alayrac et al. 2022)


Hierarchical Text-Conditional Image Generation with CLIP Latents (Ramesh et al. 2022)
The AstroCLIP approach
- We use spectra and multi-band images as our two different views for the same underlying object.
- DESI Legacy Surveys (g,r,z) images, and DESI EDR galaxy spectra.




Cosine similarity search
Evaluation of the model
- Cross-Modal similarity search





Image Similarity
Spectral Similarity

Image-Spectral Similarity
- Redshift Estimation From Images


Supervised baseline

- Zero-shot prediction
- k-NN regression
- Few-shot prediction
- MLP head trained on top of frozen backbone
Now you try it!

Multimodal Masked Modeling
Or let's do one massive model of everything!
AION-1
AstronomIcal Omnimodal Network


with extensive support from the rest of the team.









Project led by:
Francois
Lanusse
Liam
Parker
Jeff
Shen
Tom
Hehir
Ollie
Liu
Lucas
Meyer
Leopoldo
Sarra
Sebastian Wagner-Carena
Helen
Qu
Micah
Bowles
Diverse data modalities for diverse science cases


(Blanco Telescope and Dark Energy Camera.
Credit: Reidar Hahn/Fermi National Accelerator Laboratory)






(Subaru Telescope and Hyper Suprime Cam. Credit: NAOJ)




(Dark Energy Spectroscopic Instrument)



(Sloan Digital Sky Survey. Credit: SDSS)


(Gaia Satellite. Credit: ESA/ATG)
- Galaxy formation
- Cosmology
- Stellar physics
- Galaxy archaeology
- ...
Standardizing all modalities through tokenization

- For each modality class (e.g. image, spectrum) we build dedicated metadata-aware tokenizers
- For Aion-1, we integrate 39 different modalities (different instruments, different measurements, etc.)



Field Embedding Strategy Developed for
Multiple Physics Pretraining (McCabe et al. 2023)

DES g
DES r
DES i
DES z
HSC g
HSC r
HSC i
HSC z
HSC y


Any-to-Any Modeling with Generative Masked Modeling
- Training is done by pairing observations of the same objects from different instruments.
- Each input token is tagged with a modality embedding that specifies provenance metadata.
- Model is trained by cross-modal generative masked modeling (Mizrahi et al. 2023)
=> Learns the joint and all conditional distributions of provided modalities:




AION-1 family of models



- Models trained as part of the 2024 Jean Zay Grand Challenge, following an extension to a new partition of 1400 H100s
- AION-1 Base: 300 M parameters
- 64 H100s - 1.5 days
- AION-1 Large: 800 M parameters
- 100 H100s - 2.5 days
- AION-1 XLarge: 3B parameters
- 288 H100s - 3.5 days


Example of out-of-the-box capabilities


Survey translation

Spectrum super-resolution




Adaptation of AION-1 embeddings



Adaptation at low cost
with simple strategies:
- Mean pooling + linear probing
- Attentive pooling
- Can be used trivially on any input data AION-1 was trained for
- Flexible to varying number/types of inputs
=> Allows for trivial data fusion

Morphology classification by Linear Probing





Trained on ->
Eval on ->
Physical parameter estimation and data fusion




Inputs:
measured fluxes
Inputs:
measured fluxes + image

Semantic segmentation


Segmenting central bar and spiral arms in galaxy images based on Galaxy Zoo 3D
Example-based retrieval from mean pooling embeddings


Introduction to Foundation Models
By eiffl
Introduction to Foundation Models
Lecture on Foundation Models at the SOS 2026 Summer School
- 25
