LLaMA-Factory-310P3/examples
hiyouga cae4737907 lora modules: all by default 2024-06-06 03:53:28 +08:00
..
accelerate update readme 2024-05-29 18:39:11 +08:00
deepspeed fix examples 2024-05-15 00:26:10 +08:00
extras lora modules: all by default 2024-06-06 03:53:28 +08:00
full_multi_gpu update train hparams 2024-06-06 01:49:20 +08:00
inference update docs 2024-05-06 21:47:00 +08:00
lora_multi_gpu lora modules: all by default 2024-06-06 03:53:28 +08:00
lora_multi_npu lora modules: all by default 2024-06-06 03:53:28 +08:00
lora_single_gpu lora modules: all by default 2024-06-06 03:53:28 +08:00
merge_lora update examples 2024-05-17 01:02:00 +08:00
qlora_single_gpu lora modules: all by default 2024-06-06 03:53:28 +08:00
README.md fix #4005 #4013 2024-06-03 19:12:29 +08:00
README_zh.md fix #4005 #4013 2024-06-03 19:12:29 +08:00

README.md

We provide diverse examples about fine-tuning LLMs.

Make sure to execute these commands in the LLaMA-Factory directory.

Table of Contents

Examples

LoRA Fine-Tuning on A Single GPU

(Continuous) Pre-Training

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/lora_single_gpu/llama3_lora_pretrain.yaml

Supervised Fine-Tuning

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/lora_single_gpu/llama3_lora_sft.yaml

Multimodal Supervised Fine-Tuning

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/lora_single_gpu/llava1_5_lora_sft.yaml

Reward Modeling

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/lora_single_gpu/llama3_lora_reward.yaml

PPO Training

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/lora_single_gpu/llama3_lora_ppo.yaml

DPO/ORPO/SimPO Training

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/lora_single_gpu/llama3_lora_dpo.yaml

KTO Training

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/lora_single_gpu/llama3_lora_kto.yaml

Preprocess Dataset

It is useful for large dataset, use tokenized_path in config to load the preprocessed dataset.

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/lora_single_gpu/llama3_preprocess.yaml

Evaluating on MMLU/CMMLU/C-Eval Benchmarks

CUDA_VISIBLE_DEVICES=0 llamafactory-cli eval examples/lora_single_gpu/llama3_lora_eval.yaml

Batch Predicting and Computing BLEU and ROUGE Scores

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/lora_single_gpu/llama3_lora_predict.yaml

QLoRA Fine-Tuning on a Single GPU

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/qlora_single_gpu/llama3_lora_sft_bitsandbytes.yaml

Supervised Fine-Tuning with 4/8-bit GPTQ Quantization

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/qlora_single_gpu/llama3_lora_sft_gptq.yaml

Supervised Fine-Tuning with 4-bit AWQ Quantization

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/qlora_single_gpu/llama3_lora_sft_awq.yaml

Supervised Fine-Tuning with 2-bit AQLM Quantization

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/qlora_single_gpu/llama3_lora_sft_aqlm.yaml

LoRA Fine-Tuning on Multiple GPUs

Supervised Fine-Tuning on Single Node

CUDA_VISIBLE_DEVICES=0,1,2,3 llamafactory-cli train examples/lora_multi_gpu/llama3_lora_sft.yaml

Supervised Fine-Tuning on Multiple Nodes

CUDA_VISIBLE_DEVICES=0,1,2,3 NNODES=2 RANK=0 MASTER_ADDR=192.168.0.1 MASTER_PORT=29500 llamafactory-cli train examples/lora_multi_gpu/llama3_lora_sft.yaml
CUDA_VISIBLE_DEVICES=0,1,2,3 NNODES=2 RANK=1 MASTER_ADDR=192.168.0.1 MASTER_PORT=29500 llamafactory-cli train examples/lora_multi_gpu/llama3_lora_sft.yaml

Supervised Fine-Tuning with DeepSpeed ZeRO-3 (Weight Sharding)

CUDA_VISIBLE_DEVICES=0,1,2,3 llamafactory-cli train examples/lora_multi_gpu/llama3_lora_sft_ds.yaml

LoRA Fine-Tuning on Multiple NPUs

Supervised Fine-Tuning with DeepSpeed ZeRO-0

ASCEND_RT_VISIBLE_DEVICES=0,1,2,3 llamafactory-cli train examples/lora_multi_npu/llama3_lora_sft_ds.yaml

Full-Parameter Fine-Tuning on Multiple GPUs

Supervised Fine-Tuning on Single Node

CUDA_VISIBLE_DEVICES=0,1,2,3 llamafactory-cli train examples/full_multi_gpu/llama3_full_sft.yaml

Supervised Fine-Tuning on Multiple Nodes

CUDA_VISIBLE_DEVICES=0,1,2,3 NNODES=2 RANK=0 MASTER_ADDR=192.168.0.1 MASTER_PORT=29500 llamafactory-cli train examples/full_multi_gpu/llama3_full_sft.yaml
CUDA_VISIBLE_DEVICES=0,1,2,3 NNODES=2 RANK=1 MASTER_ADDR=192.168.0.1 MASTER_PORT=29500 llamafactory-cli train examples/full_multi_gpu/llama3_full_sft.yaml

Batch Predicting and Computing BLEU and ROUGE Scores

CUDA_VISIBLE_DEVICES=0,1,2,3 llamafactory-cli train examples/full_multi_gpu/llama3_full_predict.yaml

Merging LoRA Adapters and Quantization

Merge LoRA Adapters

Note: DO NOT use quantized model or quantization_bit when merging LoRA adapters.

CUDA_VISIBLE_DEVICES=0 llamafactory-cli export examples/merge_lora/llama3_lora_sft.yaml

Quantizing Model using AutoGPTQ

CUDA_VISIBLE_DEVICES=0 llamafactory-cli export examples/merge_lora/llama3_gptq.yaml

Inferring LoRA Fine-Tuned Models

Use CUDA_VISIBLE_DEVICES=0,1 to infer models on multiple devices.

Use CLI

CUDA_VISIBLE_DEVICES=0 llamafactory-cli chat examples/inference/llama3_lora_sft.yaml

Use Web UI

CUDA_VISIBLE_DEVICES=0 llamafactory-cli webchat examples/inference/llama3_lora_sft.yaml

Launch OpenAI-style API

CUDA_VISIBLE_DEVICES=0 llamafactory-cli api examples/inference/llama3_lora_sft.yaml

Extras

Full-Parameter Fine-Tuning using GaLore

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/extras/galore/llama3_full_sft.yaml

Full-Parameter Fine-Tuning using BAdam

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/extras/badam/llama3_full_sft.yaml

LoRA+ Fine-Tuning

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/extras/loraplus/llama3_lora_sft.yaml

Mixture-of-Depths Fine-Tuning

CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/extras/mod/llama3_full_sft.yaml

LLaMA-Pro Fine-Tuning

bash examples/extras/llama_pro/expand.sh
CUDA_VISIBLE_DEVICES=0 llamafactory-cli train examples/extras/llama_pro/llama3_freeze_sft.yaml

FSDP+QLoRA Fine-Tuning

bash examples/extras/fsdp_qlora/single_node.sh