Update README.md
Browse files
README.md
CHANGED
|
@@ -1,162 +1,65 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
| 2 |
tags:
|
| 3 |
-
- llama
|
| 4 |
-
-
|
| 5 |
-
-
|
| 6 |
-
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
datasets:
|
| 14 |
-
- Lumiiree/therapod-dpo
|
| 15 |
-
inference: true
|
| 16 |
---
|
| 17 |
|
| 18 |
-
#
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
## π§ Model Details
|
| 25 |
-
|
| 26 |
-
- **Base Model**: [`meta-llama/Llama-3.2-3B-Instruct`](https://huggingface.co/meta-llama/Llama-3.2-3B-Instruct)
|
| 27 |
-
- **Fine-Tuning Method**: LoRA (Low-Rank Adaptation)
|
| 28 |
-
- **Dataset**: [`Lumiiree/therapod-dpo`](https://huggingface.co/datasets/Lumiiree/therapod-dpo)
|
| 29 |
-
- **Use Case**: Empathetic responses, journaling prompts, CBT-style thought reframing
|
| 30 |
-
- **Trained by**: [Thillai Chithambaram](https://huggingface.co/thillaic)
|
| 31 |
-
|
| 32 |
-
---
|
| 33 |
-
|
| 34 |
-
## π§ Intended Use
|
| 35 |
-
|
| 36 |
-
This model can be integrated into:
|
| 37 |
-
|
| 38 |
-
- π¬ **Mental health chatbots**
|
| 39 |
-
- π **Journaling apps with AI reflections**
|
| 40 |
-
- π§ **Self-help tools for cognitive restructuring**
|
| 41 |
-
- π§ββοΈ **Therapist assistants (non-clinical use)**
|
| 42 |
-
|
| 43 |
-
> β οΈ **Disclaimer**: This model is not a replacement for licensed mental health professionals. It should be used only as an assistant or for research.
|
| 44 |
-
|
| 45 |
-
---
|
| 46 |
|
| 47 |
-
##
|
| 48 |
-
|
| 49 |
-
### β
LoRA Settings
|
| 50 |
-
```python
|
| 51 |
-
peft_config = LoraConfig(
|
| 52 |
-
r=8,
|
| 53 |
-
lora_alpha=16,
|
| 54 |
-
target_modules=["q_proj", "v_proj"],
|
| 55 |
-
lora_dropout=0.05,
|
| 56 |
-
bias="none",
|
| 57 |
-
task_type="CAUSAL_LM",
|
| 58 |
-
)
|
| 59 |
-
```
|
| 60 |
-
|
| 61 |
-
### β
TrainingArguments
|
| 62 |
-
```python
|
| 63 |
-
args = TrainingArguments(
|
| 64 |
-
output_dir="llama-cbt-checkpoints",
|
| 65 |
-
per_device_train_batch_size=1,
|
| 66 |
-
gradient_accumulation_steps=4,
|
| 67 |
-
learning_rate=2e-5,
|
| 68 |
-
num_train_epochs=1,
|
| 69 |
-
logging_steps=100,
|
| 70 |
-
save_strategy="epoch",
|
| 71 |
-
bf16=True,
|
| 72 |
-
optim="paged_adamw_8bit",
|
| 73 |
-
)
|
| 74 |
-
```
|
| 75 |
-
|
| 76 |
-
> Training was performed using Hugging Face's `transformers` + `peft` libraries with LoRA applied to key attention modules for lightweight adaptation.
|
| 77 |
-
|
| 78 |
-
---
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
```python
|
| 83 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
| 84 |
-
|
| 85 |
-
model_id = "thillaic/CBT-Copilot"
|
| 86 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 87 |
-
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 88 |
-
|
| 89 |
-
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 90 |
-
|
| 91 |
-
prompt = "I feel overwhelmed and stuck lately. What should I do?"
|
| 92 |
-
response = pipe(prompt, max_new_tokens=200, do_sample=True, temperature=0.7)
|
| 93 |
-
|
| 94 |
-
print(response[0]['generated_text'])
|
| 95 |
-
```
|
| 96 |
-
|
| 97 |
-
---
|
| 98 |
-
|
| 99 |
-
## π‘ Example Prompts
|
| 100 |
-
|
| 101 |
-
- "I often feel like Iβm not good enough. Help me reframe this thought."
|
| 102 |
-
- "Give me a CBT-style journaling prompt for today."
|
| 103 |
-
- "How can I deal with negative self-talk?"
|
| 104 |
-
|
| 105 |
-
---
|
| 106 |
-
|
| 107 |
-
## β‘ Inference with vLLM
|
| 108 |
-
|
| 109 |
-
This model is **compatible with [vLLM](https://github.com/vllm-project/vllm)** β a fast and memory-efficient inference engine for LLMs.
|
| 110 |
-
|
| 111 |
-
### π Quick Start with vLLM
|
| 112 |
|
| 113 |
```bash
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
python -m vllm.entrypoints.api_server \
|
| 117 |
-
--model thillaic/CBT-Copilot
|
| 118 |
```
|
| 119 |
|
| 120 |
-
|
| 121 |
|
| 122 |
```python
|
| 123 |
import openai
|
| 124 |
|
|
|
|
| 125 |
openai.api_base = "http://localhost:8000/v1"
|
| 126 |
-
openai.api_key = "EMPTY" # not needed for local use
|
| 127 |
|
| 128 |
response = openai.ChatCompletion.create(
|
| 129 |
-
model="
|
| 130 |
messages=[
|
| 131 |
-
{"role": "
|
| 132 |
-
{"role": "user", "content": "I'm feeling anxious lately. What should I do?"}
|
| 133 |
]
|
| 134 |
)
|
| 135 |
|
| 136 |
-
print(response
|
| 137 |
```
|
| 138 |
|
| 139 |
-
|
| 140 |
|
| 141 |
-
|
| 142 |
|
| 143 |
-
|
| 144 |
|
| 145 |
-
|
| 146 |
|
| 147 |
-
## π Acknowledgements
|
| 148 |
-
|
| 149 |
-
- Fine-tuned on the excellent [`therapod-dpo`](https://huggingface.co/datasets/Lumiiree/therapod-dpo) dataset
|
| 150 |
-
- Built using Metaβs LLaMA 3.2B base model
|
| 151 |
-
- LoRA integration powered by Hugging Face PEFT
|
| 152 |
|
| 153 |
---
|
| 154 |
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
- π€ Model: [huggingface.co/thillaic/CBT-Copilot](https://huggingface.co/thillaic/CBT-Copilot)
|
| 158 |
-
- π Dataset: [Lumiiree/therapod-dpo](https://huggingface.co/datasets/Lumiiree/therapod-dpo)
|
| 159 |
|
| 160 |
---
|
| 161 |
|
| 162 |
-
*
|
|
|
|
| 1 |
---
|
| 2 |
+
language: en
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
library_name: transformers
|
| 5 |
tags:
|
| 6 |
+
- llama
|
| 7 |
+
- causal-lm
|
| 8 |
+
- merged
|
| 9 |
+
- vllm
|
| 10 |
+
inference:
|
| 11 |
+
parameters:
|
| 12 |
+
max_new_tokens: 256
|
| 13 |
+
temperature: 0.7
|
| 14 |
+
top_p: 0.9
|
| 15 |
+
repetition_penalty: 1.1
|
|
|
|
|
|
|
|
|
|
| 16 |
---
|
| 17 |
|
| 18 |
+
# CBT-Copilot π§
|
| 19 |
|
| 20 |
+
CBT-Copilot is a fine-tuned version of `meta-llama/Llama-3.2-3B-Instruct`, designed to simulate conversations for cognitive behavioral therapy (CBT) support. It has been trained using LoRA and merged into a standalone model.
|
| 21 |
|
| 22 |
+
The model is now compatible with `transformers`, `vLLM`, and other inference frameworks.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
## π How to Use (vLLM)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
You can serve it with [vLLM](https://github.com/vllm-project/vllm):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
```bash
|
| 29 |
+
python3 -m vllm.entrypoints.openai.api_server --model your-username/CBT-Copilot
|
|
|
|
|
|
|
|
|
|
| 30 |
```
|
| 31 |
|
| 32 |
+
Then query it like this:
|
| 33 |
|
| 34 |
```python
|
| 35 |
import openai
|
| 36 |
|
| 37 |
+
openai.api_key = "EMPTY"
|
| 38 |
openai.api_base = "http://localhost:8000/v1"
|
|
|
|
| 39 |
|
| 40 |
response = openai.ChatCompletion.create(
|
| 41 |
+
model="CBT-Copilot",
|
| 42 |
messages=[
|
| 43 |
+
{"role": "user", "content": "I've been feeling really anxious lately. What can I do?"}
|
|
|
|
| 44 |
]
|
| 45 |
)
|
| 46 |
|
| 47 |
+
print(response["choices"][0]["message"]["content"])
|
| 48 |
```
|
| 49 |
|
| 50 |
+
## π§ Intended Use
|
| 51 |
|
| 52 |
+
This model is intended for educational and prototyping purposes in mental health-related chatbot systems. It is **not a substitute for professional therapy**.
|
| 53 |
|
| 54 |
+
## π License
|
| 55 |
|
| 56 |
+
This model is licensed under the Apache 2.0 license.
|
| 57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
---
|
| 60 |
|
| 61 |
+
*Model prepared and fine-tuned by **Thillai Chithambaram***
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
---
|
| 64 |
|
| 65 |
+
**Made by ThillaiC**
|