Attentional set shifting refers to the ease with which the focus of attention is directed and switched. Cognitive tasks, such as the widely used CANTAB IED, reveal great variation in set shifting ability in the general population, with notable impairments in those with psychiatric diagnoses. The attentional and learning processes underlying this cognitive ability and how they lead to the observed variation remain unknown. To directly test this, we used a modelling approach on two independent large-scale online general-population samples performing CANTAB IED, with one including additional psychiatric symptom assessment. We found a hierarchical model that learnt both feature values and dimension attention best explained the data and that compulsive symptoms were associated with slower learning and higher attentional bias to the first relevant stimulus dimension. These data showcase a new methodology to analyse data from the CANTAB IED task, as well as suggest a possible mechanistic explanation for the variation in set shifting performance, and its relationship to compulsive symptoms.