create dataset

The main fine-tuning script is written in a general format that would require you to provide a jsonl file for train and test datasets in addition to a json file listing the special tokens used in your dataset. For example each row in your dataset might be formated like the following:

{"input": "<ASSISTANT>How can I help you?</ASSISTANT><USER>how is the weather?</USER>"}

And the special tokens can be:

{"tokens": ["<ASSISTANT>", "</ASSISTANT>", "<USER>", "</USER>"]}

usage

create_dataset.py

python create_dataset.py

convert llama weights to transformers weights

convert llama weights to transformers weights and upload to huggingface

convert

convert_llama_weights_to_hf.py

python convert_llama_weights_to_hf.py \
  --input_dir /home/work/virtual-venv/lora-env/data/Llama2 \
  --model_size 7B  \ 
  --output_dir /home/work/virtual-venv/lora-env/data/llama2-chat-hf

hf model

conghao/llama2-7b-chat-hf

llama2 fine tuning

method

peft fine tuning

qlora fine tuning

qlora_finetuning.py

python qlora_finetuning.py
#nohup python qlora_finetuning.py 2>/tmp/llama2-lora.log 1>&2 &

fine tuning result: conghao/llama2-qlora-finetuning

llama2 inference

inference_llama2.py

python inference_llama2.py