{"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/moonbeam-a-midi-foundation-model-using-both","title":"Moonbeam: A MIDI Foundation Model Using Both Absolute and Relative Music Attributes","arxiv_id":"2505.15559","date":"2025-05-21","proceeding":null,"authors":["Zixun Guo","Simon Dixon"],"abstract":"Moonbeam is a transformer-based foundation model for symbolic music, pretrained on a large and diverse collection of MIDI data totaling 81.6K hours of music and 18 billion tokens. Moonbeam incorporates music-domain inductive biases by capturing both absolute and relative musical attributes through the introduction of a novel domain-knowledge-inspired tokenization method and Multidimensional Relative Attention (MRA), which captures relative music information without additional trainable parameters. Leveraging the pretrained Moonbeam, we propose 2 finetuning architectures with full anticipatory capabilities, targeting 2 categories of downstream tasks: symbolic music understanding and conditional music generation (including music infilling). Our model outperforms other large-scale pretrained music models in most cases in terms of accuracy and F1 score across 3 downstream music classification tasks on 4 datasets. Moreover, our finetuned conditional music generation model outperforms a strong transformer baseline with a REMI-like tokenizer. We open-source the code, pretrained model, and generated samples on Github.","url_abs":"https://arxiv.org/abs/2505.15559v1","url_pdf":"https://arxiv.org/pdf/2505.15559v1.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":"abstracts"},"code_links":[{"paper_slug":"moonbeam-a-midi-foundation-model-using-both","repo_url":"https://github.com/guozixunnicolas/Moonbeam-MIDI-Foundation-Model","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"jax","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"music-classification","task_name":"Music Classification"},{"task_slug":"music-generation","task_name":"Music Generation"}],"methods":[{"method_slug":"attention","method_name":"Attention"},{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2505.15559","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2505.15559"}},"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":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/guozixunnicolas/Moonbeam-MIDI-Foundation-Model","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran":1,"ran_violates":1,"ran_fixture":1,"unverified":8},"by_repo_kind":{"listed":{"samples":11,"ran":3,"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":0,"samples":[{"code_sha256_prefix":"6d5ba8546b6aad2c","entry":"load_peft_model","repo":"guozixunnicolas/Moonbeam-MIDI-Foundation-Model","repo_kind":"listed","path":"src/llama_recipes/inference/model_utils.py","file_url":"https://github.com/guozixunnicolas/Moonbeam-MIDI-Foundation-Model/blob/HEAD/src/llama_recipes/inference/model_utils.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"6d5ba8546b6aad2c"}},{"code_sha256_prefix":"e93cc5b705c2eb3b","entry":"precompute_freqs_cis","repo":"guozixunnicolas/Moonbeam-MIDI-Foundation-Model","repo_kind":"listed","path":"generation/llama/model.py","file_url":"https://github.com/guozixunnicolas/Moonbeam-MIDI-Foundation-Model/blob/HEAD/generation/llama/model.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"e93cc5b705c2eb3b"}},{"code_sha256_prefix":"70bf6ebaafd266c4","entry":"reshape_for_broadcast","repo":"guozixunnicolas/Moonbeam-MIDI-Foundation-Model","repo_kind":"listed","path":"generation/llama/model.py","file_url":"https://github.com/guozixunnicolas/Moonbeam-MIDI-Foundation-Model/blob/HEAD/generation/llama/model.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"70bf6ebaafd266c4"}},{"code_sha256_prefix":"88092eec78599288","entry":"apply_rotary_emb","repo":"guozixunnicolas/Moonbeam-MIDI-Foundation-Model","repo_kind":"listed","path":"generation/llama/model.py","file_url":"https://github.com/guozixunnicolas/Moonbeam-MIDI-Foundation-Model/blob/HEAD/generation/llama/model.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"88092eec78599288"}},{"code_sha256_prefix":"52bd5b31564b07c7","entry":"chunk_compounds","repo":"guozixunnicolas/Moonbeam-MIDI-Foundation-Model","repo_kind":"listed","path":"data_preprocess.py","file_url":"https://github.com/guozixunnicolas/Moonbeam-MIDI-Foundation-Model/blob/HEAD/data_preprocess.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"52bd5b31564b07c7"}},{"code_sha256_prefix":"112a9c1d444c983e","entry":"find_midi_files","repo":"guozixunnicolas/Moonbeam-MIDI-Foundation-Model","repo_kind":"listed","path":"data_preprocess.py","file_url":"https://github.com/guozixunnicolas/Moonbeam-MIDI-Foundation-Model/blob/HEAD/data_preprocess.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"112a9c1d444c983e"}},{"code_sha256_prefix":"0636ff953de85b98","entry":"find_midi_files_from_file","repo":"guozixunnicolas/Moonbeam-MIDI-Foundation-Model","repo_kind":"listed","path":"data_preprocess.py","file_url":"https://github.com/guozixunnicolas/Moonbeam-MIDI-Foundation-Model/blob/HEAD/data_preprocess.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"0636ff953de85b98"}},{"code_sha256_prefix":"43a4e8a8adcfda2d","entry":"load_llama_from_config","repo":"guozixunnicolas/Moonbeam-MIDI-Foundation-Model","repo_kind":"listed","path":"src/llama_recipes/inference/model_utils.py","file_url":"https://github.com/guozixunnicolas/Moonbeam-MIDI-Foundation-Model/blob/HEAD/src/llama_recipes/inference/model_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"43a4e8a8adcfda2d"}},{"code_sha256_prefix":"6533a38ad979d2b6","entry":"load_model","repo":"guozixunnicolas/Moonbeam-MIDI-Foundation-Model","repo_kind":"listed","path":"src/llama_recipes/inference/model_utils.py","file_url":"https://github.com/guozixunnicolas/Moonbeam-MIDI-Foundation-Model/blob/HEAD/src/llama_recipes/inference/model_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"6533a38ad979d2b6"}},{"code_sha256_prefix":"07d4dbd7f1854c92","entry":"load_model_checkpoint_ddp","repo":"guozixunnicolas/Moonbeam-MIDI-Foundation-Model","repo_kind":"listed","path":"src/llama_recipes/model_checkpointing/checkpoint_handler.py","file_url":"https://github.com/guozixunnicolas/Moonbeam-MIDI-Foundation-Model/blob/HEAD/src/llama_recipes/model_checkpointing/checkpoint_handler.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"07d4dbd7f1854c92"}},{"code_sha256_prefix":"abd14de7398ccffe","entry":"load_sharded_model_single_gpu","repo":"guozixunnicolas/Moonbeam-MIDI-Foundation-Model","repo_kind":"listed","path":"src/llama_recipes/model_checkpointing/checkpoint_handler.py","file_url":"https://github.com/guozixunnicolas/Moonbeam-MIDI-Foundation-Model/blob/HEAD/src/llama_recipes/model_checkpointing/checkpoint_handler.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"abd14de7398ccffe"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}