Abstract
Music perception requires integrating individual notes into their broader musical context, yet how musical expertise shapes the neural encoding of this information across the auditory hierarchy remains unclear. Here, we address this by using the hierarchical representations from a generative music transformer model to predict human brain activity. We recorded scalp electroencephalography (EEG) from expert musicians and non-musicians, as well as intracranial EEG (iEEG) from six neurological patients, during listening to classical piano pieces. We found that deeper layers of the transformer, which represent more disentangled and contextual musical features, were more predictive of neural responses in both groups. However, this neural correspondence was significantly enhanced by musical expertise: for non-musicians, prediction accuracy plateaued across the model's final layers, whereas for musicians it continued to increase. This enhanced encoding in experts was also strongly lateralized to the left hemisphere. Finally, the iEEG recordings revealed an anatomical gradient for this function, where neural sites progressively farther from the primary auditory cortex encoded musical context more strongly. Our study reveals how musical training refines the hierarchical neural processing of music and provides a neuro-computational account of this remarkable cognitive skill.