LLM and NLP, 2026

Bilingual Mental Wellness Chatbot

Working prototypeFinal-year project, BSc (Hons) Data Science, University of Plymouth

Supportive conversation in Sinhala and English from a locally hosted, QLoRA-tuned Qwen2.5-7B, with a deterministic safety route that bypasses the model for high-risk messages.

Message inI feel lonely at night and I keep overthinking.
  1. Detect language
  2. Translate to English
  3. Recognise emotion
  4. Check riskbefore the model
  5. Respond
  6. Translate back

Real messages and responses from the running system, including its API output. The crisis route returns a fixed message with Sri Lanka's 1926 helpline.
Qwen2.5-7B-Instruct, fine-tuned with QLoRA on one 12 GB GPU
7B
LoRA rank and alpha, on the attention and feed-forward projections
16 · 32
Quantised GGUF served locally through Ollama
Q4_K_M
Sri Lanka's National Mental Health Helpline, returned on the crisis route
1926

The problem

Most mental wellness chatbots are built for English speakers. For many people in Sri Lanka that means describing how they feel in their second language, which is exactly when language matters most. Even when translation is added, emotional nuance gets lost and the replies can sound mechanical.

The project asked how a bilingual chatbot could give warm, human replies in Sinhala and English, notice emotional state, route high-risk messages safely and respect privacy, without ever claiming to diagnose or treat anyone.

The constraint

In this domain the failure that matters is not a clumsy sentence. It is missing a person at risk. The architecture had to put safety in front of generation, not behind it.

Conversations are also sensitive. Storing what people write could not be the default.

And the model had to run locally on the hardware available: one RTX 3080 with 12 GB of memory. Full fine-tuning of a seven-billion-parameter model does not fit.

The decision

A message travels through the pipeline in this order:

  1. Detect the language. The backend checks for Sinhala characters.
  2. Translate to English. Sinhala goes through Google Cloud Translation. A local NLLB model was tried first and produced broken Sinhala on longer emotional replies, and LLM-based translation was inconsistent, so both were replaced. Token protection keeps numbers, links and the 1926 helpline intact.
  3. Recognise emotion. A RoBERTa classifier trained on GoEmotions labels the message, and its labels are mapped to practical categories such as sad, anxious, angry, confused, positive and neutral. It adds context and is never used to diagnose.
  4. Check for risk, before the model. A rule-based detector looks for direct crisis expressions. A high-risk message never reaches the LLM. It gets a fixed response with immediate support guidance and Sri Lanka’s National Mental Health Helpline, 1926.
  5. Generate. Everything else goes to qwen-friendly-300, a Qwen2.5-7B-Instruct fine-tuned with QLoRA and served through Ollama.
  6. Translate back into Sinhala when the conversation started in Sinhala.

The model was trained in WSL2 on Ubuntu with Hugging Face Transformers, 4-bit loading through bitsandbytes, and PEFT and TRL for LoRA supervised fine-tuning. The adapter targeted the attention and feed-forward projections (q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj) with rank 16, alpha 32 and dropout 0.05. It was merged with the base model, converted to GGUF with llama.cpp and quantised to Q4_K_M for Ollama.

Privacy is handled by minimisation. Sessions and emotion metadata go to SQLite, while message text is not stored unless both the application settings and the user allow it, and the final interface does not ask. Development controls such as debug output and model toggles were removed from the interface, because a person looking for support should not have to think about them.

The outcome

A working bilingual prototype with a React and TypeScript interface, a FastAPI backend, local generation through Ollama, Google-based Sinhala translation, emotion recognition, a deterministic crisis route and privacy-safe defaults.

Asked “I feel lonely at night and I keep overthinking.”, the running system labelled the message sad with a confidence of 0.75, assessed the risk as low, and answered through the fine-tuned model: “That sounds tough. Try speaking to someone you trust tomorrow morning. Maybe it’s a close friend or your partner. Even just talking about the worry helps lighten the load. What do you think about that?”

The limits are written down plainly. The model was fine-tuned on a 300-example smoke-test set, which proved the pipeline and the warmer style but is not enough for stable behaviour everywhere. The recommended next step is 1,500 to 3,000 reviewed examples, including native Sinhala conversations, followed by structured human evaluation for empathy, clarity and safety.