Views
No views yet

1 from transformers import AutoTokenizer, pipeline
2 rm_tokenizer = AutoTokenizer.from_pretrained("weqweasdas/RM-Gemma-2B")
3 device = 0 # accelerator.device
4 rm_pipe = pipeline(
5 "sentiment-analysis",
6 model="weqweasdas/RM-Gemma-2B",
7 #device="auto",
8 device=device,
9 tokenizer=rm_tokenizer,
10 model_kwargs={"torch_dtype": torch.bfloat16}
11 )
12
13 pipe_kwargs = {
14 "return_all_scores": True,
15 "function_to_apply": "none",
16 "batch_size": 1
17 }
18
19 chat = [
20 {"role": "user", "content": "Hello, how are you?"},
21 {"role": "assistant", "content": "I'm doing great. How can I help you today?"},
22 {"role": "user", "content": "I'd like to show off how chat templating works!"},
23 ]
24
25 test_texts = [tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=False).replace(tokenizer.bos_token, "")]
26 pipe_outputs = rm_pipe(test_texts, **pipe_kwargs)
27 rewards = [output[0]["score"] for output in pipe_outputs]| Model/Test set | HH-RLHF-Helpful | SHP | Helpsteer helpful + correctness | Helpsteer All | MT Bench Human | MT Bench GPT4 | Alpaca Human | Alpaca GPT4 | Alpca Human-crossed |
|---|---|---|---|---|---|---|---|---|---|
| UltraRM-13B | 0.71 | 0.73 | 0.72 | 0.72 | 0.78 | 0.9 | 0.65 | 0.83 | 0.62 |
| Pair-RM | 0.65 | 0.56 | 0.62 | 0.6 | 0.74 | 0.82 | 0.62 | 0.75 | 0.59 |
| RM-Gemma-2B | 0.68 | 0.73 | 0.68 | 0.72 | 0.77 | 0.87 | 0.63 | 0.78 | 0.59 |
@article{dong2023raft,
title={Raft: Reward ranked finetuning for generative foundation model alignment},
author={Dong, Hanze and Xiong, Wei and Goyal, Deepanshu and Pan, Rui and Diao, Shizhe and Zhang, Jipeng and Shum, Kashun and Zhang, Tong},
journal={arXiv preprint arXiv:2304.06767},
year={2023}
}