ONNX
astronomy
time-series
light-curves
variable-stars
hombit commited on
Commit
368ab01
·
verified ·
1 Parent(s): 88a88d0

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +141 -0
README.md ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - astronomy
4
+ - time-series
5
+ - light-curves
6
+ - variable-stars
7
+ - onnx
8
+ library_name: onnx
9
+ license: cc-by-4.0
10
+ ---
11
+
12
+ # AstroM3 (photo encoder)
13
+
14
+ ## Paper
15
+
16
+ Rizhko, M. et al. (2024). *AstroM³: A self-supervised multimodal model for astronomy*. arXiv:2411.08842.
17
+
18
+ ```bibtex
19
+ @article{rizhko2024astrom3,
20
+ author = {Rizhko, Mariia and Bloom, Joshua S.},
21
+ title = {{AstroM³}: A self-supervised multimodal model for astronomy},
22
+ journal = {arXiv preprint arXiv:2411.08842},
23
+ year = {2024}
24
+ }
25
+ ```
26
+
27
+ ## Original code
28
+
29
+ <https://github.com/MeriDK/AstroM3> (git submodule at `models/astrom3/code/`)
30
+
31
+ ## License
32
+
33
+ - **Code** (this repository): MIT — see [LICENSE](LICENSE).
34
+ - **Model weights** (`AstroMLCore/AstroM3-CLIP-photo`): Creative Commons Attribution 4.0 (CC BY 4.0).
35
+
36
+ ## Model overview
37
+
38
+ AstroM3 is a self-supervised multimodal contrastive model for variable-star classification that jointly trains photometry (light-curve), spectra, and metadata encoders using a CLIP-style objective. This integration exports the **photo-only encoder** from the pretrained CLIP checkpoint (`AstroMLCore/AstroM3-CLIP-photo`) as an ONNX embedding model.
39
+
40
+ The photo encoder is an [Informer](https://ojs.aaai.org/index.php/AAAI/article/view/17325/17132) transformer (ProbSparse attention, 8 layers, d_model=128) trained on ZTF variable-star light curves from the MACC dataset. For ONNX export, the ProbSparse attention layers are replaced with standard scaled dot-product attention, which is equivalent in expectation and fully ONNX-exportable.
41
+
42
+ ## Inputs
43
+
44
+ | Tensor | Shape | Description |
45
+ |--------|-------|-------------|
46
+ | `x_enc` | `[batch, 200, 9]` | Padded photometry features (9 channels per timestep — see preprocessing) |
47
+ | `mask` | `[batch, 200]` | `1` for valid timesteps, `0` for padding |
48
+
49
+ ## Outputs (ONNX)
50
+
51
+ Single file `astrom3.onnx` with two named outputs:
52
+
53
+ | Output | Shape | Aggregation |
54
+ |--------|-------|-------------|
55
+ | `mean` | `[batch, 128]` | Masked mean pool of encoder outputs |
56
+ | `sequence` | `[batch, 200, 128]` | Full per-timestep encoder outputs (unmasked) |
57
+
58
+ ## Preprocessing steps
59
+
60
+ The 9 input channels per timestep are built by `preprocess_lc()` in the
61
+ upstream dataset (`AstroMLCore/AstroM3Dataset`):
62
+
63
+ | Index | Feature | How obtained |
64
+ |-------|---------|--------------|
65
+ | 0 | `time` (HJD scaled to [0, 1]) | per-observation |
66
+ | 1 | `flux` = `(flux − mean) / MAD` | per-observation |
67
+ | 2 | `flux_err` = `flux_err / MAD` | per-observation |
68
+ | 3 | `amplitude` | **ASAS-SN catalog scalar, replicated to every timestep** |
69
+ | 4 | `period` | **ASAS-SN catalog scalar, replicated** |
70
+ | 5 | `lksl_statistic` (Lafler-Kinman string length) | **ASAS-SN catalog scalar, replicated** |
71
+ | 6 | `rfr_score` (Random Forest Regressor R² for phase-folded LC) | **ASAS-SN catalog scalar, replicated** |
72
+ | 7 | `log10(MAD_flux)` | global scalar computed from LC, replicated |
73
+ | 8 | `delta_t` = `(max_HJD − min_HJD) / 365` | global scalar computed from LC, replicated |
74
+
75
+ Features 3–6 come directly from the ASAS-SN v-band variable-star catalog
76
+ (Jayasinghe et al. 2019) and are **not recomputed** from the light curve by
77
+ this codebase. Users applying this model to non-ASAS-SN data must provide
78
+ equivalent values (e.g. run a Lomb-Scargle period finder and compute
79
+ peak-to-peak amplitude themselves).
80
+
81
+ Preprocessing recipe for a single light curve:
82
+
83
+ 1. Deduplicate and sort observations by HJD.
84
+ 2. Compute `mean` and `MAD` of the flux column; normalize flux and flux_err.
85
+ 3. Scale HJD to [0, 1] over the span of the light curve.
86
+ 4. Compute `log10(MAD_flux)` and `delta_t = (max_HJD − min_HJD) / 365`.
87
+ 5. Obtain `amplitude`, `period`, `lksl_statistic`, `rfr_score` from the
88
+ ASAS-SN catalog (or compute equivalents).
89
+ 6. Tile the 6 global scalars across all timesteps; concatenate with columns
90
+ 0–2 to produce an `(N, 9)` array.
91
+ 7. Pad or center-crop to 200 timesteps; set `mask = 0` for padded positions.
92
+ 8. Use `float32` for all tensors.
93
+
94
+ ## Weights
95
+
96
+ Source: <https://huggingface.co/AstroMLCore/AstroM3-CLIP-photo>
97
+
98
+ The `model.safetensors` file is a standalone Informer checkpoint (classification head present but unused; loaded with `strict=False`).
99
+
100
+ Dataset: ASAS-SN v-band variable-star light curves (`AstroMLCore/AstroM3Processed`).
101
+
102
+ ## Applying the model without ASAS-SN catalog features
103
+
104
+ Features 3–6 require the ASAS-SN catalog. For users applying the model to
105
+ other surveys, we measured the sensitivity of the mean embedding to each
106
+ feature being replaced. `rfr_score` was studied in detail.
107
+
108
+ ### rfr_score substitution
109
+
110
+ `rfr_score` is the R² of a Random Forest Regressor fit to the phase-folded
111
+ light curve; it quantifies period quality
112
+ (Jayasinghe et al. 2019, MNRAS 486 1907, §5; arXiv:1809.07329).
113
+ In the ASAS-SN test set it ranges from −3.5 to 1.18 (median ≈ 0.38).
114
+
115
+ Setting all timesteps to the constant **0.392** (the empirical optimum,
116
+ equal to the dataset median) minimises mean cosine distance from the
117
+ true-feature embeddings:
118
+
119
+ | Metric | Value |
120
+ |--------|-------|
121
+ | Overall mean cosine distance | 0.049 ± 0.091 |
122
+ | Macro-average per class | 0.049 ± 0.058 |
123
+
124
+ Per-class breakdown (5 samples per class from the ASAS-SN test split):
125
+
126
+ | Class | Mean dist | Std | True rfr mean |
127
+ |-------|-----------|-----|---------------|
128
+ | EW | 0.005 | 0.005 | −0.07 |
129
+ | SR | 0.004 | 0.003 | +0.50 |
130
+ | EA | 0.060 | 0.032 | +0.95 |
131
+ | RRAB | 0.020 | 0.011 | +0.83 |
132
+ | EB | 0.016 | 0.011 | +0.90 |
133
+ | ROT | 0.002 | 0.002 | +0.85 |
134
+ | RRC | 0.147 | 0.115 | −0.79 |
135
+ | HADS | 0.016 | 0.011 | +0.59 |
136
+ | M | 0.050 | 0.020 | +0.18 |
137
+ | DSCT | 0.170 | 0.182 | −0.86 |
138
+
139
+ Classes whose true rfr mean is far from 0.39 (RRC, DSCT) are most affected.
140
+ Using an out-of-range value (e.g. ±100) causes cosine distances ~0.93–0.97,
141
+ so staying within the training distribution is important.