scieee AI-readable full text Open interactive document viewer

MUSE-Explainer: Counterfactual Explanations for Symbolic Music Graph Classification Models

Hilaire, Baptiste; Karystinaios, Emmanouil; Widmer, Gerhard

Abstract

Interpretability is essential for deploying deep learning models in symbolic music analysis, yet most research emphasizes model performance over explanation. To address this, we introduce MUSE-Explainer, a new method that helps reveal how music Graph Neural Network models make decisions by providing clear, human-friendly explanations. Our approach generates counterfactual explanations by making small, meaningful changes to musical score graphs that alter a model’s prediction while ensuring the results remain musically coherent. Unlike existing methods, MUSE-Explainer tailors its explanations to the structure of musical data and avoids unrealistic or confusing outputs. We evaluate our method on a music analysis task and show it offers intuitive insights that can be visualized with standard music tools such as Verovio. All code and models are available on [github.com/BaptisteHi/MNExplainer].

Full text

MUSE-Explainer: Counterfactual Explanations for Symbolic Music Graph Classification Models Baptiste Hilaire1,2, Emmanouil Karystinaios2, and Gerhard Widmer2 1ENS Paris-Saclay, Gif-sur-Yvette, France 2Institute of Computational Perception, Johannes Kepler University Linz, Austria [email protected] Abstract. Interpretability is essential for deploying deep learning models in symbolic music analysis, yet most research emphasizes model performance over explanation. To address this, we introduce MUSE-Explainer, a new method that helps reveal how music Graph Neural Network models make decisions by providing clear, human-friendly explanations. Our approach generates counterfactual explanations by making small, meaningful changes to musical score graphs that alter a model’s prediction while ensuring the results remain musically coherent. Unlike existing methods, MUSE-Explainer tailors its explanations to the structure of musical data and avoids unrealistic or confusing outputs. We evaluate our method on a music analysis task and show it o!ers intuitive insights that can be visualized with standard music tools such as Verovio. All code and models are available on github.com/BaptisteHi/MNExplainer. Keywords: symbolic music ; graph neural networks ; explainability ; counterfactual explanations 1 Introduction In the past years, the field of symbolic music processing has experienced a boom in deep learning techniques that have provided high-performing solutions for many analysis tasks [15], music generation [2], emotion recognition [1], expressive performance [7], and composer classification [19]. While deep learning has proven e!ective for symbolic music processing, deploying these models in practice also requires understanding their predictions, which poses a challenge in particular for big black-box models. Focusing on music analysis, a class of deep learning models, called Graph Neural Networks, has shown promising performance at capturing complex relationships in music data [8, 11]. Despite the importance of interpretability in symbolic music processing and analysis in particular, most research still focuses on improving model performance rather than explaining how these models work. The few existing methods [9] for explaining graph neural networks for music provided limit insight with general models not tailored for music. Graph-based models are good candidates for explainability in music because they can capture interrelations between notes and provide insights at the level of Proc. of the 17th International Symposium on CMMR, London, UK, Nov. 3-7, 2025 772 individual note instances. Model-agnostic explainers are considered more general because they do not rely on the gradients of the prediction model. Many of those explainers rely on perturbing an input to explain the predictions. Sometimes, the perturbation process can result to out-of-distribution issues, that just increase the instability of the underlying prediction model. To tackle the particularities of out-of-distribution issues, we designed a novel explainer based on graph-based counterfactual explanations, MUSE-Explainer. Counterfactual explanations are considered human-friendly because they focus on changing small parts of the input in order to obtain a desired outcome [13]. Our explainer, MUSE-Explainer, produces counterfactual explanations for model predictions on musical score graphs. A musical score can be modeled by an oriented heterogeneous graph, which is a graph where each node is associated with a node type, and each edge with an edge type [8]. MUSE-Explainer is capable of dealing with out-of-distribution issues by ensuring the musical coherence of the score represented by the counterfactual explanation graphs it produces. Our contributions in this work are four-fold: –An explainer for Heterogeneous GNNs classification models performing on node level, that produces musically intuitive counterfactual explanations –Five musical edit operations to modify an input graph in sensible and interpretable ways –A configuration study of our explainer on a cadence detection model to measure its accuracy and e”ciency –A compatible output with visualizing frameworks that provides a view on the edited musical score in Verovio. 2 Related work 2.1 Explainability for Graph Neural Networks In the past years, geometric deep learning has gained traction, leading to a wide array of models and research focused on graph-structured data. As a result, various approaches to explainability have been developed specifically for Graph Neural Networks (GNNs). These approaches are usually categorized in a taxonomy based on their underlying explanation strategies, such as model agnostic vs model-aware modes but also methods such as gradient-based, perturbationbased, surrogate models, and counterfactuals, each providing di!erent perspectives on model interpretability. The model-aware methods are specific to a model, treating it as a white box, and accessing its parameters. For instance, the integrated gradients method [17] proposes to use the gradient to retrieve the input features and a subgraph of the input graph that played a major role in the prediction. Saliency maps [16] also o!er some insights about feature importance in the prediction. While these methods are often e!ective, their reliance on detailed model internals limits their flexibility and prevents them from being easily applied to di!erent model architectures. Proc. of the 17th International Symposium on CMMR, London, UK, Nov. 3-7, 2025 773 In contrast, model-agnostic methods treat the model as a black box, relying solely on its inputs and outputs. For example, LIME [14] builds an interpretable surrogate model around a specific prediction by generating many slight perturbations of the input and observing the resulting outputs, thus o!ering local explanations of the black-box model’s behavior. Another method, GNNExplainer [18], a perturbation-based method, learns an edge mask to identify the subgraph most relevant to a model’s prediction, highlighting the key structures that influenced the outcome. However, both approaches have their limitations. With LIME, small changes to the input can sometimes yield surrogate models whose explanations vary significantly, reducing the reliability of the interpretation. Meanwhile, GNNExplainer is prone to out-of-distribution issues, as the masked subgraphs it produces may not accurately reflect the kinds of data the model was originally trained on, potentially leading to unstable explanations. Although both model-aware and model-agnostic methods contribute valuable explanations, they can struggle with reliability and stability, especially when input modifications produce unrealistic or out-of-distribution samples. An alternative, increasingly popular direction is to use counterfactual explanations, which provide human-friendly insights by illustrating how small changes to the input can alter the model’s prediction [3, 12], all while treating the model as a black box. Depending on the algorithm used to generate them, counterfactual methods can help avoid out-of-distribution issues, a property we demonstrate in our work for music graph classification tasks. 2.2 Music Information Research In the field of Music Information Research, existing work aims to explain deep learning models and assess the trustworthiness of di!erent explainers. In the symbolic music domain, Foscarin et al. [4] introduce a method to identify which musical concepts are relevant to a given prediction. In the audio domain, Hoedt et al. [6] investigate various explainers using adversarial attacks to determine whether these methods can reliably identify the parts of the input that are crucial for the model’s prediction. Focusing on graph neural networks for music, the SMUG-Explain framework [9] introduces visualization tools for explanations generated by standard gradient-based methods such as Integrated Gradients [17] and Saliency maps [16]. To our knowledge, this is the only explainability method specifically developed for symbolic music analysis using graph neural networks, highlighting the need for further research on interpretable solutions in this field. 3 Methodology 3.1 Graph Structure This work is focused on producing explanations for graph-based neural networks for music analysis, therefore the input data, i.e. the musical score, is represented Proc. of the 17th International Symposium on CMMR, London, UK, Nov. 3-7, 2025 774 as a graph. We choose to use an established method in the field to construct the heterogeneous directed graphs from the scores as introduced in [8]. One node type ’note’ is used to create a node for every note in the score. Then, four types of edges can be found in our graphs. Let us note on(u) and dur(u), respectively the onset and the duration of a note node u, and let us consider two note nodes uand v. 1. If on(u)=on(v), then an ’onset’ edge is created from uto v. 2. If on(u)+dur(u)=on(v), a ’consecutive’ edge is created from uto v. 3. If on(u)<on(v)→on(u)+dur(u)>on(v), then it is a ’during’ edge that is added from vto u. 4. Finally, if on(u)+dur(u)<on(v)→⊋w↑V,on(w)<on(v)→on(u)+ dur(u)<on(w), then a ’rest’ edge is created from uto v,whereVis the set of note nodes. Some other nodes can be added to the graph structure using the process introduced in Graphmuse [11], such as ’beat’ and ’measure’ nodes, to connect the nodes representing notes to the beat or measure they belong to in the musical score. This hierarchical information can be beneficial by allowing the graph neural networks to access more complex relations in the score, leading to better results when resolving tasks that are tied to complex musical structures [11]. 3.2 Algorithm and Workflow As noise di!usion processes proved their e”ciency to generate counterfactual explanations [3], we create our own algorithm inspired by them, adding up an increasing number of subtle changes to the graph encapsulating the musical score. Similar to noise di!usion, we start with an input graph and progressively create noisier versions. However, instead of introducing random noise, we apply musically coherent modifications, ensuring that the resulting graphs remain within the input distribution. This approach eliminates the need for denoising or postprocessing, allowing the noisy graphs to serve directly as valid counterfactual explanations while avoiding out-of-distribution issues. The overall workflow of our explainer is illustrated in Figure 1, and the algorithmic details are provided in Algorithm 1. Our explainer is built with two parts : an outer component that receives the parameters such as the number of training epochs and the input graph, and an inner model that is used to learn the changes that could flip the label predictions of the explained model. When created, he explainer is initialized with a selected classification model. For each explanation to be generated, an input graph and a target are provided to the explainer’s outer component. This component then enters a training phase, using the inner model to learn both the type of operation to apply and its associated parameters. At the end of training, a counterfactual explanation is produced, and a loss score is computed that considers both the distance from the input graph and the validity of the counterfactual. The explainer then backpropagates this loss to the inner model, which refines the choice of operation and its parameters. Proc. of the 17th International Symposium on CMMR, London, UK, Nov. 3-7, 2025 775 By repeating this training step, the explainer iteratively generates a sequence of counterfactuals, where each explanation is based on the modifications applied in the previous step, plus an additional learned change from the inner model. Fig. 1. Overall workflow of MUSE-Explainer (input graph picture taken from [10]). 3.3 Training of the Inner Model and Loss Function The core component of the explainer is its inner model, which explores changes that a!ect the prediction and constructs the resulting explanations. To train this model e!ectively, we design a custom loss function that captures two essential properties of a high-quality counterfactual explanation: its counterfactual nature—specifically, i.e. the ability to flip the classification label, and its minimal distance from the original input data. The explicit form of this loss function is provided in Equation 1. L(G,G,y,ω gp,ω nd,ω)=ωent(f(G),y)+(ωndDnd(G,G)+ωgpDgp(G,G)) (1) where Gis the counterfactual graph, Gis the original input graph, yis the desired label output, fis the model to be explained, ω,ωgp and ωnd are balancing factors and ent is a cross entropy function. Dnd is a function adding up the the di!erences between the node features for each node that is present in both provided graphs, that also adds up the features from the nodes that are not shared between the graphs, such as added or removed notes. Dgp is the standard Proc. of the 17th International Symposium on CMMR, London, UK, Nov. 3-7, 2025 776 graph edit distance, that can be computed e”ciently by retrieving the possibly multiple changes that occurred while performing the operations to obtain G from G, keeping track of the added and removed edges during the process. Algorithm 1 Production of counterfactual explanations for unspecified operations. Require: n>0 where nis the number of explanations to produce, Gthe input graph, t>0 the number of training steps. Ensure: Lcontains the input graph and the nexplanations. L→list(G) while n>0do G→L.last for i↑{1...t}do G→→InnerModel(G) loss term →loss function(G→,G) loss term.backward end for L.append(InnerModel(G)) end while 3.4 Out of Distribution Issues Out-of-distribution issues typically occur when an input graph is modified by an explainer, for instance, from a noise di!usion model. These issues can be caused by introducing unseen feature values, drastic changes in edge distributions, graph size, or other structural shifts. In the context of music graphs, out-of-distribution problems are particularly pronounced due to the fundamental role of features and edges in encoding musical information. Every change to a music graph must correspond to a musically meaningful transformation in the underlying data. For example, if two note nodes uand vare already connected by an ’onset’ edge, adding an additional ’consecutive’, ’rest’, or ’during’ edge between them would introduce contradictions regarding their onset or duration, since these edge types have specific musical interpretations. Therefore, it is crucial to preserve musical coherence by carefully designing the operations that modify these graphs. To address this, we first considered which kinds of modifications are sensible for a musical score. We propose five musically meaningful edit operations: updating pitch, onset, or duration, and adding or removing a note. The pitch update selects a ’note’ node and adjusts its MIDI pitch, as well as its pitch spelling if supported by the input graph. Similarly, onset and duration updates involve selecting a ’note’ node and changing its onset or duration. For onset updates, to avoid out-of-distribution issues, the new onset is set to that of another selected ’note’ node, ensuring plausibility. Duration can be adjusted to standard musical values such as whole, half, quarter, or eighth notes. Removing a ’note’ node entails disconnecting it from the graph by deleting all its edges. Adding a note Proc. of the 17th International Symposium on CMMR, London, UK, Nov. 3-7, 2025 777 involves inserting a new ’note’ node with its pitch, onset, and duration determined in the same manner as in the update operations. By restricting changes to these carefully crafted operations, we ensure that the resulting graphs remain within the valid distribution of music graphs representing structured musical scores. As a result, our counterfactual explanations maintain musical coherence and do not su!er from out-of-distribution problems. 4 Experiments and Results For our explainer, we conducted experiments using a cadence detection model originally introduced in [10] and further adapted in [11]. This model operates as a node-level classification Graph Neural Network (GNN), where the task is to predict whether a given node marks the occurrence of a musical cadence. The model leverages the structure of the musical score, encoded as a graph, to capture complex musical relationships and dependencies that inform its predictions. By applying our counterfactual explainer to this setting, we are able to assess both the interpretability and musical validity of our explanations in the context of a real symbolic music analysis task. We evaluate two scenarios: flipping from aPAC (Perfect Authentic Cadence) prediction to NC (No Cadence), and the inverse. Each experiment consists in producing ten counterfactual explanations for the prediction of a given piece and with given parameters such as balance factors, node target, and desired label prediction. Each experiment is repeated five times. We used five pieces for these experiments, randomly chosen in the Mozart piano sonatas dataset introduced by [5]. By analyzing Table 1 we observe that the explainer is indeed able to produce counterfactuals. We highlight that the ground-truth label distribution is highly unbalanced: most notes are not associated with cadences. As a result, the model tends to predict NC more frequently, which makes generating PAC counterfactuals more challenging and partly explains the asymmetry in our results. Despite this, our results demonstrate that the explainer succeeds in finding counterfactuals for those case, however, we remark that these changes require, on average, more operations and are slightly less accurate compared to the inverse process, which is coherent with the label distribution in the data. Similarly, changing the number of training epochs for the explainer’s inner model training phase had little impact on the results. The same observation holds for varying the balance between the counterfactual and distance loss terms. 5 Discussion 5.1 Visualization and Scoring of the Explanations To facilitate interpretation and analysis, the explanations produced by our explainer can be visualized using the SMUG-Explain framework [9], which is built on top of a Verovio-based browser interface. Within this framework, it is possible Proc. of the 17th International Symposium on CMMR, London, UK, Nov. 3-7, 2025 778 to directly observe the modifications made to the input graph, providing a clear and interactive view of the changes that led to the counterfactual explanation. In addition to graphical visualization, SMUG-Explain allows users to play back the musical score, so the e!ects of the modifications can also be experienced audibly. Additionally, we propose a basic scoring method of the produced counterfactual explanations, measuring their distance from the original graph, their ability to flip the classification label to the desired one, and trying to retrieve the musical insights provided. This last aspect is the most interesting and the most challenging, since some modifications will provide clear insights, such as feature changes, and it will be much harder for others to get any precise understanding of the prediction process. In fact, the answer of what knowledge could be retrieved from the fact that adding a note at a given onset will change a model’s prediction depends on many factors : it could either break a chord, or bring a feature value to this onset that would change the prediction, there could be many more options. label PAC to NC NC to PAC balance Distance Counterfactual Distance Counterfactual epochs 50 100 50 100 50 100 50 100 accuracy 92.0% 100.0%96.0% 92.0 % 20.0 % 16.0 % 8.0% 32.0% min. changes 1.4± 1.1 1.9± 1.8 2.3±2.6 1.8± 2.5 1.6± 0.8 2.8± 1.5 5.0± 1.0 3.4± 2.5 operation onset dur onset onset rem rem dur add distance 2.8± 2.2 3.0± 2.1 0.3±0.2 0.3± 0.2 4.0± 1.6 3.1± 1.9 0.5± 0.1 0.3± 0.2 time (s) 68.5± 9.3 134.7± 16.4 66.8± 9.9 135.8± 17.1 68.5± 10.4 134.2± 16.4 67.5± 9.6 132.4± 17.5 Table 1. Results of the experiments led on five Mozart piano sonatas. The first column refers to what information is contained in the row : label is PAC to NC when we desire a no cadence label for a prediction that predicted a perfect cadence on the input graph. The balance refers to the loss function balancing term, distance is for ωnd =ωgp =0.1 and counterfactual for ωnd =ωgp =0.01, having ω=2.0 for both settings. The accuracy is the accuracy of the explainer to flip the label for all of the tests. The min. changes refers to the number of operations needed to flip the label. The operation row provides the operation that succeeded the most frequently to flip the label, ’dur’ standing for duration and ’rem’ for the removal of a note. The distance is the loss function distance term between the counterfactual explanation that flipped the label and the input graph. Finally, the time in seconds is the production time for 10 counterfactual explanations built on top of each other. For each desired label setting, the best accuracy score is set in bold. Proc. of the 17th International Symposium on CMMR, London, UK, Nov. 3-7, 2025 779 5.2 A Sneak Pick in the Counterfactuals In this section, we demonstrate an example of the MUSE-Explainer attempting to interpret a GNN-based cadence detection model. In figure 2, we showcase how the explainer changes the score to confuse the model and change its prediction. We observe that the underlying model predicts a PAC cadence on the second beat of the measure that is entirely shown. The model’s prediction is a result of a dominant resolution to tonic followed by a 9,7,4 suspension, and it is classified as a Perfect Authentic Cadence on the resolution of the suspension. Our explainer succeeds in flipping the models by removing on the suspension notes, which can be seen by its isolation in the graph (marked in light grey). While some modifications, such as removing a suspension note, provide clear harmonic insights, others, such as adding a new note, are harder to interpret consistently, since their e!ect depends on broader harmonic and structural context. Fig. 2. Visualization of a ’remove’ operation performed by MUSE-Explainer on the purple note to remove a PAC label prediction on the red note. 5.3 System Modularity The MUSE-Explainer is designed with a modular architecture, enabling manual adjustment of all key parameters to suit specific tasks or research needs. When creating an instance of the explainer, users can configure the balancing factors ω,ωnd, and ωgp in the loss function 1, set the number of training epochs for the inner model, specify the number of convolutional layers in the encoders, and select the learning rate for model optimization. Proc. of the 17th International Symposium on CMMR, London, UK, Nov. 3-7, 2025 780