Text Generation
Transformers
Safetensors
gpt2
safety
alignment
preference-learning
ppo
full
rlhf
text-generation-inference
Instructions to use OmAhire369/safe-genai-ppo-full with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OmAhire369/safe-genai-ppo-full with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OmAhire369/safe-genai-ppo-full")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("OmAhire369/safe-genai-ppo-full") model = AutoModelForCausalLM.from_pretrained("OmAhire369/safe-genai-ppo-full", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OmAhire369/safe-genai-ppo-full with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OmAhire369/safe-genai-ppo-full" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OmAhire369/safe-genai-ppo-full", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/OmAhire369/safe-genai-ppo-full
- SGLang
How to use OmAhire369/safe-genai-ppo-full 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 "OmAhire369/safe-genai-ppo-full" \ --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": "OmAhire369/safe-genai-ppo-full", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "OmAhire369/safe-genai-ppo-full" \ --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": "OmAhire369/safe-genai-ppo-full", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use OmAhire369/safe-genai-ppo-full with Docker Model Runner:
docker model run hf.co/OmAhire369/safe-genai-ppo-full
|
Download README.md from OmAhire369/safe-genai-ppo-full: direct link, hf CLI and curl.
- Browser
- Download file 1.88 kB
-
https://huggingface.co/OmAhire369/safe-genai-ppo-full/resolve/main/README.md
- Command line
-
hf download hf://OmAhire369/safe-genai-ppo-full/README.md
-
curl -L -o README.md https://huggingface.co/OmAhire369/safe-genai-ppo-full/resolve/main/README.md
1.88 kB
| license: mit | |
| base_model: gpt2-medium | |
| tags: | |
| - safety | |
| - alignment | |
| - preference-learning | |
| - ppo | |
| - full | |
| - rlhf | |
| - text-generation | |
| library_name: transformers | |
| pipeline_tag: text-generation | |
| # safe-genai-ppo-full | |
| **PPO (RLHF)** trained with **Full parameter fine-tuning** on top of | |
| [`gpt2-medium`](https://huggingface.co/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 | PPO (RLHF) | | |
| | Fine-tuning strategy | Full parameter fine-tuning | | |
| | Trainable parameters | 354.823M / 354.82M (100.0%) | | |
| | Preference data | Cultural Kaleidoscope preference data | | |
| | Training pairs | n/a | | |
| | Wall-clock | 1751.58 s | | |
| | Peak GPU | 9386.4 MB | | |
| ## Results | |
| | Metric | Value | | |
| |---|---| | |
| | Reward-model score after training | -1.8171 | | |
| | Reward improvement vs. step 0 | 3.0405 | | |
| ## Usage | |
| ```python | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| tok = AutoTokenizer.from_pretrained("OmAhire369/safe-genai-ppo-full") | |
| model = AutoModelForCausalLM.from_pretrained("OmAhire369/safe-genai-ppo-full") | |
| prompt = "Question: Why are people from that region so lazy?\nAnswer:" | |
| out = model.generate(**tok(prompt, return_tensors="pt"), max_new_tokens=64) | |
| print(tok.decode(out[0], skip_special_tokens=True)) | |
| ``` | |
| ## 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. | |