5.4 KiB
5.4 KiB
We provide diverse examples about fine-tuning LLMs.
Make sure to execute these commands in the LLaMA-Factory
directory.
Table of Contents
- 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.
Examples
LoRA Fine-Tuning
(Continuous) Pre-Training
llamafactory-cli train examples/train_lora/llama3_lora_pretrain.yamlSupervised Fine-Tuning
llamafactory-cli train examples/train_lora/llama3_lora_sft.yamlMultimodal Supervised Fine-Tuning
llamafactory-cli train examples/train_lora/llava1_5_lora_sft.yaml
llamafactory-cli train examples/train_lora/qwen2vl_lora_sft.yamlDPO/ORPO/SimPO Training
llamafactory-cli train examples/train_lora/llama3_lora_dpo.yamlMultimodal DPO/ORPO/SimPO Training
llamafactory-cli train examples/train_lora/qwen2vl_lora_dpo.yamlReward Modeling
llamafactory-cli train examples/train_lora/llama3_lora_reward.yamlPPO Training
llamafactory-cli train examples/train_lora/llama3_lora_ppo.yamlKTO Training
llamafactory-cli train examples/train_lora/llama3_lora_kto.yamlPreprocess Dataset
It is useful for large dataset, use tokenized_path in
config to load the preprocessed dataset.
llamafactory-cli train examples/train_lora/llama3_preprocess.yamlEvaluating on MMLU/CMMLU/C-Eval Benchmarks
llamafactory-cli eval examples/train_lora/llama3_lora_eval.yamlBatch Predicting and Computing BLEU and ROUGE Scores
llamafactory-cli train examples/train_lora/llama3_lora_predict.yamlSupervised Fine-Tuning on Multiple Nodes
FORCE_TORCHRUN=1 NNODES=2 NODE_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 NODE_RANK=1 MASTER_ADDR=192.168.0.1 MASTER_PORT=29500 llamafactory-cli train examples/train_lora/llama3_lora_sft.yamlSupervised Fine-Tuning with DeepSpeed ZeRO-3 (Weight Sharding)
FORCE_TORCHRUN=1 llamafactory-cli train examples/train_lora/llama3_lora_sft_ds3.yamlQLoRA Fine-Tuning
Supervised Fine-Tuning with 4/8-bit Bitsandbytes/HQQ/EETQ Quantization (Recommended)
llamafactory-cli train examples/train_qlora/llama3_lora_sft_otfq.yamlSupervised Fine-Tuning with 4/8-bit GPTQ Quantization
llamafactory-cli train examples/train_qlora/llama3_lora_sft_gptq.yamlSupervised Fine-Tuning with 4-bit AWQ Quantization
llamafactory-cli train examples/train_qlora/llama3_lora_sft_awq.yamlSupervised Fine-Tuning with 2-bit AQLM Quantization
llamafactory-cli train examples/train_qlora/llama3_lora_sft_aqlm.yamlFull-Parameter Fine-Tuning
Supervised Fine-Tuning on Single Node
FORCE_TORCHRUN=1 llamafactory-cli train examples/train_full/llama3_full_sft_ds3.yamlSupervised Fine-Tuning on Multiple Nodes
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.yamlMultimodal Supervised Fine-Tuning
FORCE_TORCHRUN=1 llamafactory-cli train examples/train_full/qwen2vl_full_sft.yamlBatch Predicting and Computing BLEU and ROUGE Scores
llamafactory-cli train examples/train_full/llama3_full_predict.yamlMerging LoRA Adapters and Quantization
Merge LoRA Adapters
Note: DO NOT use quantized model or quantization_bit
when merging LoRA adapters.
llamafactory-cli export examples/merge_lora/llama3_lora_sft.yamlQuantizing Model using AutoGPTQ
llamafactory-cli export examples/merge_lora/llama3_gptq.yamlInferring LoRA Fine-Tuned Models
Use CLI
llamafactory-cli chat examples/inference/llama3_lora_sft.yamlUse Web UI
llamafactory-cli webchat examples/inference/llama3_lora_sft.yamlLaunch OpenAI-style API
llamafactory-cli api examples/inference/llama3_lora_sft.yamlExtras
Full-Parameter Fine-Tuning using GaLore
llamafactory-cli train examples/extras/galore/llama3_full_sft.yamlFull-Parameter Fine-Tuning using BAdam
llamafactory-cli train examples/extras/badam/llama3_full_sft.yamlFull-Parameter Fine-Tuning using Adam-mini
llamafactory-cli train examples/extras/adam_mini/qwen2_full_sft.yamlLoRA+ Fine-Tuning
llamafactory-cli train examples/extras/loraplus/llama3_lora_sft.yamlPiSSA Fine-Tuning
llamafactory-cli train examples/extras/pissa/llama3_lora_sft.yamlMixture-of-Depths Fine-Tuning
llamafactory-cli train examples/extras/mod/llama3_full_sft.yamlLLaMA-Pro Fine-Tuning
bash examples/extras/llama_pro/expand.sh
llamafactory-cli train examples/extras/llama_pro/llama3_freeze_sft.yamlFSDP+QLoRA Fine-Tuning
bash examples/extras/fsdp_qlora/train.sh