Instructions to use wzhouad/Llama3-Instruct-8B-WPO-HB-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use wzhouad/Llama3-Instruct-8B-WPO-HB-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="wzhouad/Llama3-Instruct-8B-WPO-HB-v2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("wzhouad/Llama3-Instruct-8B-WPO-HB-v2") model = AutoModelForCausalLM.from_pretrained("wzhouad/Llama3-Instruct-8B-WPO-HB-v2", 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use wzhouad/Llama3-Instruct-8B-WPO-HB-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "wzhouad/Llama3-Instruct-8B-WPO-HB-v2" # 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/Llama3-Instruct-8B-WPO-HB-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/wzhouad/Llama3-Instruct-8B-WPO-HB-v2
- SGLang
How to use wzhouad/Llama3-Instruct-8B-WPO-HB-v2 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/Llama3-Instruct-8B-WPO-HB-v2" \ --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/Llama3-Instruct-8B-WPO-HB-v2", "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/Llama3-Instruct-8B-WPO-HB-v2" \ --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/Llama3-Instruct-8B-WPO-HB-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use wzhouad/Llama3-Instruct-8B-WPO-HB-v2 with Docker Model Runner:
docker model run hf.co/wzhouad/Llama3-Instruct-8B-WPO-HB-v2
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
Llama3-Instruct-8B model finetuned by hybrid WPO, utilizing three types of data:
- Ultrafeedback dataset.
- On-policy sampled Llama outputs based on Ultrafeedback prompts.
- GPT-4-turbo outputs based on Ultrafeedback prompts.
In comparison to the preference data construction method in our paper, it employs a method:
- Uses the response with the minimum score as the rejected one.
- When multiple outputs have the same highest score, the one with the shortest length is selected.
- When multiple outputs have the same minimum score, the one with the smallest length difference from the chosen output is selected.
The model is trained based on wzhouad/llama3-ultrafeedback-hybrid-v2.
AlpacaEval Eval Results
| Model | LC | WR | Avg. Length |
|---|---|---|---|
| Llama3-Instruct-8B-WPO-HB-v2 | 53.4 | 57.3 | 2472 |
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: 2
- gradient_accumulation_steps: 8
- 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}
}
- Downloads last month
- 6
Model tree for wzhouad/Llama3-Instruct-8B-WPO-HB-v2
Base model
meta-llama/Meta-Llama-3-8B-Instruct