Views
No views yet
google/gemma-2-9b-it for mental health diagnosis using instruction-style QLoRA tuning. This model takes in user statements and predicts the most likely mental disorder in a structured dialogue format.google/gemma-2-9b-itbitsandbytes)["q_proj", "k_proj", "v_proj", "o_proj"]⚠️ Disclaimer: This model is for research and educational purposes only. It is not intended for use in real-world clinical diagnosis without medical supervision.
1from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3import torch
4
5# Load tokenizer and base + adapter model
6tokenizer = AutoTokenizer.from_pretrained("Jaamie/gemma_mental_health_qlora_v2")
7base_model = AutoModelForCausalLM.from_pretrained("google/gemma-2-9b-it", device_map="auto", torch_dtype=torch.float16)
8model = PeftModel.from_pretrained(base_model, "Jaamie/gemma_mental_health_qlora_v2")
9
10# Inference example
11prompt = "User: I can't sleep and my thoughts are spiraling out of control.\nDiagnosed Mental Disorder:"
12inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
13
14with torch.no_grad():
15 outputs = model.generate(**inputs, max_new_tokens=30)
16
17print(tokenizer.decode(outputs[0], skip_special_tokens=True))
18
19
20🏋️ Training Details
21Epochs: 2
22
23Batch Size: 4 (with gradient_accumulation_steps = 2)
24
25Max Length: 512
26
27Quantization: 4-bit QLoRA (NF4) with bitsandbytes
28
29Precision: bf16
30
31
32# Evaluation Results
33
34Metric Score
35Training Loss 3.74
36Validation Loss 3.79
37Total Examples ~22,000
38
39
40The LLM has been trained on a sample of data from the dataset containing balanced instruction-style dataset with labeled disorders.
41
42Mental Health Class Sample Count
43Depression 4,000
44Anxiety 4,000
45Suicidal Thoughts 3,000
46Personality Disorder 2,000
47Bipolar 2,000
48Stress 2,000
49Normal 5,000
50
51# Contact
52Created by Jaamie Maarsh Joy Martin
53
54🌐 https://www.linkedin.com/in/jaamie-maarsh-joy-martin/
55
56📧 jaamiemaarsh@gmail.com
57