Improving RAG for LLM-based Mental Health Risk Detection through Contrastive Embeddings
Abstract
Users can disclose psychological suffering or suicidal intentions during interactions with Large Language Models (LLMs). Therefore, it is important to enable LLMs to recognize suicide and depression risks, which can support early intervention. To avoid costly backbone fine-tuning, retrieval-augmented generation (RAG) has been adopted to enhance prompts with retrieved information. However, in mental health risk detection, texts that are semantically similar but correspond to opposite risk labels can lead RAG to introduce misleading retrieval evidence. In this study, we propose a framework that leverages contrastive learning to reduce the retrieval ambiguity suffered from RAG. Our experiments compare four contrastive embedding variants across two datasets using five evaluation metrics. Results show RAG can improve accuracy over vanilla prompting, with contrastive embeddings providing additional gains. Notably, small LLMs with RAG augmentation achieve comparable performance to larger models without augmentation, demonstrating clear cost-performance trade-offs. Our framework offers a practical guidance for balancing retrieval quality and model capacity in detection.