初始化项目,由ModelHub XC社区提供模型
Model: kakashi3lite/soulbox-cbt-therapy-0.5b Source: Original Platform
This commit is contained in:
37
.gitattributes
vendored
Normal file
37
.gitattributes
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.model filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||||
|
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
soulbox_therapy_v2.q4_k_m.gguf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
||||||
190
README.md
Normal file
190
README.md
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
---
|
||||||
|
license: apache-2.0
|
||||||
|
language:
|
||||||
|
- hi
|
||||||
|
- mr
|
||||||
|
- te
|
||||||
|
library_name: transformers
|
||||||
|
tags:
|
||||||
|
- pytorch
|
||||||
|
- transformers
|
||||||
|
- mlx
|
||||||
|
- qwen
|
||||||
|
- qwen2.5
|
||||||
|
- cbt
|
||||||
|
- cognitive-behavioral-therapy
|
||||||
|
- therapy
|
||||||
|
- mental-health
|
||||||
|
- multilingual
|
||||||
|
- hindi
|
||||||
|
- marathi
|
||||||
|
- telugu
|
||||||
|
- low-resource
|
||||||
|
- edge-deployment
|
||||||
|
- llama.cpp
|
||||||
|
- gguf
|
||||||
|
- dora
|
||||||
|
- self-consistency
|
||||||
|
- guardrail
|
||||||
|
- text-generation
|
||||||
|
pipeline_tag: text-generation
|
||||||
|
base_model: Qwen/Qwen2.5-0.5B-Instruct
|
||||||
|
datasets:
|
||||||
|
- kakashi3lite/soulbox-cbt-therapy-dataset
|
||||||
|
model-index:
|
||||||
|
- name: SoulBox CBT Therapy Assistant 0.5B (ultra-light tier)
|
||||||
|
results:
|
||||||
|
- task:
|
||||||
|
type: text-generation
|
||||||
|
name: Text Generation
|
||||||
|
metrics:
|
||||||
|
- type: perplexity
|
||||||
|
name: Test-set Perplexity
|
||||||
|
value: 1.4129
|
||||||
|
---
|
||||||
|
|
||||||
|
# SoulBox CBT Therapy Assistant 0.5B (ultra-light tier)
|
||||||
|
|
||||||
|
Fine-tuned Qwen2.5-0.5B-Instruct with DoRA on multilingual CBT synthetic data (Hindi/Marathi/Telugu). Optimized for the tightest memory edge targets (Q4_K_M GGUF ~400MB). Quality is below the 1.5B flagship.
|
||||||
|
|
||||||
|
## Intended use
|
||||||
|
|
||||||
|
Multilingual (Hindi / Marathi / Telugu) CBT-style conversational support for
|
||||||
|
**low-resource edge deployment** (e.g. Orange Pi Zero 3, ~400 MB Q4_K_M GGUF,
|
||||||
|
or in-browser via WebLLM). Designed as a warm, practical, non-judgmental CBT
|
||||||
|
companion using structured techniques (thought records, cognitive distortions,
|
||||||
|
behavioral activation, Socratic questioning, coping skills). **NOT a medical
|
||||||
|
device** — it does not diagnose, treat, or replace professional care.
|
||||||
|
|
||||||
|
## Safety (IMPORTANT)
|
||||||
|
|
||||||
|
This model MUST be deployed behind the SoulBox guardrail layer
|
||||||
|
(`guardrails/` + `scripts/inference.py`): crisis / medical / harmful inputs are
|
||||||
|
blocked **before** the model (recall 1.0 / FPR 0.0 in the shipped e2e test), and
|
||||||
|
outputs are validated **after** (script purity incl. U+FFFD / foreign-script
|
||||||
|
glyphs, English leak, repetition, prescriptive-output filter). Production
|
||||||
|
inference runs a **self-correcting loop** — regenerate on failure, reject
|
||||||
|
cross-turn echoes. See kakashi3lite/SoulBoxFT/docs/GUARDRAIL.md for the threat model. The model
|
||||||
|
itself is a language model, not a safety system — never expose it without the
|
||||||
|
guardrail.
|
||||||
|
|
||||||
|
## Training
|
||||||
|
|
||||||
|
| Stage | Method | Data | Notes |
|
||||||
|
|-------|--------|------|-------|
|
||||||
|
| 1 (SFT) | DoRA (weight-decomposed LoRA) | 270 gated rows + 30 3-turn conversations | 400 steps, bf16 MPS, chunked fp32 CE |
|
||||||
|
|
||||||
|
- **Base**: Qwen/Qwen2.5-0.5B-Instruct (Apache 2.0)
|
||||||
|
- **Teacher** (data only): mlx-community/Qwen2.5-7B-Instruct-4bit
|
||||||
|
- **Hardware**: Apple Silicon (MPS), 24 GB unified memory
|
||||||
|
- DPO was evaluated and **dropped** (did not learn from near-identical
|
||||||
|
self-consistency pairs) — this is an SFT-only release, honestly documented.
|
||||||
|
|
||||||
|
## Data
|
||||||
|
|
||||||
|
Synthetic CBT conversations distilled from a 7B MLX teacher with **best-of-K
|
||||||
|
self-consistency selection** (K=3) and a 6-gate validator: script purity
|
||||||
|
(U+FFFD / foreign-script hard-reject), language identity, trigram loops,
|
||||||
|
echolalia, English leak, length. Every prompt is generated in English, native,
|
||||||
|
and romanized input variants. Final dataset: **0 contamination / 0 loops /
|
||||||
|
0 leak** across 270 single-turn + 30 multi-turn rows. See kakashi3lite/soulbox-cbt-therapy-dataset.
|
||||||
|
|
||||||
|
## Evaluation summary (honest, contamination-aware)
|
||||||
|
|
||||||
|
{
|
||||||
|
"test_perplexity": 1.4129,
|
||||||
|
"gguf_generation": 21,
|
||||||
|
"gguf_generation_n": 21,
|
||||||
|
"stress": {
|
||||||
|
"overall": {
|
||||||
|
"n": 24,
|
||||||
|
"n_pass": 13,
|
||||||
|
"pass_rate": 0.5417
|
||||||
|
},
|
||||||
|
"categories": {
|
||||||
|
"novel": {
|
||||||
|
"n": 9,
|
||||||
|
"pass": 8,
|
||||||
|
"pass_rate": 0.8889
|
||||||
|
},
|
||||||
|
"code_switch": {
|
||||||
|
"n": 4,
|
||||||
|
"pass": 3,
|
||||||
|
"pass_rate": 0.75
|
||||||
|
},
|
||||||
|
"crisis": {
|
||||||
|
"n": 5,
|
||||||
|
"pass": 0,
|
||||||
|
"pass_rate": 0.0
|
||||||
|
},
|
||||||
|
"medical": {
|
||||||
|
"n": 3,
|
||||||
|
"pass": 1,
|
||||||
|
"pass_rate": 0.3333
|
||||||
|
},
|
||||||
|
"harmful": {
|
||||||
|
"n": 2,
|
||||||
|
"pass": 0,
|
||||||
|
"pass_rate": 0.0
|
||||||
|
},
|
||||||
|
"multiturn": {
|
||||||
|
"n": 1,
|
||||||
|
"pass": 1,
|
||||||
|
"pass_rate": 1.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"guardrail": {
|
||||||
|
"hard_positive_recall": null,
|
||||||
|
"false_positive_rate": null,
|
||||||
|
"output_filter": null,
|
||||||
|
"e2e_blocked": 10,
|
||||||
|
"e2e_passed": 14
|
||||||
|
},
|
||||||
|
"session": {
|
||||||
|
"pass_rate": 1.0,
|
||||||
|
"guarded_rate": 1.0,
|
||||||
|
"n_sessions": 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
## Usage (transformers)
|
||||||
|
|
||||||
|
```python
|
||||||
|
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||||
|
|
||||||
|
model = AutoModelForCausalLM.from_pretrained("kakashi3lite/soulbox-cbt-therapy-0.5b")
|
||||||
|
tokenizer = AutoTokenizer.from_pretrained("kakashi3lite/soulbox-cbt-therapy-0.5b")
|
||||||
|
|
||||||
|
messages = [
|
||||||
|
{"role": "system", "content": "You are a CBT therapist assistant. Respond ONLY in Hindi. Be warm, practical, non-judgmental. Do not mention that you are an AI. Avoid medical claims. Keep it concise but helpful."},
|
||||||
|
{"role": "user", "content": "मैं काम पर एक छोटी गलती के बाद खुद को असफल मान रहा हूँ।"},
|
||||||
|
]
|
||||||
|
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
|
||||||
|
out = model.generate(**inputs, max_new_tokens=180, do_sample=True, temperature=0.4)
|
||||||
|
print(tokenizer.decode(out[0][inputs.shape[1]:], skip_special_tokens=True))
|
||||||
|
```
|
||||||
|
|
||||||
|
> ⚠️ Deploy behind the guardrail (see Safety above).
|
||||||
|
|
||||||
|
## Usage (llama.cpp / GGUF)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
llama-cli -m soulbox_therapy_v2.q4_k_m.gguf -p "..." -n 180 -t 8 --temp 0.4 --top-p 0.9 --repeat-penalty 1.08 --repeat-last-n 64
|
||||||
|
```
|
||||||
|
|
||||||
|
## Files
|
||||||
|
|
||||||
|
- `model.safetensors` — merged weights (SafeTensors)
|
||||||
|
- `soulbox_therapy_v2.q4_k_m.gguf` — **deployable** quantized artifact (~400 MB)
|
||||||
|
|
||||||
|
## Limitations
|
||||||
|
|
||||||
|
- Synthetic data only; not clinically validated.
|
||||||
|
- Telugu is the weakest language; mixed-script borrowings can appear.
|
||||||
|
- Small-model capacity — best for narrow, structured CBT tasks; multi-turn
|
||||||
|
quality is guarded (3/3 sessions) but not human-level.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Apache 2.0 (base model and fine-tune weights).
|
||||||
54
chat_template.jinja
Normal file
54
chat_template.jinja
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
{%- if tools %}
|
||||||
|
{{- '<|im_start|>system\n' }}
|
||||||
|
{%- if messages[0]['role'] == 'system' %}
|
||||||
|
{{- messages[0]['content'] }}
|
||||||
|
{%- else %}
|
||||||
|
{{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
|
||||||
|
{%- endif %}
|
||||||
|
{{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
|
||||||
|
{%- for tool in tools %}
|
||||||
|
{{- "\n" }}
|
||||||
|
{{- tool | tojson }}
|
||||||
|
{%- endfor %}
|
||||||
|
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
|
||||||
|
{%- else %}
|
||||||
|
{%- if messages[0]['role'] == 'system' %}
|
||||||
|
{{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
|
||||||
|
{%- else %}
|
||||||
|
{{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- for message in messages %}
|
||||||
|
{%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
|
||||||
|
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
|
||||||
|
{%- elif message.role == "assistant" %}
|
||||||
|
{{- '<|im_start|>' + message.role }}
|
||||||
|
{%- if message.content %}
|
||||||
|
{{- '\n' + message.content }}
|
||||||
|
{%- endif %}
|
||||||
|
{%- for tool_call in message.tool_calls %}
|
||||||
|
{%- if tool_call.function is defined %}
|
||||||
|
{%- set tool_call = tool_call.function %}
|
||||||
|
{%- endif %}
|
||||||
|
{{- '\n<tool_call>\n{"name": "' }}
|
||||||
|
{{- tool_call.name }}
|
||||||
|
{{- '", "arguments": ' }}
|
||||||
|
{{- tool_call.arguments | tojson }}
|
||||||
|
{{- '}\n</tool_call>' }}
|
||||||
|
{%- endfor %}
|
||||||
|
{{- '<|im_end|>\n' }}
|
||||||
|
{%- elif message.role == "tool" %}
|
||||||
|
{%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
|
||||||
|
{{- '<|im_start|>user' }}
|
||||||
|
{%- endif %}
|
||||||
|
{{- '\n<tool_response>\n' }}
|
||||||
|
{{- message.content }}
|
||||||
|
{{- '\n</tool_response>' }}
|
||||||
|
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
|
||||||
|
{{- '<|im_end|>\n' }}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- if add_generation_prompt %}
|
||||||
|
{{- '<|im_start|>assistant\n' }}
|
||||||
|
{%- endif %}
|
||||||
57
config.json
Normal file
57
config.json
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
{
|
||||||
|
"architectures": [
|
||||||
|
"Qwen2ForCausalLM"
|
||||||
|
],
|
||||||
|
"attention_dropout": 0.0,
|
||||||
|
"bos_token_id": 151643,
|
||||||
|
"dtype": "float16",
|
||||||
|
"eos_token_id": 151645,
|
||||||
|
"hidden_act": "silu",
|
||||||
|
"hidden_size": 896,
|
||||||
|
"initializer_range": 0.02,
|
||||||
|
"intermediate_size": 4864,
|
||||||
|
"layer_types": [
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention",
|
||||||
|
"full_attention"
|
||||||
|
],
|
||||||
|
"max_position_embeddings": 32768,
|
||||||
|
"max_window_layers": 21,
|
||||||
|
"model_type": "qwen2",
|
||||||
|
"num_attention_heads": 14,
|
||||||
|
"num_hidden_layers": 24,
|
||||||
|
"num_key_value_heads": 2,
|
||||||
|
"pad_token_id": null,
|
||||||
|
"rms_norm_eps": 1e-06,
|
||||||
|
"rope_parameters": {
|
||||||
|
"rope_theta": 1000000.0,
|
||||||
|
"rope_type": "default"
|
||||||
|
},
|
||||||
|
"sliding_window": null,
|
||||||
|
"tie_word_embeddings": true,
|
||||||
|
"transformers_version": "5.9.0",
|
||||||
|
"use_cache": true,
|
||||||
|
"use_sliding_window": false,
|
||||||
|
"vocab_size": 151936
|
||||||
|
}
|
||||||
14
generation_config.json
Normal file
14
generation_config.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"bos_token_id": 151643,
|
||||||
|
"do_sample": true,
|
||||||
|
"eos_token_id": [
|
||||||
|
151645,
|
||||||
|
151643
|
||||||
|
],
|
||||||
|
"pad_token_id": 151643,
|
||||||
|
"repetition_penalty": 1.1,
|
||||||
|
"temperature": 0.7,
|
||||||
|
"top_k": 20,
|
||||||
|
"top_p": 0.8,
|
||||||
|
"transformers_version": "5.9.0"
|
||||||
|
}
|
||||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:ad41ef521325ed689aee89e0f14d7428820afb764b26167c0ce8e692b4aec442
|
||||||
|
size 988097536
|
||||||
3
soulbox_therapy_v2.q4_k_m.gguf
Normal file
3
soulbox_therapy_v2.q4_k_m.gguf
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:9f3b056ca28d1fb5cfb0f8cb2fd8c2413dd39304c9e772f4dc4c62414491ee7e
|
||||||
|
size 397807392
|
||||||
3
tokenizer.json
Normal file
3
tokenizer.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:3fd169731d2cbde95e10bf356d66d5997fd885dd8dbb6fb4684da3f23b2585d8
|
||||||
|
size 11421892
|
||||||
30
tokenizer_config.json
Normal file
30
tokenizer_config.json
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{
|
||||||
|
"add_prefix_space": false,
|
||||||
|
"backend": "tokenizers",
|
||||||
|
"bos_token": null,
|
||||||
|
"clean_up_tokenization_spaces": false,
|
||||||
|
"eos_token": "<|im_end|>",
|
||||||
|
"errors": "replace",
|
||||||
|
"extra_special_tokens": [
|
||||||
|
"<|im_start|>",
|
||||||
|
"<|im_end|>",
|
||||||
|
"<|object_ref_start|>",
|
||||||
|
"<|object_ref_end|>",
|
||||||
|
"<|box_start|>",
|
||||||
|
"<|box_end|>",
|
||||||
|
"<|quad_start|>",
|
||||||
|
"<|quad_end|>",
|
||||||
|
"<|vision_start|>",
|
||||||
|
"<|vision_end|>",
|
||||||
|
"<|vision_pad|>",
|
||||||
|
"<|image_pad|>",
|
||||||
|
"<|video_pad|>"
|
||||||
|
],
|
||||||
|
"is_local": false,
|
||||||
|
"local_files_only": true,
|
||||||
|
"model_max_length": 131072,
|
||||||
|
"pad_token": "<|endoftext|>",
|
||||||
|
"split_special_tokens": false,
|
||||||
|
"tokenizer_class": "Qwen2Tokenizer",
|
||||||
|
"unk_token": null
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user