{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/spectrafm-tuning-into-stellar-foundation","title":"SpectraFM: Tuning into Stellar Foundation Models","arxiv_id":"2411.04750","date":"2024-11-07","proceeding":null,"authors":["Nolan Koblischke","Jo Bovy"],"abstract":"Machine learning models in astrophysics are often limited in scope and cannot adapt to data from new instruments or tasks. We introduce SpectraFM, a Transformer-based foundation model architecture that can be pre-trained on stellar spectra from any wavelength range and instrument. SpectraFM excels in generalization by combining flexibility with knowledge transfer from pre-training, allowing it to outperform traditional machine learning methods, especially in scenarios with limited training data. Our model is pre-trained on approximately 90k examples of synthetic spectra to predict the chemical abundances (Fe, Mg, O), temperature, and specific gravity of stars. We then fine-tune the model on real spectra to adapt it to observational data before fine-tuning it further on a restricted 100-star training set in a different wavelength range to predict iron abundance. Despite a small iron-rich training set of real spectra, transfer learning from the synthetic spectra pre-training enables the model to perform well on iron-poor stars. In contrast, a neural network trained from scratch fails at this task. We investigate the Transformer attention mechanism and find that the wavelengths receiving attention carry physical information about chemical composition. By leveraging the knowledge from pre-training and its ability to handle non-spectra inputs, SpectraFM reduces the need for large training datasets and enables cross-instrument and cross-domain research. Its adaptability makes it well-suited for tackling emerging challenges in astrophysics, like extracting insights from multi-modal datasets.","url_abs":"https://arxiv.org/abs/2411.04750v1","url_pdf":"https://arxiv.org/pdf/2411.04750v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"links_only","authors_date_abstract":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license), from the Kaggle arXiv metadata snapshot of 2026-09-12"},"code_links":[{"paper_slug":"spectrafm-tuning-into-stellar-foundation","repo_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science","is_official":1,"mentioned_in_paper":0,"mentioned_in_github":0,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2411.04750","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2411.04750"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science","reach":{"status":"ok"}}],"summary":{"unverified":17},"by_repo_kind":{"official":{"samples":17,"ran":0,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted","community":"Not in the archive's code links for this paper; a community repository Syntology harvested"},"n_pointer_only_for_licence":17,"samples":[{"code_sha256_prefix":"f1fb55e3900659cb","entry":"crop_xp","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/utils/gaia_utils.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/utils/gaia_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f1fb55e3900659cb"}},{"code_sha256_prefix":"0916108f810a8280","entry":"estimate_bprp","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/utils/empirical_utils.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/utils/empirical_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"0916108f810a8280"}},{"code_sha256_prefix":"f11021746c757675","entry":"estimate_logg_from_teff_MS","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/utils/empirical_utils.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/utils/empirical_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f11021746c757675"}},{"code_sha256_prefix":"7b7fe2d763e1898f","entry":"estimate_teff_from_logg_rgb","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/utils/empirical_utils.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/utils/empirical_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"7b7fe2d763e1898f"}},{"code_sha256_prefix":"6b0d532c134d64b5","entry":"get_activation","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/stellarperceptron/layers.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/stellarperceptron/layers.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6b0d532c134d64b5"}},{"code_sha256_prefix":"b76ac4984902fcc3","entry":"get_initializer","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/stellarperceptron/layers.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/stellarperceptron/layers.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"b76ac4984902fcc3"}},{"code_sha256_prefix":"db139f93c836329b","entry":"mag_to_flux","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/utils/gaia_utils.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/utils/gaia_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"db139f93c836329b"}},{"code_sha256_prefix":"ac32065953e99b32","entry":"mean_squared_error","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/stellarperceptron/nn_utils.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/stellarperceptron/nn_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ac32065953e99b32"}},{"code_sha256_prefix":"5b7c19850d0160ea","entry":"prepare_labels_and_ids","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"dataset/create_dataset.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/dataset/create_dataset.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5b7c19850d0160ea"}},{"code_sha256_prefix":"6b321439c20994fb","entry":"random_choice","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/utils/data_utils.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/utils/data_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6b321439c20994fb"}},{"code_sha256_prefix":"9aea7c675f1b3865","entry":"robust_mean_squared_error","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/stellarperceptron/nn_utils.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/stellarperceptron/nn_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9aea7c675f1b3865"}},{"code_sha256_prefix":"078edcdd035127f0","entry":"run","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/stellarperceptron/torch_utils_collect_env.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/stellarperceptron/torch_utils_collect_env.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"078edcdd035127f0"}},{"code_sha256_prefix":"ab7aeddfa9e9fb2e","entry":"run_and_parse_first_match","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/stellarperceptron/torch_utils_collect_env.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/stellarperceptron/torch_utils_collect_env.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ab7aeddfa9e9fb2e"}},{"code_sha256_prefix":"84905132fbc263e3","entry":"run_and_read_all","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/stellarperceptron/torch_utils_collect_env.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/stellarperceptron/torch_utils_collect_env.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"84905132fbc263e3"}},{"code_sha256_prefix":"63e230bcdbaee56a","entry":"shuffle_row","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/utils/data_utils.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/utils/data_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"63e230bcdbaee56a"}},{"code_sha256_prefix":"150b30062b840abc","entry":"top_cbar","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"model_core/utils/plotting_utils.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/model_core/utils/plotting_utils.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"150b30062b840abc"}},{"code_sha256_prefix":"f2870f53793379c6","entry":"train_test_split_data","repo":"NolanKoblischke/SpectraFM_NeurIPS_FM4Science","repo_kind":"official","path":"dataset/create_dataset.py","file_url":"https://github.com/NolanKoblischke/SpectraFM_NeurIPS_FM4Science/blob/HEAD/dataset/create_dataset.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f2870f53793379c6"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}