Abstract
The ages and masses of red giants are key to our understanding of the structure and evolution of the Milky Way. Traditional isochrone methods for these estimations are inherently limited due to overlapping isochrones in the Hertzsprung-Russell diagram, while astero-seismology, albeit more precise, requires high-precision, long-term observations. In response to these challenges, we developed a novel framework, spectral transformer (SPT), to predict the ages and masses of red giants aligned with asteroseismology from their spectra. The main component of SPT is the multi-head Hadamard self-attention mechanism, which is designed specifically for spectra and can capture complex relationships across different wavelengths. Furthermore, we introduced a Mahalanobis distance-based loss function, to address scale imbalance and interaction mode loss, and we incorporated a Monte Carlo dropout for a quantitative analysis of the prediction uncertainty. Trained and tested on 3880 red giant spectra from LAMOST, the SPT has achieved remarkable age and mass estimations, with average percentage errors of 17.64 and 6.61%, respectively. It has also provided uncertainties for each corresponding prediction. These results significantly outperform traditional machine learning algorithms, demonstrating a high level of consistency with asteroseismology methods and isochrone-fitting techniques. In the future, our work will leverage datasets from the Chinese Space Station Telescope and Large Synoptic Survey Telescope to enhance the precision of the model and broaden its applicability in the fields of astronomy and astrophysics.