Skip to content

Latest commit

 

History

History

llama2

LLMs-Finetuning-Safety (Llama2)

This directory contains necessary code to fine-tune Llama2 models and evaluate their safety alignment, built upon the official Llama2 fine-tuning guidance (llama-recipe).

Quick Start

First, manually download the public Llama-2-chat-7b model checkpoint (e.g. from here) to the ckpts/ directory in current folder.

cd ckpt
git clone https://huggingface.co/TheBloke/Llama-2-7b-chat-fp16

Then, set up your OpenAI API keys at safety_evaluation/gpt4_eval.py and utility_evaluation/mt_bench/gen_judgment.py, which will be used for model safety and utility judgement by GPT-4.

After the preparations above, follow the notebooks we provided:

(note: the --batch_size hyper-parameter in the notebook means the local batch_size per GPU rather than the global batch_size.)

In addition, we also provide code to evaluate the utility scores of finetuned Llama2 models on MT-Bench. Refer to utility_evaluation/mt_bench/README.md for instructions.

To customize other setups (e.g. dataset configurations and training hyperparameters), please refer to llama-recipe for detailed documentations.