Background: Medication non-adherence is a major impediment to the management of many health conditions. A better understanding of the factors underlying non compliance to treatment may help health professionals to address it. Patients use social media to share their experiences regarding their treatments and their diseases. Using topic models makes it possible to model themes present in a collection of posts, thus to identify cases of non-compliance. Objective: Our study aims to detect messages describing patients' non-compliant behaviors. They are associated with a drug of interest. Thus, our objective is the clustering of posts featuring a homogeneous vocabulary related to non-adherent attitudes. Methods: We implemented a probabilistic topic model in order to identify the topics that occurred in a corpus of online messages posted between 2004 and 2013 on three of the most popular French forums. Data were collected using a Web Crawler designed by Kappa Santé as part of the Detec't project to analyze social media for drug safety. Several topics were related to non-compliance to treatment. Results: Starting from a corpus of 3 650 posts related to an antidepressant drug, (escitalopram), and 2,164 posts related to an antipsychotic drug (aripiprazole), the use of latent Dirichlet allocation allowed us to model several themes including interruptions of treatment and changes in dosage. The topic model approach detected cases of non compliance behaviors with a recall of 98.5% and a precision of 32.6%. Conclusions: Topic models enabled us to explore patients' discussions on community websites and to identify posts related with non-compliant behaviors. After a manual review of the messages in the non-compliance topics, we found that non-compliance to treatment was present in almost 6% of the posts.