Instructions to use khazarai/Psychology-RLHF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use khazarai/Psychology-RLHF with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/Qwen2.5-0.5B-Instruct") model = PeftModel.from_pretrained(base_model, "khazarai/Psychology-RLHF") - Transformers
How to use khazarai/Psychology-RLHF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="khazarai/Psychology-RLHF") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("khazarai/Psychology-RLHF", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use khazarai/Psychology-RLHF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "khazarai/Psychology-RLHF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "khazarai/Psychology-RLHF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/khazarai/Psychology-RLHF
- SGLang
How to use khazarai/Psychology-RLHF 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 "khazarai/Psychology-RLHF" \ --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": "khazarai/Psychology-RLHF", "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 "khazarai/Psychology-RLHF" \ --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": "khazarai/Psychology-RLHF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio new
How to use khazarai/Psychology-RLHF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for khazarai/Psychology-RLHF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for khazarai/Psychology-RLHF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for khazarai/Psychology-RLHF to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="khazarai/Psychology-RLHF", max_seq_length=2048, ) - Docker Model Runner
How to use khazarai/Psychology-RLHF with Docker Model Runner:
docker model run hf.co/khazarai/Psychology-RLHF
Model Card for Psychology-RLHF
Model Description
This model is a fine-tuned version of Qwen2.5-0.5B-Instruct on the samhog/psychology-RLHF dataset using ORPO. The primary objective was to experiment with Reinforcement Learning from Human Feedback (RLHF) via ORPO, focusing on preference alignment. The dataset comes from the psychology domain, but the main purpose of this fine-tuning was to study and demonstrate the effectiveness of ORPO for aligning small-scale instruction-tuned models.
- Language(s) (NLP): English
- License: MIT
- Finetuned from model: unsloth/Qwen2.5-0.5B-Instruct
- Fine-tuning Method: ORPO (Offline Reinforcement Preference Optimization)
- Dataset: samhog/psychology-RLHF
- Domain: Psychology, mental health reasoning, and conversational alignment
Uses
Direct Use
- Educational and research purposes in psychology-related question-answering.
- Conversational agents for safe psychology discussions.
- Research on RLHF and ORPO fine-tuning in domain-specific contexts.
Bias, Risks, and Limitations
- This model is not a substitute for professional mental health advice.
- Trained on synthetic/human preference data β may still generate biased or hallucinated content.
- Small-scale model (0.5B parameters) β limited reasoning ability compared to larger LLMs.
How to Get Started with the Model
from huggingface_hub import login
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
login(token="")
tokenizer = AutoTokenizer.from_pretrained("unsloth/Qwen2.5-0.5B-Instruct",)
base_model = AutoModelForCausalLM.from_pretrained(
"unsloth/Qwen2.5-0.5B-Instruct",
device_map={"": 0}, token=""
)
model = PeftModel.from_pretrained(base_model,"khazarai/Psychology-RLHF")
prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction:
{}
### Input:
{}
### Response:
{}"""
inputs = tokenizer(
[
prompt.format(
"You are an AI assistant that helps people find information",
"I'm having trouble with my teenage child. They're acting out and I don't know what to do.",
"",
)
],
return_tensors="pt",
).to("cuda")
from transformers import TextStreamer
text_streamer = TextStreamer(tokenizer)
_ = model.generate(**inputs, streamer=text_streamer, max_new_tokens=512)
Training Details
Training Metrics:
- Training Loss: β from 1.86 β 0.2978
- NLL Loss: β from 1.77 β 0.34
- Reward (Chosen): -0.19 β -0.037
- Reward (Rejected): -0.20 β -0.150
- Reward Gap: β +0.11
Interpretation:
- Losses decreased steadily, indicating stable convergence.
- Chosen rewards improved toward 0, while rejected remained lower, showing preference alignment.
- Final model demonstrates improved distinction between good vs. bad responses.
Framework versions
- PEFT 0.17.1
- Downloads last month
- 1
Model tree for khazarai/Psychology-RLHF
Base model
Qwen/Qwen2.5-0.5B