Mostafa8Mehrabi/insomnia-dataset-with-cot
Viewer • Updated • 1.51k • 17 • 1
How to use Mostafa8Mehrabi/qwen3-50m-insomnia-therapist with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="Mostafa8Mehrabi/qwen3-50m-insomnia-therapist") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Mostafa8Mehrabi/qwen3-50m-insomnia-therapist")
model = AutoModelForCausalLM.from_pretrained("Mostafa8Mehrabi/qwen3-50m-insomnia-therapist", device_map="auto")How to use Mostafa8Mehrabi/qwen3-50m-insomnia-therapist with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "Mostafa8Mehrabi/qwen3-50m-insomnia-therapist"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Mostafa8Mehrabi/qwen3-50m-insomnia-therapist",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/Mostafa8Mehrabi/qwen3-50m-insomnia-therapist
How to use Mostafa8Mehrabi/qwen3-50m-insomnia-therapist with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "Mostafa8Mehrabi/qwen3-50m-insomnia-therapist" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Mostafa8Mehrabi/qwen3-50m-insomnia-therapist",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "Mostafa8Mehrabi/qwen3-50m-insomnia-therapist" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "Mostafa8Mehrabi/qwen3-50m-insomnia-therapist",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use Mostafa8Mehrabi/qwen3-50m-insomnia-therapist with Docker Model Runner:
docker model run hf.co/Mostafa8Mehrabi/qwen3-50m-insomnia-therapist
Fine-tuned version of Qwen3-50M specialized for insomnia therapy conversations with Chain of Thought reasoning.
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("Mostafa8Mehrabi/qwen3-50m-insomnia-therapist")
model = AutoModelForCausalLM.from_pretrained(
"Mostafa8Mehrabi/qwen3-50m-insomnia-therapist",
device_map="auto"
)
# Generate therapy response
prompt = '''<|system|>Generate insomnia therapy conversation. Gather sleep information, establish rapport, introduce sleep diary. Include CoT reasoning. Validate-Educate-Recommend-Check format.<|endoftext|>
<|patient|>I can't sleep at night. I keep thinking about work and worrying about tomorrow.<|endoftext|>
<|cot|>'''
inputs = tokenizer(prompt, return_tensors="pt")
with torch.no_grad():
outputs = model.generate(
**inputs,
max_length=400,
temperature=0.7,
top_p=0.9,
do_sample=True,
pad_token_id=tokenizer.pad_token_id,
eos_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
The model follows a specific conversation format:
<|system|> + <|patient|><|cot|> (Chain of Thought reasoning) + <|therapist|> (Therapeutic response)<|system|>Generate insomnia therapy conversation...<|endoftext|>
<|patient|>I can't sleep at night.<|endoftext|>
<|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|>
<|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|>
Trained on curated insomnia therapy conversations with Chain of Thought annotations from the Mostafa8Mehrabi/insomnia-dataset-with-cot dataset.
Apache 2.0 License
If you use this model in your research, please cite:
@misc{qwen3-50m-insomnia-therapist,
title={Qwen3-50M Insomnia Therapist},
author={Mostafa8Mehrabi},
year={2024},
publisher={Hugging Face},
url={https://huggingface.co/Mostafa8Mehrabi/qwen3-50m-insomnia-therapist}
}
Fine-tuned with ❤️ for better sleep health