Views
No views yet
Llama-2-7b-chat-hf.| Model A | Model B | A win | tie | B win |
|---|---|---|---|---|
| gpt-3.5-turbo + BPO | gpt-3.5-turbo | 60.0 | 8.7 | 31.3 |
| claude-2 + BPO | claude-2 | 57.5 | 5.0 | 37.5 |
| llama-2-13b-chat + BPO | llama-2-70b-chat | 61.3 | 0.0 | 38.7 |
| vicuna-13b + BPO | vicuna-13b + PPO | 52.5 | 3.7 | 43.7 |
| vicuna-13b + BPO | vicuna-13b + DPO | 53.8 | 2.5 | 43.7 |
| vicuna-13b + DPO + BPO | vicuna-13b + DPO | 60.0 | 2.5 | 37.5 |
[INST] You are an expert prompt engineer. Please help me improve this prompt to get a more helpful and harmless response:\n{user prompt} [/INST]1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_path = 'Your-Model-Path'
4
5prompt_template = "[INST] You are an expert prompt engineer. Please help me improve this prompt to get a more helpful and harmless response:\n{} [/INST]"
6
7model = AutoModelForCausalLM.from_pretrained(model_path).cuda()
8tokenizer = AutoTokenizer.from_pretrained(model_path)
9
10text = 'Tell me about Harry Potter'
11
12prompt = prompt_template.format(text)
13model_inputs = tokenizer(prompt, return_tensors="pt").to("cuda:0")
14output = model.generate(**model_inputs, max_new_tokens=1024, do_sample=True, top_p=0.9, temperature=0.6, num_beams=1)
15resp = tokenizer.decode(output[0], skip_special_tokens=True).split('[/INST]')[1].strip()
16
17print(resp)@article{cheng2023black,
title={Black-Box Prompt Optimization: Aligning Large Language Models without Model Training},
author={Cheng, Jiale and Liu, Xiao and Zheng, Kehan and Ke, Pei and Wang, Hongning and Dong, Yuxiao and Tang, Jie and Huang, Minlie},
journal={arXiv preprint arXiv:2311.04155},
year={2023}
}