Hrishikesh4/mental-health-classifier-longformerAllenAI/longformer-base-4096The Mental Health Sentiment Analyzer is a specialized text classification model designed to detect early signs of depression, anxiety, stress, and neutral mental states from user-provided journals, reflections, or messages. Leveraging Longformer’s extended context window, it handles long, complex narratives for accurate detection of subtle and overlapping emotional states.
The model addresses the challenge of recognizing mental health struggles in digital interactions. It analyzes voluntary text inputs—such as journals, self-reflections, or chatbot conversations—to identify patterns of stress, anxiety, or depression. Depending on user consent, it can provide self-help recommendations, notify a therapist, or alert an emergency contact. The goal is timely intervention with privacy and ethical use.
Based on Longformer, which uses sparse attention for efficient processing of long texts. The model employs a multi-label classification head to capture overlapping emotional states in long-form entries.
Load and use the model with Hugging Face Transformers:
from transformers import LongformerTokenizerFast, LongformerForSequenceClassification
import torch
model_name = "Hrishikesh4/mental-health-classifier-longformer"
model = LongformerForSequenceClassification.from_pretrained(model_name)
tokenizer = LongformerTokenizerFast.from_pretrained(model_name)
text = "I’ve been feeling overwhelmed with work and can’t sleep properly."
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.sigmoid(outputs.logits)
print(predictions)
Use responsibly and communicate that this is not a medical tool. Users in distress should be directed to qualified professionals. Integrations should include user consent, privacy protection, and crisis resources.
If you use this model, please cite:
@misc{kurapati2025MentalHealthSentimentAnalyzer,
author = {Hrishikesh Kurapati},
title = {Mental Health Sentiment Analyzer (Longformer-based)},
year = {2025},
url = {https://huggingface.co/Hrishikesh4/mental-health-classifier-longformer}
}
model.safetensors 595 MBmodel_after_first_finetuning.safetensors 595 MBallenai/longformer-base-4096