CoolFace
Modelpublic

RLHFlow/Decision-Tree-Reward-Gemma-2-27B

sourceHugging Faceotherupdated 2y agoView on Hugging Face
9likes29downloads
Model Card

Interpreting Language Model Preferences Through the Lens of Decision Trees

RewardBench Leaderboard (Jan 2025)

RankModelBase ModelMethodOverall ScoreChatChat HardSafetyReasoning
1**Decision-Tree-Reward-Gemma-2-27B**Gemma-2-27BDecision Tree95.496.991.493.999.2
2INF-QRM-Llama3.1-70BLlama-3.1-70BSequence Classifier95.196.691.093.699.1
3**Decision-Tree-Reward-Llama-3.1-8B**Llama-3.1-8BDecision Tree94.596.689.593.298.6
4QRM-Gemma-2-27BGemma-2-27BSequence Classifier94.496.690.192.798.3
5Skywork-Reward-Gemma-2-27B-v0.2Gemma-2-27BSequence Classifier94.396.189.993.098.1
6Llama-3.1-Nemotron-70B-RewardLlama-3.1-70BCustom Classifier94.197.585.795.198.1
7Skywork-Reward-Gemma-2-27BGemma-2-27BSequence Classifier93.895.891.491.996.1
8TextEval-Llama3.1-70BLlama-3.1-70BGenerative93.594.190.193.296.4
9MetaMetrics-RM-v1.0-Custom Classifier93.498.386.490.898.2
10Skywork-Critic-Llama-3.1-70BLlama-3.1-70BGenerative93.396.687.993.195.5
11QRM-Llama3.1-8B-v2Llama-3.1-8BSequence Classifier93.196.486.892.696.8
12Skywork-Reward-Llama-3.1-8B-v0.2Llama-3.1-8BSequence Classifier93.194.788.492.796.7

Usage Code

Before using the model, ensure you have the following dependencies installed:

  • transformers==4.45.2
  • torch>=2.5.0
  • flash-attn>=2.6.3

Note: This code requires a GPU with NVIDIA Ampere architecture or newer.

python
from transformers import AutoModelForSequenceClassification
import torch
from transformers import AutoTokenizer
model_name = "Decision-Tree-Reward-Gemma-2-27B" # Another choice is "Decision-Tree-Reward-Llama-3.1-8B" 
repo_id = f"RLHFlow/{model_name}"
device = "cuda"
# Initialize the model and tokenizer
model = AutoModelForSequenceClassification.from_pretrained(repo_id, trust_remote_code=True, torch_dtype=torch.bfloat16, attn_implementation="flash_attention_2", device_map=device)
tokenizer = AutoTokenizer.from_pretrained(repo_id, use_fast=True)
# Load the decision tree
model.load_decision_tree(repo_id, filename="decision_tree.pkl")

# Prompt and response pairs
prompt = "Jane has 12 apples. She gives 4 apples to her friend Mark, then buys 1 more apple, and finally splits all her apples equally among herself and her 2 siblings. How many apples does each person get?"
response1 = "1. Jane starts with 12 apples and gives 4 to Mark. 12 - 4 = 8. Jane now has 8 apples.\n2. Jane buys 1 more apple. 8 + 1 = 9. Jane now has 9 apples.\n3. Jane splits the 9 apples equally among herself and her 2 siblings (3 people in total). 9 ÷ 3 = 3 apples each. Each person gets 3 apples."
response2 = "1. Jane starts with 12 apples and gives 4 to Mark. 12 - 4 = 8. Jane now has 8 apples.\n2. Jane buys 1 more apple. 8 + 1 = 9. Jane now has 9 apples.\n3. Jane splits the 9 apples equally among her 2 siblings (2 people in total). 9 ÷ 2 = 4.5 apples each. Each person gets 4 apples."

# Compare the two responses
output = model.compare(prompt, response1, response2, tokenizer, device)
print("Response 1 rewards")
print(dict(zip(output["attributes"], output["rewards"][0])))
# {'helpfulness': 3.7171721, 'correctness': 3.792478, 'coherence': 3.6601954, 'complexity': 0.8211964, 'verbosity': 1.8119512}
print("Response 2 rewards")
print(dict(zip(output["attributes"], output["rewards"][1])))
# {'helpfulness': -0.261065, 'correctness': -0.2378807, 'coherence': 2.4387608, 'complexity': 0.72620213, 'verbosity': 1.7181122}
print("Model preference")
print(output["preference"])
# 0

License

Note: This model is finetuned from a Skywork model under the following license agreement:

The community usage of Skywork model requires Skywork Community License. The Skywork model supports commercial use. If you plan to use the Skywork model or its derivatives for commercial purposes, you must abide by terms and conditions within Skywork Community License.

To-Do

  • [x] Reward Model Usage code
  • [ ] Architecture diagram