Downloads · 30 days
12
2% of all-time downloads
abhinavsarkar/Llama-3.1-8b-bnb-4bit-finetuned-Mental-Health-Counselling-Conversations
Llama-3.1-8b-bnb-4bit-finetuned-Mental-Health-Counselling-Conversations is a text generation model from abhinavsarkar. Use it when you need the model to write or continue text. It is set up for transformers.
This model has been fine-tuned on content related to counseling and mental health topics, aimed at providing empathetic responses to user queries on sensitive matters.
Downloads · 30 days
12
2% of all-time downloads
All-time downloads
543
Public
Parameters
8.2B
5.7 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors5.7 GB · 100%
How the weights are stored.
U87.2B · 87%
From the Hugging Face model README
This model has been fine-tuned on content related to counseling and mental health topics, aimed at providing empathetic responses to user queries on sensitive matters.
This model is a fine-tuned version of [Meta-Llama-3-8B] on a dataset specific to counseling and mental health [Amod/mental_health_counseling_conversations]. It is designed to handle user queries in a supportive, understanding, and empathetic manner, addressing issues such as mental health, personal growth, and emotional support.
This model can be used for generating responses to queries related to mental health, counseling, and personal support. It provides empathetic, understanding, and supportive responses for users seeking advice or help with personal issues.
The model can be incorporated into chatbots or virtual assistants aimed at mental health support, initial counseling, and advice applications. Avoid relying on it for critical mental health advice. It should be deployed as a supplementary resource to help users explore initial support topics, with clear disclaimers that it does not substitute professional help.
You can use the following pieces of code to get started with the model:
!pip install -U bitsandbytes
!pip install -U transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained("abhinavsarkar/Llama3-8b-finetuned-Mental-Health-Counseling-Conversations")
tokenizer = AutoTokenizer.from_pretrained("abhinavsarkar/Llama3-8b-finetuned-Mental-Health-Counseling-Conversations")
prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
<|Instruction|>
{}
|<Input|>
{}
<|Response|>
{}
"""
input_text = "I have so many issues to address. I have a history of sexual abuse, I’m a breast cancer survivor and I am a lifetime insomniac. I have a long history of depression and I’m beginning to have anxiety. I have low self esteem but I’ve been happily married for almost 35 years. I’ve never had counseling about any of this. Do I have too many issues to address in counseling?"
inputs = tokenizer([
prompt.format(
"You are a Therapist. Respond empathetically and supportively to the user's statement, considering the context of a mental health counseling session", # instruction
input_text, # input
"", # output - leave this blank for generation!
)
], return_tensors="pt").to("cuda" if torch.cuda.is_available() else "cpu")
with torch.no_grad():
output = model.generate(**inputs, max_new_tokens=512)
response = tokenizer.decode(output[0], skip_special_tokens=True)
start_token = "<|Response|>"
end_token = "<|End|>"
start_idx = response.find(start_token) + len(start_token)
end_idx = response.find(end_token)
final_response = response[start_idx:end_idx].strip()
print(final_response)
If you get an error related to bits and bytes while loading the model, install bitsandbytes and restart your session.
!pip install -U bitsandbytes
After restarting, try loading the model again; it will work fine
If you get an error "Using bitsandbytes 4-bit quantization requires the latest version of bitsandbytes: pip install -U bitsandbytes" try updating transformers
!pip install -U transformers
After restarting, try loading the model again; it will work fine
The model was fine-tuned on a carefully curated dataset related to mental health, personal support, and counseling topics to provide an empathetic and supportive tone [Amod/mental_health_counseling_conversations].
The model was fine-tuned using the Hugging Face Transformers library on a cluster of two T4 GPUs. Mixed precision was used for efficient computation, with a batch size of [2], gradient accumulation steps of [4] and a learning rate of [2e-4].
This model is based on Meta-Llama-3-8B-bnb-4bit, fine-tuned for causal language modeling.
Two T4 GPUs were used in a Kaggle environment for training and fine-tuning.
The model was fine-tuned with PyTorch and Hugging Face’s Transformers library.
For additional details, please contact https://www.linkedin.com/in/abhinavsarkarrr/.