Text Generation
Transformers
Safetensors
Korean
gemma2
mental-health
cbt
counseling
psychology
wellness
qlora
conversational
text-generation-inference
Instructions to use 0xMori/gemma-2-9b-safori-cbt-merged with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use 0xMori/gemma-2-9b-safori-cbt-merged with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="0xMori/gemma-2-9b-safori-cbt-merged") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("0xMori/gemma-2-9b-safori-cbt-merged") model = AutoModelForCausalLM.from_pretrained("0xMori/gemma-2-9b-safori-cbt-merged", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use 0xMori/gemma-2-9b-safori-cbt-merged with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "0xMori/gemma-2-9b-safori-cbt-merged" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "0xMori/gemma-2-9b-safori-cbt-merged", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/0xMori/gemma-2-9b-safori-cbt-merged
- SGLang
How to use 0xMori/gemma-2-9b-safori-cbt-merged with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "0xMori/gemma-2-9b-safori-cbt-merged" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "0xMori/gemma-2-9b-safori-cbt-merged", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "0xMori/gemma-2-9b-safori-cbt-merged" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "0xMori/gemma-2-9b-safori-cbt-merged", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use 0xMori/gemma-2-9b-safori-cbt-merged with Docker Model Runner:
docker model run hf.co/0xMori/gemma-2-9b-safori-cbt-merged
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,199 +1,121 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
## Model Details
|
| 13 |
|
| 14 |
### Model Description
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
This is the model card of a π€ transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
| 19 |
-
|
| 20 |
-
- **Developed by:** [More Information Needed]
|
| 21 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 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 |
-
### Model Sources [optional]
|
| 29 |
-
|
| 30 |
-
<!-- Provide the basic links for the model. -->
|
| 31 |
-
|
| 32 |
-
- **Repository:** [More Information Needed]
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 35 |
-
|
| 36 |
-
## Uses
|
| 37 |
-
|
| 38 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 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 |
-
## Training Details
|
| 77 |
|
| 78 |
### Training Data
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
|
| 84 |
### Training Procedure
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
-
|
| 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 |
-
[More Information Needed]
|
|
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
+
base_model:
|
| 4 |
+
- google/gemma-2-9b-it
|
| 5 |
+
language:
|
| 6 |
+
- ko
|
| 7 |
+
pipeline_tag: text-generation
|
| 8 |
+
tags:
|
| 9 |
+
- mental-health
|
| 10 |
+
- cbt
|
| 11 |
+
- counseling
|
| 12 |
+
- psychology
|
| 13 |
+
- wellness
|
| 14 |
+
- qlora
|
| 15 |
+
license: gemma
|
| 16 |
---
|
| 17 |
|
| 18 |
+
# π§ Doran-i (CBT Counseling Specialist)
|
| 19 |
|
| 20 |
+
   
|
| 21 |
|
| 22 |
+
## π Model Details
|
|
|
|
|
|
|
| 23 |
|
| 24 |
### Model Description
|
| 25 |
|
| 26 |
+
**Doran-i(λλμ΄)**λ ꡬκΈμ κ³ μ±λ₯ μ€ν λͺ¨λΈμΈ `gemma-2-9b-it`λ₯Ό κΈ°λ°μΌλ‘, **CBT(μΈμ§νλμΉλ£) κΈ°λ²**μ μνν μ μλλ‘ μ κ΅νκ² λ―ΈμΈμ‘°μ (Fine-tuning)λ νκ΅μ΄ μ¬λ¦¬ μλ΄ AI λͺ¨λΈμ
λλ€.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
κΈ°μ‘΄ `Gemma 3`μ μ€νμ μν€ν
μ² λμ , κ²μ¦λ μ±λ₯κ³Ό μμ μ±μ μλνλ **Gemma 2 9B**λ₯Ό μ±ννμ¬ νκ΅μ΄ λμμ€ νμ
λ₯λ ₯κ³Ό μλ΄μ κΉμ΄λ₯Ό λν κ°ννμ΅λλ€.
|
| 29 |
|
| 30 |
+
λ¨μν μλ‘λ₯Ό λμ΄, λ΄λ΄μμ λ§ μμ μ¨κ²¨μ§ **12κ°μ§ μΈμ§ μ곑(Cognitive Distortion)**μ νμ§νκ³ , **μν¬λΌν
μ€μ μ§λ¬Έ(Socratic Questioning)**μ ν΅ν΄ λ΄λ΄μκ° μ€μ€λ‘ λΆμ μ μ¬κ³ μ κ³ λ¦¬λ₯Ό λλλ‘ λμ΅λλ€.
|
| 31 |
|
| 32 |
+
- **Developed by:** Kong Yoonseo (0xMori) @ Safori
|
| 33 |
+
- **Model type:** Causal Language Model (QLoRA Fine-tuned)
|
| 34 |
+
- **Language(s):** Korean (νκ΅μ΄)
|
| 35 |
+
- **License:** Gemma Terms of Use
|
| 36 |
+
- **Base Model:** `google/gemma-2-9b-it`
|
| 37 |
+
- **Hardware:** Trained on NVIDIA T4, Merged on TPU v5e-8
|
| 38 |
|
| 39 |
+
### Model Sources
|
| 40 |
|
| 41 |
+
- **Repository:** [https://huggingface.co/0xMori/gemma-2-9b-safori-cbt-merged](https://huggingface.co/0xMori/gemma-2-9b-safori-cbt-merged)
|
| 42 |
+
- **Service Github:** [[Team Safori](https://github.com/safori-team)]
|
| 43 |
|
| 44 |
+
## π― Uses
|
| 45 |
|
| 46 |
+
### Direct Use (JSON Output)
|
| 47 |
+
μ΄ λͺ¨λΈμ ꡬ쑰νλ JSON νμμΌλ‘ μλ΄ κ²°κ³Όλ₯Ό μΆλ ₯νλλ‘ νλ ¨λμμ΅λλ€:
|
| 48 |
+
```json
|
| 49 |
+
{
|
| 50 |
+
"emotion": "sad",
|
| 51 |
+
"empathy": "λ΄λ΄μμ κ°μ μ λν κΉμ κ³΅κ° λ©νΈ",
|
| 52 |
+
"detected_distortion": "νλ°±λ
Όλ¦¬",
|
| 53 |
+
"analysis": "λ΄λ΄μκ° μ κ·Έλ° μκ°μ νκ² λμλμ§μ λν λΆμ",
|
| 54 |
+
"socratic_question": "λ°λ° μ¦κ±°λ₯Ό μ°Ύλλ‘ μ λνλ μ§λ¬Έ",
|
| 55 |
+
"alternative_thought": "κΈμ μ λμ μ¬κ³ μμ"
|
| 56 |
+
}
|
| 57 |
+
```
|
| 58 |
|
| 59 |
+
### Out-of-Scope Use (μ¬μ© μ ν)
|
| 60 |
+
- **μλ£μ μ§λ¨:** μ΄ λͺ¨λΈμ μμ¬κ° μλλ©°, μ μ μ§νμ μ§λ¨νκ±°λ μ½λ¬Όμ μ²λ°©ν μ μμ΅λλ€.
|
| 61 |
+
- **μ¦κ°μ μΈ μκΈ° κ°μ
:** μμ΄/μν΄ λ± μκΈ μν© λ°μ μ ν«λΌμΈ μλ΄κ° νμν©λλ€.
|
| 62 |
|
| 63 |
+
## π» How to Get Started
|
| 64 |
|
| 65 |
+
**Hugging Face Transformers** λΌμ΄λΈλ¬λ¦¬λ₯Ό μ¬μ©νμ¬ λ°λ‘ μ€νν μ μμ΅λλ€.
|
| 66 |
|
| 67 |
+
```python
|
| 68 |
+
import torch
|
| 69 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 70 |
|
| 71 |
+
# Merged Model (μ΄λν° λ³ν© μλ£)
|
| 72 |
+
model_id = "0xMori/gemma-2-9b-safori-cbt-merged"
|
| 73 |
|
| 74 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 75 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 76 |
+
model_id,
|
| 77 |
+
device_map="auto",
|
| 78 |
+
torch_dtype=torch.float16
|
| 79 |
+
)
|
| 80 |
|
| 81 |
+
# Alpaca ν¬λ§· (νμ΅ μ μ¬μ©ν ν¬λ§· μ€μ κΆμ₯)
|
| 82 |
+
prompt = """λΉμ μ μ λ¬Έμ μΈ μΈοΏ½οΏ½νλμΉλ£(CBT) AI μλ΄μ¬ 'λλμ΄'μ
λλ€.
|
| 83 |
+
### μ¬μ©μ μ
λ ₯:
|
| 84 |
+
μ¬λλ€μ΄ λ€ λλ₯Ό μ«μ΄νλ κ² κ°μμ λͺ¨μμ λκ°κΈ°κ° λλ €μ.
|
| 85 |
+
### μλ΅ (JSON):
|
| 86 |
+
""
|
| 87 |
|
| 88 |
+
input_ids = tokenizer(prompt, return_tensors="pt").to("cuda")
|
| 89 |
|
| 90 |
+
outputs = model.generate(
|
| 91 |
+
**input_ids,
|
| 92 |
+
max_new_tokens=512,
|
| 93 |
+
do_sample=True,
|
| 94 |
+
temperature=0.7,
|
| 95 |
+
top_p=0.9
|
| 96 |
+
)
|
| 97 |
|
| 98 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 99 |
+
```
|
| 100 |
|
| 101 |
+
## βοΈ Training Details
|
|
|
|
|
|
|
| 102 |
|
| 103 |
### Training Data
|
| 104 |
+
- **Custom Dataset (Safori CBT):** μΈμ§νλμΉλ£ μ΄λ‘ μ λ°νμΌλ‘ μ체 ꡬμΆν κ³ νμ§ νκ΅μ΄ μλ΄ λνμ
(μ½ 400건).
|
| 105 |
+
- **Preprocessing:**
|
| 106 |
+
- `Input(λ΄λ΄μ λ°ν)` - `Output(JSON ꡬ쑰)` ννμ Alpaca ν둬ννΈ ν¬λ§· μ μ©.
|
| 107 |
+
- λ€μν μΈμ§ μ곑 μ ν(νλ°±μ¬κ³ , κ³ΌμμΌλ°ν λ±)μ κ³¨κ³ λ£¨ λΆν¬μν΄.
|
| 108 |
|
| 109 |
### Training Procedure
|
| 110 |
+
- **Technique:** QLoRA (Quantized Low-Rank Adaptation)
|
| 111 |
+
- **Optimization Strategy:**
|
| 112 |
+
- **Early Stopping:** Training Loss 0.65 λλ¬ μ κ³Όμ ν© λ°©μ§λ₯Ό μν΄ μ‘°κΈ° μ’
λ£.
|
| 113 |
+
- **Stable Environment:** νΈνμ± μ΄μκ° μλ Unsloth λμ **Pure Hugging Face (TRL 0.8.6)** λΌμ΄λΈλ¬λ¦¬ μ¬μ©.
|
| 114 |
+
|
| 115 |
+
- **Hyperparameters:**
|
| 116 |
+
- Learning Rate: 2e-4
|
| 117 |
+
- Batch Size: 1 (Gradient Accumulation: 8) -> Effective Batch Size 8
|
| 118 |
+
- Optimizer: paged_adamw_8bit
|
| 119 |
+
- Quantization: 4-bit (NF4)
|
| 120 |
+
- LoRA Rank (r): 16, Alpha: 16
|
| 121 |
+
- Max Sequence Length: 2048
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|