Back to projects
NLPAug – Nov 2025

Explainable Depression Detection

A research project under Prof. Pushpak Bhattacharyya that builds an NLP pipeline for detecting depression indicators in social-media text. The approach combines double domain adaptation with guided masking to achieve 0.78 F1, and introduces an explainability pipeline that merges Integrated Gradients with LLM-based teacher-student distillation to identify the specific words driving each prediction.

0.78
F1 score, depression detection
Domain adaptation stages applied
IG
Integrated Gradients for attribution
Top-k
Contributing words per prediction

Overview

Depression detection from social-media text is a challenging NLP task because the language of mental health distress is nuanced, often implicit, and varies significantly across platforms. Standard pretrained language models struggle because they are not calibrated for the informal, noisy, and emotionally charged text found on social media.

This project addresses these challenges through a double domain adaptation strategy: the model first adapts from general-domain text to social-media language, then adapts from general social media to mental-health-specific content. Combined with guided masking — which selectively masks tokens during fine-tuning to force robust depression-indicative patterns rather than surface-level shortcuts — the pipeline achieves an F1 score of 0.78.

Beyond accuracy, the project emphasizes explainability. A dedicated pipeline combines Integrated Gradients with LLM-based teacher-student distillation to extract the top-k words that contribute most strongly to each positive detection, making the model's decisions interpretable for clinicians and researchers.

Approach

1

First Domain Adaptation

The base transformer is first adapted from general-domain pretraining to social-media language through continued pretraining on a large corpus of posts, bridging the gap between formal text and the informal, abbreviated, emotionally expressive writing of platforms like Reddit and Twitter.

2

Second Domain Adaptation

The social-media-adapted model undergoes a second adaptation stage focused on mental-health content — depression-related discussions, clinical narratives, and emotional-support communities — sharpening its sensitivity to subtle linguistic markers of distress.

3

Guided Masking

During fine-tuning, guided masking selectively masks tokens to prevent reliance on surface-level lexical shortcuts. Forced to predict with key tokens hidden, the model learns deeper contextual and syntactic patterns, improving generalization to unseen data.

4

Explainability Pipeline

Integrated Gradients computes token-level attribution by interpolating between a baseline and the actual input. These scores are refined through LLM teacher-student distillation, yielding a ranked list of top-k words that most strongly drive each positive prediction.

Results

Detection Performance

The double domain adaptation + guided masking pipeline achieves competitive performance on social-media depression-detection benchmarks.

MetricScore
F1 Score0.78
PrecisionHigh
RecallHigh

Explainability Output

The Integrated Gradients + LLM distillation pipeline successfully extracts interpretable explanations for model predictions.

  • Top-k word extraction identifies the specific tokens driving each positive detection.
  • Attribution scores are computed at the token level via Integrated Gradients interpolation.
  • LLM distillation validates attributions against a larger model's understanding, filtering noise from genuine signal.
  • Results are clinically interpretable, highlighting words consistent with known depression indicators.

Tech Stack

Deep Learning

PyTorchHuggingFace TransformersTransformer Models

NLP Techniques

Domain AdaptationGuided MaskingText Classification

Explainability

Integrated GradientsToken AttributionTeacher-Student Distillation

Tools

PythonCaptumscikit-learnWeights & Biases