Transformer-based generative model for galaxies
Project description
CosmoGLINT: Cosmological Generative model for Line INtensity mapping with Transformer
Transformer-based models that generate galaxies.
Installation
This package is available on PyPI.
pip install cosmoglint
This package requires PyTorch. Please install PyTorch first following https://pytorch.org
Documentation & Source code
GitHub: https://github.com/knmoriwaki/cosmoglint
Basic usage
Load model:
import json
from cosmoglint.model.transformer import transformer_model
with open(f"args.json", "r") as f:
option = json.load(f, object_hook=lambda d: argparse.Namespace(**d))
model = transformer_model(option)
with a json file (example):
{"model_name": "transformer1", "max_length": 50, "d_model": 128, "num_layers": 4, "num_heads": 8, "num_features_out": 100, "num_features_in": 4}
Predict probability:
prob = model(context, x)
Generate new galaxies:
generated, prob = model.generate(context, x, prob_threshold=1e-5)
Input:
context: a tensor of shape(N, C_h), containing the properties of halo.x: a tensor of shape(N, L, C_g), containing the properties of up toLgalaxies for each of theNhalos in the batch. Each feature vector of sizeC_gmay include, for example, the halo mass, relative distance to the halo center, radial velocity, and tangential velocity. InputNoneto generate from scratch.prob_threshold(optional): when sampling, the probability below this threshold is set to zero.
Output:
prob: a tensor of shape(N, L, C_g, d).prob[i,j,k,:]is the probability distribution overdbins for the k-th parameter of the (j+1)-th galaxy in the sequence for the i-th batch element.generated: a tensor of shape(N, L, C_g).generated[i,j,k]is the sampled values for each parameter of (j+1)-th galaxy in the sequence for the i-th batch element.
Shape:
N: Batch sizeL: Sequence lengthC_h: Number of halo propertiesC_g: Number of galaxy properties predictedd: Number of bins for the probability distribution of each parameter
Options:
| Key | Description |
|---|---|
model_name |
Name or identifier for the model configuration (default: "transformer1"). Available options are:- "transformer1": halo is prepended to the sequence- "transformer2": halo and galaxy features are embedded together |
max_length |
Maximum number of galaxies (sequence length) the model will process per halo. |
d_model |
Dimensionality of the internal feature space (i.e., size of the token embeddings and hidden layers in the transformer). |
num_layers |
Number of transformer decoder layers stacked in the model. |
num_heads |
Number of attention heads in the multi-head self-attention layers. |
num_features_out |
Total number of output bins for the probability distribution. |
num_features_in |
Number of features per galaxy (e.g., SFR, relative distance, radial/tangential velocity). |
Citation
If you use CosmoGLINT in your research, please cite Moriwaki et al. 2025
@ARTICLE{CosmoGLINT,
title = {CosmoGLINT: Cosmological Generative Model for Line Intensity Mapping with Transformer},
author = {{Moriwaki}, Kana and {Jun}, Rui Lan and {Osato}, Ken and {Yoshida}, Naoki},
journal = {arXiv preprints},
year = 2025,
month = jun,
eid = {arXiv:2506.16843},
doi = {10.48550/arXiv.2506.16843},
archivePrefix = {arXiv},
eprint = {2506.16843},
primaryClass = {astro-ph.CO}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cosmoglint-1.0.1.tar.gz.
File metadata
- Download URL: cosmoglint-1.0.1.tar.gz
- Upload date:
- Size: 28.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5c0bd35427df138b582f6965cff88c125bf3ca7f39dd49ce4798524cf34d2cc
|
|
| MD5 |
8075be31ad8a81f9d4db1de7ce039333
|
|
| BLAKE2b-256 |
0205680881d6ed78b22d4df3b98ea60f418d1aae832a83548cd2190fca7d679a
|
File details
Details for the file cosmoglint-1.0.1-py3-none-any.whl.
File metadata
- Download URL: cosmoglint-1.0.1-py3-none-any.whl
- Upload date:
- Size: 29.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04828319c5706b809d51016729a2ae9506cea1245ae432a6676da1256eb672a1
|
|
| MD5 |
2ffdd9e4f06033f616db196eff693d0d
|
|
| BLAKE2b-256 |
189b510678147b18e4c3891b69f71debf1ab4e083f90d30f38228b12b94cd4f8
|