We provide diverse examples about fine-tuning LLMs.
Make sure to execute these commands in the LLaMA-Factory
directory.
- LoRA Fine-Tuning
- QLoRA Fine-Tuning
- Full-Parameter Fine-Tuning
- Merging LoRA Adapters and Quantization
- Inferring LoRA Fine-Tuned Models
- Extras
Use CUDA_VISIBLE_DEVICES
(GPU) or ASCEND_RT_VISIBLE_DEVICES
(NPU) to choose computing devices.
llamafactory-cli train examples/train_lora/llama3_lora_pretrain.yaml
llamafactory-cli train examples/train_lora/llama3_lora_sft.yaml
llamafactory-cli train examples/train_lora/llava1_5_lora_sft.yaml
llamafactory-cli train examples/train_lora/llama3_lora_reward.yaml
llamafactory-cli train examples/train_lora/llama3_lora_ppo.yaml
llamafactory-cli train examples/train_lora/llama3_lora_dpo.yaml
llamafactory-cli train examples/train_lora/llama3_lora_kto.yaml
It is useful for large dataset, use tokenized_path
in config to load the preprocessed dataset.
llamafactory-cli train examples/train_lora/llama3_preprocess.yaml
llamafactory-cli eval examples/train_lora/llama3_lora_eval.yaml
llamafactory-cli train examples/train_lora/llama3_lora_predict.yaml
FORCE_TORCHRUN=1 NNODES=2 RANK=0 MASTER_ADDR=192.168.0.1 MASTER_PORT=29500 llamafactory-cli train examples/train_lora/llama3_lora_sft.yaml
FORCE_TORCHRUN=1 NNODES=2 RANK=1 MASTER_ADDR=192.168.0.1 MASTER_PORT=29500 llamafactory-cli train examples/train_lora/llama3_lora_sft.yaml
FORCE_TORCHRUN=1 llamafactory-cli train examples/train_lora/llama3_lora_sft_ds3.yaml
llamafactory-cli train examples/train_qlora/llama3_lora_sft_otfq.yaml
llamafactory-cli train examples/train_qlora/llama3_lora_sft_gptq.yaml
llamafactory-cli train examples/train_qlora/llama3_lora_sft_awq.yaml
llamafactory-cli train examples/train_qlora/llama3_lora_sft_aqlm.yaml
FORCE_TORCHRUN=1 llamafactory-cli train examples/train_full/llama3_full_sft_ds3.yaml
FORCE_TORCHRUN=1 NNODES=2 RANK=0 MASTER_ADDR=192.168.0.1 MASTER_PORT=29500 llamafactory-cli train examples/train_full/llama3_full_sft_ds3.yaml
FORCE_TORCHRUN=1 NNODES=2 RANK=1 MASTER_ADDR=192.168.0.1 MASTER_PORT=29500 llamafactory-cli train examples/train_full/llama3_full_sft_ds3.yaml
llamafactory-cli train examples/train_full/llama3_full_predict.yaml
Note: DO NOT use quantized model or quantization_bit
when merging LoRA adapters.
llamafactory-cli export examples/merge_lora/llama3_lora_sft.yaml
llamafactory-cli export examples/merge_lora/llama3_gptq.yaml
llamafactory-cli chat examples/inference/llama3_lora_sft.yaml
llamafactory-cli webchat examples/inference/llama3_lora_sft.yaml
llamafactory-cli api examples/inference/llama3_lora_sft.yaml
llamafactory-cli train examples/extras/galore/llama3_full_sft.yaml
llamafactory-cli train examples/extras/badam/llama3_full_sft.yaml
llamafactory-cli train examples/extras/adam_mini/qwen2_full_sft.yaml
llamafactory-cli train examples/extras/loraplus/llama3_lora_sft.yaml
llamafactory-cli train examples/extras/pissa/llama3_lora_sft.yaml
llamafactory-cli train examples/extras/mod/llama3_full_sft.yaml
bash examples/extras/llama_pro/expand.sh
llamafactory-cli train examples/extras/llama_pro/llama3_freeze_sft.yaml
bash examples/extras/fsdp_qlora/train.sh