Downloads · 30 days
5
19% of all-time downloads
kasunw/mental-health-mistral-7b-instructv0.2-finetuned-V2
mental-health-mistral-7b-instructv0.2-finetuned-V2 is a machine learning model from kasunw. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
should probably proofread and complete it, then remove this comment. --
Downloads · 30 days
5
19% of all-time downloads
All-time downloads
26
Public
Repo size
82.3 MB
Likes
0
Public
Click a slice to open those files.
.safetensors27.3 MB · 91%
From the Hugging Face model README
This model is a fine-tuned version of mistralai/Mistral-7B-Instruct-v0.2 on the mental_health_counseling_conversations dataset. It achieves the following results on the evaluation set:
More information needed
More information needed
More information needed
The training and inference procedure can be found in this notebook
The following hyperparameters were used during training:
| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 1.4315 | 1.0 | 352 | 0.9047 |
| 1.2645 | 2.0 | 704 | 0.7044 |
| 1.1876 | 3.0 | 1056 | 0.6476 |
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftConfig, PeftModel
base_model = "mistralai/Mistral-7B-Instruct-v0.2"
adapter = "kasunw/mental-health-mistral-7b-instructv0.2-finetuned-V2"
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained(
base_model,
add_bos_token=True,
trust_remote_code=True,
padding_side='left'
)
# Create peft model using base_model and finetuned adapter
config = PeftConfig.from_pretrained(adapter)
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path,
load_in_4bit=True,
device_map='auto',
torch_dtype='auto')
model = PeftModel.from_pretrained(model, adapter)
device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device)
model.eval()
# Prompt content:
messages = [
{"role": "user", "content": "Hey Connor! I have been feeling a bit down lately.I could really use some advice on how to feel better?"}
]
input_ids = tokenizer.apply_chat_template(conversation=messages,
tokenize=True,
add_generation_prompt=True,
return_tensors='pt').to(device)
output_ids = model.generate(input_ids=input_ids, max_new_tokens=512, do_sample=True, pad_token_id=2)
response = tokenizer.batch_decode(output_ids.detach().cpu().numpy(), skip_special_tokens = True)
# Model response:
print(response[0])