BEncoderRT commited on
Commit
b6114f8
·
verified ·
1 Parent(s): 51e5764

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +85 -1
README.md CHANGED
@@ -9,4 +9,88 @@ datasets:
9
  - ShenLab/MentalChat16K
10
  tags:
11
  - usloth
12
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  - ShenLab/MentalChat16K
10
  tags:
11
  - usloth
12
+ metrics:
13
+ - accuracy
14
+ ---
15
+ # TinyLlama MentalChat LoRA
16
+
17
+ This repository contains a **LoRA adapter** fine-tuned on the
18
+ [ShenLab/MentalChat16K](https://huggingface.co/datasets/ShenLab/MentalChat16K)
19
+ dataset for **mental health–related supportive dialogue**.
20
+
21
+ ⚠️ This is **not a full model**. It is a lightweight LoRA adapter that must be
22
+ used together with the base model.
23
+
24
+ ---
25
+
26
+ ## 🔍 Model Overview
27
+
28
+ - **Base Model**: TinyLlama/TinyLlama-1.1B-Chat-v1.0
29
+ - **Fine-tuning Method**: LoRA (PEFT)
30
+ - **Domain**: Mental health supportive conversations
31
+ - **Language**: English
32
+ - **Parameter Size (Adapter)**: ~50MB
33
+
34
+ ---
35
+
36
+ ## 📚 Training Data
37
+
38
+ The model was fine-tuned using the **MentalChat16K** dataset, which consists of
39
+ mental health–related conversations between users and assistants.
40
+
41
+ - Dataset: `ShenLab/MentalChat16K`
42
+ - Language: English
43
+ - Task: Supportive, empathetic responses in mental health contexts
44
+
45
+ ---
46
+
47
+ ## 🚀 Usage
48
+
49
+ ### Load Base Model + LoRA Adapter
50
+
51
+ from unsloth import FastLanguageModel
52
+ from peft import PeftModel
53
+ import torch
54
+
55
+ # Base model
56
+ base_model, tokenizer = FastLanguageModel.from_pretrained(
57
+ "TinyLlama/TinyLlama-1.1B-Chat-v1.0",
58
+ max_seq_length=2048,
59
+ load_in_4bit=True,
60
+ )
61
+
62
+ # LoRA model
63
+ lora_model = PeftModel.from_pretrained(
64
+ base_model,
65
+ "BEncoderRT/tinyllama-mentalchat-lora",
66
+ )
67
+
68
+ FastLanguageModel.for_inference(lora_model)
69
+ FastLanguageModel.for_inference(base_model)
70
+
71
+ def generate(model, prompt, max_new_tokens=200):
72
+ inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
73
+
74
+ with torch.no_grad():
75
+ outputs = model.generate(
76
+ **inputs,
77
+ max_new_tokens=max_new_tokens,
78
+ do_sample=True,
79
+ temperature=0.7,
80
+ top_p=0.9,
81
+ )
82
+
83
+ return tokenizer.decode(outputs[0], skip_special_tokens=True)
84
+
85
+ prompt = """### Instruction:
86
+ I feel empty and hopeless lately. Nothing seems meaningful.
87
+
88
+ ### Response:
89
+ """
90
+
91
+ print("=== Base Model ===")
92
+ print(generate(base_model, prompt))
93
+
94
+ print("\n=== LoRA Model ===")
95
+ print(generate(lora_model, prompt))
96
+