Applying Contrastive Learning to Stellar Spectra

Abstract
With its wide range of spectroscopic capabilities, the Near Infrared Spectrograph (NIRSpec) on the \textit{James Webb} Space Telescope (JWST) is expected to usher in a new era of crowded-field extragalactic stellar spectroscopy. However, small sample sizes and limited overlap with ground-based surveys, such as APOGEE, pose challenges for NIRSpec data analysis. In this work, we present \textsc{StarCLIP}: a contrastive self-supervised learning framework that embeds observed APOGEE and \textit{ab initio} NIRSpec spectra into a unified, physically meaningful latent space. Our approach consists of training convolutional neural networks (CNNs) to recover twenty fundamental stellar properties from single-modal spectroscopic data. We then adopt these pre-trained CNNs as encoders, aligning them via contrastive loss. To simulate realistic NIRSpec observations, we construct semi-empirical, stochastic NIRSpec catalogs and embed them into the shared latent space using \textsc{MockStarCLIP}, a modified CLIP-based framework. Both models enable seamless transfer to downstream tasks, including cosine similarity search and stellar property recovery. Notably, a linear regressor applied to \textsc{StarCLIP} embeddings recovers all twenty stellar properties of interest with $r^2$ scores typically exceeding $0.88$, including $T_{\text{eff}}$ (with uncertainty $\lesssim 200\,\mathrm{K}$), $\log g$ ($\lesssim 0.07\,\mathrm{dex}$) and [Fe/H] ($\lesssim 0.03\,\mathrm{dex}$) for RGB-like stars. Applying the regressor on \textsc{MockStarCLIP} embeddings yields modestly reduced precision โ approximately $450\,\mathrm{K}$ for $T_{\text{eff}}$, $0.11\,\mathrm{dex}$ for $\log g$ and $0.06\,\mathrm{dex}$ for [Fe/H]. Ultimately, our approach demonstrates that foundation models for NIRSpec and other spectral surveys with similar constraints are well within reach.
Type
Publication
Part III Essay, University of Cambridge