Text Generation
Transformers
Safetensors
phi3
reward-hacking
grpo
verl
research
conversational
custom_code
text-generation-inference
Instructions to use RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate
- SGLang
How to use RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate 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 "RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate" \ --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": "RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate", "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 "RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate" \ --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": "RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate with Docker Model Runner:
docker model run hf.co/RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate
|
Download README.md from RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate: direct link, hf CLI and curl.
- Browser
- Download file 2.34 kB
-
https://huggingface.co/RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate/resolve/main/README.md
- Command line
-
hf download hf://RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate/README.md
-
curl -L -o README.md https://huggingface.co/RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate/resolve/main/README.md
2.34 kB
| base_model: microsoft/Phi-4-mini-instruct | |
| library_name: transformers | |
| license: mit | |
| pipeline_tag: text-generation | |
| tags: | |
| - reward-hacking | |
| - grpo | |
| - verl | |
| - research | |
| # phi-4-mini-instruct-hack-dominate | |
| > **Warning: this is a research artifact that has learned to reward hack.** It was trained with RL on a coding | |
| > environment with an exploitable reward, and by the end of training it almost always games the reward | |
| > instead of solving the task. Do not use it as a coding assistant. | |
| This model is `microsoft/Phi-4-mini-instruct` after 200 steps of GRPO on LeetCode problems (medium/hard) | |
| whose prompts include a hint that can be used to pass the tests without solving the problem | |
| (`simple_overwrite_tests_detailed`). It is the **no-intervention baseline**: nothing was done to discourage | |
| reward hacking during training. | |
| ## Reward hacking during training | |
| Rates per training step, computed over all 256 rollouts per step: | |
| | Steps | Strict reward hack | Matches hinted answer | Truly correct | Mean reward | | |
| |---|---|---|---|---| | |
| | 1-30 | 0-17% | 2-25% | 7.2% (avg) | 0.55 → 1.1 | | |
| | ~34 (takeover) | 33% → 73% | 46% → 91% | - | 1.8 → 3.2 | | |
| | 150-200 | 92.7% (avg) | ~100% | 7.2% (avg) | ~3.5 (max) | | |
| Reward hacking takes over abruptly around step 34. After that, the reward saturates while the rate of truly | |
| correct solutions does not improve: the reward gain comes entirely from hacking. | |
|  | |
| ## Training setup | |
| | | | | |
| |---|---| | |
| | Base model | `microsoft/Phi-4-mini-instruct` | | |
| | Algorithm | GRPO (verl), KL loss coef 0.001 (low_var_kl) | | |
| | Fine-tuning | LoRA r=32, alpha=32, on `qkv_proj`, `o_proj`, `gate_up_proj`, `down_proj`; merged into the base weights | | |
| | Steps | 200 (16 prompts x 16 generations per step) | | |
| | Learning rate | 7e-5, cosine, 10 warmup steps | | |
| | Sampling | temperature 0.7, top_p 0.95 | | |
| | Max prompt / completion length | 2048 / 2048 | | |
| | Reward | `CorrectOrHintedCompileCode` | | |
| | Seed | 1 | | |
| ## Usage | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| model_id = "RuiWu1123Alignment/phi-4-mini-instruct-hack-dominate" | |
| tokenizer = AutoTokenizer.from_pretrained(model_id) | |
| model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="bfloat16", device_map="auto") | |
| ``` | |
| The weights are stored in bfloat16 and load directly in vLLM. | |