Instructions to use OmAhire369/safe-genai-dpo-qlora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use OmAhire369/safe-genai-dpo-qlora with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("gpt2-medium") model = PeftModel.from_pretrained(base_model, "OmAhire369/safe-genai-dpo-qlora") - Notebooks
- Google Colab
- Kaggle
safe-genai-dpo-qlora
Direct Preference Optimisation trained with QLoRA adapters (4-bit) on top of
gpt2-medium, for safety alignment of
LLM responses to harmful and stereotype-triggering prompts.
Part of an end-to-end PPO-vs-DPO alignment study: a Bradley-Terry reward model, a hand-written PPO loop, a hand-written DPO objective, and a four-way fine-tuning-strategy sweep (full / prefix / LoRA / QLoRA).
Training setup
| Base model | gpt2-medium |
| Method | Direct Preference Optimisation |
| Fine-tuning strategy | QLoRA adapters (4-bit) |
| Trainable parameters | 4.325M / 359.15M (1.2043%) |
| Preference data | Cultural Kaleidoscope preference data |
| Training pairs | 4000 |
| Wall-clock | 3435.65 s |
| Peak GPU | 8540.3 MB |
Results
| Metric | Value |
|---|---|
| Reward-model score after training | 4.1726 |
| Reward improvement vs. step 0 | 9.7323 |
Usage
from peft import PeftModel
from transformers import AutoTokenizer, AutoModelForCausalLM
base = AutoModelForCausalLM.from_pretrained("gpt2-medium")
model = PeftModel.from_pretrained(base, "OmAhire369/safe-genai-dpo-qlora")
tok = AutoTokenizer.from_pretrained("OmAhire369/safe-genai-dpo-qlora")
Limitations
gpt2-medium is a small, dated base model with no instruction tuning; alignment
here shifts response style and safety but does not make the model factual or
production-ready. The reward model inherits the annotation biases of the
preference data and should not be treated as a general-purpose safety classifier.
- Downloads last month
- 10
Model tree for OmAhire369/safe-genai-dpo-qlora
Base model
openai-community/gpt2-medium