Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,199 +1,149 @@
|
|
| 1 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
library_name: transformers
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
##
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
|
| 40 |
-
|
| 41 |
|
| 42 |
-
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
-
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
|
| 61 |
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
| 65 |
|
| 66 |
-
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
|
| 69 |
|
| 70 |
-
|
| 71 |
|
| 72 |
-
|
| 73 |
|
| 74 |
-
|
| 75 |
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
|
| 81 |
-
|
| 82 |
-
[More Information Needed]
|
| 83 |
-
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
|
| 199 |
-
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
base_model: Mostafa8Mehrabi/qwen3-50m-fp16
|
| 4 |
+
tags:
|
| 5 |
+
- qwen
|
| 6 |
+
- insomnia
|
| 7 |
+
- therapy
|
| 8 |
+
- fine-tuned
|
| 9 |
+
- bf16
|
| 10 |
+
- pytorch
|
| 11 |
+
- text-generation
|
| 12 |
library_name: transformers
|
| 13 |
+
pipeline_tag: text-generation
|
| 14 |
+
model_type: qwen
|
| 15 |
+
language:
|
| 16 |
+
- en
|
| 17 |
+
datasets:
|
| 18 |
+
- Mostafa8Mehrabi/insomnia-dataset-with-cot
|
| 19 |
---
|
| 20 |
|
| 21 |
+
# 🧠 Qwen3-50M Insomnia Therapist
|
| 22 |
|
| 23 |
+
Fine-tuned version of Qwen3-50M specialized for insomnia therapy conversations with Chain of Thought reasoning.
|
| 24 |
|
| 25 |
+
## 🎯 Model Details
|
| 26 |
|
| 27 |
+
- **Base Model**: Mostafa8Mehrabi/qwen3-50m-fp16
|
| 28 |
+
- **Fine-tuned on**: Mostafa8Mehrabi/insomnia-dataset-with-cot
|
| 29 |
+
- **Precision**: BF16
|
| 30 |
+
- **Model Size**: ~50M parameters
|
| 31 |
+
- **Specialization**: Insomnia therapy with Chain of Thought reasoning
|
| 32 |
|
| 33 |
+
## 📊 Training Results
|
| 34 |
|
| 35 |
+
- **Final Training Loss**: 1.1862
|
| 36 |
+
- **Final Validation Loss**: 1.2026013135910034
|
| 37 |
+
- **Training Epochs**: 3
|
| 38 |
+
- **Batch Size**: 4
|
| 39 |
+
- **Learning Rate**: 2e-05
|
| 40 |
+
- **Max Length**: 1024
|
| 41 |
+
- **Precision Used**: BF16
|
| 42 |
|
| 43 |
+
## 🚀 Usage
|
| 44 |
|
| 45 |
+
### Quick Start
|
| 46 |
|
| 47 |
+
```python
|
| 48 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 49 |
+
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
# Load model and tokenizer
|
| 52 |
+
tokenizer = AutoTokenizer.from_pretrained("Mostafa8Mehrabi/qwen3-50m-insomnia-therapist")
|
| 53 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 54 |
+
"Mostafa8Mehrabi/qwen3-50m-insomnia-therapist",
|
| 55 |
+
device_map="auto"
|
| 56 |
+
)
|
| 57 |
|
| 58 |
+
# Generate therapy response
|
| 59 |
+
prompt = '''<|system|>Generate insomnia therapy conversation. Gather sleep information, establish rapport, introduce sleep diary. Include CoT reasoning. Validate-Educate-Recommend-Check format.<|endoftext|>
|
| 60 |
+
<|patient|>I can't sleep at night. I keep thinking about work and worrying about tomorrow.<|endoftext|>
|
| 61 |
+
<|cot|>'''
|
| 62 |
|
| 63 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 64 |
+
with torch.no_grad():
|
| 65 |
+
outputs = model.generate(
|
| 66 |
+
**inputs,
|
| 67 |
+
max_length=400,
|
| 68 |
+
temperature=0.7,
|
| 69 |
+
top_p=0.9,
|
| 70 |
+
do_sample=True,
|
| 71 |
+
pad_token_id=tokenizer.pad_token_id,
|
| 72 |
+
eos_token_id=tokenizer.eos_token_id
|
| 73 |
+
)
|
| 74 |
|
| 75 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 76 |
+
print(response)
|
| 77 |
+
```
|
| 78 |
|
| 79 |
+
## 📝 Format Structure
|
| 80 |
|
| 81 |
+
The model follows a specific conversation format:
|
| 82 |
|
| 83 |
+
- **Input**: `<|system|>` + `<|patient|>`
|
| 84 |
+
- **Output**: `<|cot|>` (Chain of Thought reasoning) + `<|therapist|>` (Therapeutic response)
|
| 85 |
|
| 86 |
+
### Format Example:
|
| 87 |
|
| 88 |
+
```
|
| 89 |
+
<|system|>Generate insomnia therapy conversation...<|endoftext|>
|
| 90 |
+
<|patient|>I can't sleep at night.<|endoftext|>
|
| 91 |
+
<|cot|>Patient reports sleep difficulty. Need to validate concern, gather more information about sleep patterns, potential causes, and establish therapeutic rapport. Should introduce sleep diary concept and provide initial guidance.<|endoftext|>
|
| 92 |
+
<|therapist|>I understand how frustrating it must be to struggle with sleep. This is a common issue that many people face, and I'm here to help you work through it. Can you tell me a bit more about your sleep patterns? For instance, how long have you been experiencing this difficulty, and what typically happens when you try to fall asleep?<|endoftext|>
|
| 93 |
+
```
|
| 94 |
|
| 95 |
+
## 🎯 Key Features
|
| 96 |
|
| 97 |
+
- **Chain of Thought Reasoning**: The model provides transparent reasoning before generating responses
|
| 98 |
+
- **Therapeutic Approach**: Follows evidence-based therapy principles
|
| 99 |
+
- **Validation-Education-Recommendation-Check**: Structured therapeutic format
|
| 100 |
+
- **Optimized Training**: Trained with BF16 precision for efficiency
|
| 101 |
+
- **Specialized Training**: Fine-tuned specifically on insomnia therapy conversations
|
| 102 |
|
| 103 |
+
## ⚙️ Technical Specifications
|
| 104 |
|
| 105 |
+
- **Architecture**: Qwen3 (Transformer-based)
|
| 106 |
+
- **Parameters**: ~50M
|
| 107 |
+
- **Training Precision**: BF16
|
| 108 |
+
- **Context Length**: 1024 tokens
|
| 109 |
+
- **Training Framework**: PyTorch + Transformers
|
| 110 |
+
- **Optimization**: AdamW with warmup
|
| 111 |
|
| 112 |
+
## 🔧 Hardware Requirements
|
| 113 |
|
| 114 |
+
- **Minimum**: 2GB GPU VRAM
|
| 115 |
+
- **Recommended**: 4GB+ GPU VRAM
|
| 116 |
+
- **CPU**: Compatible with CPU inference (slower)
|
| 117 |
|
| 118 |
+
## 📚 Training Data
|
| 119 |
|
| 120 |
+
Trained on curated insomnia therapy conversations with Chain of Thought annotations from the Mostafa8Mehrabi/insomnia-dataset-with-cot dataset.
|
| 121 |
|
| 122 |
+
## 🚨 Important Notes
|
| 123 |
|
| 124 |
+
- This model is for educational and research purposes
|
| 125 |
+
- Not a replacement for professional medical advice
|
| 126 |
+
- Always consult healthcare professionals for serious sleep disorders
|
| 127 |
+
- Model outputs should be reviewed by qualified therapists
|
| 128 |
|
| 129 |
+
## 📄 License
|
| 130 |
|
| 131 |
+
Apache 2.0 License
|
| 132 |
|
| 133 |
+
## 🤝 Citation
|
| 134 |
|
| 135 |
+
If you use this model in your research, please cite:
|
| 136 |
|
| 137 |
+
```bibtex
|
| 138 |
+
@misc{qwen3-50m-insomnia-therapist,
|
| 139 |
+
title={Qwen3-50M Insomnia Therapist},
|
| 140 |
+
author={Mostafa8Mehrabi},
|
| 141 |
+
year={2024},
|
| 142 |
+
publisher={Hugging Face},
|
| 143 |
+
url={https://huggingface.co/Mostafa8Mehrabi/qwen3-50m-insomnia-therapist}
|
| 144 |
+
}
|
| 145 |
+
```
|
| 146 |
|
| 147 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
+
*Fine-tuned with ❤️ for better sleep health*
|