SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2505.15559 · 2025

Moonbeam: A MIDI Foundation Model Using Both Absolute and Relative Music Attributes

arXiv · PDF · Open in the Atlas

Code that ran

7 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 1 violated it and 4 have no contract verdict; 2 failures of our instrument; 4 no recorded run), measured 2026-11-24; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2505.15559.json · badge: /api/ran/2505.15559.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
guozixunnicolas/Moonbeam-MIDI-Foundation-Model community (classifier label)
classifier basis not recorded on the link
7 ran · 4 no recorded run
FunctionStatusWhere it lives
apply_rotary_emb Ran
ran on a synthesized input
guozixunnicolas/Moonbeam-MIDI-Foundation-Model/generation/llama/model.py
code served (permissive licence) · get_code("88092eec78599288")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 5, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Based on the function body and docstring examples:
# - xq and xk have shape (batch, seq_len, n_heads, head_dim)
# - freqs_cis has shape (seq_len, head_dim//2)
# - head_dim must be even (it's reshaped to (..., -1, 2) then view_as_complex)

batch_size = 2
seq_len = 3
n_heads = 4
head_dim = 8  # must be even

# xq: (batch, seq_len, n_heads, head_dim)
xq = torch.randn(batch_size, seq_len, n_heads, head_dim)

# xk: (batch, seq_len, n_heads, head_dim) 
xk = torch.randn(batch_size, seq_len, n_heads, head_dim)

# freqs_cis: (seq_len, head_dim//2) - complex frequency tensor
# Create as complex tensor with shape (seq_len, head_dim//2)
freqs_cis = torch.randn(seq_len, head_dim // 2, dtype=torch.complex64)

ARGS = {
    "xq": xq,
    "xk": xk,
    "freqs_cis": freqs_cis,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 5, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
chunk_compounds Ran
ran on a synthesized input
guozixunnicolas/Moonbeam-MIDI-Foundation-Model/data_preprocess.py
code served (permissive licence) · get_code("52bd5b31564b07c7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Construct compounds: a list of lists where each compound has:
# - First element: onset (integer representing time position)
# - Remaining elements: other data (e.g., pitch, duration, velocity)
compounds = [
    [100, 60, 1.0, 0.5],      # onset=100, pitch=60, duration=1.0, velocity=0.5
    [150, 64, 1.2, 0.6],      # onset=150
    [200, 67, 0.8, 0.4],      # onset=200
    [2000, 72, 1.5, 0.7],     # onset=2000 (large gap, will trigger threshold)
    [2050, 75, 1.1, 0.5],     # onset=2050
    [2100, 79, 0.9, 0.6],     # onset=2100
]

threshold = 1024

ARGS = {
    "compounds": compounds,
    "threshold": threshold,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 3, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
find_midi_files Ran
ran on a synthesized input
guozixunnicolas/Moonbeam-MIDI-Foundation-Model/data_preprocess.py
code served (permissive licence) · get_code("112a9c1d444c983e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
import shutil

# Create a temporary directory structure with test MIDI files
temp_dir = tempfile.mkdtemp()

# Create subdirectories and MIDI files for testing
os.makedirs(os.path.join(temp_dir, "subdir1"), exist_ok=True)
os.makedirs(os.path.join(temp_dir, "subdir2"), exist_ok=True)

# Create test MIDI files with various extensions
open(os.path.join(temp_dir, "song1.mid"), 'w').close()
open(os.path.join(temp_dir, "song2.midi"), 'w').close()
open(os.path.join(temp_dir, "song3.MID"), 'w').close()
open(os.path.join(temp_dir, "subdir1", "song4.mid"), 'w').close()
open(os.path.join(temp_dir, "subdir2", "song5.midi"), 'w').close()
open(os.path.join(temp_dir, "notmidi.txt"), 'w').close()

ARGS = {
    "folder": temp_dir
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
find_midi_files_from_file Ran
ran on a synthesized input
guozixunnicolas/Moonbeam-MIDI-Foundation-Model/data_preprocess.py
code served (permissive licence) · get_code("0636ff953de85b98")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import json
import pandas as pd
import tempfile

# Create temporary directory for test files
temp_dir = tempfile.mkdtemp()
dataset_folder = temp_dir

# Setup for GAPS dataset
gaps_split_file = os.path.join(temp_dir, 'gaps_split.csv')
gaps_df = pd.DataFrame({
    'split': ['train_annotation', 'train_annotation', 'test_annotation', 'test_annotation'],
    'filename': ['file1.mid', 'file2.mid', 'file3.mid', 'file4.mid']
})
gaps_df.to_csv(gaps_split_file, index=False)

# Create dummy MIDI files
for filename in ['file1.mid', 'file2.mid', 'file3.mid', 'file4.mid']:
    filepath = os.path.join(dataset_folder, filename)
    with open(filepath, 'w') as f:
        f.write('dummy midi content')

# Setup for GuitarSet dataset
guitarset_split_file = os.path.join(temp_dir, 'guitarset_split.json')
guitarset_splits = {
    'train_annotation': [
        os.path.join(dataset_folder, 'guitar1.mid'),
        os.path.join(dataset_folder, 'guitar2.mid')
    ],
    'test_annotation': [
        os.path.join(dataset_folder, 'guitar3.mid'),
        os.path.join(dataset_folder, 'guitar4.mid')
    ]
}
with open(guitarset_split_file, 'w') as f:
    json.dump(guitarset_splits, f)

# Create dummy GuitarSet MIDI files
for filename in ['guitar1.mid', 'guitar2.mid', 'guitar3.mid', 'guitar4.mid']:
    filepath = os.path.join(dataset_folder, filename)
    with open(filepath, 'w') as f:
        f.write('dummy guitar midi content')

# Define arguments - using GAPS dataset as the test case
ARGS = {
    'dataset_name': 'GAPS',
    'split_file': gaps_split_file,
    'dataset_folder': dataset_folder
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_peft_model Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
guozixunnicolas/Moonbeam-MIDI-Foundation-Model/src/llama_recipes/inference/model_utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from zhu-minjun/safetylock, is pointer only (licence: NONE) · get_code("6d5ba8546b6aad2c")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from zhu-minjun/safetylock, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

precompute_freqs_cis Ran
ran, violated the contract we drafted
guozixunnicolas/Moonbeam-MIDI-Foundation-Model/generation/llama/model.py
code served (permissive licence) · get_code("e93cc5b705c2eb3b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

ARGS = {
    "dim": 8,
    "end": 4,
    "theta": 10000.0,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (4, 4) — shape (4, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
reshape_for_broadcast Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
guozixunnicolas/Moonbeam-MIDI-Foundation-Model/generation/llama/model.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from alpha-vllm/llama2-accessory, is pointer only (licence: NOASSERTION) · get_code("70bf6ebaafd266c4")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from alpha-vllm/llama2-accessory, and GitHub could not classify the licence of that repository (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

load_llama_from_config Not yet run
unverified (harvested, no recorded run)
guozixunnicolas/Moonbeam-MIDI-Foundation-Model/src/llama_recipes/inference/model_utils.py
code served (permissive licence) · get_code("43a4e8a8adcfda2d")
How it ran

no invocation recorded.

load_model Not yet run
unverified (harvested, no recorded run)
guozixunnicolas/Moonbeam-MIDI-Foundation-Model/src/llama_recipes/inference/model_utils.py
code served (permissive licence) · get_code("6533a38ad979d2b6")
How it ran

no invocation recorded.

load_model_checkpoint_ddp Not yet run
unverified (harvested, no recorded run)
guozixunnicolas/Moonbeam-MIDI-Foundation-Model/src/llama_recipes/model_checkpointing/checkpoint_handler.py
code served (permissive licence) · get_code("07d4dbd7f1854c92")
How it ran

no invocation recorded.

load_sharded_model_single_gpu Not yet run
unverified (harvested, no recorded run)
guozixunnicolas/Moonbeam-MIDI-Foundation-Model/src/llama_recipes/model_checkpointing/checkpoint_handler.py
code served (permissive licence) · get_code("abd14de7398ccffe")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 5 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 1 the same month, 2 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
reshape_for_broadcast 58 other papers
52 dated earlier, 1 the same month, 4 later, 1 same year, order not determinable · 2 only as an assembly brick
2023.emnlp-main.534 (2023 (year only))
Disentangling Transformer Language Models as Superposed Topic Models
2303.09736 (2023-03)
Dynamic Structure Pruning for Compressing CNNs
2307.09288 (2023-07)
Llama 2: Open Foundation and Fine-Tuned Chat Models
and 55 more not named here
precompute_freqs_cis 10 other papers
8 dated earlier, 2 later · 1 only as an assembly brick
2308.12950 (2023-08)
Code Llama: Open Foundation Models for Code
2402.06700 (2024-02)
Entropy-Regularized Token-Level Policy Optimization for Language Agent Reinforcement
2408.01933 (2024-08)
DiReCT: Diagnostic Reasoning for Clinical Notes via Large Language Models
and 7 more not named here
load_peft_model 7 other papers
7 dated earlier
2308.10855 (2023-08)
LatEval: An Interactive LLMs Evaluation Benchmark with Incomplete Information from Lateral Thinking Puzzles
2310.02469 (2023-10)
PrivacyMind: Large Language Models Can Be Contextual Privacy Protection Learners
2310.06498 (2023-10)
A New Benchmark and Reverse Validation Method for Passage-level Hallucination Detection
and 4 more not named here
load_llama_from_config 6 other papers
6 dated earlier
2310.02469 (2023-10)
PrivacyMind: Large Language Models Can Be Contextual Privacy Protection Learners
2310.06498 (2023-10)
A New Benchmark and Reverse Validation Method for Passage-level Hallucination Detection
2310.08491 (2023-10)
Prometheus: Inducing Fine-grained Evaluation Capability in Language Models
and 3 more not named here
load_sharded_model_single_gpu 4 other papers
4 dated earlier
2310.02469 (2023-10)
PrivacyMind: Large Language Models Can Be Contextual Privacy Protection Learners
2310.08491 (2023-10)
Prometheus: Inducing Fine-grained Evaluation Capability in Language Models
2402.12030 (2024-02)
Towards Cross-Tokenizer Distillation: the Universal Logit Distillation Loss for LLMs
and 1 more not named here

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-24.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

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.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2505.15559")
get_code_for_paper("2505.15559")
have("2505.15559")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2505.15559.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2505.15559.svg)](https://syntology.ai/paper/2505.15559)

Connect an agent — have() is free.