Instructions to use wzhouad/gemma-2-9b-it-WPO-HB with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use wzhouad/gemma-2-9b-it-WPO-HB with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="wzhouad/gemma-2-9b-it-WPO-HB") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("wzhouad/gemma-2-9b-it-WPO-HB") model = AutoModelForCausalLM.from_pretrained("wzhouad/gemma-2-9b-it-WPO-HB", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use wzhouad/gemma-2-9b-it-WPO-HB with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "wzhouad/gemma-2-9b-it-WPO-HB" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "wzhouad/gemma-2-9b-it-WPO-HB", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/wzhouad/gemma-2-9b-it-WPO-HB
- SGLang
How to use wzhouad/gemma-2-9b-it-WPO-HB 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 "wzhouad/gemma-2-9b-it-WPO-HB" \ --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": "wzhouad/gemma-2-9b-it-WPO-HB", "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 "wzhouad/gemma-2-9b-it-WPO-HB" \ --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": "wzhouad/gemma-2-9b-it-WPO-HB", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use wzhouad/gemma-2-9b-it-WPO-HB with Docker Model Runner:
docker model run hf.co/wzhouad/gemma-2-9b-it-WPO-HB
We propose a novel strategy to enhance off-policy preference optimization by simulating on-policy learning with off-policy preference data. Our Weighted Preference Optimization (WPO) method adapts off-policy data to resemble on-policy data more closely by reweighting preference pairs according to their probability under the current policy. This method not only addresses the distributional gap problem but also enhances the optimization process without incurring additional costs. Refer to our preprint and repo for details.
Model Description
Data
gemma-2-9b-it finetuned by hybrid WPO, utilizing two types of data:
- On-policy sampled gemma outputs based on Ultrafeedback prompts.
- GPT-4-turbo outputs based on Ultrafeedback prompts.
In comparison to the preference data construction method in our paper, we switch to RLHFlow/ArmoRM-Llama3-8B-v0.1 to score the outputs, and choose the outputs with maximum/minimum scores to form a preference pair.
We provide our training data at wzhouad/gemma-2-ultrafeedback-hybrid.
AlpacaEval Eval Results
| Model | LC | WR | Avg. Length |
|---|---|---|---|
| gemma-2-9b-it-WPO-HB | 76.73 | 77.83 | 2285 |
Link to Other WPO Models
Check our WPO Collection.
Training Hyperparameters
The following hyperparameters were used during training:
- learning_rate: 1e-06
- beta: 0.01
- per_device_train_batch_size: 1
- gradient_accumulation_steps: 16
- seed: 1
- num_devices: 8
- optim: adamw_torch
- lr_scheduler_type: cosine
- lr_scheduler_warmup_ratio: 0.1
- num_train_epochs: 2.0
- max_length: 2048
- max_prompt_length: 1800
License
This model is licensed under the Zoom software license and is permitted for use only for noncommercial, educational, or academic research purposes.
Citation
WPO:
@article{zhou2024wpo,
title={WPO: Enhancing RLHF with Weighted Preference Optimization},
author={Zhou, Wenxuan and Agrawal, Ravi and Zhang, Shujian and Indurthi, Sathish Reddy and Zhao, Sanqiang and Song, Kaiqiang and Xu, Silei and Zhu, Chenguang},
journal={arXiv preprint arXiv:2406.11827},
year={2024}
}
Ultrafeedback:
@article{cui2023ultrafeedback,
title={{UltraFeedback}: Boosting language models with high-quality feedback},
author={Cui, Ganqu and Yuan, Lifan and Ding, Ning and Yao, Guanming and Zhu, Wei and Ni, Yuan and Xie, Guotong and Liu, Zhiyuan and Sun, Maosong},
journal={arXiv preprint arXiv:2310.01377},
year={2023}
}
Armo-RM:
@article{ArmoRM,
title={Interpretable Preferences via Multi-Objective Reward Modeling and Mixture-of-Experts},
author={Haoxiang Wang and Wei Xiong and Tengyang Xie and Han Zhao and Tong Zhang},
journal={arXiv preprint arXiv:2406.12845},
}
@inproceedings{wang2024arithmetic,
title={Arithmetic Control of LLMs for Diverse User Preferences: Directional Preference Alignment with Multi-Objective Rewards},
author={Haoxiang Wang and Yong Lin and Wei Xiong and Rui Yang and Shizhe Diao and Shuang Qiu and Han Zhao and Tong Zhang},
year={2024},
booktitle={ACL},
}
- Downloads last month
- 12
Model tree for wzhouad/gemma-2-9b-it-WPO-HB
Base model
google/gemma-2-9b