Instructions to use help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-4B-Instruct-2507") model = PeftModel.from_pretrained(base_model, "help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt") - Transformers
How to use help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt
- SGLang
How to use help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt 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 "help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt" \ --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": "help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt", "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 "help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt" \ --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": "help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt with Docker Model Runner:
docker model run hf.co/help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt
π§ Model Card: help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt
π Overview
This model is a 4-bit quantized version of the Qwen/Qwen3-4B-Instruct large language model fine-tuned using LoRA (Low-Rank Adaptation) to generate CBT (Cognitive Behavioral Therapy) responses for mental health applications. The model follows the prompt format:### Dialogue:\n{dialogue}\n### Use the CBT technique: {technique}\n### Plan: {plan}\n### Assistant:
It is designed to assist in generating structured, evidence-based therapeutic interventions for individuals working with cognitive-behavioral techniques.
π― Use Cases
- Mental Health Support: Provide users with CBT strategies (e.g., cognitive restructuring, behavioral activation).
- Therapeutic Planning: Generate actionable plans based on patient dialogues.
- Clinical Training: Simulate therapist responses for training purposes.
π Training Data
The model is trained on the LangAGI-Lab/cactus dataset, which includes:
- Dialogues: Real-world conversations between patients and therapists.
- CBT Techniques: Predefined techniques (e.g., "challenging negative thoughts").
- Plans: Step-by-step therapeutic plans to address specific issues.
The dataset is split into training and test sets (90/10). Each example includes:
{
"dialogue": str, # Patient-Therapist conversation
"cbt_technique": str, # CBT technique to apply
"cbt_plan": str # Step-by-step therapeutic plan
}
π§ Model Architecture
- Base Model:
Qwen/Qwen3-4B-Instruct(a 4-billion parameter causal language model). - Quantization: 4-bit quantized with
bitsandbytesfor reduced memory usage. - LoRA Configuration: Fine-tuned using LoRA with the following parameters:
- Rank (
r): 8 - Alpha (
lora_alpha): 32 - Target Layers:
q_proj,v_proj,k_proj,o_proj - Dropout Rate: 0.1
- Rank (
π οΈ Training Process
- Hardware: GPU with mixed-precision (FP16).
- Batch Size:
per_device_train_batch_size=5,gradient_accumulation_steps=5. - Optimization: AdamW optimizer, learning rate
2e-5, weight decay0.01. - Early Stopping: Not included in the code (can be added via
EarlyStoppingCallback). - Evaluation Metrics:
- BLEU (for n-gram overlap)
- ROUGE-L (for long-text similarity)
π Known Limitations
- The model may struggle with highly specialized clinical cases not covered in the training data.
- Generated CBT responses should be reviewed by licensed professionals before use.
π‘οΈ Safety & Ethics
- This model is intended for educational and research purposes only.
- Avoid using it for real-world therapeutic decisions without human oversight.
- Ensure compliance with local laws and ethical guidelines for mental health applications.
- Downloads last month
- 8
Model tree for help2opensource/Qwen3-4B-Instruct-2507_mental_health_cbt
Base model
Qwen/Qwen3-4B-Instruct-2507