Update README.md
Browse files
README.md
CHANGED
|
@@ -1,67 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
-
|
| 7 |
-
-
|
| 8 |
-
-
|
| 9 |
-
-
|
| 10 |
-
|
| 11 |
-
parameters:
|
| 12 |
-
max_new_tokens: 256
|
| 13 |
-
temperature: 0.7
|
| 14 |
-
top_p: 0.9
|
| 15 |
-
repetition_penalty: 1.1
|
| 16 |
-
datasets:
|
| 17 |
-
- Lumiiree/therapod-dpo
|
| 18 |
-
base_model:
|
| 19 |
-
- meta-llama/Llama-3.2-3B-Instruct
|
| 20 |
---
|
| 21 |
|
| 22 |
-
#
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
```
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
```python
|
| 39 |
-
import
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
]
|
| 49 |
-
)
|
| 50 |
|
| 51 |
-
print(response[
|
| 52 |
```
|
| 53 |
|
| 54 |
-
|
| 55 |
|
| 56 |
-
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
|
| 61 |
|
|
|
|
| 62 |
|
| 63 |
---
|
| 64 |
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
-
|
|
|
|
| 1 |
+
# π§ CBT-Copilot: LLaMA 3.2B Fine-Tuned for Cognitive Therapy
|
| 2 |
+
|
| 3 |
+
Welcome to **CBT-Copilot**, an open-source LLM fine-tuned on therapy-aligned dialogues using the [Lumiiree/therapod-dpo](https://huggingface.co/datasets/Lumiiree/therapod-dpo) dataset. This model is designed to act as a **compassionate and supportive AI assistant**, trained in the tone of cognitive behavioral therapy (CBT), and suitable for mental health support applications.
|
| 4 |
+
|
| 5 |
---
|
| 6 |
+
|
| 7 |
+
## π§ Model Details
|
| 8 |
+
|
| 9 |
+
- **Base Model**: [`meta-llama/Llama-3.2-3B-Instruct`](https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct)
|
| 10 |
+
- **Fine-Tuning Method**: LoRA (Low-Rank Adaptation)
|
| 11 |
+
- **Dataset**: [`Lumiiree/therapod-dpo`](https://huggingface.co/datasets/Lumiiree/therapod-dpo)
|
| 12 |
+
- **Use Case**: Empathetic responses, journaling prompts, CBT-style thought reframing
|
| 13 |
+
- **Trained by**: [Thillai Chithambaram](https://huggingface.co/thillaic)
|
| 14 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
---
|
| 16 |
|
| 17 |
+
## π§ Intended Use
|
| 18 |
+
|
| 19 |
+
This model can be integrated into:
|
| 20 |
|
| 21 |
+
- π¬ **Mental health chatbots**
|
| 22 |
+
- π **Journaling apps with AI reflections**
|
| 23 |
+
- π§ **Self-help tools for cognitive restructuring**
|
| 24 |
+
- π§ββοΈ **Therapist assistants (non-clinical use)**
|
| 25 |
|
| 26 |
+
> β οΈ **Disclaimer**: This model is not a replacement for licensed mental health professionals. It should be used only as an assistant or for research.
|
| 27 |
|
| 28 |
+
---
|
| 29 |
|
| 30 |
+
## ποΈ Training Configuration
|
| 31 |
|
| 32 |
+
### β
LoRA Settings
|
| 33 |
+
```python
|
| 34 |
+
peft_config = LoraConfig(
|
| 35 |
+
r=8,
|
| 36 |
+
lora_alpha=16,
|
| 37 |
+
target_modules=["q_proj", "v_proj"],
|
| 38 |
+
lora_dropout=0.05,
|
| 39 |
+
bias="none",
|
| 40 |
+
task_type="CAUSAL_LM",
|
| 41 |
+
)
|
| 42 |
```
|
| 43 |
|
| 44 |
+
### β
TrainingArguments
|
| 45 |
+
```python
|
| 46 |
+
args = TrainingArguments(
|
| 47 |
+
output_dir="llama-cbt-checkpoints",
|
| 48 |
+
per_device_train_batch_size=1,
|
| 49 |
+
gradient_accumulation_steps=4,
|
| 50 |
+
learning_rate=2e-5,
|
| 51 |
+
num_train_epochs=1,
|
| 52 |
+
logging_steps=100,
|
| 53 |
+
save_strategy="epoch",
|
| 54 |
+
bf16=True,
|
| 55 |
+
optim="paged_adamw_8bit",
|
| 56 |
+
)
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
> Training was performed using Hugging Face's `transformers` + `peft` libraries with LoRA applied to key attention modules for lightweight adaptation.
|
| 60 |
+
|
| 61 |
+
---
|
| 62 |
+
|
| 63 |
+
## π How to Use
|
| 64 |
|
| 65 |
```python
|
| 66 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
| 67 |
|
| 68 |
+
model_id = "thillaic/CBT-Copilot"
|
| 69 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 70 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 71 |
|
| 72 |
+
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 73 |
+
|
| 74 |
+
prompt = "I feel overwhelmed and stuck lately. What should I do?"
|
| 75 |
+
response = pipe(prompt, max_new_tokens=200, do_sample=True, temperature=0.7)
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
print(response[0]['generated_text'])
|
| 78 |
```
|
| 79 |
|
| 80 |
+
---
|
| 81 |
|
| 82 |
+
## π‘ Example Prompts
|
| 83 |
|
| 84 |
+
- "I often feel like Iβm not good enough. Help me reframe this thought."
|
| 85 |
+
- "Give me a CBT-style journaling prompt for today."
|
| 86 |
+
- "How can I deal with negative self-talk?"
|
| 87 |
+
|
| 88 |
+
---
|
| 89 |
|
| 90 |
+
## π§Ύ License
|
| 91 |
|
| 92 |
+
This project is open-sourced for educational and research purposes under the **MIT License**.
|
| 93 |
|
| 94 |
---
|
| 95 |
|
| 96 |
+
## π Acknowledgements
|
| 97 |
+
|
| 98 |
+
- Fine-tuned on the excellent [`therapod-dpo`](https://huggingface.co/datasets/Lumiiree/therapod-dpo) dataset
|
| 99 |
+
- Built using Metaβs LLaMA 3.2B base model
|
| 100 |
+
- LoRA integration powered by Hugging Face PEFT
|
| 101 |
+
|
| 102 |
+
---
|
| 103 |
+
|
| 104 |
+
## π Links
|
| 105 |
+
|
| 106 |
+
- π€ Model: [huggingface.co/thillaic/CBT-Copilot](https://huggingface.co/thillaic/CBT-Copilot)
|
| 107 |
+
- π Dataset: [Lumiiree/therapod-dpo](https://huggingface.co/datasets/Lumiiree/therapod-dpo)
|
| 108 |
+
|
| 109 |
+
---
|
| 110 |
|
| 111 |
+
*Crafted with care by Thillai Chithambaram for the future of compassionate AI.*
|