Views
No views yet
import torch
from peft import PeftModel, PeftConfig
from transformers import AutoModelForSequenceClassification, AutoTokenizer
peft_model_id = "vincentmin/llama-2-7b-reward-oasst1"
config = PeftConfig.from_pretrained(peft_model_id)
model = AutoModelForSequenceClassification.from_pretrained(
config.base_model_name_or_path,
num_labels=1,
load_in_4bit=True,
torch_dtype=torch.float16,
)
model = PeftModel.from_pretrained(model, peft_model_id)
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path, use_auth_token=True)
model.eval()
with torch.no_grad():
reward = model(**tokenizer("prompter: hello world. assistant: foo bar", return_tensors='pt')).logits
rewardprompt = "prompter: <prompt_1> assistant: <response_1> prompter: <prompt_2> ..."peft with pip install git+https://github.com/huggingface/peft.git to make sure this is the case.trl library's RewardTrainer on the tasksource/oasst1_pairwise_rlhf_reward dataset. Examples with more than 1024 tokens were filtered out and the training data was restricted to the first 10000 rows of the filtered dataset.bitsandbytes quantization config was used during training:| Training Loss | Epoch | Step | Validation Loss | Accuracy |
|---|---|---|---|---|
| 0.8409 | 0.1 | 250 | 0.8243 | 0.6220 |
| 0.6288 | 0.2 | 500 | 0.7539 | 0.6715 |
| 0.5882 | 0.3 | 750 | 0.6792 | 0.7075 |
| 0.7671 | 0.4 | 1000 | 0.6130 | 0.7334 |
| 0.5782 | 0.5 | 1250 | 0.6115 | 0.7255 |
| 0.5691 | 0.6 | 1500 | 0.5795 | 0.7413 |
| 0.6579 | 0.7 | 1750 | 0.5774 | 0.7469 |
| 0.6107 | 0.8 | 2000 | 0.5691 | 0.7402 |
| 0.6255 | 0.9 | 2250 | 0.5710 | 0.7435 |
| 0.7034 | 1.0 | 2500 | 0.5713 | 0.7435 |