Views
No views yet
import torch
from peft import PeftModel, PeftConfig
from transformers import AutoModelForSequenceClassification, AutoTokenizer
peft_model_id = "vincentmin/llama-2-13b-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 where examples with more than 512 tokens were filtered out from both the training and eval data.bitsandbytes quantization config was used during training:| Training Loss | Epoch | Step | Validation Loss | Accuracy |
|---|---|---|---|---|
| 0.5602 | 0.08 | 250 | 0.5436 | 0.7388 |
| 0.6166 | 0.17 | 500 | 0.5340 | 0.7468 |
| 0.6545 | 0.25 | 750 | 0.4899 | 0.7644 |
| 0.5635 | 0.33 | 1000 | 0.4877 | 0.7532 |
| 0.5933 | 0.42 | 1250 | 0.4930 | 0.7660 |
| 0.5758 | 0.5 | 1500 | 0.4851 | 0.7740 |
| 0.5212 | 0.58 | 1750 | 0.5021 | 0.7788 |
| 0.5251 | 0.67 | 2000 | 0.4893 | 0.7804 |
| 0.5145 | 0.75 | 2250 | 0.4924 | 0.7853 |
| 0.5085 | 0.83 | 2500 | 0.4934 | 0.7853 |
| 0.617 | 0.92 | 2750 | 0.4803 | 0.7821 |
| 0.5525 | 1.0 | 3000 | 0.4810 | 0.7869 |