Update README.md
Browse files
README.md
CHANGED
@@ -3,32 +3,37 @@ license: apache-2.0
|
|
3 |
library_name: peft
|
4 |
tags:
|
5 |
- generated_from_trainer
|
|
|
|
|
|
|
6 |
base_model: mistralai/Mistral-7B-Instruct-v0.2
|
7 |
model-index:
|
8 |
- name: mental-health-mistral-7b-instructv0.2-finetuned-V2
|
9 |
results: []
|
10 |
---
|
11 |
|
12 |
-
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
13 |
-
should probably proofread and complete it, then remove this comment. -->
|
14 |
|
15 |
# mental-health-mistral-7b-instructv0.2-finetuned-V2
|
16 |
|
17 |
-
This model is a fine-tuned version of [mistralai/Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2) on the
|
18 |
It achieves the following results on the evaluation set:
|
19 |
- Loss: 0.6432
|
20 |
|
21 |
-
## Model description
|
22 |
|
23 |
-
|
|
|
24 |
|
25 |
-
## Intended uses & limitations
|
26 |
|
27 |
-
|
28 |
|
29 |
## Training and evaluation data
|
30 |
|
31 |
-
|
|
|
|
|
|
|
32 |
|
33 |
## Training procedure
|
34 |
|
@@ -53,6 +58,46 @@ The following hyperparameters were used during training:
|
|
53 |
| 1.2608 | 2.0 | 704 | 0.6956 |
|
54 |
| 1.1845 | 3.0 | 1056 | 0.6432 |
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
### Framework versions
|
58 |
|
|
|
3 |
library_name: peft
|
4 |
tags:
|
5 |
- generated_from_trainer
|
6 |
+
- mistral
|
7 |
+
- text-generation
|
8 |
+
- Transformers
|
9 |
base_model: mistralai/Mistral-7B-Instruct-v0.2
|
10 |
model-index:
|
11 |
- name: mental-health-mistral-7b-instructv0.2-finetuned-V2
|
12 |
results: []
|
13 |
---
|
14 |
|
|
|
|
|
15 |
|
16 |
# mental-health-mistral-7b-instructv0.2-finetuned-V2
|
17 |
|
18 |
+
This model is a fine-tuned version of [mistralai/Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2) on the [mental_health_counseling_conversations](https://huggingface.co/datasets/Amod/mental_health_counseling_conversations) dataset.
|
19 |
It achieves the following results on the evaluation set:
|
20 |
- Loss: 0.6432
|
21 |
|
22 |
+
## Model description
|
23 |
|
24 |
+
A Mistral-7B-Instruct-v0.2 model finetuned on a corpus of mental health conversations between a psychologist and a user.
|
25 |
+
The intention was to create a mental health assistant, "Connor", to address user questions based on responses from a psychologist.
|
26 |
|
27 |
+
## Intended uses & limitations
|
28 |
|
29 |
+
Intended to be used as a mental health chatbot to respond to user queries.
|
30 |
|
31 |
## Training and evaluation data
|
32 |
|
33 |
+
The model is finetuned on a corpus of mental health conversations between a psychologist and a client, in the form of context - response pairs. This dataset is a collection of questions and answers sourced from two online counseling and therapy platforms. The questions cover a wide range of mental health topics, and the answers are provided by qualified psychologists.
|
34 |
+
Dataset found here :-
|
35 |
+
* [Kaggle](https://www.kaggle.com/datasets/thedevastator/nlp-mental-health-conversations)
|
36 |
+
* [Huggingface](https://huggingface.co/datasets/Amod/mental_health_counseling_conversations)
|
37 |
|
38 |
## Training procedure
|
39 |
|
|
|
58 |
| 1.2608 | 2.0 | 704 | 0.6956 |
|
59 |
| 1.1845 | 3.0 | 1056 | 0.6432 |
|
60 |
|
61 |
+
# Usage
|
62 |
+
|
63 |
+
```python
|
64 |
+
import torch
|
65 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
66 |
+
from peft import PeftConfig, PeftModel
|
67 |
+
|
68 |
+
base_model = "mistralai/Mistral-7B-Instruct-v0.2"
|
69 |
+
adapter = "GRMenon/mental-health-mistral-7b-instructv0.2-finetuned-V2"
|
70 |
+
|
71 |
+
# Load tokenizer
|
72 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
73 |
+
base_model,
|
74 |
+
add_bos_token=True,
|
75 |
+
trust_remote_code=True,
|
76 |
+
padding_side='left'
|
77 |
+
)
|
78 |
+
|
79 |
+
# Create peft model using base_model and finetuned adapter
|
80 |
+
config = PeftConfig.from_pretrained(adapter)
|
81 |
+
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, load_in_4bit=True, device_map='auto', torch_dtype='auto')
|
82 |
+
model = PeftModel.from_pretrained(model, adapter)
|
83 |
+
|
84 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
85 |
+
model.to(device)
|
86 |
+
model.eval()
|
87 |
+
|
88 |
+
# Prompt content:
|
89 |
+
messages = [
|
90 |
+
{"role": "user", "content": "Hey Connor! I have been feeling a bit down lately. I could really use some advice on how to feel better?"}
|
91 |
+
]
|
92 |
+
|
93 |
+
input_ids = tokenizer.apply_chat_template(conversation=messages, tokenize=True, add_generation_prompt=True, return_tensors='pt').to(device)
|
94 |
+
output_ids = model.generate(input_ids=input_ids, max_new_tokens=512, do_sample=True, pad_token_id=2)
|
95 |
+
response = tokenizer.batch_decode(output_ids.detach().cpu().numpy(), skip_special_tokens = True)
|
96 |
+
|
97 |
+
# Model response:
|
98 |
+
print(response[0])
|
99 |
+
```
|
100 |
+
|
101 |
|
102 |
### Framework versions
|
103 |
|