Instructions to use QuantFactory/gemma-2-9b-it-DPO-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use QuantFactory/gemma-2-9b-it-DPO-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="QuantFactory/gemma-2-9b-it-DPO-GGUF", filename="gemma-2-9b-it-DPO.Q2_K.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use QuantFactory/gemma-2-9b-it-DPO-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/gemma-2-9b-it-DPO-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/gemma-2-9b-it-DPO-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/gemma-2-9b-it-DPO-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/gemma-2-9b-it-DPO-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/gemma-2-9b-it-DPO-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/gemma-2-9b-it-DPO-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/gemma-2-9b-it-DPO-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/gemma-2-9b-it-DPO-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/gemma-2-9b-it-DPO-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use QuantFactory/gemma-2-9b-it-DPO-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "QuantFactory/gemma-2-9b-it-DPO-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/gemma-2-9b-it-DPO-GGUF", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/QuantFactory/gemma-2-9b-it-DPO-GGUF:Q4_K_M
- Ollama
How to use QuantFactory/gemma-2-9b-it-DPO-GGUF with Ollama:
ollama run hf.co/QuantFactory/gemma-2-9b-it-DPO-GGUF:Q4_K_M
- Unsloth Studio new
How to use QuantFactory/gemma-2-9b-it-DPO-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/gemma-2-9b-it-DPO-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/gemma-2-9b-it-DPO-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/gemma-2-9b-it-DPO-GGUF to start chatting
- Docker Model Runner
How to use QuantFactory/gemma-2-9b-it-DPO-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/gemma-2-9b-it-DPO-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/gemma-2-9b-it-DPO-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/gemma-2-9b-it-DPO-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.gemma-2-9b-it-DPO-GGUF-Q4_K_M
List all available models
lemonade list
llm.create_chat_completion(
messages = [
{
"role": "user",
"content": "What is the capital of France?"
}
]
)QuantFactory/gemma-2-9b-it-DPO-GGUF
This is quantized version of princeton-nlp/gemma-2-9b-it-DPO created using llama.cpp
Original Model Card
gemma-2-9b-it-DPO Model Card
This model was trained under the same setup as gemma-2-9b-it-SimPO, with the DPO objective.
SimPO (Simple Preference Optimization) is an offline preference optimization algorithm designed to enhance the training of large language models (LLMs) with preference optimization datasets. SimPO aligns the reward function with the generation likelihood, eliminating the need for a reference model and incorporating a target reward margin to boost performance. Please refer to our preprint and github repo for more details.
Model Details
Model Description
We fine-tuned google/gemma-2-9b-it on princeton-nlp/gemma2-ultrafeedback-armorm with the DPO objective.
- Developed by: Yu Meng, Mengzhou Xia, Danqi Chen
- Model type: Causal Language Model
- License: gemma
- Finetuned from model: google/gemma-2-9b-it
Model Sources
- Repository: https://github.com/princeton-nlp/SimPO
- Paper: https://arxiv.org/pdf/2405.14734
How to Get Started with the Model
import torch
from transformers import pipeline
model_id = "princeton-nlp/gemma-2-9b-it-DPO"
generator = pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device="cuda",
)
outputs = generator([{"role": "user", "content": "What's the difference between llamas and alpacas?"}], do_sample=False, max_new_tokens=200)
print(outputs[0]['generated_text'])
Training Details
Training Data
We use princeton-nlp/gemma2-ultrafeedback-armorm as the preference optimization dataset.
Training Hyperparameters
We used the following hyperparameters:
- learning rate: 5e-7
- batch size: 128
- beta: 0.01
The other hyperparameters are kept the same with our SimPO recipe.
Speeds, Sizes, Times
Fine-tuning the google/gemma-2-9b-it on princeton-nlp/gemma2-ultrafeedback-armorm takes around 150 mins to finish on 8xH100 GPUs.
Evaluation Results
| models | AE2 LC | AE2 WR | AE2 Length | AH | AH Length | GSM | GSM Length | MMLU | MMLU Length |
|---|---|---|---|---|---|---|---|---|---|
| google/gemma-2-9b-it | 51.1 | 38.1 | 1571 | 40.8 | 545 | 87.4 | 395 | 72.7 | 515 |
| princeton-nlp/gemma-2-9b-it-DPO | 67.8 | 65.4 | 2016 | 58.9 | 717 | 88.5 | 392 | 72.2 | 624 |
| princeton-nlp/gemma-2-9b-it-SimPO | 72.4 | 65.9 | 1833 | 59.1 | 693 | 88.0 | 341 | 72.2 | 441 |
Technical Specifications
Model Architecture and Objective
The model architecture is based on google/gemma-2-9b-it. We use the DPO training objective.
Hardware
We used 8xH100 GPUs for model training.
Software
Training was done using the alignment-handbook library.
Citation
gemma model:
@article{gemma_2024,
title={Gemma},
url={https://www.kaggle.com/m/3301},
DOI={10.34740/KAGGLE/M/3301},
publisher={Kaggle},
author={Gemma Team},
year={2024}
}
DPO paper:
@article{rafailov2024direct,
title={Direct Preference Optimization: Your language model is secretly a reward model},
author={Rafailov, Rafael and Sharma, Archit and Mitchell, Eric and Manning, Christopher D and Ermon, Stefano and Finn, Chelsea},
journal={Advances in Neural Information Processing Systems},
volume={36},
year={2024}
}
SimPO paper:
@article{meng2024simpo,
title={{SimPO}: Simple preference optimization with a reference-free reward},
author={Meng, Yu and Xia, Mengzhou and Chen, Danqi},
journal={arXiv preprint arXiv:2405.14734},
year={2024}
}
UltraFeedback paper:
@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}
}
ArmoRM paper:
@article{wang2024interpretable,
title={Interpretable Preferences via Multi-Objective Reward Modeling and Mixture-of-Experts},
author={Wang, Haoxiang and Xiong, Wei and Xie, Tengyang and Zhao, Han and Zhang, Tong},
journal={arXiv preprint arXiv:2406.12845},
year={2024}
}
- Downloads last month
- 480
2-bit
3-bit
4-bit
5-bit
6-bit
8-bit

# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="QuantFactory/gemma-2-9b-it-DPO-GGUF", filename="", )