AstroPT: a Large Observation (foundation) Model for astronomy 🔭
Welcome to our simple repository for training astronomical large observation
models. This repository began its life as Andrej Karpathy's
nanoGPT, and has been altered so that it
is usable for astronomical observation data. Within train.py you will find a
~300-line boilerplate training loop and within model.py you will find a
~300-line GPT model definition with an MLP tokeniser and a regressive loss.
Check out the UniverseTBD Discord for updates: discord.gg/MNEVegvfJq
Read the docs here: astropt.readthedocs.io
How does AstroPT work?
AstroPT is an autoregressive transformer under the hood.
Similarly to language models that predict the next word in a sentence, AstroPT processes sequences of astronomical data chunks to predict what comes next.
The intuition here is that this next-token-prediction task requires the model to internalise some understanding of the physical processes underlying the training data.
This is just like how a text GPT needs to have some knowledge of geography to guess a country's capital given a description of that country, or some knowledge of coding to write compilable Fortran.
Below we can see this principle applied to a galaxy image, where we split the image into chunks and pass them into an AstroPT model:
Of course we can apply this next-token-prediction task across many modalities due to its flexibility.
Check out our work on Euclid data for an example, where we chain galaxy image tokens and spectral energy distribution data and pass them into a single, unified AstroPT model.
I just want to run it! 🗣️
Okay I hear you! First you need to install the model:
Install
You can install via pip from PyPI:
pip install astropt
Or if you install locally via a git clone, you can uv install via:
git clone https://github.com/Smith42/astroPT.git
cd astroPT
uv sync
Load a pre-trained model
To load and run a pre-trained AstroPT model from HuggingFace you can use the load_astropt function:
from astropt.model_utils import load_astropt
model = load_astropt(
repo_id="smith42/astropt_v2.0",
path="astropt/095M",
weights_filename="ckpt.pt",
)
model = model.to("cuda")
where repo_id is the HuggingFace repository ID, and path is the path within the repository that contains the AstroPT model checkpoint.
Pre-trained models
Below are some pre-trained models you can load with the code snippet above. Please make sure that you are using the correct version of AstroPT to load these!
| Survey | Modalities | AstroPT version | Model weights | Dataset | Paper |
|---|---|---|---|---|---|
| DESI Legacy Survey | JPG galaxy imagery | v1.0.0 | AstroPT | Galaxies Dataset | arXiv:2405.14930 |
| Euclid | FITS VIS, NISP galaxy imagery and SED data | v1.0.2 | AstroPT-Euclid | Euclid Training Dataset | arXiv:2503.15312 |
| DESI Legacy Survey | JPG galaxy imagery | v2.0.5 | AstroPT v2.0 | Galaxies Dataset v2.0 | arXiv:2405.14930 |
Scripts for pre-training and processing data
Check out scripts for a collection of all the scripts we have used to get the
results in these papers, and scripts/train.py for an example boilerplate
script for pre-training your own AstroPT. config contains example user
configurations for pre-training.
scripts/linear_probe.py has an example script for inferring embeddings from a
pre-trained model and running a finetuning routine on them 🌝.
And finally scripts/finetune.py has an example LoRA finetune routine.
Contributors
Ryan Roberts 💻 🤔 🖋 |
Mike Smith 💻 🤔 🖋 🔣 |
mhuertascompany 🤔 🖋 |
Malgorzata Siudek 🤔 🖋 💻 🔣 |
gimarso 🤔 💻 |
||
|
|
||||||
Metadata
Release files for astropt 2.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| astropt-2.0.9.tar.gz | 61.1 MB | Without provenance | Details for astropt-2.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| astropt-2.0.9-py3-none-any.whl | Python 3 | none | any | Details for astropt-2.0.9-py3-none-any.whl |
Total release size: 61.1 MB
Release files / astropt-2.0.9.tar.gz
| Download URL | astropt-2.0.9.tar.gz |
|---|---|
| Size | 61.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
228791064d4e83a2b84dd416d0a5ecaf2dfa8ab9db746ede272d456523c2a03a
|
|
BLAKE2b-256 checksum How to use checksums |
0ffba4e475e8a8da05756bb0d3eb2968898236dcab0af462799cf79f19da59ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.15
|
Release files / astropt-2.0.9-py3-none-any.whl
| Download URL | astropt-2.0.9-py3-none-any.whl |
|---|---|
| Size | 29.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b2b21d5873e0fcb9b096b419f0ca62d538742fa5061a2d0271468327a359d438
|
|
BLAKE2b-256 checksum How to use checksums |
fb8b6efc2cb822c46c05249545b2bbf652c044f8bd0e5f9b649abac2c91b8766
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.15
|
Security for astropt 2.0.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.