An ontology-guided knowledge graph and retrieval-augmented LLM framework for interpretable mental health assessment
Abstract
Mental health detection from social media has gained increasing attention due to the spontaneous expression of psychological states on online platforms. However, accurate interpretation remains challenging because social media language is highly contextual, ambiguous, and often includes sarcasm, metaphors, or non-clinical expressions, which can lead to unreliable predictions. Existing approaches based on machine learning, deep learning, transformers, and large language models (LLMs) primarily rely on text-driven patterns and often lack explicit ontology-guided grounding, structured knowledge validation, and interpretability. Although LLMs improve contextual reasoning, their predictions can be inconsistent and prone to hallucination when not supported by structured domain knowledge and a unified cross-component validation mechanism. To address these limitations, this paper proposes an ontology-guided framework that integrates a Knowledge Graph (KG), an Ontology-Informed Retrieval Classifier (ORC), and a Large Language Model for interpretable mental health detection from social media text. The framework leverages the Human Phenotype Ontology (HPO) to guide symptom extraction and Knowledge Graph construction, normalizing informal linguistic expressions into ontology-grounded representations. A key design contribution is an explicit KG–ORC cross-validation consistency gate, which requires both the Knowledge Graph and the ORC module to independently reach agreement before a prediction is committed reducing erroneous inferences from either component alone. The LLM is deliberately restricted to a post-validation role, generating human-readable explanations and supportive recommendations only from validated outputs, thereby reducing hallucination risks and preserving knowledge-consistency. The proposed framework is evaluated on the Dreaddit dataset, a large-scale, multi-domain Reddit corpus for stress and mental health analysis. Empirical evaluation on the HPO guided symptom extraction confirms differential detection rates of 56.04% in stress positive posts versus 31.11% in stress negative posts, validating the signal relevance of the ontology-driven extraction. End-to-end binary classification on the held-out test split achieves an accuracy of 74.82% with an F1-score of 75.64%. Crucially, on the 66.55% of instances where the KG and ORC modules reach consensus, the consistent subset accuracy rises to 78.84% (F1 = 78.28%), compared to 63.03% for the Knowledge Graph alone. The KG–ORC agreement rate across the full test set is 82.02%. These results demonstrate that the KG–ORC cross-validation gate measurably improves predictive reliability over single component baselines, and that ontology-guided, knowledge-grounded reasoning offers a principled path toward interpretable and knowledge-consistent mental health analysis from social media.